feat: Use toggle switch for layerable themes in quick settings menu (#712)

* feat: Add px-0 utlility class
This commit is contained in:
Aman Harwara
2021-10-30 21:22:46 +05:30
committed by GitHub
parent db1139fd44
commit 5da51048bf
2 changed files with 38 additions and 23 deletions

View File

@@ -38,7 +38,8 @@ const ThemeButton: FunctionComponent<ThemeButtonProps> = ({
theme, theme,
onBlur, onBlur,
}) => { }) => {
const toggleTheme = () => { const toggleTheme = (e: any) => {
e.preventDefault();
if (theme.isLayerable() || !theme.active) { if (theme.isLayerable() || !theme.active) {
application.toggleComponent(theme); application.toggleComponent(theme);
} }
@@ -46,22 +47,29 @@ const ThemeButton: FunctionComponent<ThemeButtonProps> = ({
return ( return (
<button <button
className="sn-dropdown-item justify-between focus:bg-info-backdrop focus:shadow-none" className={`sn-dropdown-item focus:bg-info-backdrop focus:shadow-none ${
theme.isLayerable() ? `justify-start` : `justify-between`
}`}
onClick={toggleTheme} onClick={toggleTheme}
onBlur={onBlur} onBlur={onBlur}
> >
<div className="flex items-center">
{theme.isLayerable() ? ( {theme.isLayerable() ? (
theme.active ? ( <>
<Icon type="check" className="color-info mr-2" /> <Switch
) : null className="px-0 mr-2"
checked={theme.active}
onChange={toggleTheme}
/>
{theme.package_info.name}
</>
) : ( ) : (
<>
<div className="flex items-center">
<div <div
className={`pseudo-radio-btn ${ className={`pseudo-radio-btn ${
theme.active ? 'pseudo-radio-btn--checked' : '' theme.active ? 'pseudo-radio-btn--checked' : ''
} mr-2`} } mr-2`}
></div> ></div>
)}
<span className={theme.active ? 'font-semibold' : undefined}> <span className={theme.active ? 'font-semibold' : undefined}>
{theme.package_info.name} {theme.package_info.name}
</span> </span>
@@ -72,6 +80,8 @@ const ThemeButton: FunctionComponent<ThemeButtonProps> = ({
backgroundColor: theme.package_info?.dock_icon?.background_color, backgroundColor: theme.package_info?.dock_icon?.background_color,
}} }}
></div> ></div>
</>
)}
</button> </button>
); );
}; };

View File

@@ -422,6 +422,11 @@
padding-bottom: 0.625rem; padding-bottom: 0.625rem;
} }
.sn-component .px-0 {
padding-left: 0;
padding-right: 0;
}
.px-9 { .px-9 {
padding-left: 2.25rem; padding-left: 2.25rem;
padding-right: 2.25rem; padding-right: 2.25rem;