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 / components / TaxonomySection.js

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

50 lines 2.2 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 '../state/Templates'
4 import { getTaxonomyName } from '../util/general'
5
6 export default function TaxonomySection({ taxType, taxonomies }) {
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(taxType)}
16 className="ext-type-control p-0"
17 initialOpen={true}>
18 <PanelRow>
19 <div className="overflow-hidden w-full relative">
20 <ul className="px-5 py-1 m-0 w-full">
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="text-left text-sm cursor-pointer w-full flex justify-between items-center px-0 py-2 m-0 leading-none bg-transparent hover:text-wp-theme-500 transition duration-200 button-focus"
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