PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.11.1
Code Block Pro – Beautiful Syntax Highlighting v1.11.1
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 / SimpleStringEnd.tsx

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

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