wip: add setting page

This commit is contained in:
Sanster
2022-04-14 20:43:07 +08:00
parent aa411c7524
commit 78d6b1cc3e
11 changed files with 155 additions and 15 deletions

View File

@@ -7,6 +7,7 @@ type SelectorChevronDirection = 'up' | 'down'
type SelectorProps = {
minWidth?: number
chevronDirection?: SelectorChevronDirection
value: string
options: string[]
onChange: (value: string) => void
}
@@ -17,9 +18,8 @@ const selectorDefaultProps = {
}
function Selector(props: SelectorProps) {
const { minWidth, chevronDirection, options, onChange } = props
const { minWidth, chevronDirection, value, options, onChange } = props
const [showOptions, setShowOptions] = useState<boolean>(false)
const [index, setIndex] = useState<number>(0)
const selectorRef = useRef<HTMLDivElement | null>(null)
const showOptionsHandler = () => {
@@ -46,7 +46,6 @@ function Selector(props: SelectorProps) {
const currentRes = e.target.textContent.split('x')
onChange(currentRes[0])
setShowOptions(false)
setIndex(newIndex)
}
return (
@@ -57,7 +56,7 @@ function Selector(props: SelectorProps) {
onClick={showOptionsHandler}
aria-hidden="true"
>
<p>{options[index]}</p>
<p>{value}</p>
<div className="selector-icon">
{chevronDirection === 'up' ? <ChevronUpIcon /> : <ChevronDownIcon />}
</div>