PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.27.2
Code Block Pro – Beautiful Syntax Highlighting v1.27.2
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.27.2, at src/editor/components/FooterSelect.tsx

76 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 } = attributes;
13 const { bgColor } = attributes;
14 const types = {
15 none: __('None', 'code-block-pro'),
16 simpleStringEnd: __('Simple string end', 'code-block-pro'),
17 simpleStringStart: __('Simple string start', 'code-block-pro'),
18 };
19
20 return (
21 <div className="code-block-pro-editor">
22 {Object.entries(types).map(([slug, type]) => (
23 <BaseControl
24 id={`code-block-pro-footer-${slug}`}
25 label={
26 footerType === slug
27 ? sprintf(
28 __('%s (current)', 'code-block-pro'),
29 type,
30 )
31 : type
32 }
33 help={
34 ['simpleStringEnd', 'simpleStringStart'].includes(slug)
35 ? // Settings refers to the panel that can be expanded
36 __(
37 'Set the text at the top of this panel.',
38 'code-block-pro',
39 )
40 : undefined
41 }
42 key={slug}>
43 <button
44 id={`code-block-pro-footer-${slug}`}
45 type="button"
46 onClick={() => onClick(slug)}
47 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">
48 <span className="pointer-events-none w-full">
49 <span
50 className="block w-full h-8"
51 style={{ backgroundColor: bgColor }}
52 />
53 <FooterType
54 footerType={slug}
55 {...attributesWithoutFooterType}
56 />
57 </span>
58 </button>
59 </BaseControl>
60 ))}
61 </div>
62 );
63 };
64
65 export const FooterType = (props: Attributes) => {
66 const { footerType } = props;
67 if (footerType === 'simpleStringEnd') {
68 return <SimpleStringEnd {...props} />;
69 }
70 if (footerType === 'simpleStringStart') {
71 return <SimpleStringStart {...props} />;
72 }
73
74 return null;
75 };
76