2022-01-22 17:55:03 +01:00
|
|
|
import React from 'react'
|
2022-07-01 18:41:07 -05:00
|
|
|
import DesignIcon from 'shared/components/icons/design'
|
2022-02-07 20:02:28 +01:00
|
|
|
import { useTranslation } from 'next-i18next'
|
2022-07-01 18:41:07 -05:00
|
|
|
import {Picker, PickerLink} from 'shared/components/picker'
|
2022-01-22 17:55:03 +01:00
|
|
|
|
2022-07-02 11:27:39 -05:00
|
|
|
|
2022-01-22 17:55:03 +01:00
|
|
|
const PatternPicker = ({ app }) => {
|
2022-02-13 15:45:27 +01:00
|
|
|
const { t } = useTranslation(['common'])
|
2022-02-10 21:40:19 +01:00
|
|
|
|
2022-07-02 11:27:39 -05:00
|
|
|
const sectionPatterns = (section) => Object.keys(app.navigation[section]).filter((p)=>!p.startsWith('__'))
|
|
|
|
|
2022-07-01 18:41:07 -05:00
|
|
|
const pickerProps = {
|
|
|
|
Icon: DesignIcon,
|
|
|
|
title: t('designs'),
|
|
|
|
className: 'overflow-y-scroll navdrop'
|
|
|
|
}
|
|
|
|
|
|
|
|
return (<Picker {...pickerProps}>
|
|
|
|
{Object.keys(app.navigation).map(section => {
|
|
|
|
const sectionTitle = t(app.navigation[section].__title);
|
2022-07-02 11:27:39 -05:00
|
|
|
|
2022-07-01 18:41:07 -05:00
|
|
|
{return (<React.Fragment key={section}>
|
|
|
|
<li className={`
|
|
|
|
capitalize font-bold text-base-content text-center
|
|
|
|
opacity-50 border-b2 my-2 border-base-content
|
2022-07-02 11:27:39 -05:00
|
|
|
`}>
|
2022-07-01 18:41:07 -05:00
|
|
|
{sectionTitle}
|
|
|
|
</li>
|
2022-07-02 11:27:39 -05:00
|
|
|
|
|
|
|
{sectionPatterns(section).map(pattern => {
|
2022-07-01 18:41:07 -05:00
|
|
|
const patternProps = {
|
2022-07-02 10:57:30 -05:00
|
|
|
href: app.navigation[section][pattern].__slug
|
2022-07-01 18:41:07 -05:00
|
|
|
}
|
|
|
|
|
2022-07-02 10:57:30 -05:00
|
|
|
return (<PickerLink {...patternProps} key={pattern}>
|
2022-07-01 18:41:07 -05:00
|
|
|
<span className="sr-only">{sectionTitle}</span> {app.navigation[section][pattern].__title}
|
|
|
|
</PickerLink>)
|
|
|
|
})}
|
|
|
|
</React.Fragment>)}
|
|
|
|
})}
|
|
|
|
</Picker>)
|
2022-01-22 17:55:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default PatternPicker
|