aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/Inputs.js
blob: b61869fc39bdcf3b90026e8ba5ff2551bcca1cf2 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import React from 'react';
import CharLimit from './decorators/CharLimit'
import styled from 'styled-components'
import FloatingLabel from './decorators/FloatingLabel'
import Dropdown from 'react-dropdown';

const CharLimitContainer = styled.div`
    position: relative; 
`

const FlexChild = styled.div`
    display: block;
    margin-left: 2em;
`

class TitleInput extends React.Component {
    render() {
        return (
            <CharLimitContainer>
                <FloatingLabel
                    label="title"
                    id={this.props.id}
                    value={this.props.value} />
                <input
                    name="title"
                    readOnly={this.props.readOnly}
                    className="lt-shadow"
                    placeholder="Title"
                    id={this.props.id}
                    type="text"
                    autoFocus
                    autoComplete="off"
                    onChange={this.props.onChange}
                    value={this.props.value} />
                <CharLimit
                    content={this.props.value}
                    maxLength={this.props.maxLength} />
            </CharLimitContainer>
        );
    }
}

class PasteInput extends React.Component {
    render() {
        return (
            <CharLimitContainer>
                <FloatingLabel
                    label="content"
                    id={this.props.id}
                    value={this.props.content} />
                <textarea
                    name="content"
                    readOnly={this.props.readOnly}
                    placeholder="Paste your text here"
                    value={this.props.content}
                    id={this.props.id}
                    required
                    onChange={this.props.onChange}
                    className="lt-shadow" />
                <CharLimit
                    content={this.props.content}
                    maxLength={this.props.maxLength} />
            </CharLimitContainer>
        );
    }
}

class PassInput extends React.Component {
    render() {
        return (
            <FlexChild>
                <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>
            </FlexChild>
        );
    }
}

class ExpiryInput extends React.Component {
    
    _onSelect(option) {
        this.callBackRef({target: {
            name: 'expiry',
            value: option.label
        }});
    }

    render() {
        const options = [
            '5 years',
            '1 year', 
            '1 month',
            '1 week',
            '1 day',
            '1 hour',
            '10 min',
        ];

        return (
            <FlexChild>
                <Dropdown 
                    options={options} 
                    onChange={this._onSelect} 
                    callBackRef={this.props.onChange}
                    value={this.props.value} 
                    placeholder="1 week"
                    id={this.props.id} />
                <FloatingLabel
                    label="expiry"
                    id={this.props.id}
                    value={this.props.value} />
            </FlexChild>
        );
    }
}

export { TitleInput, PasteInput, PassInput, ExpiryInput }