PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.4.0
Code Block Pro – Beautiful Syntax Highlighting v1.4.0
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / src / editor / components / ThemeSelect.tsx

ThemeSelect.tsx in Code Block Pro – Beautiful Syntax Highlighting 1.4.0, at src/editor/components/ThemeSelect.tsx

47 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { BaseControl } from '@wordpress/components';
2 import { sprintf, __ } from '@wordpress/i18n';
3 import { Lang, Theme } from 'shiki';
4 import defaultThemes from '../../defaultThemes.json';
5 import { ThemePreview } from '../components/ThemePreview';
6
7 type ThemeSelectProps = {
8 theme: Theme;
9 language: Lang;
10 code: string;
11 onClick: (slug: Theme) => void;
12 };
13 export const ThemeSelect = ({
14 theme,
15 language,
16 code,
17 onClick,
18 }: ThemeSelectProps) => {
19 return (
20 <div className="code-block-pro-editor">
21 {Object.entries(defaultThemes).map(([slug, name]) => (
22 <BaseControl
23 id={`code-block-pro-theme-${slug}`}
24 label={
25 theme === slug
26 ? sprintf(
27 __('%s (current)', 'code-block-pro'),
28 name,
29 )
30 : name
31 }
32 key={slug}>
33 <ThemePreview
34 id={`code-block-pro-theme-${slug}`}
35 theme={slug as Theme}
36 lang={language}
37 onClick={() => {
38 onClick(slug as Theme);
39 }}
40 code={code}
41 />
42 </BaseControl>
43 ))}
44 </div>
45 );
46 };
47