-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
197 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,11 @@ | |
&_one-line { | ||
display: flex; | ||
} | ||
|
||
&_select { | ||
margin-left: 0; | ||
margin-bottom: 0; | ||
} | ||
} | ||
|
||
&-annotation { | ||
|
41 changes: 41 additions & 0 deletions
41
packages/ui/src/ui/containers/SettingsMenu/SettingsMenuSelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, {useEffect, useState} from 'react'; | ||
import block from 'bem-cn-lite'; | ||
import {SelectSingle} from '../../components/Select/Select'; | ||
|
||
import './SettingsMenu.scss'; | ||
|
||
const b = block('elements-page'); | ||
|
||
type SettingsMenuSelectOption = | ||
| {options: Array<{value: string; text: string}>} | ||
| {getOptionsOnMount: () => Promise<Array<{value: string; text: string}>>}; | ||
type SettingsMenuSelectProps = { | ||
placeholder?: string; | ||
label?: string; | ||
getSetting: () => string; | ||
setSetting: (value?: string) => void; | ||
} & SettingsMenuSelectOption; | ||
|
||
export const SettingsMenuSelect = (props: SettingsMenuSelectProps) => { | ||
const value = props.getSetting(); | ||
const [items, setItems] = useState('options' in props ? props.options : []); | ||
|
||
useEffect(() => { | ||
if ('getOptionsOnMount' in props) { | ||
props?.getOptionsOnMount().then((options) => { | ||
setItems(options); | ||
}); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div className={b('settings-item', {select: true})} title={props.label}> | ||
<SelectSingle | ||
value={value} | ||
items={items} | ||
onChange={(value) => props.setSetting(value)} | ||
placeholder={props.placeholder} | ||
/> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.