fix: preferences dropdown contrast and color (#1591)
This commit is contained in:
@@ -14,6 +14,7 @@ type DropdownProps = {
|
|||||||
value: string
|
value: string
|
||||||
onChange: (value: string, item: DropdownItem) => void
|
onChange: (value: string, item: DropdownItem) => void
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
className?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListboxButtonProps = DropdownItem & {
|
type ListboxButtonProps = DropdownItem & {
|
||||||
@@ -41,7 +42,7 @@ const CustomDropdownButton: FunctionComponent<ListboxButtonProps> = ({
|
|||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
const Dropdown: FunctionComponent<DropdownProps> = ({ id, label, items, value, onChange, disabled }) => {
|
const Dropdown: FunctionComponent<DropdownProps> = ({ id, label, items, value, onChange, disabled, className }) => {
|
||||||
const labelId = `${id}-label`
|
const labelId = `${id}-label`
|
||||||
|
|
||||||
const handleChange = (value: string) => {
|
const handleChange = (value: string) => {
|
||||||
@@ -51,7 +52,7 @@ const Dropdown: FunctionComponent<DropdownProps> = ({ id, label, items, value, o
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className={className}>
|
||||||
<VisuallyHidden id={labelId}>{label}</VisuallyHidden>
|
<VisuallyHidden id={labelId}>{label}</VisuallyHidden>
|
||||||
<ListboxInput value={value} onChange={handleChange} aria-labelledby={labelId} disabled={disabled}>
|
<ListboxInput value={value} onChange={handleChange} aria-labelledby={labelId} disabled={disabled}>
|
||||||
<StyledListboxButton
|
<StyledListboxButton
|
||||||
@@ -85,7 +86,7 @@ const Dropdown: FunctionComponent<DropdownProps> = ({ id, label, items, value, o
|
|||||||
</div>
|
</div>
|
||||||
</ListboxPopover>
|
</ListboxPopover>
|
||||||
</ListboxInput>
|
</ListboxInput>
|
||||||
</>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { FunctionComponent, useMemo } from 'react'
|
import { FunctionComponent, useMemo } from 'react'
|
||||||
|
import styled from 'styled-components'
|
||||||
import Dropdown from '../Dropdown/Dropdown'
|
import Dropdown from '../Dropdown/Dropdown'
|
||||||
import { DropdownItem } from '../Dropdown/DropdownItem'
|
import { DropdownItem } from '../Dropdown/DropdownItem'
|
||||||
import PreferencesMenuItem from './PreferencesComponents/MenuItem'
|
import PreferencesMenuItem from './PreferencesComponents/MenuItem'
|
||||||
@@ -9,6 +10,19 @@ type Props = {
|
|||||||
menu: PreferencesMenu
|
menu: PreferencesMenu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const StyledDropdown = styled(Dropdown)`
|
||||||
|
[data-reach-listbox-button] {
|
||||||
|
background: var(--sn-stylekit-contrast-background-color);
|
||||||
|
color: var(--sn-stylekit-info-color);
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 0.55rem 0.875rem;
|
||||||
|
|
||||||
|
[data-reach-listbox-arrow] svg {
|
||||||
|
fill: var(--sn-stylekit-info-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
const PreferencesMenuView: FunctionComponent<Props> = ({ menu }) => {
|
const PreferencesMenuView: FunctionComponent<Props> = ({ menu }) => {
|
||||||
const { selectedPaneId, selectPane, menuItems } = menu
|
const { selectedPaneId, selectPane, menuItems } = menu
|
||||||
|
|
||||||
@@ -23,7 +37,7 @@ const PreferencesMenuView: FunctionComponent<Props> = ({ menu }) => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="px-5 pt-2 pb-4 md:px-0 md:py-0">
|
<div className="border-t border-border bg-default px-5 pt-2 pb-6 md:border-0 md:bg-transparent md:px-0 md:py-0">
|
||||||
<div className="hidden min-w-55 flex-col overflow-y-auto px-3 py-6 md:flex">
|
<div className="hidden min-w-55 flex-col overflow-y-auto px-3 py-6 md:flex">
|
||||||
{menuItems.map((pref) => (
|
{menuItems.map((pref) => (
|
||||||
<PreferencesMenuItem
|
<PreferencesMenuItem
|
||||||
@@ -37,7 +51,7 @@ const PreferencesMenuView: FunctionComponent<Props> = ({ menu }) => {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="md:hidden">
|
<div className="md:hidden">
|
||||||
<Dropdown
|
<StyledDropdown
|
||||||
id="preferences-menu"
|
id="preferences-menu"
|
||||||
items={dropdownMenuItems}
|
items={dropdownMenuItems}
|
||||||
label="Preferences Menu"
|
label="Preferences Menu"
|
||||||
|
|||||||
Reference in New Issue
Block a user