PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.19.0
Code Block Pro – Beautiful Syntax Highlighting v1.19.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 / seemore / BlockRight.tsx

BlockRight.tsx in Code Block Pro – Beautiful Syntax Highlighting 1.19.0, at src/editor/components/seemore/BlockRight.tsx

63 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n';
2 import { colord, AnyColor } from 'colord';
3 import { Attributes } from '../../../types';
4 import { findBackgroundColor, findTextColor } from '../../../util/colors';
5
6 export const BlockRight = (
7 attributes: Partial<Attributes> & { context?: string },
8 ) => {
9 const {
10 bgColor,
11 textColor,
12 seeMoreString,
13 disablePadding,
14 context,
15 footerType,
16 } = attributes;
17 let backgroundColor = colord(bgColor as AnyColor).toHex();
18 const textC = colord(textColor as AnyColor);
19 let color = textC.isDark()
20 ? textC.lighten(0.05).toHex()
21 : textC.darken(0.05).toHex();
22 const hasFooter = footerType !== 'none';
23 const inEditor = context === 'editor';
24
25 if (textColor?.startsWith('var(')) {
26 color = findTextColor(attributes) ?? textColor;
27 }
28 if (bgColor?.startsWith('var(')) {
29 backgroundColor = findBackgroundColor(attributes) ?? bgColor;
30 }
31
32 return (
33 <div
34 className="cbp-see-more-container"
35 style={{
36 display: context === 'front' ? 'none' : 'flex',
37 flexDirection: 'column',
38 alignItems: 'flex-end',
39 width: '100%',
40 backgroundColor: 'transparent',
41 fontSize: '12px',
42 lineHeight: '1',
43 position: 'relative',
44 marginBottom: hasFooter || inEditor ? 0 : '-16px',
45 height: hasFooter && !inEditor ? '16px' : '32px',
46 }}>
47 {/* span is used to avoid theme button styling */}
48 <span
49 role={inEditor ? 'presentation' : 'button'}
50 tabIndex={inEditor ? -1 : 0}
51 className="cbp-see-more-simple-btn cbp-see-more-simple-btn-hover"
52 style={{
53 color,
54 backgroundColor,
55 padding: disablePadding ? '10px 0 0' : '10px 16px',
56 cursor: 'default',
57 }}>
58 {seeMoreString || __('Expand', 'code-block-pro')}
59 </span>
60 </div>
61 );
62 };
63