diff --git a/sites/lab/components/pattern-picker.js b/sites/lab/components/pattern-picker.js index 0a1f68b0b08..72f979a85f3 100644 --- a/sites/lab/components/pattern-picker.js +++ b/sites/lab/components/pattern-picker.js @@ -1,47 +1,44 @@ import React from 'react' -import DesignIcon from 'shared/components/icons/design.js' -import Link from 'next/link' +import DesignIcon from 'shared/components/icons/design' import { useTranslation } from 'next-i18next' +import {Picker, PickerLink} from 'shared/components/picker' const PatternPicker = ({ app }) => { const { t } = useTranslation(['common']) - return ( -
-
- - {t('designs')} -
- -
- ) + const pickerProps = { + Icon: DesignIcon, + title: t('designs'), + className: 'overflow-y-scroll navdrop' + } + + return ( + {Object.keys(app.navigation).map(section => { + const sectionProps = { + selectedItem: t(app.navigation[section].__title), + isStatic: true + } + const sectionTitle = t(app.navigation[section].__title); + {return ( +
  • + {sectionTitle} +
  • + {Object.keys(app.navigation[section]).filter((p)=>!p.startsWith('__')).map(pattern => { + const patternProps = { + href: app.navigation[section][pattern].__slug, + key: pattern + } + + return ( + {sectionTitle} {app.navigation[section][pattern].__title} + ) + })} +
    )} + })} +
    ) } export default PatternPicker diff --git a/sites/lab/components/version-picker.js b/sites/lab/components/version-picker.js index d358d596fdc..3e89b4d6bb3 100644 --- a/sites/lab/components/version-picker.js +++ b/sites/lab/components/version-picker.js @@ -1,9 +1,9 @@ import React from 'react' import VersionsIcon from 'shared/components/icons/versions.js' -import Link from 'next/link' import { useTranslation } from 'next-i18next' import versions from 'site/versions.json' import useVersion from 'site/hooks/useVersion.js' +import {Picker, PickerLink} from 'shared/components/picker' export const defaultVersion = 'next' @@ -23,31 +23,16 @@ const PatternPicker = ({ app }) => { const { t } = useTranslation(['common']) const version = useVersion() - return ( -
    -
    - - {formatVersionTitle(version)} -
    - -
    - ) + const pickerProps = { + title: formatVersionTitle(version), + Icon: VersionsIcon + } + + return ( + {[defaultVersion, ...versions].map(v => ( + {formatVersionTitle(v)} + ))} + ) } export default PatternPicker diff --git a/sites/shared/components/locale-picker.js b/sites/shared/components/locale-picker.js index b7c78999dc1..56e8e31e1bb 100644 --- a/sites/shared/components/locale-picker.js +++ b/sites/shared/components/locale-picker.js @@ -2,9 +2,7 @@ import themes from 'shared/themes/index.js' 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' +import {Picker, PickerLink} from './picker'; const LocalePicker = ({ app, iconOnly=false }) => { const { t } = useTranslation(['locales']) @@ -13,7 +11,7 @@ const LocalePicker = ({ app, iconOnly=false }) => { const pickerProps = { iconOnly, Icon: LocaleIcon, - selectedItem: t(router.locale) + title: t(router.locale) } return ( @@ -28,34 +26,6 @@ const LocalePicker = ({ app, iconOnly=false }) => { ))} ) - - // return ( - //
    - //
    - // - // {!iconOnly && {t(router.locale)}} - //
    - // - //
    - // ) } export default LocalePicker diff --git a/sites/shared/components/picker.js b/sites/shared/components/picker.js index 44949b422de..4fe7b8113f0 100644 --- a/sites/shared/components/picker.js +++ b/sites/shared/components/picker.js @@ -2,9 +2,9 @@ import {useRef, forwardRef} from 'react' import { Menu } from '@headlessui/react' import Link from 'next/link' -const Picker = ({Icon, className, selectedItem, iconOnly=false, children}) => { +export const Picker = ({Icon, className, title, iconOnly=false, children, isStatic=false}) => { - return ( + return ( { `} aria-label="Choose Theme"> - {!iconOnly && {selectedItem}} + {!iconOnly && {title}} - + {children} ) } -export default Picker - const itemClass = (active) => "btn btn-ghost " + (active ? 'bg-base-200' : '') export const PickerLink = (props) => { diff --git a/sites/shared/components/theme-picker.js b/sites/shared/components/theme-picker.js index 7eb70d387f3..9bf1e2fade5 100644 --- a/sites/shared/components/theme-picker.js +++ b/sites/shared/components/theme-picker.js @@ -1,8 +1,7 @@ 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 {Picker, PickerButton} from './picker'; import { Menu } from '@headlessui/react' const ThemePicker = ({ app, className, iconOnly=false }) => { @@ -17,7 +16,7 @@ const ThemePicker = ({ app, className, iconOnly=false }) => { className, iconOnly, Icon: ThemeIcon, - selectedItem: t(`${app.theme}Theme`) + title: t(`${app.theme}Theme`) } return ( {Object.keys(themes).map(theme => ( @@ -27,41 +26,6 @@ const ThemePicker = ({ app, className, iconOnly=false }) => { ))} ) - - - - // return ( - //
    - //
    - // - // {!iconOnly && {t(`${app.theme}Theme`)}} - //
    - // - //
    - // ) - // return null; } export default ThemePicker diff --git a/sites/shared/components/wrappers/workbench.js b/sites/shared/components/wrappers/workbench.js index d31cf594b75..a73c2d09a23 100644 --- a/sites/shared/components/wrappers/workbench.js +++ b/sites/shared/components/wrappers/workbench.js @@ -57,10 +57,11 @@ const WorkbenchWrapper = ({ app, design, preload=false, from=false, layout=false // If we don't have the required measurements, // force view to measurements useEffect(() => { + if (!gistReady) return if (gistReady && gist._state?.view !== 'measurements' && !hasRequiredMeasurements ) updateGist(['_state', 'view'], 'measurements') - }, [gistReady, gist._state.view, hasRequiredMeasurements]) + }, [gistReady, gist._state?.view, hasRequiredMeasurements]) // If we need to preload the gist, do so useEffect(() => {