diff options
| author | jackyzha0 <[email protected]> | 2021-03-05 22:17:18 -0800 |
|---|---|---|
| committer | jackyzha0 <[email protected]> | 2021-03-05 22:17:18 -0800 |
| commit | 3e8500d466b641ef34c24f8b0de8163a44ba7a9e (patch) | |
| tree | ebb3411d636912b12f9fee14ecd494601cd796fc /frontend/src/components/Inputs/Dropdown.js | |
| parent | remove extra langs (diff) | |
| download | ctrl-v-3e8500d466b641ef34c24f8b0de8163a44ba7a9e.tar.xz ctrl-v-3e8500d466b641ef34c24f8b0de8163a44ba7a9e.zip | |
refactoring css
Diffstat (limited to 'frontend/src/components/Inputs/Dropdown.js')
| -rw-r--r-- | frontend/src/components/Inputs/Dropdown.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/frontend/src/components/Inputs/Dropdown.js b/frontend/src/components/Inputs/Dropdown.js new file mode 100644 index 0000000..c467408 --- /dev/null +++ b/frontend/src/components/Inputs/Dropdown.js @@ -0,0 +1,84 @@ +import Dropdown from "react-dropdown"; +import FloatingLabel from "../decorators/FloatingLabel"; +import React from "react"; +import {LANGS, THEMES} from "../renderers/Code"; +import {FlexChild} from "./shared"; + +const GenericDropdown = (props) => { + function _onSelect(option) { + props.onChange({ + target: { + name: props.label, + value: option.label + } + }); + } + + return ( + <FlexChild> + <Dropdown + options={props.options} + onChange={_onSelect} + value={props.value} + placeholder={props.placeholder} + id={props.id} /> + <FloatingLabel + label={props.label} + id={props.id} + value={props.value} /> + </FlexChild> + ); +} + +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={LANGS.auto} + 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' + /> + ); +}
\ No newline at end of file |