diff options
| author | Ryan Mehri <[email protected]> | 2020-05-12 09:29:49 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-05-12 09:29:49 -0600 |
| commit | c0fc08d77570232cfda3f6e2bdbac2c3bf1aafeb (patch) | |
| tree | 9463f3be987993bda22ef4bfc3a56c9174fceee8 /frontend/src/components/decorators | |
| parent | Merge pull request #17 from jackyzha0/password (diff) | |
| parent | working no pass rendering (diff) | |
| download | ctrl-v-c0fc08d77570232cfda3f6e2bdbac2c3bf1aafeb.tar.xz ctrl-v-c0fc08d77570232cfda3f6e2bdbac2c3bf1aafeb.zip | |
Merge pull request #18 from jackyzha0/no-pass-rendering
no password paste rendering
Diffstat (limited to 'frontend/src/components/decorators')
| -rw-r--r-- | frontend/src/components/decorators/CharLimit.js | 37 | ||||
| -rw-r--r-- | frontend/src/components/decorators/FloatingLabel.js | 34 |
2 files changed, 71 insertions, 0 deletions
diff --git a/frontend/src/components/decorators/CharLimit.js b/frontend/src/components/decorators/CharLimit.js new file mode 100644 index 0000000..623b378 --- /dev/null +++ b/frontend/src/components/decorators/CharLimit.js @@ -0,0 +1,37 @@ +import React from 'react'; +import styled, { css } from 'styled-components' + +// show char limit if length > half of max +const Chars = styled.p` + color: #11111100; + font-family: 'Roboto Mono', monospace; + position: absolute; + font-size: 0.8em; + writing-mode: vertical-rl; + top: 50%; + transform: translate(5em, -50%); + right: 0; + transition: all 0.5s cubic-bezier(.25,.8,.25,1); + + ${props => + ((props.content.length / props.maxLength) > 0.5) && + css` + color: #111111; + `}; + + ${props => + ((props.content.length / props.maxLength) > 1) && + css` + color: #ee1111; + `}; +`; + +class CharLimit extends React.Component { + render() { + return ( + <Chars {...this.props} >{this.props.maxLength - this.props.content.length}/{this.props.maxLength}</Chars> + ); + } +} + +export default CharLimit
\ No newline at end of file diff --git a/frontend/src/components/decorators/FloatingLabel.js b/frontend/src/components/decorators/FloatingLabel.js new file mode 100644 index 0000000..e1fc0ba --- /dev/null +++ b/frontend/src/components/decorators/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: -0.1em; + 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 |