Add growth option for the main appshelf

This commit is contained in:
ajnart
2022-11-30 09:00:29 +09:00
parent 37ae8e2356
commit da3e412c63
6 changed files with 42 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ import { ColorSelector } from './ColorSelector';
import { OpacitySelector } from './OpacitySelector';
import { AppCardWidthSelector } from './AppCardWidthSelector';
import { ShadeSelector } from './ShadeSelector';
import { GrowthSelector } from './GrowthSelector';
export default function TitleChanger() {
const { config, setConfig } = useConfig();
@@ -74,6 +75,7 @@ export default function TitleChanger() {
<Button type="submit">{t('buttons.submit')}</Button>
</Stack>
</form>
<GrowthSelector />
<ColorSelector type="primary" />
<ColorSelector type="secondary" />
<ShadeSelector />

View File

@@ -0,0 +1,30 @@
import { Switch } from '@mantine/core';
import { useTranslation } from 'next-i18next';
import { useState } from 'react';
import { useConfig } from '../../tools/state';
export function GrowthSelector() {
const { config, setConfig } = useConfig();
const defaultPosition = config?.settings?.grow || false;
const [growState, setGrowState] = useState(defaultPosition);
const { t } = useTranslation('settings/common.json');
const toggleGrowState = () => {
setGrowState(!growState);
setConfig({
...config,
settings: {
...config.settings,
grow: !growState,
},
});
};
return (
<Switch
label={t('settings/common:grow')}
checked={growState === true}
onChange={() => toggleGrowState()}
size="md"
/>
);
}