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
|
import Dropdown from "react-dropdown";
import React from "react";
import styled from 'styled-components';
import {LANGS, THEMES} from "../renderers/Code";
import {Labelled} from "../decorators/Labelled";
import {Border, DropShadow, InputLike, Rounded} from "../Common/mixins";
const StyledDropdown = styled(Dropdown)`
${Border}
${Rounded}
${DropShadow}
${InputLike}
cursor: pointer;
& .Dropdown-root {
cursor: pointer;
&:hover, &.is-open {
opacity: 1;
}
& + label {
opacity: 1;
top: -0.1em;
}
}
& .Dropdown-placeholder {
width: 5.5em;
}
& .Dropdown-menu {
border-top: 1px solid ${p => p.theme.colors.text};
margin-top: 0.5em;
bottom: auto;
}
& .Dropdown-option {
margin-top: 0.5em;
transition: all 0.5s cubic-bezier(.25,.8,.25,1);
&:hover {
font-weight: 700;
opacity: 0.4;
}
}
`
const GenericDropdown = (props) => {
function _onSelect(option) {
props.onChange({
target: {
name: props.label,
value: option.label
}
});
}
return (
<Labelled
label={props.label}
id={props.id}
value={props.value}>
<StyledDropdown
options={props.options}
onChange={_onSelect}
value={props.value}
placeholder={props.placeholder}
id={props.id} />
</Labelled>
);
}
export const Expiry = (props) => {
const options = [
'5 years',
'1 year',
'1 month',
'1 week',
'1 day',
'1 hour',
'10 min',
];
return (
<GenericDropdown
{...props}
options={options}
placeholder='1 week'
label='expiry'
/>
);
}
export const Language = (props) => {
const options = Object.entries(LANGS).map((key, _) => ({
'value': key[1],
'label': key[0]
}))
return (
<GenericDropdown
{...props}
options={options}
placeholder='detect'
label='language'
/>
);
}
export const Theme = (props) => {
const options = Object.entries(THEMES).map((key) => ({
'value': key[1],
'label': key[0]
}))
return (
<GenericDropdown
{...props}
options={options}
placeholder='atom'
label='theme'
/>
);
}
|