diff --git a/package.json b/package.json index ff6192008be..5ded8286e7c 100644 --- a/package.json +++ b/package.json @@ -138,6 +138,7 @@ ], "version": "0.0.0", "dependencies": { + "@headlessui/react": "^1.6.5", "autoprefixer": "^10.4.0", "handlebars": "^4.7.7", "jsonfile": "^6.1.0", diff --git a/sites/shared/components/locale-picker.js b/sites/shared/components/locale-picker.js index dcc3ee8a7f6..b7c78999dc1 100644 --- a/sites/shared/components/locale-picker.js +++ b/sites/shared/components/locale-picker.js @@ -3,38 +3,59 @@ import LocaleIcon from 'shared/components/icons/i18n.js' import { useRouter } from 'next/router' import { useTranslation } from 'next-i18next' import Link from 'next/link' +import Picker, {PickerLink} from './picker'; +import { Menu } from '@headlessui/react' const LocalePicker = ({ app, iconOnly=false }) => { const { t } = useTranslation(['locales']) const router = useRouter() + const pickerProps = { + iconOnly, + Icon: LocaleIcon, + selectedItem: t(router.locale) + } + return ( -
-
- - {!iconOnly && {t(router.locale)}} -
- -
+ ) + + // return ( + //
+ //
+ // + // {!iconOnly && {t(router.locale)}} + //
+ // + //
+ // ) } export default LocalePicker diff --git a/sites/shared/components/picker.js b/sites/shared/components/picker.js new file mode 100644 index 00000000000..44949b422de --- /dev/null +++ b/sites/shared/components/picker.js @@ -0,0 +1,56 @@ +import {useRef, forwardRef} from 'react' +import { Menu } from '@headlessui/react' +import Link from 'next/link' + +const Picker = ({Icon, className, selectedItem, iconOnly=false, children}) => { + + return ( + + + {!iconOnly && {selectedItem}} + + + {children} + + ) +} + +export default Picker + +const itemClass = (active) => "btn btn-ghost " + (active ? 'bg-base-200' : '') + +export const PickerLink = (props) => { + return (
  • + + {({active}) => ()} + +
  • ) +} + +const ForwardLink = forwardRef(({href, locale, active, children, ...rest}, ref) => ( + + + + {children} + + + +)) + +export const PickerButton = ({onClick, children}) => { + return ( + {({ active }) => ( + + )} + ) +} diff --git a/sites/shared/components/theme-picker.js b/sites/shared/components/theme-picker.js index 8abee2a2e01..7eb70d387f3 100644 --- a/sites/shared/components/theme-picker.js +++ b/sites/shared/components/theme-picker.js @@ -1,41 +1,67 @@ import themes from 'shared/themes/index.js' import ThemeIcon from 'shared/components/icons/theme.js' +import {useRef} from 'react' import { useTranslation } from 'next-i18next' +import Picker, {PickerButton} from './picker'; +import { Menu } from '@headlessui/react' const ThemePicker = ({ app, className, iconOnly=false }) => { const { t } = useTranslation(['themes']) - return ( -
    -
    - - {!iconOnly && {t(`${app.theme}Theme`)}} -
    - -
    - ) + 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 ( + {Object.keys(themes).map(theme => ( + + app.setTheme(theme)} key={theme}> + {t(`${theme}Theme`)} + + ))} + ) + + + + // return ( + //
    + //
    + // + // {!iconOnly && {t(`${app.theme}Theme`)}} + //
    + // + //
    + // ) + // return null; } export default ThemePicker diff --git a/yarn.lock b/yarn.lock index 683882c4eaa..766efb2a602 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1909,6 +1909,11 @@ resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6" integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw== +"@headlessui/react@^1.6.5": + version "1.6.5" + resolved "https://registry.yarnpkg.com/@headlessui/react/-/react-1.6.5.tgz#5587c537de809cf3146eb2ff263e5e940b1bf69c" + integrity sha512-3VkKteDxlxf3fE0KbfO9t60KC1lM7YNpZggLpwzVNg1J/zwL+h+4N7MBlFDVpInZI3rKlZGpNx0PWsG/9c2vQg== + "@heroicons/react@^1.0.5": version "1.0.6" resolved "https://registry.yarnpkg.com/@heroicons/react/-/react-1.0.6.tgz#35dd26987228b39ef2316db3b1245c42eb19e324"