PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.13.0
Code Block Pro – Beautiful Syntax Highlighting v1.13.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 / FooterSelect.tsx

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

77 lines 3.0 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 { Attributes } from '../../types';
4 import { SimpleStringEnd } from './footers/SimpleStringEnd';
5 import { SimpleStringStart } from './footers/SimpleStringStart';
6
7 type FooterSelectProps = {
8 attributes: Attributes;
9 onClick: (slug: string) => void;
10 };
11 export const FooterSelect = ({ attributes, onClick }: FooterSelectProps) => {
12 const { footerType, ...attributesWithoutFooterType }: Partial<Attributes> =
13 attributes;
14 const { bgColor } = attributes;
15 const types = {
16 none: __('None', 'code-block-pro'),
17 simpleStringEnd: __('Simple string end', 'code-block-pro'),
18 simpleStringStart: __('Simple string start', 'code-block-pro'),
19 };
20
21 return (
22 <div className="code-block-pro-editor">
23 {Object.entries(types).map(([slug, type]) => (
24 <BaseControl
25 id={`code-block-pro-footer-${slug}`}
26 label={
27 footerType === slug
28 ? sprintf(
29 __('%s (current)', 'code-block-pro'),
30 type,
31 )
32 : type
33 }
34 help={
35 ['simpleStringEnd', 'simpleStringStart'].includes(slug)
36 ? // Settings refers to the panel that can be expanded
37 __(
38 'Update extras in the Settings panel',
39 'code-block-pro',
40 )
41 : undefined
42 }
43 key={slug}>
44 <button
45 id={`code-block-pro-footer-${slug}`}
46 type="button"
47 onClick={() => onClick(slug)}
48 className="p-0 border flex items-start w-full text-left outline-none cursor-pointer no-underline ring-offset-2 ring-offset-white focus:shadow-none focus:ring-wp overflow-x-auto">
49 <span className="pointer-events-none w-full">
50 <span
51 className="block w-full h-8"
52 style={{ backgroundColor: bgColor }}
53 />
54 <FooterType
55 footerType={slug}
56 {...attributesWithoutFooterType}
57 />
58 </span>
59 </button>
60 </BaseControl>
61 ))}
62 </div>
63 );
64 };
65
66 export const FooterType = (props: Partial<Attributes>) => {
67 const { footerType } = props;
68 if (footerType === 'simpleStringEnd') {
69 return <SimpleStringEnd {...props} />;
70 }
71 if (footerType === 'simpleStringStart') {
72 return <SimpleStringStart {...props} />;
73 }
74
75 return null;
76 };
77