@@ -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
2336const 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 ,
0 commit comments