Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ol-style-text): added fill and stroke props #283

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/componentsguide/styles/text/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,15 @@ Fill color for the text background when `placement` is 'point'. Default is no fi
- **Type**: `Object`

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.

### fill

- **Type**: `array`, `string`

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.

### stroke

- **Type**: `Object`

Stroke style for the text. Default is no stroke. Please see [ol-style-stroke](/componentsguide/styles/stroke/#properties) for available options.
12 changes: 9 additions & 3 deletions src/components/styles/OlStyleText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const props = withDefaults(
textAlign?: CanvasTextAlign;
textBaseline?: CanvasTextBaseline;
padding?: [number, number, number, number];
fill?: Color | ColorLike;
stroke?: StrokeOptions;
backgroundFill?: Color | ColorLike;
backgroundStroke?: StrokeOptions;
}>(),
Expand Down Expand Up @@ -64,10 +66,14 @@ const createText = (properties: typeof props) => {
"fill" | "stroke" | "backgroundFill" | "backgroundStroke"
>;
const options: Options = {
...innerProperties,
fill: new Fill(),
stroke: new Stroke(),
...innerProperties
};
if (properties.fill) {
options.fill = new Fill({ color: properties.fill });
}
if (properties.stroke) {
options.stroke = new Stroke(properties.stroke);
}
if (properties.backgroundFill) {
options.backgroundFill = new Fill({ color: properties.backgroundFill });
}
Expand Down