2021-12-11 14:04:05 +01:00
|
|
|
import themes from 'shared/themes/index.js'
|
2021-12-30 14:23:02 +01:00
|
|
|
import ThemeIcon from 'shared/components/icons/theme.js'
|
2022-07-01 15:58:39 -05:00
|
|
|
import {useRef} from 'react'
|
2022-02-10 21:40:19 +01:00
|
|
|
import { useTranslation } from 'next-i18next'
|
2022-07-01 15:58:39 -05:00
|
|
|
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'])
|
2022-02-10 21:40:19 +01:00
|
|
|
|
2022-07-01 15:58:39 -05:00
|
|
|
const items = {};
|
|
|
|
for (var k in themes){
|
|
|
|
items[k] = {...themes[k], key: k}
|
|
|
|
}
|
|
|
|
|
|
|
|
const pickerProps = {
|
|
|
|
className,
|
|
|
|
iconOnly,
|
|
|
|
Icon: ThemeIcon,
|
|
|
|
selectedItem: t(`${app.theme}Theme`)
|
|
|
|
}
|
|
|
|
return (<Picker {...pickerProps}>
|
|
|
|
{Object.keys(themes).map(theme => (
|
|
|
|
<PickerButton onClick={() =>
|
|
|
|
app.setTheme(theme)} key={theme}>
|
|
|
|
{t(`${theme}Theme`)}
|
|
|
|
</PickerButton>
|
|
|
|
))}
|
|
|
|
</Picker>)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return (
|
|
|
|
// <div className={`dropdown dropdown-end ${className} w-auto`}>
|
|
|
|
// <div tabIndex="0" className={iconOnly
|
|
|
|
// ? `btn btn-sm`
|
|
|
|
// : `m-0 btn btn-neutral flex flex-row gap-2 btn-outline
|
|
|
|
// md:btn-ghost
|
|
|
|
// hover:bg-neutral hover:border-neutral-content
|
|
|
|
// `}
|
|
|
|
// >
|
|
|
|
// <ThemeIcon />
|
|
|
|
// {!iconOnly && <span>{t(`${app.theme}Theme`)}</span>}
|
|
|
|
// </div>
|
|
|
|
// <ul
|
|
|
|
// tabIndex="0"
|
|
|
|
// className="p-2 shadow menu dropdown-content bg-base-100 rounded-box w-52"
|
|
|
|
// >
|
|
|
|
// {Object.keys(themes).map(theme => (
|
|
|
|
// <li key={theme}>
|
|
|
|
// <button
|
|
|
|
// onClick={() => app.setTheme(theme)}
|
|
|
|
// className="btn btn-ghost hover:bg-base-200"
|
|
|
|
// >
|
|
|
|
// <span className="text-base-content">
|
|
|
|
// {t(`${theme}Theme`)}
|
|
|
|
// </span>
|
|
|
|
// </button>
|
|
|
|
// </li>
|
|
|
|
// ))}
|
|
|
|
// </ul>
|
|
|
|
// </div>
|
|
|
|
// )
|
|
|
|
// return null;
|
2021-12-11 14:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ThemePicker
|