Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/brush-default-styles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'layerchart': patch
---

fix(Brush): Style the region and handle cursors with CSS instead of Tailwind classes
5 changes: 5 additions & 0 deletions .changeset/remove-tailwind-merge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'layerchart': patch
---

chore: Replace `tailwind-merge` with `clsx` (~42 KB smaller)
2 changes: 1 addition & 1 deletion docs/src/examples/components/Rule/data-x-band.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
<Layer>
<Axis placement="bottom" rule />
<Axis placement="left" />
<Rule class="stroke-2 stroke-primary stroke-4" />
<Rule class="stroke-primary stroke-4" />
</Layer>
</Chart>
2 changes: 1 addition & 1 deletion packages/layerchart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
"@dagrejs/dagre": "^2.0.4",
"@layerstack/svelte-actions": "1.0.1-next.20",
"@layerstack/svelte-state": "0.1.0-next.25",
"@layerstack/tailwind": "2.0.0-next.21",
"@layerstack/utils": "2.0.0-next.19",
"clsx": "^2.1.1",
"d3-array": "^3.2.4",
"d3-chord": "^3.0.1",
"d3-color": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script lang="ts">
import { getChartContext } from '$lib/contexts/chart.js';
import { cls } from '@layerstack/tailwind';
import { clsx } from 'clsx';
import type { LineProps } from '../Line/Line.shared.svelte.js';
import type { TextProps } from '../Text/Text.shared.svelte.js';

Expand Down Expand Up @@ -160,13 +160,13 @@
const resolvedLineProps = $derived({
...line,
...props?.line,
class: cls('lc-annotation-line', props?.line?.class),
class: clsx('lc-annotation-line', props?.line?.class),
} as LineProps);

const resolvedLabelProps = $derived({
...labelProps,
...props?.label,
class: cls('lc-annotation-line-label', props?.label?.class),
class: clsx('lc-annotation-line-label', props?.label?.class),
} as TextProps);
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import { isScaleBand } from '$lib/utils/scales.svelte.js';
import { getPointLabelLayout } from '$lib/utils/labelPlacement.js';
import { getPixelValue } from '../Text/Text.shared.svelte.js';
import { cls } from '@layerstack/tailwind';
import { clsx } from 'clsx';
import type { CircleProps } from '../Circle/Circle.shared.svelte.js';
import type { TextProps } from '../Text/Text.shared.svelte.js';

Expand Down Expand Up @@ -154,14 +154,14 @@
onmouseleave: onPointerLeave,
ontouchend: onPointerLeave,
...props?.circle,
class: cls('lc-annotation-point', link && 'lc-annotation-point-ring', props?.circle?.class),
class: clsx('lc-annotation-point', link && 'lc-annotation-point-ring', props?.circle?.class),
} as CircleProps);

const resolvedLabelProps = $derived({
...labelProps,
z: height,
...props?.label,
class: cls('lc-annotation-point-label', props?.label?.class),
class: clsx('lc-annotation-point-label', props?.label?.class),
} as TextProps);
</script>

