Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
feat: add font weight (#3408)
Igor Dykhta602e61d31503
diff --git a/src/components/src/side-panel/layer-panel/text-label-panel.tsx b/src/components/src/side-panel/layer-panel/text-label-panel.tsxindex ad3b04479..22aeb6975 100644--- a/src/components/src/side-panel/layer-panel/text-label-panel.tsx+++ b/src/components/src/side-panel/layer-panel/text-label-panel.tsx@@ -22,7 +22,7 @@ import LayerConfigGroupFactory, {ConfigGroupCollapsibleHeader} from './layer-config-group';-import {LAYER_TEXT_CONFIGS} from '@kepler.gl/constants';+import {LAYER_TEXT_CONFIGS, DEFAULT_TEXT_LABEL} from '@kepler.gl/constants';import {Field, LayerTextLabel, RGBAColor, RGBColor} from '@kepler.gl/types';import FieldSelectorFactory from '../../common/field-selector';import ColorSelectorFactory from './color-selector';@@ -95,6 +95,17 @@ function TextLabelPanelFactory(onChange={v => updateLayerTextLabel(idx, 'size', v[1])}/></SidePanelSection>+ <SidePanelSection>+ <PanelLabel>+ <FormattedMessage id="panel.text.fontWeight" />+ </PanelLabel>+ <RangeSlider+ {...LAYER_TEXT_CONFIGS.fontWeight}+ value1={tl.weight ?? DEFAULT_TEXT_LABEL.weight}+ isRanged={false}+ onChange={v => updateLayerTextLabel(idx, 'weight', v[1])}+ />+ </SidePanelSection><SidePanelSection><PanelLabel><FormattedMessage id="panel.text.fontColor" />diff --git a/src/constants/src/layers.ts b/src/constants/src/layers.tsindex 4d0add2fd..02d13e911 100644--- a/src/constants/src/layers.ts+++ b/src/constants/src/layers.ts@@ -41,6 +41,7 @@ export const DEFAULT_TEXT_LABEL: LayerTextLabel = {field: null,color: [255, 255, 255],size: 18,+ weight: 400,offset: [0, 0],anchor: 'start',alignment: 'center',@@ -518,6 +519,15 @@ export const LAYER_TEXT_CONFIGS: LayerTextConfig = {label: 'Font size',showInput: true},+ fontWeight: {+ type: 'number',+ range: [100, 900],+ value0: 100,+ step: 100,+ isRanged: false,+ label: 'Font weight',+ showInput: true+ },outlineWidth: {type: 'number',range: [0, 1],diff --git a/src/layers/src/base-layer.ts b/src/layers/src/base-layer.tsindex f06c763a3..0ad20c6c9 100644--- a/src/layers/src/base-layer.ts+++ b/src/layers/src/base-layer.ts@@ -1604,6 +1604,7 @@ class Layer implements KeplerLayer {getPixelOffset: getPixelOffset(textLabel[i]),getSize: PROJECTED_PIXEL_SIZE_MULTIPLIER,sizeScale: textLabel[i].size,+ fontWeight: textLabel[i].weight ?? DEFAULT_TEXT_LABEL.weight,getTextAnchor: textLabel[i].anchor,getAlignmentBaseline: textLabel[i].alignment,getColor: textLabel[i].color,diff --git a/src/localization/src/translations/ca.ts b/src/localization/src/translations/ca.tsindex 67c7688a1..17ea19edd 100644--- a/src/localization/src/translations/ca.ts+++ b/src/localization/src/translations/ca.ts@@ -53,6 +53,7 @@ export default {label: 'etiqueta',labelWithId: 'Etiqueta {labelId}',fontSize: 'Mida de la font',+ fontWeight: 'Pes de la font',fontColor: 'Color de la font',backgroundColor: 'Color de fons',textAnchor: 'Àncora del text',diff --git a/src/localization/src/translations/cn.ts b/src/localization/src/translations/cn.tsindex ce0c60c04..f52f0da01 100644--- a/src/localization/src/translations/cn.ts+++ b/src/localization/src/translations/cn.ts@@ -53,6 +53,7 @@ export default {label: '标签',labelWithId: '标签 {labelId}',fontSize: '字体大小',+ fontWeight: '字体粗细',fontColor: '字体颜色',backgroundColor: '背景色',textAnchor: '文本锚',diff --git a/src/localization/src/translations/en.ts b/src/localization/src/translations/en.tsindex 531b5fee2..ad16df3e4 100644--- a/src/localization/src/translations/en.ts+++ b/src/localization/src/translations/en.ts@@ -53,6 +53,7 @@ export default {label: 'label',labelWithId: 'Label {labelId}',fontSize: 'Font size',+ fontWeight: 'Font weight',fontColor: 'Font color',backgroundColor: 'Background color',textAnchor: 'Text anchor',diff --git a/src/localization/src/translations/es.ts b/src/localization/src/translations/es.tsindex 650778878..80a6d82ec 100644--- a/src/localization/src/translations/es.ts+++ b/src/localization/src/translations/es.ts@@ -53,6 +53,7 @@ export default {label: 'etiqueta',labelWithId: 'Etiqueta {labelId}',fontSize: 'Tamaño de fuente',+ fontWeight: 'Peso de fuente',fontColor: 'Color de fuente',backgroundColor: 'Color de fondo',textAnchor: 'Anclaje del texto',diff --git a/src/localization/src/translations/fi.ts b/src/localization/src/translations/fi.tsindex 421b031e6..8ce573772 100644--- a/src/localization/src/translations/fi.ts+++ b/src/localization/src/translations/fi.ts@@ -52,6 +52,7 @@ export default {label: 'Nimiö',labelWithId: 'Nimiö {labelId}',fontSize: 'Fontin koko',+ fontWeight: 'Fontin paino',fontColor: 'Fontin väri',backgroundColor: 'Taustaväri',textAnchor: 'Tekstin ankkuri',diff --git a/src/localization/src/translations/ja.ts b/src/localization/src/translations/ja.tsindex f850723b1..ccb1fe0ab 100644--- a/src/localization/src/translations/ja.ts+++ b/src/localization/src/translations/ja.ts@@ -53,6 +53,7 @@ export default {label: 'ラベル',labelWithId: 'ラベル {labelId}',fontSize: '文字サイズ',+ fontWeight: 'フォントの太さ',fontColor: '文字色',textAnchor: '文字左右',alignment: '文字上下',diff --git a/src/localization/src/translations/pt.ts b/src/localization/src/translations/pt.tsindex ddf0d280b..c182f3287 100644--- a/src/localization/src/translations/pt.ts+++ b/src/localization/src/translations/pt.ts@@ -53,6 +53,7 @@ export default {label: 'Rótulo',labelWithId: 'Rótulo {labelId}',fontSize: 'Tamanho da fonte',+ fontWeight: 'Peso da fonte',fontColor: 'Cor da fonte',textAnchor: 'Âncora do texto',alignment: 'Alinhamento',diff --git a/src/localization/src/translations/ru.ts b/src/localization/src/translations/ru.tsindex 4e987683e..0a36bc3d9 100644--- a/src/localization/src/translations/ru.ts+++ b/src/localization/src/translations/ru.ts@@ -53,6 +53,7 @@ export default {label: 'Ярлык',labelWithId: 'Ярлык {labelId}',fontSize: 'Размер шрифта',+ fontWeight: 'Толщина шрифта',fontColor: 'Цвет шрифта',backgroundColor: 'Цвет фона',textAnchor: 'Анкор текста',diff --git a/src/types/layers.d.ts b/src/types/layers.d.tsindex c7933ccb5..460f77243 100644--- a/src/types/layers.d.ts+++ b/src/types/layers.d.ts@@ -162,6 +162,7 @@ export type LayerTextLabel = {color: RGBColor;background: boolean;size: number;+ weight: number;offset: [number, number];anchor: string;alignment: string;@@ -404,6 +405,7 @@ export type TextConfigNumber = {export type LayerTextConfig = {fontSize: TextConfigNumber;+ fontWeight: TextConfigNumber;outlineWidth: TextConfigNumber;textAnchor: TextConfigSelect;textAlignment: TextConfigSelect;diff --git a/test/browser/layer-tests/h3-hexagon-layer-specs.js b/test/browser/layer-tests/h3-hexagon-layer-specs.jsindex ff9b12b6c..528985552 100644--- a/test/browser/layer-tests/h3-hexagon-layer-specs.js+++ b/test/browser/layer-tests/h3-hexagon-layer-specs.js@@ -316,6 +316,7 @@ test('#H3Layer -> renderLayer', t => {},color: [255, 255, 255],size: 18,+ weight: 400,offset: [0, 0],anchor: 'middle',alignment: 'center',diff --git a/test/fixtures/state-saved-v1-4.js b/test/fixtures/state-saved-v1-4.jsindex df193c48d..9615675b2 100644--- a/test/fixtures/state-saved-v1-4.js+++ b/test/fixtures/state-saved-v1-4.js@@ -219,6 +219,7 @@ mergedLayer0.config = {},color: [184, 15, 135, 255],size: 27,+ weight: 400,offset: [-10, 0],anchor: 'end',alignment: 'center',diff --git a/test/fixtures/test-hex-id-data.js b/test/fixtures/test-hex-id-data.jsindex f20d680e9..822fb4db1 100644--- a/test/fixtures/test-hex-id-data.js+++ b/test/fixtures/test-hex-id-data.js@@ -301,6 +301,7 @@ mergedH3Layer.config = {field: null,color: [255, 255, 255],size: 18,+ weight: 400,offset: [0, 0],anchor: 'start',alignment: 'center',