PluginProbe
Extendify / 0.5.0
Extendify v0.5.0
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / pages / Sidebar.js

Sidebar.js in Extendify 0.5.0, at src/pages/Sidebar.js

79 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Panel } from '@wordpress/components'
2 import { memo } from '@wordpress/element'
3 import { __ } from '@wordpress/i18n'
4 import { Icon } from '@wordpress/icons'
5 import classNames from 'classnames'
6 import { ImportCounter } from '@extendify/components/ImportCounter'
7 import { SiteTypeSelector } from '@extendify/components/SiteTypeSelector'
8 import TaxonomySection from '@extendify/components/TaxonomySection'
9 import { featured } from '@extendify/components/icons'
10 import { brandMark } from '@extendify/components/icons/'
11 import { useTaxonomyStore } from '@extendify/state/Taxonomies'
12 import { useTemplatesStore } from '@extendify/state/Templates'
13 import { useUserStore } from '@extendify/state/User'
14
15 export const Sidebar = memo(function Sidebar() {
16 const taxonomies = useTaxonomyStore((state) => state.taxonomies)
17 const searchParams = useTemplatesStore((state) => state.searchParams)
18 const updatePreferredSiteType = useUserStore(
19 (state) => state.updatePreferredSiteType,
20 )
21 const updateTaxonomies = useTemplatesStore(
22 (state) => state.updateTaxonomies,
23 )
24 const apiKey = useUserStore((state) => state.apiKey)
25 const taxonomyType =
26 searchParams.type === 'pattern' ? 'patternType' : 'layoutType'
27 const isFeatured = !searchParams?.taxonomies[taxonomyType]?.slug?.length
28
29 return (
30 <>
31 <div className="-ml-1.5 hidden px-5 text-extendify-black sm:flex">
32 <Icon icon={brandMark} size={40} />
33 </div>
34 <div className="px-5">
35 <button
36 onClick={() =>
37 updateTaxonomies({
38 [taxonomyType]: { slug: '', title: 'Featured' },
39 })
40 }
41 className={classNames(
42 'button-focus m-0 flex w-full cursor-pointer items-center space-x-1 bg-transparent px-0 py-2 text-left text-sm leading-none transition duration-200 hover:text-wp-theme-500',
43 { 'text-wp-theme-500': isFeatured },
44 )}>
45 <Icon icon={featured} size={24} />
46 <span className="text-sm">
47 {__('Featured', 'extendify')}
48 </span>
49 </button>
50 </div>
51 <div className="mx-6 px-5 pt-0.5 sm:mx-0 sm:mb-8 sm:mt-0">
52 {Object.keys(taxonomies?.siteType ?? {}).length > 0 && (
53 <SiteTypeSelector
54 value={searchParams?.taxonomies?.siteType ?? ''}
55 setValue={(termData) => {
56 updatePreferredSiteType(termData)
57 updateTaxonomies({ siteType: termData })
58 }}
59 terms={taxonomies.siteType}
60 />
61 )}
62 </div>
63 <div className="mt-px hidden flex-grow overflow-y-auto pb-32 pt-px sm:block">
64 <Panel className="bg-transparent">
65 <TaxonomySection
66 taxType={taxonomyType}
67 taxonomies={taxonomies[taxonomyType]}
68 />
69 </Panel>
70 </div>
71 {!apiKey.length && (
72 <div className="px-5">
73 <ImportCounter />
74 </div>
75 )}
76 </>
77 )
78 })
79