Expand All @@ -181,7 +181,7 @@
z2={height}
type="straight"
{...linkProps}
class={cls(
class={clsx(
'lc-annotation-point-link',
typeof linkProps.class === 'string' ? linkProps.class : undefined
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script lang="ts">
import { getChartContext } from '$lib/contexts/chart.js';
import { isScaleBand } from '$lib/utils/scales.svelte.js';
import { cls } from '@layerstack/tailwind';
import { clsx } from 'clsx';
import type { RectProps } from '../Rect/Rect.shared.svelte.js';
import type { TextProps } from '../Text/Text.shared.svelte.js';

Expand Down Expand Up @@ -99,13 +99,13 @@
...rect,
...props?.rect,
fill,
class: cls('lc-annotation-range', props?.rect?.class, className),
class: clsx('lc-annotation-range', props?.rect?.class, className),
} as RectProps);

const resolvedLabelProps = $derived({
...labelProps,
...props?.label,
class: cls('lc-annotation-range-label', props?.label?.class),
class: clsx('lc-annotation-range-label', props?.label?.class),
} as TextProps);
</script>

Expand Down
4 changes: 2 additions & 2 deletions packages/layerchart/src/lib/components/Arc/Arc.base.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<script lang="ts">
import type { PointerEventHandler, TouchEventHandler } from 'svelte/elements';
import { cls } from '@layerstack/tailwind';
import { clsx } from 'clsx';

import { extractLayerProps } from '$lib/utils/attributes.js';
import { ArcState } from './Arc.shared.svelte.js';
Expand Down Expand Up @@ -122,7 +122,7 @@
transform="translate({c.xOffset}, {c.yOffset})"
{stroke}
{...restProps}
class={cls('lc-arc-line', className)}
class={clsx('lc-arc-line', className)}
onpointerenter={onPointerEnter}
onpointermove={onPointerMove}
onpointerleave={onPointerLeave}
Expand Down
6 changes: 3 additions & 3 deletions packages/layerchart/src/lib/components/Axis/Axis.base.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</script>

<script lang="ts" generics="T extends Transition = Transition">
import { cls } from '@layerstack/tailwind';
import { clsx } from 'clsx';

import { extractLayerProps } from '$lib/utils/attributes.js';

Expand Down Expand Up @@ -92,7 +92,7 @@
<Group
{...restProps}
data-placement={placement}
class={cls('lc-axis', `placement-${placement}`, classes.root, className)}
class={clsx('lc-axis', `placement-${placement}`, classes.root, className)}
>
{#if rule !== false && placement === 'back'}
{#if c.back}
Expand Down Expand Up @@ -142,7 +142,7 @@
{/if}

{#if tickMarks}
{@const tickClasses = cls('lc-axis-tick', classes.tick)}
{@const tickClasses = clsx('lc-axis-tick', classes.tick)}
{#if c.orientation === 'horizontal'}
<Line
x1={item.tickCoordsX}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { extent } from 'd3-array';
import { pointRadial } from 'd3-shape';

import { type FormatType, type FormatConfig, unique, PeriodType } from '@layerstack/utils';
import { cls } from '@layerstack/tailwind';
import { clsx } from 'clsx';

import type { Transition, TransitionParams, Without } from '$lib/utils/types.js';
import type { GroupProps } from '../Group/Group.shared.svelte.js';
Expand Down Expand Up @@ -624,7 +624,7 @@ export class AxisState {
fill,
stroke,
...labelProps,
class: cls('lc-axis-label', classes.label, labelProps?.class),
class: clsx('lc-axis-label', classes.label, labelProps?.class),
} as TextProps;
}

Expand All @@ -642,7 +642,7 @@ export class AxisState {
fill,
stroke,
...labelProps,
class: cls('lc-axis-label', classes.label, labelProps?.class),
class: clsx('lc-axis-label', classes.label, labelProps?.class),
} as TextProps;
});

Expand Down Expand Up @@ -726,7 +726,7 @@ export class AxisState {
fill,
stroke,
...tickLabelProps,
class: cls('lc-axis-tick-label', classes.tickLabel, tickLabelProps?.class),
class: clsx('lc-axis-tick-label', classes.tickLabel, tickLabelProps?.class),
} as TextProps;

return {
Expand Down
6 changes: 3 additions & 3 deletions packages/layerchart/src/lib/components/Bin/Bin.base.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</script>

<script lang="ts">
import { cls } from '@layerstack/tailwind';
import { clsx } from 'clsx';
import { extent, max } from 'd3-array';
import { geoInterpolate, geoPath } from 'd3-geo';
import { scaleSequential } from 'd3-scale';
Expand Down Expand Up @@ -343,7 +343,7 @@
strokeOpacity={item.strokeOpacity}
strokeWidth={item.strokeWidth}
opacity={item.opacity}
class={cls('lc-bin-cell', className)}
class={clsx('lc-bin-cell', className)}
onclick={onclick && ((e: MouseEvent) => onclick(e, cell))}
onpointerenter={onpointerenter && ((e: PointerEvent) => onpointerenter(e, cell))}
onpointermove={onpointermove && ((e: PointerEvent) => onpointermove(e, cell))}
Expand All @@ -365,7 +365,7 @@
fill={item.fill}
fillOpacity={item.fillOpacity}
opacity={item.opacity}
class={cls('lc-bin-side', className)}
class={clsx('lc-bin-side', className)}
/>
{#each item.shades as shade}
<Path
Expand Down
30 changes: 15 additions & 15 deletions packages/layerchart/src/lib/components/BoxPlot/BoxPlot.base.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<script lang="ts">
import type { PointerEventHandler } from 'svelte/elements';
import { cls } from '@layerstack/tailwind';
import { clsx } from 'clsx';
import { quantile } from 'd3-array';

import { accessor } from '$lib/utils/common.js';
Expand Down Expand Up @@ -156,7 +156,7 @@
y2={q1Pos}
{stroke}
{strokeWidth}
class={cls('lc-boxplot-whisker', className)}
class={clsx('lc-boxplot-whisker', className)}
/>
<Line
x1={categoryPos}
Expand All @@ -165,7 +165,7 @@
y2={maxPos}
{stroke}
{strokeWidth}
class={cls('lc-boxplot-whisker', className)}
class={clsx('lc-boxplot-whisker', className)}
/>
<Line
x1={categoryPos - whiskerCapWidth / 2}
Expand All @@ -174,7 +174,7 @@
y2={minPos}
{stroke}
{strokeWidth}
class={cls('lc-boxplot-cap', className)}
class={clsx('lc-boxplot-cap', className)}
/>
<Line
x1={categoryPos - whiskerCapWidth / 2}
Expand All @@ -183,7 +183,7 @@
y2={maxPos}
{stroke}
{strokeWidth}
class={cls('lc-boxplot-cap', className)}
class={clsx('lc-boxplot-cap', className)}
/>
<Rect
x={categoryPos - boxWidth / 2}
Expand All @@ -195,7 +195,7 @@
{stroke}
{strokeWidth}
rx={radius}
class={cls('lc-boxplot-box', className)}
class={clsx('lc-boxplot-box', className)}
/>
<Line
x1={categoryPos - boxWidth / 2}
Expand All @@ -204,7 +204,7 @@
y2={medianPos}
{stroke}
strokeWidth={strokeWidth * 2}
class={cls('lc-boxplot-median', className)}
class={clsx('lc-boxplot-median', className)}
/>
{#each outliersVal as outlier, i (i)}
<Circle
Expand All @@ -213,7 +213,7 @@
r={outlierRadius}
{stroke}
{strokeWidth}
class={cls('lc-boxplot-outlier', className)}
class={clsx('lc-boxplot-outlier', className)}
/>
{/each}
{:else}
Expand All @@ -224,7 +224,7 @@
y2={categoryPos}
{stroke}
{strokeWidth}
class={cls('lc-boxplot-whisker', className)}
class={clsx('lc-boxplot-whisker', className)}
/>
<Line
x1={q3Pos}
Expand All @@ -233,7 +233,7 @@
y2={categoryPos}
{stroke}
{strokeWidth}
class={cls('lc-boxplot-whisker', className)}
class={clsx('lc-boxplot-whisker', className)}
/>
<Line
x1={minPos}
Expand All @@ -242,7 +242,7 @@
y2={categoryPos + whiskerCapWidth / 2}
{stroke}
{strokeWidth}
class={cls('lc-boxplot-cap', className)}
class={clsx('lc-boxplot-cap', className)}
/>
<Line
x1={maxPos}
Expand All @@ -251,7 +251,7 @@
y2={categoryPos + whiskerCapWidth / 2}
{stroke}
{strokeWidth}
class={cls('lc-boxplot-cap', className)}
class={clsx('lc-boxplot-cap', className)}
/>
<Rect
x={Math.min(q1Pos, q3Pos)}
Expand All @@ -263,7 +263,7 @@
{stroke}
{strokeWidth}
rx={radius}
class={cls('lc-boxplot-box', className)}
class={clsx('lc-boxplot-box', className)}
/>
<Line
x1={medianPos}
Expand All @@ -272,7 +272,7 @@
y2={categoryPos + boxWidth / 2}
{stroke}
strokeWidth={strokeWidth * 2}
class={cls('lc-boxplot-median', className)}
class={clsx('lc-boxplot-median', className)}
/>
{#each outliersVal as outlier, i (i)}
<Circle
Expand All @@ -281,7 +281,7 @@
r={outlierRadius}
{stroke}
{strokeWidth}
class={cls('lc-boxplot-outlier', className)}
class={clsx('lc-boxplot-outlier', className)}
/>
{/each}
{/if}
Expand Down
Loading
Loading