PluginProbe
Extendify / 1.9.3
Extendify v1.9.3
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 0.7.0 All 126 releases
extendify / src / Library / components / TaxonomySection.js

TaxonomySection.js in Extendify 1.9.3, at src/Library/components/TaxonomySection.js

70 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { PanelBody, PanelRow } from '@wordpress/components'
2 import classNames from 'classnames'
3 import { useTemplatesStore } from '@library/state/Templates'
4 import { getTaxonomyName } from '@library/util/general'
5
6 const SingleTaxItem = ({ active, tax, update }) => {
7 return (
8 <li className="m-0 w-full" key={tax.slug}>
9 <button
10 type="button"
11 className="group m-0 p-0 flex w-full cursor-pointer text-left text-sm leading-none my-px bg-transparent"
12 onClick={update}>
13 <span
14 className={classNames(
15 'w-full group-hover:bg-gray-900 p-2 group-hover:text-gray-50 rounded',
16 {
17 'group-hover:bg-design-main':
18 window.extendifyData?.partnerLogo,
19 'bg-transparent text-gray-900':
20 !active && !window.extendifyData?.partnerLogo,
21 'bg-gray-900 text-gray-50':
22 active && !window.extendifyData?.partnerLogo,
23 'bg-design-main text-gray-50':
24 active && window.extendifyData?.partnerLogo,
25 },
26 )}>
27 {tax?.title ?? tax.slug}
28 </span>
29 </button>
30 </li>
31 )
32 }
33
34 export const TaxonomySection = ({ taxType, taxonomies, taxLabel }) => {
35 const searchParams = useTemplatesStore((state) => state.searchParams)
36 const updateTaxonomies = useTemplatesStore(
37 (state) => state.updateTaxonomies,
38 )
39 if (!taxonomies?.length > 0) return null
40
41 return (
42 <PanelBody
43 title={getTaxonomyName(taxLabel ?? taxType)}
44 className="ext-type-control p-0"
45 initialOpen={true}>
46 <PanelRow>
47 <div className="relative w-full overflow-hidden">
48 <ul id="filter-patterns" className="m-0 w-full px-5 py-1">
49 {taxonomies.map((tax) => {
50 const update = () =>
51 updateTaxonomies({ [taxType]: tax })
52 const isCurrentTax =
53 searchParams?.taxonomies[taxType]?.slug ===
54 tax?.slug
55 return (
56 <SingleTaxItem
57 key={tax?.slug}
58 active={isCurrentTax}
59 tax={tax}
60 update={update}
61 />
62 )
63 })}
64 </ul>
65 </div>
66 </PanelRow>
67 </PanelBody>
68 )
69 }
70