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

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

79 lines 2.9 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 { BlockLeft } from './seemore/BlockLeft';
5 import { BlockRight } from './seemore/BlockRight';
6 import { RoundCenter } from './seemore/RoundCenter';
7
8 type SeeMoreSelectProps = {
9 attributes: Attributes;
10 onClick: (slug: string) => void;
11 };
12 export const SeeMoreSelect = ({ attributes, onClick }: SeeMoreSelectProps) => {
13 const {
14 seeMoreType,
15 ...attributesWithoutSeeMoreType
16 }: Partial<Attributes> = attributes;
17 const { bgColor } = attributes;
18 const types = {
19 none: __('None', 'code-block-pro'),
20 roundCenter: __('See more center', 'code-block-pro'),
21 blockLeft: __('See more left', 'code-block-pro'),
22 blockRight: __('See more right', 'code-block-pro'),
23 };
24
25 return (
26 <div className="code-block-pro-editor">
27 {Object.entries(types).map(([slug, type]) => (
28 <BaseControl
29 id={`code-block-pro-see-more-${slug}`}
30 label={
31 seeMoreType === slug || !seeMoreType
32 ? sprintf(
33 __('%s (current)', 'code-block-pro'),
34 type,
35 )
36 : type
37 }
38 key={slug}>
39 <button
40 id={`code-block-pro-see-more-${slug}`}
41 type="button"
42 onClick={() => onClick(slug)}
43 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">
44 <span className="pointer-events-none w-full">
45 <span
46 className="block w-full h-8"
47 style={{ backgroundColor: bgColor }}
48 />
49 <SeeMoreType
50 seeMoreType={slug}
51 context="editor"
52 {...attributesWithoutSeeMoreType}
53 />
54 </span>
55 </button>
56 </BaseControl>
57 ))}
58 </div>
59 );
60 };
61
62 export const SeeMoreType = (
63 props: Partial<Attributes> & { context?: string },
64 ) => {
65 const { seeMoreType, enableMaxHeight, context } = props;
66 if (!enableMaxHeight) return null;
67 if (seeMoreType === 'roundCenter') {
68 return <RoundCenter {...props} context={context} />;
69 }
70 if (seeMoreType === 'blockLeft') {
71 return <BlockLeft {...props} context={context} />;
72 }
73 if (seeMoreType === 'blockRight') {
74 return <BlockRight {...props} context={context} />;
75 }
76
77 return null;
78 };
79