diff options
| author | Ryan Mehri <[email protected]> | 2020-05-10 12:52:43 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-05-10 12:52:43 -0600 |
| commit | 22a2e8b5d9ae005527bd23e8d6e31a765c690e80 (patch) | |
| tree | f05d45608790aa29942caab5d30e39c2171d498d /frontend/src/components | |
| parent | Merge pull request #9 from jackyzha0/backend (diff) | |
| parent | add focus opacity change, password input (diff) | |
| download | ctrl-v-22a2e8b5d9ae005527bd23e8d6e31a765c690e80.tar.xz ctrl-v-22a2e8b5d9ae005527bd23e8d6e31a765c690e80.zip | |
Merge pull request #10 from jackyzha0/react
add focus opacity change, password input
Diffstat (limited to 'frontend/src/components')
| -rw-r--r-- | frontend/src/components/FloatingLabel.js | 34 | ||||
| -rw-r--r-- | frontend/src/components/Inputs.js | 36 | ||||
| -rw-r--r-- | frontend/src/components/Options.js | 22 | ||||
| -rw-r--r-- | frontend/src/components/PasteArea.js | 11 |
4 files changed, 100 insertions, 3 deletions
diff --git a/frontend/src/components/FloatingLabel.js b/frontend/src/components/FloatingLabel.js new file mode 100644 index 0000000..814790c --- /dev/null +++ b/frontend/src/components/FloatingLabel.js @@ -0,0 +1,34 @@ +import React from 'react'; +import styled, { css } from 'styled-components' + +const StyledLabel = styled.label` + position: absolute; + top: 0.5em; + font-weight: 700; + font-size: 1em; + opacity: 0; + transition: all 0.5s cubic-bezier(.25,.8,.25,1); + + ${props => + (props.value.length > 0) && + css` + top: 0em; + opacity: 1 + `}; +` + +class FloatingLabel extends React.Component { + render() { + return ( + <StyledLabel + label={this.props.label} + value={this.props.value} + className={this.props.id} + htmlFor={this.props.id}> + {this.props.label} + </StyledLabel> + ); + } +} + +export default FloatingLabel
\ No newline at end of file diff --git a/frontend/src/components/Inputs.js b/frontend/src/components/Inputs.js index d2238af..a45e6de 100644 --- a/frontend/src/components/Inputs.js +++ b/frontend/src/components/Inputs.js @@ -1,6 +1,7 @@ import React from 'react'; import CharLimit from './CharLimit' import styled from 'styled-components' +import FloatingLabel from './FloatingLabel' const CharLimitContainer = styled.div` position: relative; @@ -10,11 +11,17 @@ class TitleInput extends React.Component { render() { return ( <CharLimitContainer> + <FloatingLabel + label="title" + id={this.props.id} + value={this.props.value} /> <input name="title" className="lt-shadow" placeholder="Title" + id={this.props.id} type="text" + autoFocus autoComplete="off" onChange={this.props.onChange} value={this.props.value} /> @@ -30,10 +37,15 @@ class PasteInput extends React.Component { render() { return ( <CharLimitContainer> + <FloatingLabel + label="content" + id={this.props.id} + value={this.props.content} /> <textarea name="content" placeholder="Paste your text here" value={this.props.content} + id={this.props.id} onChange={this.props.onChange} className="lt-shadow" /> <CharLimit @@ -44,4 +56,26 @@ class PasteInput extends React.Component { } } -export { TitleInput, PasteInput }
\ No newline at end of file +class PassInput extends React.Component { + render() { + return ( + <CharLimitContainer> + <FloatingLabel + label="password" + id={this.props.id} + value={this.props.value} /> + <input + name="pass" + className="lt-shadow" + placeholder="password (optional)" + type="password" + autoComplete="off" + onChange={this.props.onChange} + value={this.props.value} + id={this.props.id} /> + </CharLimitContainer> + ); + } +} + +export { TitleInput, PasteInput, PassInput }
\ No newline at end of file diff --git a/frontend/src/components/Options.js b/frontend/src/components/Options.js new file mode 100644 index 0000000..81f2046 --- /dev/null +++ b/frontend/src/components/Options.js @@ -0,0 +1,22 @@ +import React from 'react'; +import styled from 'styled-components' +import { PassInput } from './Inputs' + +const Float = styled.div` + float: right; +` + +class OptionsContainer extends React.Component { + render() { + return ( + <Float> + <PassInput + value={this.props.pass} + onChange={this.props.onChange} + id="passwordInput" /> + </Float> + ); + } +} + +export default OptionsContainer
\ No newline at end of file diff --git a/frontend/src/components/PasteArea.js b/frontend/src/components/PasteArea.js index f026ef9..95ef6d8 100644 --- a/frontend/src/components/PasteArea.js +++ b/frontend/src/components/PasteArea.js @@ -1,5 +1,6 @@ import React from 'react'; import { TitleInput, PasteInput } from './Inputs' +import OptionsContainer from './Options' class PasteArea extends React.Component { constructor(props) { @@ -7,6 +8,7 @@ class PasteArea extends React.Component { this.state = { title: '', content: '', + pass: '', }; this.handleChange = this.handleChange.bind(this); @@ -42,13 +44,18 @@ class PasteArea extends React.Component { <TitleInput onChange={this.handleChange} value={this.state.title} - maxLength="100" /> + maxLength="100" + id="titleInput" /> <PasteInput onChange={this.handleChange} content={this.state.content} - maxLength="100000" /> + maxLength="100000" + id="pasteInput" /> <br /> <input className="lt-button lt-shadow lt-hover" type="submit" value="new paste" /> + <OptionsContainer + pass={this.state.pass} + onChange={this.handleChange} /> </form> ); } |