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 / FooterSelect.tsx

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

69 lines 2.1 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 type { 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(__('%s (current)', 'code-block-pro'), type)
28 : type
29 }
30 help={
31 ['simpleStringEnd', 'simpleStringStart'].includes(slug)
32 ? // Settings refers to the panel that can be expanded
33 __('Set the text at the top of this panel.', 'code-block-pro')
34 : undefined
35 }
36 key={slug}
37 >
38 <button
39 id={`code-block-pro-footer-${slug}`}
40 type="button"
41 onClick={() => onClick(slug)}
42 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"
43 >
44 <span className="pointer-events-none w-full">
45 <span
46 className="block w-full h-8"
47 style={{ backgroundColor: bgColor }}
48 />
49 <FooterType footerType={slug} {...attributesWithoutFooterType} />
50 </span>
51 </button>
52 </BaseControl>
53 ))}
54 </div>
55 );
56 };
57
58 export const FooterType = (props: Attributes) => {
59 const { footerType } = props;
60 if (footerType === 'simpleStringEnd') {
61 return <SimpleStringEnd {...props} />;
62 }
63 if (footerType === 'simpleStringStart') {
64 return <SimpleStringStart {...props} />;
65 }
66
67 return null;
68 };
69