From 5ea9f1feb39b29cb0e3382694adf8120a1e63d1c Mon Sep 17 00:00:00 2001 From: hs05june Date: Sat, 13 May 2023 02:15:56 +0530 Subject: [PATCH] UI Channel Form Signed-off-by: hs05june --- client/src/components/Forms/ChannelForm.js | 140 ++++++++++----------- client/src/components/Forms/FileInput.js | 84 +++++++++++++ 2 files changed, 152 insertions(+), 72 deletions(-) create mode 100644 client/src/components/Forms/FileInput.js diff --git a/client/src/components/Forms/ChannelForm.js b/client/src/components/Forms/ChannelForm.js index e0de30e8b..4c0ac6d73 100644 --- a/client/src/components/Forms/ChannelForm.js +++ b/client/src/components/Forms/ChannelForm.js @@ -6,84 +6,80 @@ import React, { Component } from 'react'; import Button from '@material-ui/core/Button'; import TextField from '@material-ui/core/TextField'; import { withStyles } from '@material-ui/core/styles'; +import FileInput from './FileInput'; const styles = theme => ({ - container: { - display: 'flex', - flexWrap: 'wrap', - }, - form: { - width: 310, - }, - textField: { - marginLeft: theme.spacing.unit, - marginRight: theme.spacing.unit, - width: 130, - }, - fileField: { - marginLeft: theme.spacing.unit, - marginRight: theme.spacing.unit, - width: 300, - }, - menu: { - width: 200, - }, + container: { + display: 'flex', + flexWrap: 'wrap' + }, + form: { + width: 310 + }, + textField: { + marginLeft: theme.spacing.unit, + marginRight: theme.spacing.unit, + width: 130 + }, + fileField: { + marginLeft: theme.spacing.unit, + marginRight: theme.spacing.unit, + width: 300 + }, + menu: { + width: 200 + }, + button: { + fontSize: 16, + color: '#466bd4', + margin: 'auto', + display: 'block', + border: 'none' + } }); class ChannelForm extends Component { - render() { - const { classes } = this.props; + render() { + const { classes } = this.props; - return ( - // TODO : Replace with liform-react -
-
- - - -
-
- - - - - -
- ); - } + return ( + // TODO : Replace with liform-react +
+
+ + + +
+ + + + + +
+ ); + } } export default withStyles(styles)(ChannelForm); diff --git a/client/src/components/Forms/FileInput.js b/client/src/components/Forms/FileInput.js new file mode 100644 index 000000000..5bc8cd778 --- /dev/null +++ b/client/src/components/Forms/FileInput.js @@ -0,0 +1,84 @@ +/** + * SPDX-License-Identifier: Apache-2.0 + */ + +import React, { Component } from 'react'; +import { withStyles } from '@material-ui/core/styles'; +import Box from '@material-ui/core/Box'; +import TextField from '@material-ui/core/TextField'; +import ButtonBase from '@material-ui/core/ButtonBase'; + +const styles = theme => ({ + field: { + '& .MuiFormLabel-root.Mui-disabled': { + color: theme.palette.text.secondary + } + }, + button: { + width: '100%', + height: '100%', + overflow: 'hidden' + }, + box: { + marginLeft: theme.spacing.unit, + marginRight: theme.spacing.unit, + borderBottom: '1px #8b8e91 solid', + '&:hover': { + borderBottom: '2px #1f2020 solid' + } + } +}); + +class FileInput extends Component { + constructor(props) { + super(props); + this.state = { + attachment: null + }; + this.ref = React.createRef(); + } + + handleChange = event => { + const files = Array.from(event.target.files); + const [file] = files; + this.setState({ attachment: file }); + }; + + render() { + const { label, helperText, classes } = this.props; + const { attachment } = this.state; + + return ( + + + + + e.keyCode === 32 && this.ref.current.click()} + > + + + + ); + } +} + +export default withStyles(styles)(FileInput);