-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Maps] add text halo color and width style properties #53827
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c9de8dd
[Maps] add text halo color and width style properties
nreese 948de75
fix jest test
nreese 4287d30
Merge branch 'master' of github.com:elastic/kibana into text-halo
nreese 98f2fd9
update for new editor UI
nreese 6119f23
add removed styling
nreese 0cb97cc
get halo size from label size
nreese 04ca5bf
fix label border size with dynamic label size
nreese 3ea01da
clean up
nreese 66a5571
Merge branch 'master' into text-halo
elasticmachine d98b20f
fix jest test
nreese 5efd862
Merge branch 'master' into text-halo
elasticmachine ed30450
Merge branch 'text-halo' of github.com:nreese/kibana into text-halo
nreese 412e912
Merge branch 'master' of github.com:elastic/kibana into text-halo
nreese 4074895
fix jest test
nreese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...aps/public/layers/styles/vector/components/label/vector_style_label_border_size_editor.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
|
|
||
| import { EuiFormRow, EuiSelect } from '@elastic/eui'; | ||
| import { LABEL_BORDER_SIZES, VECTOR_STYLES } from '../../vector_style_defaults'; | ||
| import { getVectorStyleLabel } from '../get_vector_style_label'; | ||
| import { i18n } from '@kbn/i18n'; | ||
|
|
||
| const options = [ | ||
| { | ||
| value: LABEL_BORDER_SIZES.NONE, | ||
| text: i18n.translate('xpack.maps.styles.labelBorderSize.noneLabel', { | ||
| defaultMessage: 'None', | ||
| }), | ||
| }, | ||
| { | ||
| value: LABEL_BORDER_SIZES.SMALL, | ||
| text: i18n.translate('xpack.maps.styles.labelBorderSize.smallLabel', { | ||
| defaultMessage: 'Small', | ||
| }), | ||
| }, | ||
| { | ||
| value: LABEL_BORDER_SIZES.MEDIUM, | ||
| text: i18n.translate('xpack.maps.styles.labelBorderSize.mediumLabel', { | ||
| defaultMessage: 'Medium', | ||
| }), | ||
| }, | ||
| { | ||
| value: LABEL_BORDER_SIZES.LARGE, | ||
| text: i18n.translate('xpack.maps.styles.labelBorderSize.largeLabel', { | ||
| defaultMessage: 'Large', | ||
| }), | ||
| }, | ||
| ]; | ||
|
|
||
| export function VectorStyleLabelBorderSizeEditor({ handlePropertyChange, styleProperty }) { | ||
| function onChange(e) { | ||
| const styleDescriptor = { | ||
| options: { size: e.target.value }, | ||
| }; | ||
| handlePropertyChange(styleProperty.getStyleName(), styleDescriptor); | ||
| } | ||
|
|
||
| return ( | ||
| <EuiFormRow | ||
| label={getVectorStyleLabel(VECTOR_STYLES.LABEL_BORDER_SIZE)} | ||
| display="columnCompressed" | ||
| > | ||
| <EuiSelect | ||
| options={options} | ||
| value={styleProperty.getOptions().size} | ||
| onChange={onChange} | ||
| aria-label={i18n.translate('xpack.maps.styles.labelBorderSizeSelect.ariaLabel', { | ||
| defaultMessage: 'Select label border size', | ||
| })} | ||
| compressed | ||
| /> | ||
| </EuiFormRow> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
.../legacy/plugins/maps/public/layers/styles/vector/properties/label_border_size_property.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import _ from 'lodash'; | ||
| import { AbstractStyleProperty } from './style_property'; | ||
| import { DEFAULT_LABEL_SIZE, LABEL_BORDER_SIZES } from '../vector_style_defaults'; | ||
|
|
||
| const SMALL_SIZE = 1 / 16; | ||
| const MEDIUM_SIZE = 1 / 8; | ||
| const LARGE_SIZE = 1 / 5; // halo of 1/4 is just a square. Use smaller ratio to preserve contour on letters | ||
|
|
||
| function getWidthRatio(size) { | ||
| switch (size) { | ||
| case LABEL_BORDER_SIZES.LARGE: | ||
| return LARGE_SIZE; | ||
| case LABEL_BORDER_SIZES.MEDIUM: | ||
| return MEDIUM_SIZE; | ||
| default: | ||
| return SMALL_SIZE; | ||
| } | ||
| } | ||
|
|
||
| export class LabelBorderSizeProperty extends AbstractStyleProperty { | ||
| constructor(options, styleName, labelSizeProperty) { | ||
| super(options, styleName); | ||
| this._labelSizeProperty = labelSizeProperty; | ||
| } | ||
|
|
||
| syncLabelBorderSizeWithMb(mbLayerId, mbMap) { | ||
| const widthRatio = getWidthRatio(this.getOptions().size); | ||
|
|
||
| if (this.getOptions().size === LABEL_BORDER_SIZES.NONE) { | ||
| mbMap.setPaintProperty(mbLayerId, 'text-halo-width', 0); | ||
| } else if (this._labelSizeProperty.isDynamic() && this._labelSizeProperty.isComplete()) { | ||
| const labelSizeExpression = this._labelSizeProperty.getMbSizeExpression(); | ||
| mbMap.setPaintProperty(mbLayerId, 'text-halo-width', [ | ||
| 'max', | ||
| ['*', labelSizeExpression, widthRatio], | ||
| 1, | ||
| ]); | ||
| } else { | ||
| const labelSize = _.get(this._labelSizeProperty.getOptions(), 'size', DEFAULT_LABEL_SIZE); | ||
| const labelBorderSize = Math.max(labelSize * widthRatio, 1); | ||
| mbMap.setPaintProperty(mbLayerId, 'text-halo-width', labelBorderSize); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.