aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/CharLimit.js
blob: 623b378dc253dab74166a5b0b5a260643d1454c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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