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 / footers / SimpleStringStart.tsx

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

83 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { colord, AnyColor } from 'colord';
2 import { Attributes, Lang } from '../../../types';
3 import { languages } from '../../../util/languages';
4
5 export const SimpleStringStart = ({
6 language,
7 bgColor,
8 textColor,
9 footerString,
10 footerLink,
11 footerLinkTarget,
12 disablePadding,
13 }: Partial<Attributes>) => {
14 const bgC = colord(bgColor as AnyColor);
15 const textC = colord(textColor as AnyColor);
16 const text = textC.isDark() ? textC.lighten(0.05) : textC.darken(0.05);
17 return (
18 <span
19 style={{
20 display: 'flex',
21 alignItems: 'flex-end',
22 padding: disablePadding ? '10px 0 0 0' : '10px',
23 width: '100%',
24 justifyContent: 'flex-start',
25 backgroundColor: bgC.toHex(),
26 color: text.toHex(),
27 fontSize: '12px',
28 lineHeight: '1',
29 position: 'relative',
30 }}>
31 <Inner
32 text={footerString || languages[language as Lang]}
33 color={text.toHex()}
34 link={footerLink}
35 linkTarget={footerLinkTarget}
36 />
37 </span>
38 );
39 };
40
41 const Inner = ({
42 text,
43 color,
44 link,
45 linkTarget,
46 }: {
47 text?: string;
48 color: string;
49 link?: string;
50 linkTarget?: boolean;
51 }) => {
52 if (!link) return <>{text}</>;
53 const style = {
54 color,
55 // attempt to reset the link to not inheret from theme
56 textDecoration: 'none',
57 fontWeight: 'normal',
58 border: 'none',
59 background: 'none',
60 borderRadius: '0',
61 padding: '0',
62 margin: '0',
63 };
64 if (linkTarget) {
65 return (
66 <a
67 className="cbp-footer-link"
68 href={link}
69 style={style}
70 target={'_blank'}
71 // Gutenberg required
72 rel={'noopener noreferrer'}>
73 {text}
74 </a>
75 );
76 }
77 return (
78 <a className="cbp-footer-link" href={link} style={style}>
79 {text}
80 </a>
81 );
82 };
83