| @@ -1,37 +1,33 @@ | ||
| 1 | 1 | import { PanelBody } from '@wordpress/components'; |
| 2 | 2 | import { useState } from '@wordpress/element'; |
| 3 | 3 | import { __ } from '@wordpress/i18n'; |
| 4 | -import type { Theme } from 'shiki'; | |
| 4 | +import { Theme } from 'shiki'; | |
| 5 | 5 | import { useSettingsStoreReady } from '../../state/settings'; |
| 6 | 6 | import { useThemeStore } from '../../state/theme'; |
| 7 | -import type { AttributesPropsAndSetter } from '../../types'; | |
| 7 | +import { AttributesPropsAndSetter } from '../../types'; | |
| 8 | 8 | import { ThemeFilter } from './ThemeFilter'; |
| 9 | 9 | import { ThemeSelect } from './ThemeSelect'; |
| 10 | 10 | |
| 11 | 11 | export const ThemesPanel = ({ |
| 12 | - bringAttentionToThemes, | |
| 13 | - attributes, | |
| 14 | - setAttributes, | |
| 15 | -}: AttributesPropsAndSetter & { bringAttentionToThemes?: boolean }) => { | |
| 16 | - const { updateThemeHistory } = useThemeStore(); | |
| 17 | - const [search, setSearch] = useState<string>(''); | |
| 18 | - const ready = useSettingsStoreReady(); | |
| 19 | - return ( | |
| 20 | - <PanelBody | |
| 21 | - title={__('Theme', 'code-block-pro')} | |
| 22 | - initialOpen={bringAttentionToThemes ?? false} | |
| 23 | - > | |
| 24 | - {ready && <ThemeFilter search={search} setSearch={setSearch} />} | |
| 25 | - {ready && ( | |
| 26 | - <ThemeSelect | |
| 27 | - {...attributes} | |
| 28 | - search={search} | |
| 29 | - onClick={(theme: Theme) => { | |
| 30 | - setAttributes({ theme }); | |
| 31 | - updateThemeHistory({ theme }); | |
| 32 | - }} | |
| 33 | - /> | |
| 34 | - )} | |
| 35 | - </PanelBody> | |
| 36 | - ); | |
| 12 | + attributes, | |
| 13 | + setAttributes, | |
| 14 | +}: AttributesPropsAndSetter) => { | |
| 15 | + const { updateThemeHistory } = useThemeStore(); | |
| 16 | + const [search, setSearch] = useState<string>(''); | |
| 17 | + const ready = useSettingsStoreReady(); | |
| 18 | + return ( | |
| 19 | + <PanelBody title={__('Themes', 'code-block-pro')} initialOpen={false}> | |
| 20 | + {ready && <ThemeFilter search={search} setSearch={setSearch} />} | |
| 21 | + {ready && ( | |
| 22 | + <ThemeSelect | |
| 23 | + {...attributes} | |
| 24 | + search={search} | |
| 25 | + onClick={(slug: Theme) => { | |
| 26 | + setAttributes({ theme: slug }); | |
| 27 | + updateThemeHistory({ ...attributes, theme: slug }); | |
| 28 | + }} | |
| 29 | + /> | |
| 30 | + )} | |
| 31 | + </PanelBody> | |
| 32 | + ); | |
| 37 | 33 | }; |