@communitiesuk/svelte-component-library 0.1.19-beta.24 → 0.1.19-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/content/Tag.svelte +32 -0
- package/dist/components/content/Tag.svelte.d.ts +13 -0
- package/dist/components/data-vis/axis/Axis.svelte +3 -0
- package/dist/components/data-vis/axis/Axis.svelte.d.ts +1 -0
- package/dist/components/data-vis/axis/Ticks.svelte +5 -1
- package/dist/components/data-vis/axis/Ticks.svelte.d.ts +1 -0
- package/dist/components/data-vis/line-chart/ValueLabel.svelte +2 -1
- package/dist/components/data-vis/line-chart/ValueLabel.svelte.d.ts +2 -0
- package/dist/components/data-vis/position-chart/PositionChart.svelte +16 -1
- package/dist/components/data-vis/position-chart/PositionChart.svelte.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
let { text, color } = $props();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<strong class="govuk-tag trend-tag {color ? `govuk-tag--${color}` : ''}"
|
|
6
|
+
>{text}</strong
|
|
7
|
+
>
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
.govuk-tag.trend-tag {
|
|
11
|
+
padding: 0.25rem 0.625rem;
|
|
12
|
+
border-bottom: 2px solid #b1b4b6;
|
|
13
|
+
font-size: 1rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.govuk-tag.trend-tag.govuk-tag--red {
|
|
17
|
+
border-bottom-color: #ff5e5e;
|
|
18
|
+
}
|
|
19
|
+
.govuk-tag.trend-tag.govuk-tag--orange {
|
|
20
|
+
border-bottom-color: #ffaf4a;
|
|
21
|
+
}
|
|
22
|
+
.govuk-tag.trend-tag.govuk-tag--green {
|
|
23
|
+
border-bottom-color: #0fbd54;
|
|
24
|
+
}
|
|
25
|
+
.govuk-tag.trend-tag.govuk-tag--grey {
|
|
26
|
+
border-bottom-color: #b1b4b6;
|
|
27
|
+
}
|
|
28
|
+
.govuk-tag.trend-tag.govuk-tag--white {
|
|
29
|
+
background-color: #fbfbfb;
|
|
30
|
+
border-bottom-color: #cdcdcd;
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default Tag;
|
|
2
|
+
type Tag = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Tag: import("svelte").Component<{
|
|
7
|
+
text: any;
|
|
8
|
+
color: any;
|
|
9
|
+
}, {}, "">;
|
|
10
|
+
type $$ComponentProps = {
|
|
11
|
+
text: any;
|
|
12
|
+
color: any;
|
|
13
|
+
};
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
showGridlines = false,
|
|
57
57
|
showTickMarks = false,
|
|
58
58
|
strokeWidth = 2,
|
|
59
|
+
niceTicks = true,
|
|
59
60
|
}: {
|
|
60
61
|
chartHeight?: number;
|
|
61
62
|
chartWidth?: number;
|
|
@@ -83,6 +84,7 @@
|
|
|
83
84
|
strokeWidth?: Number;
|
|
84
85
|
showGridlines?: Boolean;
|
|
85
86
|
showTickMarks?: Boolean;
|
|
87
|
+
niceTicks?: Boolean;
|
|
86
88
|
} = $props();
|
|
87
89
|
|
|
88
90
|
// --- Helpers to compute default domain/range when not supplied ---
|
|
@@ -156,6 +158,7 @@
|
|
|
156
158
|
{showGridlines}
|
|
157
159
|
{showTickMarks}
|
|
158
160
|
{strokeWidth}
|
|
161
|
+
{niceTicks}
|
|
159
162
|
/>
|
|
160
163
|
{/key}
|
|
161
164
|
{/if}
|
|
@@ -31,6 +31,7 @@ type $$ComponentProps = {
|
|
|
31
31
|
strokeWidth?: Number;
|
|
32
32
|
showGridlines?: Boolean;
|
|
33
33
|
showTickMarks?: Boolean;
|
|
34
|
+
niceTicks?: Boolean;
|
|
34
35
|
};
|
|
35
36
|
declare const Axis: import("svelte").Component<$$ComponentProps, {}, "ticksArray" | "chartWidth">;
|
|
36
37
|
type Axis = ReturnType<typeof Axis>;
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
strokeWidth = 2,
|
|
38
38
|
labelFormatter = undefined as LabelFormatter | undefined,
|
|
39
|
+
niceTicks = true,
|
|
39
40
|
}: {
|
|
40
41
|
ticksArray?: number[]; // bindable
|
|
41
42
|
chartWidth: number;
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
|
|
55
56
|
strokeWidth?: number;
|
|
56
57
|
labelFormatter?: LabelFormatter;
|
|
58
|
+
niceTicks?: Boolean;
|
|
57
59
|
} = $props();
|
|
58
60
|
function axisValue(fn: any, tick: number): number {
|
|
59
61
|
// Try single-call first: axisFunction(tick)
|
|
@@ -142,7 +144,9 @@
|
|
|
142
144
|
);
|
|
143
145
|
|
|
144
146
|
let rawTicks = $derived(
|
|
145
|
-
|
|
147
|
+
niceTicks
|
|
148
|
+
? generateTicks(min, max, computedTickCount, floor, ceiling)
|
|
149
|
+
: [min, max],
|
|
146
150
|
);
|
|
147
151
|
|
|
148
152
|
let ticksOrdered = $derived(
|
|
@@ -23,6 +23,7 @@ type $$ComponentProps = {
|
|
|
23
23
|
showTickMarks?: Boolean;
|
|
24
24
|
strokeWidth?: number;
|
|
25
25
|
labelFormatter?: LabelFormatter;
|
|
26
|
+
niceTicks?: Boolean;
|
|
26
27
|
};
|
|
27
28
|
declare const Ticks: import("svelte").Component<$$ComponentProps, {}, "ticksArray">;
|
|
28
29
|
type Ticks = ReturnType<typeof Ticks>;
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
markerRect = undefined,
|
|
12
12
|
tooltipSnippet,
|
|
13
13
|
labelText = undefined,
|
|
14
|
+
yOffset = 20,
|
|
14
15
|
} = $props();
|
|
15
16
|
|
|
16
17
|
let textDimensions = $state();
|
|
@@ -31,7 +32,7 @@ left: {markerRect?.x +
|
|
|
31
32
|
style="position:absolute; left: {markerRect?.x - textDimensions?.width / 2}px;
|
|
32
33
|
top: {markerRect?.y -
|
|
33
34
|
textDimensions?.height -
|
|
34
|
-
|
|
35
|
+
yOffset}px; pointer-events: none"
|
|
35
36
|
bind:contentRect={textDimensions}
|
|
36
37
|
>
|
|
37
38
|
{#if tooltipSnippet === undefined}
|
|
@@ -15,6 +15,7 @@ declare const ValueLabel: import("svelte").Component<{
|
|
|
15
15
|
markerRect?: any;
|
|
16
16
|
tooltipSnippet: any;
|
|
17
17
|
labelText?: any;
|
|
18
|
+
yOffset?: number;
|
|
18
19
|
}, {}, "">;
|
|
19
20
|
type $$ComponentProps = {
|
|
20
21
|
activeMarkerId: any;
|
|
@@ -28,4 +29,5 @@ type $$ComponentProps = {
|
|
|
28
29
|
markerRect?: any;
|
|
29
30
|
tooltipSnippet: any;
|
|
30
31
|
labelText?: any;
|
|
32
|
+
yOffset?: number;
|
|
31
33
|
};
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
labelFormatter = (tick, index, ticksArrayLength) => {
|
|
97
97
|
return tick;
|
|
98
98
|
},
|
|
99
|
+
niceTicks = true,
|
|
99
100
|
} = $props();
|
|
100
101
|
|
|
101
102
|
let xTicks = $state([]);
|
|
@@ -420,6 +421,18 @@
|
|
|
420
421
|
2})"
|
|
421
422
|
>
|
|
422
423
|
{#if rowValue.shape === "line"}
|
|
424
|
+
<line
|
|
425
|
+
x1={0}
|
|
426
|
+
x2={0}
|
|
427
|
+
y1={chartHeight / 1.5}
|
|
428
|
+
y2={-chartHeight / 1.5}
|
|
429
|
+
stroke={rowValue.color === "inherit"
|
|
430
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
431
|
+
: rowValue.color}
|
|
432
|
+
stroke-width={rowValue.markerRadius * 5}
|
|
433
|
+
opacity={0}
|
|
434
|
+
pointer-events={rowValue.pointerEvents}
|
|
435
|
+
></line>
|
|
423
436
|
<line
|
|
424
437
|
x1={0}
|
|
425
438
|
x2={0}
|
|
@@ -430,7 +443,7 @@
|
|
|
430
443
|
: rowValue.color}
|
|
431
444
|
stroke-width={rowValue.markerRadius}
|
|
432
445
|
opacity={rowValue.opacity}
|
|
433
|
-
pointer-events=
|
|
446
|
+
pointer-events="none"
|
|
434
447
|
></line>
|
|
435
448
|
{:else}
|
|
436
449
|
<circle
|
|
@@ -478,6 +491,7 @@
|
|
|
478
491
|
{showTickMarks}
|
|
479
492
|
{showGridlines}
|
|
480
493
|
{labelFormatter}
|
|
494
|
+
{niceTicks}
|
|
481
495
|
></Axis>
|
|
482
496
|
{/if}
|
|
483
497
|
{#if showAverage}
|
|
@@ -576,6 +590,7 @@
|
|
|
576
590
|
{showTickMarks}
|
|
577
591
|
{showGridlines}
|
|
578
592
|
{labelFormatter}
|
|
593
|
+
{niceTicks}
|
|
579
594
|
></Axis>
|
|
580
595
|
{/if}
|
|
581
596
|
</div>
|
|
@@ -54,6 +54,7 @@ declare const PositionChart: import("svelte").Component<{
|
|
|
54
54
|
showTickMarks?: boolean;
|
|
55
55
|
showGridlines?: boolean;
|
|
56
56
|
labelFormatter?: Function;
|
|
57
|
+
niceTicks?: boolean;
|
|
57
58
|
}, {}, "chartWidth">;
|
|
58
59
|
type $$ComponentProps = {
|
|
59
60
|
value?: any;
|
|
@@ -106,4 +107,5 @@ type $$ComponentProps = {
|
|
|
106
107
|
showTickMarks?: boolean;
|
|
107
108
|
showGridlines?: boolean;
|
|
108
109
|
labelFormatter?: Function;
|
|
110
|
+
niceTicks?: boolean;
|
|
109
111
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "./main.css";
|
|
2
2
|
export { default as InsetText } from './components/content/InsetText.svelte';
|
|
3
|
+
export { default as Tag } from './components/content/Tag.svelte';
|
|
3
4
|
export { default as WarningText } from './components/content/WarningText.svelte';
|
|
4
5
|
export { default as Histogram } from './components/data-vis/Histogram.svelte';
|
|
5
6
|
export { default as Axis } from './components/data-vis/axis/Axis.svelte';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// this file is auto-generated — do not edit by hand
|
|
2
2
|
import "./main.css";
|
|
3
3
|
export { default as InsetText } from './components/content/InsetText.svelte';
|
|
4
|
+
export { default as Tag } from './components/content/Tag.svelte';
|
|
4
5
|
export { default as WarningText } from './components/content/WarningText.svelte';
|
|
5
6
|
export { default as Histogram } from './components/data-vis/Histogram.svelte';
|
|
6
7
|
export { default as Axis } from './components/data-vis/axis/Axis.svelte';
|