aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/CharLimit.js
diff options
context:
space:
mode:
authorjackyzha0 <[email protected]>2020-05-10 00:25:31 -0700
committerjackyzha0 <[email protected]>2020-05-10 00:25:31 -0700
commit22c58b4d7d864414c599761f92212a5825003950 (patch)
tree8a89e71ebf8c3e549f1f22cda3180eb305f4b202 /frontend/src/components/CharLimit.js
parentadd title component (diff)
downloadctrl-v-22c58b4d7d864414c599761f92212a5825003950.tar.xz
ctrl-v-22c58b4d7d864414c599761f92212a5825003950.zip
input length check and component splitting
Diffstat (limited to 'frontend/src/components/CharLimit.js')
-rw-r--r--frontend/src/components/CharLimit.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/frontend/src/components/CharLimit.js b/frontend/src/components/CharLimit.js
new file mode 100644
index 0000000..623b378
--- /dev/null
+++ b/frontend/src/components/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