PluginProbe
Extendify / 0.2.0
Extendify v0.2.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.2.0, at src/pages/Sidebar.js

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