Skip to content

Commit 111be7c

Browse files
chadyd-koppenhagen
authored andcommitted
feat(ol-style-text): fill and stroke properties for the text (#283)
1 parent e5b1782 commit 111be7c

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Diff for: docs/componentsguide/styles/text/index.md

+12
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,15 @@ Fill color for the text background when `placement` is 'point'. Default is no fi
9494
- **Type**: `Object`
9595

9696
Stroke style for the text background when `placement` is 'point'. Default is no stroke. Please see [ol-style-stroke](/componentsguide/styles/stroke/#properties) for available options.
97+
98+
### fill
99+
100+
- **Type**: `array`, `string`
101+
102+
Fill color for the text. Default is '#333'. Either in hexadecimal or as RGBA array with red, green, and blue values betweeen 0 and 255 and alpha value between 0 and 1 inclusive.
103+
104+
### stroke
105+
106+
- **Type**: `Object`
107+
108+
Stroke style for the text. Default is no stroke. Please see [ol-style-stroke](/componentsguide/styles/stroke/#properties) for available options.

Diff for: src/components/styles/OlStyleText.vue

+9-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ const props = withDefaults(
3434
textAlign?: CanvasTextAlign;
3535
textBaseline?: CanvasTextBaseline;
3636
padding?: [number, number, number, number];
37+
fill?: Color | ColorLike;
38+
stroke?: StrokeOptions;
3739
backgroundFill?: Color | ColorLike;
3840
backgroundStroke?: StrokeOptions;
3941
}>(),
@@ -64,10 +66,14 @@ const createText = (properties: typeof props) => {
6466
"fill" | "stroke" | "backgroundFill" | "backgroundStroke"
6567
>;
6668
const options: Options = {
67-
...innerProperties,
68-
fill: new Fill(),
69-
stroke: new Stroke(),
69+
...innerProperties
7070
};
71+
if (properties.fill) {
72+
options.fill = new Fill({ color: properties.fill });
73+
}
74+
if (properties.stroke) {
75+
options.stroke = new Stroke(properties.stroke);
76+
}
7177
if (properties.backgroundFill) {
7278
options.backgroundFill = new Fill({ color: properties.backgroundFill });
7379
}

0 commit comments

Comments
 (0)