PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.28.0
Code Block Pro – Beautiful Syntax Highlighting v1.28.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 / FontSelect.tsx

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

133 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { FontSizePicker, SelectControl } from '@wordpress/components';
2 import { __ } from '@wordpress/i18n';
3
4 // This file ignores types as they are outdated from the source
5
6 export const FontSizeSelect = ({
7 value,
8 onChange,
9 }: {
10 value: string;
11 onChange: (v: string | undefined) => void;
12 }) => {
13 return (
14 <FontSizePicker
15 onChange={(size) => {
16 // @ts-expect-error-next-line
17 onChange(size ?? '.875rem');
18 }}
19 // @ts-expect-error-next-line
20 value={value}
21 fontSizes={[
22 {
23 name: 'Tiny',
24 // @ts-expect-error-next-line
25 size: '.75rem',
26 slug: 'tiny',
27 },
28 {
29 name: 'Small',
30 // @ts-expect-error-next-line
31 size: '.875rem',
32 slug: 'small',
33 },
34 {
35 name: 'Normal',
36 // @ts-expect-error-next-line
37 size: '1rem',
38 slug: 'normal',
39 },
40 {
41 name: 'Big',
42 // @ts-expect-error-next-line
43 size: '1.125rem',
44 slug: 'big',
45 },
46 ]}
47 />
48 );
49 };
50
51 export const FontLineHeightSelect = ({
52 value,
53 onChange,
54 }: {
55 value: string;
56 onChange: (v: string | undefined) => void;
57 }) => {
58 return (
59 <FontSizePicker
60 onChange={(size) => {
61 // @ts-expect-error-next-line
62 onChange(size ?? '.875rem');
63 }}
64 // @ts-expect-error-next-line
65 value={value}
66 fontSizes={[
67 {
68 name: 'None',
69 // @ts-expect-error-next-line
70 size: '1rem',
71 slug: 'none',
72 },
73 {
74 name: 'Tight',
75 // @ts-expect-error-next-line
76 size: '1.25rem',
77 slug: 'tight',
78 },
79 {
80 name: 'Normal',
81 // @ts-expect-error-next-line
82 size: '1.5rem',
83 slug: 'normal',
84 },
85 {
86 name: 'Relaxed',
87 // @ts-expect-error-next-line
88 size: '1.625rem',
89 slug: 'relaxed',
90 },
91 ]}
92 />
93 );
94 };
95 export const FontFamilySelect = ({
96 value,
97 onChange,
98 }: {
99 value: string;
100 onChange: (v: string) => void;
101 }) => {
102 const fonts = {
103 '': __('System Default', 'code-block-pro'),
104 'Code-Pro-Comic-Mono.ttf': 'Comic Mono',
105 'Code-Pro-Cozette': 'Cozette',
106 'Code-Pro-Deja-Vu-Mono.ttf': 'DejaVu Mono',
107 'Code-Pro-Fantasque-Sans-Mono': 'Fantasque Sans Mono',
108 'Code-Pro-Fira-Code': 'Fira Code',
109 'Code-Pro-Geist-Mono': 'Geist Mono',
110 'Code-Pro-Hack': 'Hack',
111 'Code-Pro-JetBrains-Mono': 'JetBrains Mono',
112 'Code-Pro-JetBrains-Mono-NL.ttf': 'JetBrains Mono (No Ligatures)',
113 'Code-Pro-Monaspace-Argon.woff': 'Monaspace Argon',
114 'Code-Pro-Monaspace-Krypton.woff': 'Monaspace Krypton',
115 'Code-Pro-Monaspace-Neon.woff': 'Monaspace Neon',
116 'Code-Pro-Monaspace-Radon.woff': 'Monaspace Radon',
117 'Code-Pro-Monaspace-Xenon.woff': 'Monaspace Xenon',
118 'Code-Pro-Roboto-Mono.ttf': 'Roboto Mono',
119 };
120 return (
121 <SelectControl
122 id="code-block-pro-font-family"
123 label={__('Font Family', 'code-block-pro')}
124 value={value}
125 onChange={onChange}
126 options={Object.entries(fonts).map(([value, label]) => ({
127 label,
128 value,
129 }))}
130 />
131 );
132 };
133