← All changes
|
src/editor/components/footers/SimpleStringEnd.tsx
+14
-19
1.27.1
→
1.13.0
View file →
| @@ -1,25 +1,20 @@ | ||
| 1 | 1 | import { colord, AnyColor } from 'colord'; |
| 2 | 2 | import { Attributes, Lang } from '../../../types'; |
| 3 | -import { findBackgroundColor, findTextColor } from '../../../util/colors'; | |
| 4 | 3 | import { languages } from '../../../util/languages'; |
| 5 | 4 | |
| 6 | -export const SimpleStringEnd = (attributes: Attributes) => { | |
| 7 | - const { | |
| 8 | - language, | |
| 9 | - bgColor, | |
| 10 | - textColor, | |
| 11 | - footerString, | |
| 12 | - footerLink, | |
| 13 | - footerLinkTarget, | |
| 14 | - disablePadding, | |
| 15 | - } = attributes; | |
| 5 | +export const SimpleStringEnd = ({ | |
| 6 | + language, | |
| 7 | + bgColor, | |
| 8 | + textColor, | |
| 9 | + footerString, | |
| 10 | + footerLink, | |
| 11 | + footerLinkTarget, | |
| 12 | + disablePadding, | |
| 13 | +}: Partial<Attributes>) => { | |
| 14 | + const bgC = colord(bgColor as AnyColor); | |
| 16 | 15 | const textC = colord(textColor as AnyColor); |
| 17 | - const text = textColor?.startsWith('var(') | |
| 18 | - ? findTextColor(attributes) ?? textColor | |
| 19 | - : textC.isDark() | |
| 20 | - ? textC.lighten(0.05).toHex() | |
| 21 | - : textC.darken(0.05).toHex(); | |
| 16 | + const text = textC.isDark() ? textC.lighten(0.05) : textC.darken(0.05); | |
| 22 | 17 | return ( |
| 23 | 18 | <span |
| 24 | 19 | style={{ |
| 25 | 20 | display: 'flex', |
| @@ -26,10 +21,10 @@ | ||
| 26 | 21 | alignItems: 'flex-end', |
| 27 | 22 | padding: disablePadding ? '10px 0 0 0' : '10px', |
| 28 | 23 | width: '100%', |
| 29 | 24 | justifyContent: 'flex-end', |
| 30 | - backgroundColor: findBackgroundColor(attributes) ?? bgColor, | |
| 31 | - color: text, | |
| 25 | + backgroundColor: bgC.toHex(), | |
| 26 | + color: text.toHex(), | |
| 32 | 27 | fontSize: '12px', |
| 33 | 28 | lineHeight: '1', |
| 34 | 29 | position: 'relative', |
| 35 | 30 | }}> |
| @@ -34,9 +29,9 @@ | ||
| 34 | 29 | position: 'relative', |
| 35 | 30 | }}> |
| 36 | 31 | <Inner |
| 37 | 32 | text={footerString || languages[language as Lang]} |
| 38 | - color={text} | |
| 33 | + color={text.toHex()} | |
| 39 | 34 | link={footerLink} |
| 40 | 35 | linkTarget={footerLinkTarget} |
| 41 | 36 | /> |
| 42 | 37 | </span> |