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

67 lines 2.6 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
6 type FooterSelectProps = {
7 attributes: Attributes;
8 onClick: (slug: string) => void;
9 };
10 export const FooterSelect = ({ attributes, onClick }: FooterSelectProps) => {
11 const { footerType, ...attributesWithoutFooterType }: Partial<Attributes> =
12 attributes;
13 const { bgColor } = attributes;
14 const types = {
15 none: __('None', 'code-block-pro'),
16 simpleStringEnd: __('Simple string end', 'code-block-pro'),
17 };
18
19 return (
20 <div className="code-block-pro-editor">
21 {Object.entries(types).map(([slug, type]) => (
22 <BaseControl
23 id={`code-block-pro-footer-${slug}`}
24 label={
25 footerType === slug
26 ? sprintf(
27 __('%s (current)', 'code-block-pro'),
28 type,
29 )
30 : type
31 }
32 help={
33 ['simpleStringEnd'].includes(slug)
34 ? __('Update text in Settings', 'code-block-pro')
35 : undefined
36 }
37 key={slug}>
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 <span className="pointer-events-none w-full">
44 <span
45 className="block w-full h-8"
46 style={{ backgroundColor: bgColor }}
47 />
48 <FooterType
49 footerType={slug}
50 {...attributesWithoutFooterType}
51 />
52 </span>
53 </button>
54 </BaseControl>
55 ))}
56 </div>
57 );
58 };
59
60 export const FooterType = (attributes: Partial<Attributes>) => {
61 const { footerType } = attributes;
62 if (footerType === 'simpleStringEnd') {
63 return <SimpleStringEnd {...attributes} />;
64 }
65 return null;
66 };
67