PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.19.0
Code Block Pro – Beautiful Syntax Highlighting v1.19.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.19.0, at src/editor/components/FontSelect.tsx

135 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { SelectControl, FontSizePicker } 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 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
17 // @ts-ignore-next-line
18 onChange(size ?? '.875rem');
19 }}
20 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
21 // @ts-ignore-next-line
22 value={value}
23 fontSizes={[
24 {
25 name: 'Tiny',
26 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
27 // @ts-ignore-next-line
28 size: '.75rem',
29 slug: 'tiny',
30 },
31 {
32 name: 'Small',
33 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34 // @ts-ignore-next-line
35 size: '.875rem',
36 slug: 'small',
37 },
38 {
39 name: 'Normal',
40 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
41 // @ts-ignore-next-line
42 size: '1rem',
43 slug: 'normal',
44 },
45 {
46 name: 'Big',
47 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
48 // @ts-ignore-next-line
49 size: '1.125rem',
50 slug: 'big',
51 },
52 ]}
53 />
54 );
55 };
56
57 export const FontLineHeightSelect = ({
58 value,
59 onChange,
60 }: {
61 value: string;
62 onChange: (v: string | undefined) => void;
63 }) => {
64 return (
65 <FontSizePicker
66 onChange={(size) => {
67 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
68 // @ts-ignore-next-line
69 onChange(size ?? '.875rem');
70 }}
71 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
72 // @ts-ignore-next-line
73 value={value}
74 fontSizes={[
75 {
76 name: 'None',
77 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
78 // @ts-ignore-next-line
79 size: '1rem',
80 slug: 'none',
81 },
82 {
83 name: 'Tight',
84 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
85 // @ts-ignore-next-line
86 size: '1.25rem',
87 slug: 'tight',
88 },
89 {
90 name: 'Normal',
91 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
92 // @ts-ignore-next-line
93 size: '1.5rem',
94 slug: 'normal',
95 },
96 {
97 name: 'Relaxed',
98 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
99 // @ts-ignore-next-line
100 size: '1.625rem',
101 slug: 'relaxed',
102 },
103 ]}
104 />
105 );
106 };
107 export const FontFamilySelect = ({
108 value,
109 onChange,
110 }: {
111 value: string;
112 onChange: (v: string) => void;
113 }) => {
114 const fonts = {
115 'Code-Pro-Comic-Mono.ttf': 'Comic Mono',
116 'Code-Pro-Fantasque-Sans-Mono': 'Fantasque Sans Mono',
117 'Code-Pro-Fira-Code': 'Fira Code',
118 'Code-Pro-JetBrains-Mono': 'JetBrains Mono',
119 '': __('System Default', 'code-block-pro'),
120 };
121 return (
122 <SelectControl
123 id="code-block-pro-font-family"
124 label={__('Font Family', 'code-block-pro')}
125 help={__('Fonts only render on the frontend.', 'code-block-pro')}
126 value={value}
127 onChange={onChange}
128 options={Object.entries(fonts).map(([value, label]) => ({
129 label,
130 value,
131 }))}
132 />
133 );
134 };
135