Skip to content

Commit 2a1dc05

Browse files
committed
fix(Text): Allow negative string values (e.g. y="-6") in position props to be treated as pixel values instead of data property names
1 parent e9bb3da commit 2a1dc05

5 files changed

Lines changed: 9 additions & 4 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'layerchart': patch
3+
---
4+
5+
fix: Allow negative string values (e.g. `y="-6"`) in `Text` position props to be treated as pixel values instead of data property names

docs/src/examples/components/GeoPoint/icons.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<!-- TODO: How best to support canvas? -->
3939
<LucideStar class="text-danger text-[8px]" x={-5} y={-5} />
4040
<Text
41-
y="-6"
41+
y={-6}
4242
value={capital.description}
4343
textAnchor="middle"
4444
class="text-[8px] stroke-surface-100 stroke-[2px]"

docs/src/examples/components/GeoPoint/us-state-capitals.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<GeoPoint lat={capital.latitude} long={capital.longitude}>
3838
<Circle r={2} class="fill-white stroke-danger" />
3939
<Text
40-
y="-6"
40+
y={-6}
4141
value={capital.description}
4242
textAnchor="middle"
4343
class="text-[8px] stroke-surface-100 [stroke-width:2px]"

docs/src/examples/components/GeoPoint/world-capitals.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
>
6666
<Circle r={4} class="stroke-primary/50 fill-none" />
6767
<Text
68-
y="-6"
68+
y={-6}
6969
value={context.tooltip.data.label}
7070
textAnchor="middle"
7171
class="text-[8px] stroke-surface-100 stroke-[2px]"

packages/layerchart/src/lib/components/Text.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* rather than a data property accessor.
1111
*/
1212
function isCSSValue(value: string): boolean {
13-
return /^[\d.]+(%|em|rem|px|pt|cm|mm|in)?$/.test(value);
13+
return /^-?[\d.]+(%|em|rem|px|pt|cm|mm|in)?$/.test(value);
1414
}
1515
1616
/**

0 commit comments

Comments
 (0)