1
0
Fork 0
freesewing/sites/shared/components/theme-picker.js

32 lines
795 B
JavaScript
Raw Normal View History

2021-12-11 14:04:05 +01:00
import themes from 'shared/themes/index.js'
import ThemeIcon from 'shared/components/icons/theme.js'
import { useTranslation } from 'next-i18next'
import {Picker, PickerButton} from './picker';
import { Menu } from '@headlessui/react'
2021-12-11 14:04:05 +01:00
2022-06-04 18:30:30 +02:00
const ThemePicker = ({ app, className, iconOnly=false }) => {
2022-02-13 15:45:27 +01:00
const { t } = useTranslation(['themes'])
const items = {};
for (var k in themes){
items[k] = {...themes[k], key: k}
}
const pickerProps = {
className,
iconOnly,
Icon: ThemeIcon,
title: t(`${app.theme}Theme`)
}
return (<Picker {...pickerProps}>
{Object.keys(themes).map(theme => (
<PickerButton onClick={() =>
app.setTheme(theme)} key={theme}>
{t(`${theme}Theme`)}
</PickerButton>
))}
</Picker>)
2021-12-11 14:04:05 +01:00
}
export default ThemePicker