PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.5.0
Code Block Pro – Beautiful Syntax Highlighting v1.5.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.5.0, at src/editor/components/ThemeSelect.tsx

56 lines 1.7 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 fontSize: string;
12 lineHeight: string;
13 fontFamily: string;
14 onClick: (slug: Theme) => void;
15 };
16 export const ThemeSelect = ({
17 theme,
18 language,
19 code,
20 fontSize,
21 lineHeight,
22 fontFamily,
23 onClick,
24 }: ThemeSelectProps) => {
25 return (
26 <div className="code-block-pro-editor">
27 {Object.entries(defaultThemes).map(([slug, name]) => (
28 <BaseControl
29 id={`code-block-pro-theme-${slug}`}
30 label={
31 theme === slug
32 ? sprintf(
33 __('%s (current)', 'code-block-pro'),
34 name,
35 )
36 : name
37 }
38 key={slug}>
39 <ThemePreview
40 id={`code-block-pro-theme-${slug}`}
41 theme={slug as Theme}
42 lang={language}
43 fontSize={fontSize}
44 lineHeight={lineHeight}
45 fontFamily={fontFamily}
46 onClick={() => {
47 onClick(slug as Theme);
48 }}
49 code={code}
50 />
51 </BaseControl>
52 ))}
53 </div>
54 );
55 };
56