Skip to content

Commit aab0e5f

Browse files
authored
Merge pull request #10 from raduwen/fix-css-properties
Fix css properties
2 parents dae30d3 + 8bf370c commit aab0e5f

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

components/TextWidget/index.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,27 @@ type TextWidgetProps = {
1919
position?: Position;
2020
};
2121

22+
const calcTextShadow = (weight, color) => {
23+
const edge = [
24+
`${weight}px ${weight}px 0 ${color}`,
25+
`-${weight}px -${weight}px 0 ${color}`,
26+
`-${weight}px ${weight}px 0 ${color}`,
27+
`${weight}px -${weight}px 0 ${color}`,
28+
`0px ${weight}px 0 ${color}`,
29+
`0-${weight}px 0 ${color}`,
30+
`-${weight}px 0 0 ${color}`,
31+
`${weight}px 0 0 ${color}`
32+
].join(', ');
33+
return edge;
34+
};
2235

2336
const defaultStyle: CSSProperties = {
2437
boxSizing: 'border-box',
2538
whiteSpace: 'pre-wrap',
2639
overflow: 'hidden',
27-
textColor: 'white',
40+
color: 'white',
2841
backgroundColor: 'rgba(0, 0, 0 0.1)',
29-
edgeWeight: 1,
30-
edgeColor: 'black',
42+
textShadow: calcTextShadow(1, 'black'),
3143
width: 320,
3244
height: 540,
3345
padding: '4px 8px',
@@ -45,19 +57,7 @@ const TextWidget: VFC<TextWidgetProps> = ({
4557
padding,
4658
position,
4759
}) => {
48-
const ew = edgeWeight || 1;
49-
const edge_color = edgeColor || 'black';
50-
51-
const edge = [
52-
`${ew}px ${ew}px 0 ${edge_color}`,
53-
`-${ew}px -${ew}px 0 ${edge_color}`,
54-
`-${ew}px ${ew}px 0 ${edge_color}`,
55-
`${ew}px -${ew}px 0 ${edge_color}`,
56-
`0px ${ew}px 0 ${edge_color}`,
57-
`0-${ew}px 0 ${edge_color}`,
58-
`-${ew}px 0 0 ${edge_color}`,
59-
`${ew}px 0 0 ${edge_color}`
60-
].join(', ');
60+
const edge = calcTextShadow(edgeWeight || 1, edgeColor || 'black');
6161

6262
const style: CSSProperties = {
6363
...defaultStyle,

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,9 +1169,9 @@ lodash.sortby@^4.7.0:
11691169
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
11701170

11711171
lodash@^4.17.13:
1172-
version "4.17.20"
1173-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
1174-
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
1172+
version "4.17.21"
1173+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
1174+
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
11751175

11761176
loose-envify@^1.1.0, loose-envify@^1.4.0:
11771177
version "1.4.0"

0 commit comments

Comments
 (0)