mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: add system mode to the theme selector (#7853)
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
parent
92bc08207c
commit
cd50aa719f
21 changed files with 301 additions and 56 deletions
|
@ -75,6 +75,12 @@
|
|||
&__shortcut {
|
||||
margin-inline-start: auto;
|
||||
opacity: 0.5;
|
||||
|
||||
&--orphaned {
|
||||
text-align: right;
|
||||
font-size: 0.875rem;
|
||||
padding: 0 0.625rem;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
|
@ -94,6 +100,22 @@
|
|||
}
|
||||
}
|
||||
|
||||
.dropdown-menu-item-bare {
|
||||
align-items: center;
|
||||
height: 2rem;
|
||||
justify-content: space-between;
|
||||
|
||||
@media screen and (min-width: 1921px) {
|
||||
height: 2.25rem;
|
||||
}
|
||||
|
||||
svg {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-menu-item-custom {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
import { useDevice } from "../App";
|
||||
import { RadioGroup } from "../RadioGroup";
|
||||
|
||||
type Props<T> = {
|
||||
value: T;
|
||||
shortcut?: string;
|
||||
choices: {
|
||||
value: T;
|
||||
label: React.ReactNode;
|
||||
ariaLabel?: string;
|
||||
}[];
|
||||
onChange: (value: T) => void;
|
||||
children: React.ReactNode;
|
||||
name: string;
|
||||
};
|
||||
|
||||
const DropdownMenuItemContentRadio = <T,>({
|
||||
value,
|
||||
shortcut,
|
||||
onChange,
|
||||
choices,
|
||||
children,
|
||||
name,
|
||||
}: Props<T>) => {
|
||||
const device = useDevice();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="dropdown-menu-item-base dropdown-menu-item-bare">
|
||||
<label className="dropdown-menu-item__text" htmlFor={name}>
|
||||
{children}
|
||||
</label>
|
||||
<RadioGroup
|
||||
name={name}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
choices={choices}
|
||||
/>
|
||||
</div>
|
||||
{shortcut && !device.editor.isMobile && (
|
||||
<div className="dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned">
|
||||
{shortcut}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
DropdownMenuItemContentRadio.displayName = "DropdownMenuItemContentRadio";
|
||||
|
||||
export default DropdownMenuItemContentRadio;
|
Loading…
Add table
Add a link
Reference in a new issue