PluginProbe
Extendify / 0.6.0
Extendify v0.6.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 / components / TaxonomySection.js

TaxonomySection.js in Extendify 0.6.0, at src/components/TaxonomySection.js

50 lines 2.3 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 '@extendify/state/Templates'
4 import { getTaxonomyName } from '@extendify/util/general'
5
6 export default function TaxonomySection({ taxType, taxonomies, taxLabel }) {
7 const updateTaxonomies = useTemplatesStore(
8 (state) => state.updateTaxonomies,
9 )
10 const searchParams = useTemplatesStore((state) => state.searchParams)
11
12 if (!taxonomies?.length > 0) return null
13 return (
14 <PanelBody
15 title={getTaxonomyName(taxLabel ?? taxType)}
16 className="ext-type-control p-0"
17 initialOpen={true}>
18 <PanelRow>
19 <div className="relative w-full overflow-hidden">
20 <ul className="m-0 w-full px-5 py-1">
21 {taxonomies.map((tax) => {
22 const isCurrentTax =
23 searchParams?.taxonomies[taxType]?.slug ===
24 tax?.slug
25 return (
26 <li className="m-0 w-full" key={tax.slug}>
27 <button
28 type="button"
29 className="button-focus m-0 flex w-full cursor-pointer items-center justify-between bg-transparent px-0 py-2 text-left text-sm leading-none transition duration-200 hover:text-wp-theme-500"
30 onClick={() =>
31 updateTaxonomies({ [taxType]: tax })
32 }>
33 <span
34 className={classNames({
35 'text-wp-theme-500':
36 isCurrentTax,
37 })}>
38 {tax?.title ?? tax.slug}
39 </span>
40 </button>
41 </li>
42 )
43 })}
44 </ul>
45 </div>
46 </PanelRow>
47 </PanelBody>
48 )
49 }
50