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

72 lines 2.8 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 ? __('Update text in Settings', 'code-block-pro')
37 : undefined
38 }
39 key={slug}>
40 <button
41 id={`code-block-pro-footer-${slug}`}
42 type="button"
43 onClick={() => onClick(slug)}
44 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">
45 <span className="pointer-events-none w-full">
46 <span
47 className="block w-full h-8"
48 style={{ backgroundColor: bgColor }}
49 />
50 <FooterType
51 footerType={slug}
52 {...attributesWithoutFooterType}
53 />
54 </span>
55 </button>
56 </BaseControl>
57 ))}
58 </div>
59 );
60 };
61
62 export const FooterType = (attributes: Partial<Attributes>) => {
63 const { footerType } = attributes;
64 if (footerType === 'simpleStringEnd') {
65 return <SimpleStringEnd {...attributes} />;
66 }
67 if (footerType === 'simpleStringStart') {
68 return <SimpleStringStart {...attributes} />;
69 }
70 return null;
71 };
72