Skip to content

Commit e464eb9

Browse files
committed
Tailwind CSS v4 (#450)
* Initial migration to Tailwind 4 (and layerstack/svelte-ux @next) * Format project * Update all the non-transparent CSS variables to remove the hard coded `hsl()` (as variable now includes the color function) * fix(LinearGradient): Handle `tw-gradient-[from|to]` no longer inheriting * Cleanup * fix(Spline): Pass `fillOpacity` prop (instead of `fill-opacity`) to support Canvas * Update semi-transparent CSS variable usage to use `opacity`, `fillOpacity` or `color-mix()` depending on the usage * Add changeset * Use `1%` instead of `0%` opacity for gradient examples to workaround gray gradient issue due to TW4's use of `color-mix()` details: https://bsky.app/profile/techniq.dev/post/3lk6qr6e5b22t * Refine getting started * Restore prose heading styling (size/bold/margin) * fix: Support `opacity` prop/style when Canvas rendered for all primatives * docs(LineChart): Fix "Gradient threshold" highlight and tooltip color
1 parent 8ff86a5 commit e464eb9

File tree

112 files changed

+1429
-1507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+1429
-1507
lines changed

.changeset/pink-showers-hunt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'layerchart': major
3+
---
4+
5+
Tailwind 4 support

.changeset/polite-parts-learn.md

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: Support `opacity` prop/style when Canvas rendered for all primatives

.changeset/witty-clocks-divide.md

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(Spline): Pass `fillOpacity` prop (instead of `fill-opacity`) to support Canvas

packages/layerchart/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@sveltejs/package": "^2.3.10",
2828
"@sveltejs/vite-plugin-svelte": "^5.0.3",
2929
"@svitejs/changesets-changelog-github-compact": "^1.2.0",
30+
"@tailwindcss/postcss": "^4.0.12",
3031
"@tailwindcss/typography": "^0.5.16",
3132
"@types/d3-array": "^3.2.1",
3233
"@types/d3-color": "^3.1.3",
@@ -66,9 +67,9 @@
6667
"svelte": "5.20.4",
6768
"svelte-check": "^4.1.4",
6869
"svelte-json-tree": "^2.2.0",
69-
"svelte-ux": "^1.0.0",
70+
"svelte-ux": "2.0.0-next.1",
7071
"svelte2tsx": "^0.7.34",
71-
"tailwindcss": "^3.4.16",
72+
"tailwindcss": "^4.0.12",
7273
"topojson-client": "^3.1.0",
7374
"topojson-simplify": "^3.0.3",
7475
"tslib": "^2.8.1",
@@ -81,10 +82,10 @@
8182
"type": "module",
8283
"dependencies": {
8384
"@dagrejs/dagre": "^1.1.4",
84-
"@layerstack/svelte-actions": "^1.0.0",
85-
"@layerstack/svelte-stores": "^1.0.0",
86-
"@layerstack/tailwind": "^1.0.0",
87-
"@layerstack/utils": "^1.0.0",
85+
"@layerstack/svelte-actions": "1.0.1-next.0",
86+
"@layerstack/svelte-stores": "1.0.2-next.0",
87+
"@layerstack/tailwind": "2.0.0-next.1",
88+
"@layerstack/utils": "1.1.0-next.0",
8889
"d3-array": "^3.2.4",
8990
"d3-color": "^3.1.0",
9091
"d3-delaunay": "^6.0.4",
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module.exports = {
22
plugins: {
3-
'tailwindcss/nesting': {},
4-
tailwindcss: {},
5-
autoprefixer: {},
3+
'@tailwindcss/postcss': {},
64
},
75
};

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
export let fillOpacity: number | undefined = undefined;
8181
export let stroke: string | undefined = 'none';
8282
export let strokeWidth: number | undefined = undefined;
83+
export let opacity: number | undefined = undefined;
8384
8485
let className: string | undefined = undefined;
8586
export { className as class };
@@ -221,9 +222,10 @@
221222
pathData={arc()}
222223
transform="translate({xOffset}, {yOffset})"
223224
{fill}
224-
fill-opacity={fillOpacity}
225+
{fillOpacity}
225226
{stroke}
226227
stroke-width={strokeWidth}
228+
{opacity}
227229
class={className}
228230
{...$$restProps}
229231
{onclick}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
export let fillOpacity: number | undefined = undefined;
6262
export let stroke: string | undefined = undefined;
6363
export let strokeWidth: number | undefined = undefined;
64+
export let opacity: number | undefined = undefined;
6465
6566
let className: string | undefined = undefined;
6667
export { className as class };
@@ -166,7 +167,7 @@
166167
styleOverrides
167168
? merge({ styles: { strokeWidth } }, styleOverrides)
168169
: {
169-
styles: { fill, fillOpacity, stroke, strokeWidth },
170+
styles: { fill, fillOpacity, stroke, strokeWidth, opacity },
170171
classes: className,
171172
}
172173
);
@@ -178,7 +179,7 @@
178179
179180
$: if (renderContext === 'canvas') {
180181
// Redraw when props change
181-
fillKey && fillOpacity && strokeKey && strokeWidth && className;
182+
fillKey && fillOpacity && strokeKey && strokeWidth && opacity && className;
182183
canvasContext.invalidate();
183184
}
184185
@@ -228,6 +229,7 @@
228229
fill-opacity={fillOpacity}
229230
{stroke}
230231
stroke-width={strokeWidth}
232+
{opacity}
231233
{...$$restProps}
232234
class={cls('path-area', className)}
233235
on:click={onclick}

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import Rect from './Rect.svelte';
66
import Spline from './Spline.svelte';
77
8-
import { getRenderContext } from './Chart.svelte';
9-
import { getCanvasContext } from './layout/Canvas.svelte';
108
import { createDimensionGetter, type Insets } from '../utils/rect.js';
119
import { isScaleBand } from '../utils/scales.js';
1210
import { accessor, type Accessor } from '../utils/common.js';
@@ -37,8 +35,10 @@
3735
export let y1: Accessor = undefined;
3836
3937
export let fill: string | undefined = undefined;
38+
export let fillOpacity: number | undefined = undefined;
4039
export let stroke = 'black';
4140
export let strokeWidth = 0;
41+
export let opacity: number | undefined = undefined;
4242
export let radius = 0;
4343
4444
/** Control which corners are rounded with radius. Uses <path> instead of <rect> when not set to `all` */
@@ -113,19 +113,18 @@
113113
z`
114114
.split('\n')
115115
.join('');
116-
117-
const renderContext = getRenderContext();
118-
const canvasContext = getCanvasContext();
119116
</script>
120117

121118
{#if _rounded === 'all' || _rounded === 'none' || radius === 0}
122119
<Rect
123120
{fill}
124-
{spring}
125-
{tweened}
121+
{fillOpacity}
126122
{stroke}
127123
{strokeWidth}
124+
{opacity}
128125
rx={_rounded === 'none' ? 0 : radius}
126+
{spring}
127+
{tweened}
129128
{onclick}
130129
{onpointerenter}
131130
{onpointermove}
@@ -138,10 +137,12 @@
138137
<Spline
139138
{pathData}
140139
{fill}
141-
{spring}
142-
{tweened}
140+
{fillOpacity}
143141
{stroke}
144142
{strokeWidth}
143+
{opacity}
144+
{spring}
145+
{tweened}
145146
{onclick}
146147
{onpointerenter}
147148
{onpointermove}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
export let strokeWidth = 0;
3939
export let radius = 0;
4040
export let fill: string | undefined = undefined;
41+
export let fillOpacity: number | undefined = undefined;
42+
export let opacity: number | undefined = undefined;
4143
4244
/** Inset the rect for amount of padding. Useful with multiple bars (bullet, overlap, etc) */
4345
export let insets: Insets | undefined = undefined;
@@ -64,8 +66,10 @@
6466
{x1}
6567
{y1}
6668
fill={fill ?? ($config.c ? $cGet(d) : null)}
69+
{fillOpacity}
6770
{stroke}
6871
{strokeWidth}
72+
{opacity}
6973
{radius}
7074
{insets}
7175
{spring}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
export let fillOpacity: number | undefined = undefined;
2727
export let stroke: string | undefined = undefined;
2828
export let strokeWidth: number | undefined = undefined;
29+
export let opacity: number | undefined = undefined;
2930
3031
let className: string | undefined = undefined;
3132
export { className as class };
@@ -59,7 +60,7 @@
5960
styleOverrides
6061
? merge({ styles: { strokeWidth } }, styleOverrides)
6162
: {
62-
styles: { fill, fillOpacity, stroke, strokeWidth },
63+
styles: { fill, fillOpacity, stroke, strokeWidth, opacity },
6364
classes: className,
6465
}
6566
);
@@ -78,6 +79,7 @@
7879
fillOpacity &&
7980
strokeKey &&
8081
strokeWidth &&
82+
opacity &&
8183
className;
8284
canvasContext.invalidate();
8385
}
@@ -114,6 +116,7 @@
114116
fill-opacity={fillOpacity}
115117
{stroke}
116118
stroke-width={strokeWidth}
119+
{opacity}
117120
class={cls(fill == null && 'fill-surface-content', className)}
118121
{...$$restProps}
119122
on:click={onclick}

0 commit comments

Comments
 (0)