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

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

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