Skip to content

Commit acb050f

Browse files
committed
add text-align property
1 parent 923ea53 commit acb050f

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/components/TextWidget/editor.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ class TextWidgetEditor extends Component<Props, TextWidgetProps> {
140140
}}
141141
value={this.state.edgeColor}
142142
/>
143+
<TextField
144+
type="text"
145+
label="text align"
146+
fullWidth
147+
variant="outlined"
148+
onChange={(e) => {
149+
this.setState({ ...this.state, textAlign: e.target.value });
150+
}}
151+
value={this.state.textAlign}
152+
/>
153+
</FormGroup>
154+
<FormGroup>
143155
<TextField
144156
type="color"
145157
label="background color"
@@ -165,8 +177,6 @@ class TextWidgetEditor extends Component<Props, TextWidgetProps> {
165177
}}
166178
value={Color.fromRGBA(this.state.backgroundColor).a}
167179
/>
168-
</FormGroup>
169-
<FormGroup>
170180
<TextField
171181
type="number"
172182
label="width"
@@ -187,7 +197,8 @@ class TextWidgetEditor extends Component<Props, TextWidgetProps> {
187197
}}
188198
value={this.state.height}
189199
/>
190-
200+
</FormGroup>
201+
<FormGroup>
191202
<TextField
192203
type="number"
193204
label="position top"

src/components/TextWidget/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Property } from 'csstype';
2+
13
type Position = {
24
top?: number; // px
35
right?: number; // px
@@ -9,6 +11,7 @@ type TextWidgetProps = {
911
text: string;
1012
textColor?: string;
1113
fontSize?: string;
14+
textAlign?: Property.TextAlign;
1215
backgroundColor?: string;
1316
edgeWeight?: number; // px
1417
edgeColor?: string;

src/components/TextWidget/widget.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const defaultStyle: CSSProperties = {
2222
color: '#ffffff',
2323
backgroundColor: 'rgba(0,0,0,0.1)',
2424
textShadow: calcTextShadow(1, '#000000'),
25+
textAlign: 'left',
2526
width: 320,
2627
height: 540,
2728
padding: '0.25rem 0.5rem',
@@ -32,6 +33,7 @@ const TextWidget: VFC<TextWidgetProps> = ({
3233
text,
3334
textColor,
3435
fontSize,
36+
textAlign,
3537
backgroundColor,
3638
edgeWeight,
3739
edgeColor,
@@ -50,6 +52,7 @@ const TextWidget: VFC<TextWidgetProps> = ({
5052
color: textColor || '#ffffff',
5153
fontSize: fontSize || '1rem',
5254
textShadow: edge,
55+
textAlign: textAlign || 'left',
5356
backgroundColor: backgroundColor || 'rgba(0,0,0,0.1)',
5457
};
5558

0 commit comments

Comments
 (0)