@scalewing/react 1.37.0 → 1.39.0
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/CHANGELOG.md +18 -0
- package/README.md +91 -1
- package/dist/accessible-name.d.ts +13 -0
- package/dist/accessible-name.js +1 -0
- package/dist/chart-axis.d.ts +61 -0
- package/dist/chart-axis.js +83 -0
- package/dist/chart-dates.d.ts +6 -0
- package/dist/chart-dates.js +15 -0
- package/dist/chart-metrics.d.ts +40 -0
- package/dist/chart-metrics.js +48 -0
- package/dist/chart-scale.d.ts +48 -0
- package/dist/chart-scale.js +116 -0
- package/dist/chart-table-rows.d.ts +8 -0
- package/dist/chart-table-rows.js +1 -0
- package/dist/column-chart-bars.d.ts +38 -0
- package/dist/column-chart-bars.js +82 -0
- package/dist/column-chart-callouts.d.ts +48 -0
- package/dist/column-chart-callouts.js +54 -0
- package/dist/column-chart-input.d.ts +40 -0
- package/dist/column-chart-input.js +60 -0
- package/dist/column-chart-layout.d.ts +63 -0
- package/dist/column-chart-layout.js +97 -0
- package/dist/components/BarChart.d.ts +1 -1
- package/dist/components/BarChart.js +1 -1
- package/dist/components/ChartLegend.d.ts +38 -0
- package/dist/components/ChartLegend.js +32 -0
- package/dist/components/ColumnChart.d.ts +72 -0
- package/dist/components/ColumnChart.js +71 -0
- package/dist/components/DataBar.d.ts +48 -0
- package/dist/components/DataBar.js +28 -0
- package/dist/components/LineChart.d.ts +83 -0
- package/dist/components/LineChart.js +77 -0
- package/dist/components/Pagination.d.ts +34 -0
- package/dist/components/Pagination.js +27 -0
- package/dist/components/ScrollRegion.d.ts +9 -5
- package/dist/components/ScrollRegion.js +8 -6
- package/dist/components/SectionNav.d.ts +2 -8
- package/dist/components/SegmentedControl.d.ts +2 -8
- package/dist/components/Table.d.ts +48 -4
- package/dist/components/Table.js +9 -3
- package/dist/components/Tabs.d.ts +2 -9
- package/dist/components/chart/ChartTable.d.ts +16 -0
- package/dist/components/chart/ChartTable.js +12 -0
- package/dist/components/chart/ChartValueAxis.d.ts +14 -0
- package/dist/components/chart/ChartValueAxis.js +11 -0
- package/dist/components/chart/use-chart-width.d.ts +8 -0
- package/dist/components/chart/use-chart-width.js +34 -0
- package/dist/components/column-chart/ChartCalloutList.d.ts +16 -0
- package/dist/components/column-chart/ChartCalloutList.js +13 -0
- package/dist/components/column-chart/ColumnChartDrawing.d.ts +17 -0
- package/dist/components/column-chart/ColumnChartDrawing.js +18 -0
- package/dist/components/line-chart/LineChartDrawing.d.ts +17 -0
- package/dist/components/line-chart/LineChartDrawing.js +16 -0
- package/dist/components/table/TableRow.d.ts +8 -2
- package/dist/components/table/TableRow.js +1 -1
- package/dist/components/table/table-max-height.d.ts +20 -0
- package/dist/components/table/table-max-height.js +23 -0
- package/dist/components/use-scroll-overflow.d.ts +10 -8
- package/dist/components/use-scroll-overflow.js +23 -10
- package/dist/css/chart-marks.d.ts +10 -0
- package/dist/css/chart-marks.js +15 -0
- package/dist/css/chart-tones.d.ts +68 -0
- package/dist/css/chart-tones.js +130 -0
- package/dist/css/chevron.d.ts +6 -3
- package/dist/css/chevron.js +9 -4
- package/dist/css/{css-chart.d.ts → css-bar-chart.d.ts} +2 -2
- package/dist/css/{css-chart.js → css-bar-chart.js} +2 -2
- package/dist/css/css-chart-legend.d.ts +5 -0
- package/dist/css/css-chart-legend.js +102 -0
- package/dist/css/css-chart-plot.d.ts +2 -0
- package/dist/css/css-chart-plot.js +170 -0
- package/dist/css/css-components.js +20 -2
- package/dist/css/css-data-bar.d.ts +11 -0
- package/dist/css/css-data-bar.js +91 -0
- package/dist/css/css-line-chart.d.ts +2 -0
- package/dist/css/css-line-chart.js +31 -0
- package/dist/css/css-pagination.d.ts +2 -0
- package/dist/css/css-pagination.js +63 -0
- package/dist/css/css-scroll-region.d.ts +1 -0
- package/dist/css/css-scroll-region.js +10 -5
- package/dist/css/css-table-bounded-edges.d.ts +1 -0
- package/dist/css/css-table-bounded-edges.js +132 -0
- package/dist/css/css-table-bounded.d.ts +2 -0
- package/dist/css/css-table-bounded.js +73 -0
- package/dist/css/css-table-ledger.d.ts +5 -2
- package/dist/css/css-table-ledger.js +5 -2
- package/dist/css/css-table-metrics.d.ts +14 -0
- package/dist/css/css-table-metrics.js +13 -0
- package/dist/css/css-table-sort.js +2 -1
- package/dist/css/css-table-total-row.d.ts +2 -0
- package/dist/css/css-table-total-row.js +29 -0
- package/dist/css/css-table.js +14 -3
- package/dist/css/stylesheet.js +14 -2
- package/dist/data-bar-geometry.d.ts +24 -0
- package/dist/data-bar-geometry.js +41 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -0
- package/dist/is-one-of.d.ts +5 -0
- package/dist/is-one-of.js +7 -0
- package/dist/line-chart-input.d.ts +39 -0
- package/dist/line-chart-input.js +70 -0
- package/dist/line-chart-layout.d.ts +68 -0
- package/dist/line-chart-layout.js +99 -0
- package/dist/line-chart-markers.d.ts +29 -0
- package/dist/line-chart-markers.js +57 -0
- package/dist/line-chart-path.d.ts +18 -0
- package/dist/line-chart-path.js +33 -0
- package/dist/line-chart-points.d.ts +6 -0
- package/dist/line-chart-points.js +8 -0
- package/dist/line-chart-table.d.ts +15 -0
- package/dist/line-chart-table.js +29 -0
- package/dist/pagination-pages.d.ts +13 -0
- package/dist/pagination-pages.js +22 -0
- package/dist/scroll-overflow.d.ts +12 -0
- package/dist/scroll-overflow.js +31 -7
- package/dist/styles.css +442 -0
- package/package.json +1 -1
|
@@ -66,7 +66,7 @@ function divergingRules() {
|
|
|
66
66
|
.sw-bar-chart-diverging .sw-bar-chart-track::before { background: CanvasText; }
|
|
67
67
|
}`;
|
|
68
68
|
}
|
|
69
|
-
export function
|
|
69
|
+
export function cssBarChartClasses() {
|
|
70
70
|
return `.sw-bar-chart {
|
|
71
71
|
display: grid;
|
|
72
72
|
gap: var(--sw-space-2);
|
|
@@ -155,7 +155,7 @@ ${divergingRules()}
|
|
|
155
155
|
.sw-bar-chart-fill { background: CanvasText; }
|
|
156
156
|
}`;
|
|
157
157
|
}
|
|
158
|
-
export function
|
|
158
|
+
export function barChartClassCatalog() {
|
|
159
159
|
return [
|
|
160
160
|
'sw-bar-chart',
|
|
161
161
|
'sw-bar-chart-plot',
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The marks a legend item can show: what its words name in the chart. */
|
|
2
|
+
export declare const chartLegendSwatches: readonly ["bar", "line", "marker", "box"];
|
|
3
|
+
export type ChartLegendSwatch = (typeof chartLegendSwatches)[number];
|
|
4
|
+
export declare function cssChartLegendClasses(): string;
|
|
5
|
+
export declare function chartLegendClassCatalog(): string[];
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { typographyVariants } from '@scalewing/tokens';
|
|
2
|
+
import { chartHairline, chartLineWidth } from './chart-marks.js';
|
|
3
|
+
const caption = typographyVariants.caption;
|
|
4
|
+
/** The marks a legend item can show: what its words name in the chart. */
|
|
5
|
+
export const chartLegendSwatches = ['bar', 'line', 'marker', 'box'];
|
|
6
|
+
/*
|
|
7
|
+
* Each swatch reads its colour from the item's tone class
|
|
8
|
+
* (`sw-chart-tone-<tone>`, `chart-tones.ts`): a bar is the tone's fill, a
|
|
9
|
+
* square a spacing step 3 wide; a line is its stroke, a spacing step 4
|
|
10
|
+
* long at the charts' line width; a marker is a downward triangle in the
|
|
11
|
+
* stroke, the shape a chart's marker takes; a box is the dashed outline of
|
|
12
|
+
* the boxed current period. Forced colours draw every swatch in the system
|
|
13
|
+
* text colour, as they draw the marks.
|
|
14
|
+
*/
|
|
15
|
+
function swatchRules() {
|
|
16
|
+
return `.sw-chart-legend-bar {
|
|
17
|
+
background: var(--sw-chart-fill);
|
|
18
|
+
border-radius: calc(var(--sw-radius-sm) / 4);
|
|
19
|
+
height: var(--sw-space-3);
|
|
20
|
+
width: var(--sw-space-3);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.sw-chart-legend-line {
|
|
24
|
+
background: var(--sw-chart-stroke);
|
|
25
|
+
border-radius: var(--sw-radius-pill);
|
|
26
|
+
height: ${chartLineWidth}px;
|
|
27
|
+
width: var(--sw-space-4);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.sw-chart-legend-marker {
|
|
31
|
+
background: var(--sw-chart-stroke);
|
|
32
|
+
clip-path: polygon(0 0, 100% 0, 50% 100%);
|
|
33
|
+
height: var(--sw-space-3);
|
|
34
|
+
width: var(--sw-space-3);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.sw-chart-legend-box {
|
|
38
|
+
border: ${chartHairline}px dashed var(--sw-chart-stroke);
|
|
39
|
+
border-radius: calc(var(--sw-radius-sm) / 2);
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
height: var(--sw-space-3);
|
|
42
|
+
width: var(--sw-space-4);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@media (forced-colors: active) {
|
|
46
|
+
.sw-chart-legend-bar,
|
|
47
|
+
.sw-chart-legend-line,
|
|
48
|
+
.sw-chart-legend-marker { background: CanvasText; }
|
|
49
|
+
.sw-chart-legend-box { border-color: CanvasText; }
|
|
50
|
+
}`;
|
|
51
|
+
}
|
|
52
|
+
/*
|
|
53
|
+
* A legend is a list of its items in a wrapping row, in the caption type:
|
|
54
|
+
* each item its swatch, then its words. The words wrap within the item
|
|
55
|
+
* rather than push the row past its container, and the swatch stays
|
|
56
|
+
* centred on their first line.
|
|
57
|
+
*/
|
|
58
|
+
export function cssChartLegendClasses() {
|
|
59
|
+
return `.sw-chart-legend {
|
|
60
|
+
color: var(--sw-color-text);
|
|
61
|
+
column-gap: var(--sw-space-5);
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-wrap: wrap;
|
|
64
|
+
font-family: var(--sw-font-sans);
|
|
65
|
+
font-size: ${caption.fontSize}px;
|
|
66
|
+
font-weight: ${caption.fontWeight};
|
|
67
|
+
letter-spacing: ${caption.letterSpacing}px;
|
|
68
|
+
line-height: ${caption.lineHeight}px;
|
|
69
|
+
list-style: none;
|
|
70
|
+
margin: 0;
|
|
71
|
+
padding: 0;
|
|
72
|
+
row-gap: var(--sw-space-2);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.sw-chart-legend-item {
|
|
76
|
+
align-items: flex-start;
|
|
77
|
+
display: inline-flex;
|
|
78
|
+
gap: var(--sw-space-2);
|
|
79
|
+
min-width: 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.sw-chart-legend-swatch {
|
|
83
|
+
display: block;
|
|
84
|
+
flex: none;
|
|
85
|
+
/* Centred on the first line of the words, however many lines they wrap to. */
|
|
86
|
+
margin-block-start: calc((${caption.lineHeight}px - var(--sw-space-3)) / 2);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.sw-chart-legend-line {
|
|
90
|
+
margin-block-start: calc((${caption.lineHeight}px - ${chartLineWidth}px) / 2);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
${swatchRules()}`;
|
|
94
|
+
}
|
|
95
|
+
export function chartLegendClassCatalog() {
|
|
96
|
+
return [
|
|
97
|
+
'sw-chart-legend',
|
|
98
|
+
'sw-chart-legend-item',
|
|
99
|
+
'sw-chart-legend-swatch',
|
|
100
|
+
...chartLegendSwatches.map((swatch) => `sw-chart-legend-${swatch}`),
|
|
101
|
+
];
|
|
102
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { typographyVariants } from '@scalewing/tokens';
|
|
2
|
+
import { chartBoxDash, chartHairline, chartLeaderDash, chartLineWidth, } from './chart-marks.js';
|
|
3
|
+
const caption = typographyVariants.caption;
|
|
4
|
+
/*
|
|
5
|
+
* The parts every plotted chart (ColumnChart, LineChart) draws in its SVG:
|
|
6
|
+
* the words in the caption type, the grid and zero lines, the boxed
|
|
7
|
+
* period, a line and its last value, and the callouts with their leaders.
|
|
8
|
+
* Every colour is a theme colour or a tone's role (`chart-tones.ts`), read
|
|
9
|
+
* from the tone class on the mark or its group; words with no tone are
|
|
10
|
+
* the text colour.
|
|
11
|
+
*/
|
|
12
|
+
function plotRules() {
|
|
13
|
+
return `.sw-chart {
|
|
14
|
+
display: grid;
|
|
15
|
+
gap: var(--sw-space-2);
|
|
16
|
+
min-width: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.sw-chart-svg {
|
|
20
|
+
display: block;
|
|
21
|
+
font-family: var(--sw-font-sans);
|
|
22
|
+
font-size: ${caption.fontSize}px;
|
|
23
|
+
height: auto;
|
|
24
|
+
letter-spacing: ${caption.letterSpacing}px;
|
|
25
|
+
max-width: 100%;
|
|
26
|
+
overflow: visible;
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.sw-chart-tick,
|
|
31
|
+
.sw-chart-category {
|
|
32
|
+
fill: var(--sw-color-muted);
|
|
33
|
+
font-variant-numeric: tabular-nums;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.sw-chart-tick-line { fill: var(--sw-chart-ink); }
|
|
37
|
+
|
|
38
|
+
.sw-chart-grid {
|
|
39
|
+
stroke: var(--sw-color-border);
|
|
40
|
+
stroke-width: ${chartHairline};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.sw-chart-zero {
|
|
44
|
+
stroke: var(--sw-color-muted);
|
|
45
|
+
stroke-width: ${chartHairline};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.sw-chart-highlight {
|
|
49
|
+
fill: none;
|
|
50
|
+
stroke: var(--sw-chart-stroke);
|
|
51
|
+
stroke-dasharray: ${chartBoxDash};
|
|
52
|
+
stroke-width: ${chartHairline};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.sw-chart-line {
|
|
56
|
+
fill: none;
|
|
57
|
+
stroke: var(--sw-chart-stroke);
|
|
58
|
+
stroke-linecap: round;
|
|
59
|
+
stroke-linejoin: round;
|
|
60
|
+
stroke-width: ${chartLineWidth};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.sw-chart-dot { fill: var(--sw-chart-stroke); }
|
|
64
|
+
|
|
65
|
+
.sw-chart-end-label {
|
|
66
|
+
fill: var(--sw-chart-ink);
|
|
67
|
+
font-variant-numeric: tabular-nums;
|
|
68
|
+
font-weight: 600;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.sw-chart-leader {
|
|
72
|
+
stroke: var(--sw-chart-ink, var(--sw-color-text));
|
|
73
|
+
stroke-dasharray: ${chartLeaderDash};
|
|
74
|
+
stroke-width: ${chartHairline};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.sw-chart-callout-text {
|
|
78
|
+
fill: var(--sw-chart-ink, var(--sw-color-text));
|
|
79
|
+
font-weight: 600;
|
|
80
|
+
}`;
|
|
81
|
+
}
|
|
82
|
+
/*
|
|
83
|
+
* On a compact chart the callouts are a list under the plot: each its
|
|
84
|
+
* words in its hue's ink, after a dot in its hue's fill (the colour of its
|
|
85
|
+
* column) centred on their first line.
|
|
86
|
+
*/
|
|
87
|
+
function calloutListRules() {
|
|
88
|
+
return `.sw-chart-callouts {
|
|
89
|
+
display: grid;
|
|
90
|
+
font-family: var(--sw-font-sans);
|
|
91
|
+
font-size: ${caption.fontSize}px;
|
|
92
|
+
gap: var(--sw-space-1);
|
|
93
|
+
letter-spacing: ${caption.letterSpacing}px;
|
|
94
|
+
line-height: ${caption.lineHeight}px;
|
|
95
|
+
list-style: none;
|
|
96
|
+
margin: 0;
|
|
97
|
+
padding: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.sw-chart-callout {
|
|
101
|
+
align-items: flex-start;
|
|
102
|
+
color: var(--sw-chart-ink, var(--sw-color-text));
|
|
103
|
+
display: flex;
|
|
104
|
+
font-weight: 600;
|
|
105
|
+
gap: var(--sw-space-2);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.sw-chart-callout-dot {
|
|
109
|
+
background: var(--sw-chart-fill, currentColor);
|
|
110
|
+
border-radius: var(--sw-radius-pill);
|
|
111
|
+
flex: none;
|
|
112
|
+
height: var(--sw-space-2);
|
|
113
|
+
margin-block-start: calc((${caption.lineHeight}px - var(--sw-space-2)) / 2);
|
|
114
|
+
width: var(--sw-space-2);
|
|
115
|
+
}`;
|
|
116
|
+
}
|
|
117
|
+
/*
|
|
118
|
+
* Forced colours keep the drawing legible in the system colours: marks in
|
|
119
|
+
* the text colour (columns outlined in the canvas colour so a stack's
|
|
120
|
+
* parts stay apart), the line and its last value in the highlight colour,
|
|
121
|
+
* grid lines in the grey text colour, and every word in the text colour.
|
|
122
|
+
* The hidden table carries the figures there as everywhere.
|
|
123
|
+
*/
|
|
124
|
+
function forcedColorRules() {
|
|
125
|
+
return `@media (forced-colors: active) {
|
|
126
|
+
.sw-chart-column { fill: CanvasText; stroke: Canvas; }
|
|
127
|
+
.sw-chart-grid { stroke: GrayText; }
|
|
128
|
+
.sw-chart-zero,
|
|
129
|
+
.sw-chart-highlight,
|
|
130
|
+
.sw-chart-leader { stroke: CanvasText; }
|
|
131
|
+
.sw-chart-line { stroke: Highlight; }
|
|
132
|
+
.sw-chart-dot,
|
|
133
|
+
.sw-chart-end-label { fill: Highlight; }
|
|
134
|
+
.sw-chart-tick,
|
|
135
|
+
.sw-chart-category,
|
|
136
|
+
.sw-chart-callout-text { fill: CanvasText; }
|
|
137
|
+
.sw-chart-callout { color: CanvasText; }
|
|
138
|
+
.sw-chart-callout-dot { background: CanvasText; }
|
|
139
|
+
}`;
|
|
140
|
+
}
|
|
141
|
+
export function cssChartPlotClasses() {
|
|
142
|
+
return `${plotRules()}
|
|
143
|
+
|
|
144
|
+
.sw-chart-column { fill: var(--sw-chart-fill); }
|
|
145
|
+
|
|
146
|
+
${calloutListRules()}
|
|
147
|
+
|
|
148
|
+
${forcedColorRules()}`;
|
|
149
|
+
}
|
|
150
|
+
export function chartPlotClassCatalog() {
|
|
151
|
+
return [
|
|
152
|
+
'sw-chart',
|
|
153
|
+
'sw-chart-svg',
|
|
154
|
+
'sw-chart-tick',
|
|
155
|
+
'sw-chart-tick-line',
|
|
156
|
+
'sw-chart-category',
|
|
157
|
+
'sw-chart-grid',
|
|
158
|
+
'sw-chart-zero',
|
|
159
|
+
'sw-chart-highlight',
|
|
160
|
+
'sw-chart-line',
|
|
161
|
+
'sw-chart-dot',
|
|
162
|
+
'sw-chart-end-label',
|
|
163
|
+
'sw-chart-leader',
|
|
164
|
+
'sw-chart-callout-text',
|
|
165
|
+
'sw-chart-column',
|
|
166
|
+
'sw-chart-callouts',
|
|
167
|
+
'sw-chart-callout',
|
|
168
|
+
'sw-chart-callout-dot',
|
|
169
|
+
];
|
|
170
|
+
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { cssChartToneClasses } from './chart-tones.js';
|
|
1
2
|
import { cssActionBarClasses } from './css-action-bar.js';
|
|
2
3
|
import { cssActionMenuClasses } from './css-action-menu.js';
|
|
3
4
|
import { cssAccordionClasses } from './css-accordion.js';
|
|
4
5
|
import { cssButtonClasses } from './css-button.js';
|
|
5
6
|
import { cssCalendarButtonClasses } from './css-calendar-button.js';
|
|
6
|
-
import {
|
|
7
|
+
import { cssBarChartClasses } from './css-bar-chart.js';
|
|
8
|
+
import { cssChartLegendClasses } from './css-chart-legend.js';
|
|
9
|
+
import { cssChartPlotClasses } from './css-chart-plot.js';
|
|
10
|
+
import { cssLineChartClasses } from './css-line-chart.js';
|
|
11
|
+
import { cssDataBarClasses } from './css-data-bar.js';
|
|
12
|
+
import { cssPaginationClasses } from './css-pagination.js';
|
|
7
13
|
import { cssCheckboxClasses } from './css-checkbox.js';
|
|
8
14
|
import { cssRadioGroupClasses } from './css-radio-group.js';
|
|
9
15
|
import { cssChromeClasses } from './css-chrome.js';
|
|
@@ -135,7 +141,19 @@ ${cssDateFieldClasses()}
|
|
|
135
141
|
|
|
136
142
|
${cssCalendarButtonClasses()}
|
|
137
143
|
|
|
138
|
-
${
|
|
144
|
+
${cssBarChartClasses()}
|
|
145
|
+
|
|
146
|
+
${cssDataBarClasses()}
|
|
147
|
+
|
|
148
|
+
${cssChartToneClasses()}
|
|
149
|
+
|
|
150
|
+
${cssChartLegendClasses()}
|
|
151
|
+
|
|
152
|
+
${cssChartPlotClasses()}
|
|
153
|
+
|
|
154
|
+
${cssLineChartClasses()}
|
|
155
|
+
|
|
156
|
+
${cssPaginationClasses()}
|
|
139
157
|
|
|
140
158
|
${cssChromeClasses()}
|
|
141
159
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a range bar's fill means: the start or a carried figure (`neutral`),
|
|
3
|
+
* money in (`success`), money out (`muted`, never danger: an outflow is not
|
|
4
|
+
* an error), a subtotal (`strong`), what was counted or recorded
|
|
5
|
+
* (`accent`), and a shortage (`danger`, light red: for a shortage, never
|
|
6
|
+
* for cash leaving).
|
|
7
|
+
*/
|
|
8
|
+
export declare const dataBarTones: readonly ["neutral", "success", "muted", "strong", "accent", "danger"];
|
|
9
|
+
export type DataBarTone = (typeof dataBarTones)[number];
|
|
10
|
+
export declare function cssDataBarClasses(): string;
|
|
11
|
+
export declare function dataBarClassCatalog(): string[];
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { chartFill, statementFillTones } from './chart-tones.js';
|
|
2
|
+
/**
|
|
3
|
+
* What a range bar's fill means: the start or a carried figure (`neutral`),
|
|
4
|
+
* money in (`success`), money out (`muted`, never danger: an outflow is not
|
|
5
|
+
* an error), a subtotal (`strong`), what was counted or recorded
|
|
6
|
+
* (`accent`), and a shortage (`danger`, light red: for a shortage, never
|
|
7
|
+
* for cash leaving).
|
|
8
|
+
*/
|
|
9
|
+
export const dataBarTones = statementFillTones;
|
|
10
|
+
/*
|
|
11
|
+
* Each tone is a chart fill (`chart-tones.ts`, shared with ChartLegend's
|
|
12
|
+
* `bar` swatch so a statement's legend matches its bars): a semantic
|
|
13
|
+
* colour mixed into the surface where the board draws a lighter fill. The
|
|
14
|
+
* bar is decorative (the figure is the cell's text), so the mixes keep the
|
|
15
|
+
* tones apart from one another rather than meeting a text contrast: every
|
|
16
|
+
* tone at 1.5:1 or more on the surface, and the three greys (out, start,
|
|
17
|
+
* subtotal) 1.5:1 or more from the next one, in every palette and scheme
|
|
18
|
+
* (`data-bar.test.tsx`). `accent` is the accent itself; `danger` is the
|
|
19
|
+
* danger colour at 40 %.
|
|
20
|
+
*/
|
|
21
|
+
function toneRules() {
|
|
22
|
+
return dataBarTones
|
|
23
|
+
.map((tone) => `.sw-data-bar-${tone} > .sw-data-bar-fill { background: ${chartFill(tone)}; }`)
|
|
24
|
+
.join('\n');
|
|
25
|
+
}
|
|
26
|
+
/*
|
|
27
|
+
* A range bar fills its container's width: a track with no fill of its own,
|
|
28
|
+
* a spacing step 4 tall, and the bar placed on it by two shares the
|
|
29
|
+
* component sets (`--sw-data-bar-start`, `--sw-data-bar-size`), with
|
|
30
|
+
* logical insets so a right-to-left table mirrors it. A diverging domain
|
|
31
|
+
* draws a hairline at zero (`--sw-data-bar-zero`) across the track, under
|
|
32
|
+
* the bar, and the bar's end at zero is square (`sw-data-bar-zero-start`
|
|
33
|
+
* or `-end`), so it meets the line as BarChart's diverging bars do.
|
|
34
|
+
* Forced colours draw the bar and the line in the system text colour;
|
|
35
|
+
* the figure beside it carries the meaning there, as always.
|
|
36
|
+
*/
|
|
37
|
+
export function cssDataBarClasses() {
|
|
38
|
+
return `.sw-data-bar {
|
|
39
|
+
display: block;
|
|
40
|
+
height: var(--sw-space-4);
|
|
41
|
+
min-width: var(--sw-space-6);
|
|
42
|
+
position: relative;
|
|
43
|
+
width: 100%;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sw-data-bar-fill {
|
|
47
|
+
border-radius: calc(var(--sw-radius-sm) / 2);
|
|
48
|
+
inset-block: 0;
|
|
49
|
+
inset-inline-start: calc(var(--sw-data-bar-start, 0) * 100%);
|
|
50
|
+
position: absolute;
|
|
51
|
+
width: calc(var(--sw-data-bar-size, 0) * 100%);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
${toneRules()}
|
|
55
|
+
|
|
56
|
+
.sw-data-bar-diverging::before {
|
|
57
|
+
background: var(--sw-color-border);
|
|
58
|
+
content: '';
|
|
59
|
+
inset-block: calc(-1 * var(--sw-space-1));
|
|
60
|
+
inset-inline-start: calc(var(--sw-data-bar-zero, 0) * 100%);
|
|
61
|
+
/* Centred on zero, mirrored right to left. */
|
|
62
|
+
margin-inline-start: -0.5px;
|
|
63
|
+
position: absolute;
|
|
64
|
+
width: 1px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.sw-data-bar-zero-start > .sw-data-bar-fill {
|
|
68
|
+
border-end-start-radius: 0;
|
|
69
|
+
border-start-start-radius: 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.sw-data-bar-zero-end > .sw-data-bar-fill {
|
|
73
|
+
border-end-end-radius: 0;
|
|
74
|
+
border-start-end-radius: 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@media (forced-colors: active) {
|
|
78
|
+
.sw-data-bar > .sw-data-bar-fill,
|
|
79
|
+
.sw-data-bar-diverging::before { background: CanvasText; }
|
|
80
|
+
}`;
|
|
81
|
+
}
|
|
82
|
+
export function dataBarClassCatalog() {
|
|
83
|
+
return [
|
|
84
|
+
'sw-data-bar',
|
|
85
|
+
'sw-data-bar-fill',
|
|
86
|
+
'sw-data-bar-diverging',
|
|
87
|
+
'sw-data-bar-zero-start',
|
|
88
|
+
'sw-data-bar-zero-end',
|
|
89
|
+
...dataBarTones.map((tone) => `sw-data-bar-${tone}`),
|
|
90
|
+
];
|
|
91
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { chartAreaShare } from './chart-tones.js';
|
|
2
|
+
/*
|
|
3
|
+
* The marks only a line chart draws, beside the shared plot classes
|
|
4
|
+
* (`css-chart-plot.ts`): the area under the line, a quiet tint of its
|
|
5
|
+
* stroke; a marker's triangle in its tone's stroke; and the marker's
|
|
6
|
+
* words in its tone's ink. Forced colours drop the area and draw markers
|
|
7
|
+
* and their words in the text colour, apart from the line's highlight
|
|
8
|
+
* colour.
|
|
9
|
+
*/
|
|
10
|
+
export function cssLineChartClasses() {
|
|
11
|
+
return `.sw-chart-area {
|
|
12
|
+
fill: color-mix(in srgb, var(--sw-chart-stroke) ${chartAreaShare * 100}%, transparent);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.sw-chart-marker { fill: var(--sw-chart-stroke); }
|
|
16
|
+
|
|
17
|
+
.sw-chart-marker-label {
|
|
18
|
+
fill: var(--sw-chart-ink);
|
|
19
|
+
font-variant-numeric: tabular-nums;
|
|
20
|
+
font-weight: 600;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@media (forced-colors: active) {
|
|
24
|
+
.sw-chart-area { fill: none; }
|
|
25
|
+
.sw-chart-marker,
|
|
26
|
+
.sw-chart-marker-label { fill: CanvasText; }
|
|
27
|
+
}`;
|
|
28
|
+
}
|
|
29
|
+
export function lineChartClassCatalog() {
|
|
30
|
+
return ['sw-chart-area', 'sw-chart-marker', 'sw-chart-marker-label'];
|
|
31
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { typographyVariants } from '@scalewing/tokens';
|
|
2
|
+
import { chevronStrokeIn } from './chevron.js';
|
|
3
|
+
import { iconButtonRules } from './css-icon-button.js';
|
|
4
|
+
const caption = typographyVariants.caption;
|
|
5
|
+
/*
|
|
6
|
+
* A pager: the consumer's range words at the inline start in the muted
|
|
7
|
+
* caption, the previous and next steps at the end, wrapping under the
|
|
8
|
+
* words on a narrow column. The steps are icon-only neutral Buttons,
|
|
9
|
+
* square at their size and the touch target on a coarse pointer
|
|
10
|
+
* (`iconButtonRules`).
|
|
11
|
+
*
|
|
12
|
+
* Their glyph is private control chrome: the shared stroked chevron
|
|
13
|
+
* (`chevron.ts`) in the button's colour, pointing toward the inline start
|
|
14
|
+
* for the previous page and the end for the next; right to left one flip
|
|
15
|
+
* of the turned chevron mirrors both. It is the chevron Accordion, Select
|
|
16
|
+
* and the menus draw, not DateField's month steps (an SVG at a larger
|
|
17
|
+
* size inside the calendar).
|
|
18
|
+
*/
|
|
19
|
+
export function cssPaginationClasses() {
|
|
20
|
+
return `.sw-pagination {
|
|
21
|
+
align-items: center;
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-wrap: wrap;
|
|
24
|
+
gap: var(--sw-space-2) var(--sw-space-3);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.sw-pagination-range {
|
|
28
|
+
color: var(--sw-color-muted);
|
|
29
|
+
font-family: var(--sw-font-sans);
|
|
30
|
+
font-size: ${caption.fontSize}px;
|
|
31
|
+
font-variant-numeric: tabular-nums;
|
|
32
|
+
letter-spacing: ${caption.letterSpacing}px;
|
|
33
|
+
line-height: ${caption.lineHeight}px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.sw-pagination-steps {
|
|
37
|
+
display: flex;
|
|
38
|
+
gap: var(--sw-space-2);
|
|
39
|
+
margin-inline-start: auto;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
${iconButtonRules('sw-pagination-step')}
|
|
43
|
+
|
|
44
|
+
.sw-pagination-glyph {
|
|
45
|
+
${chevronStrokeIn('currentColor')}
|
|
46
|
+
display: block;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.sw-pagination-glyph-previous { transform: translateX(25%) rotate(135deg); }
|
|
50
|
+
.sw-pagination-glyph-next { transform: translateX(-25%) rotate(-45deg); }
|
|
51
|
+
.sw-pagination-glyph:dir(rtl) { scale: -1 1; }`;
|
|
52
|
+
}
|
|
53
|
+
export function paginationClassCatalog() {
|
|
54
|
+
return [
|
|
55
|
+
'sw-pagination',
|
|
56
|
+
'sw-pagination-range',
|
|
57
|
+
'sw-pagination-steps',
|
|
58
|
+
'sw-pagination-step',
|
|
59
|
+
'sw-pagination-glyph',
|
|
60
|
+
'sw-pagination-glyph-previous',
|
|
61
|
+
'sw-pagination-glyph-next',
|
|
62
|
+
];
|
|
63
|
+
}
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* inherited variables, so a scroll region inside another never takes its
|
|
8
8
|
* ancestor's shade.
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
10
|
+
export const scrollShadeColor = 'color-mix(in srgb, var(--sw-color-text) 28%, transparent)';
|
|
11
11
|
function edgeShade(side) {
|
|
12
12
|
const offset = side === 'left' ? 'var(--sw-space-6)' : 'calc(-1 * var(--sw-space-6))';
|
|
13
|
-
return `inset ${offset} 0 var(--sw-space-5) calc(-1 * var(--sw-space-5)) ${
|
|
13
|
+
return `inset ${offset} 0 var(--sw-space-5) calc(-1 * var(--sw-space-5)) ${scrollShadeColor}`;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* The shade each inline edge of `selector` draws while `useScrollOverflow`
|
|
@@ -61,7 +61,12 @@ ${selector}:focus-visible {
|
|
|
61
61
|
${scrollShadeRules(selector)}`;
|
|
62
62
|
}
|
|
63
63
|
export function scrollRegionClassCatalog() {
|
|
64
|
-
return [
|
|
64
|
+
return [
|
|
65
|
+
'sw-scroll-more-start',
|
|
66
|
+
'sw-scroll-more-end',
|
|
67
|
+
'sw-scroll-more-top',
|
|
68
|
+
'sw-scroll-more-bottom',
|
|
69
|
+
];
|
|
65
70
|
}
|
|
66
71
|
/**
|
|
67
72
|
* A region whose start column is pinned (sticky, on an opaque fill) hides
|
|
@@ -76,7 +81,7 @@ export function pinnedStartShadeRules(region, pinned) {
|
|
|
76
81
|
.map((cell) => `${region}.sw-scroll-more-start${direction} ${cell}::after`)
|
|
77
82
|
.join(',\n');
|
|
78
83
|
return `${after('')} {
|
|
79
|
-
background: linear-gradient(to right, ${
|
|
84
|
+
background: linear-gradient(to right, ${scrollShadeColor}, transparent);
|
|
80
85
|
content: '';
|
|
81
86
|
inset-block: 0;
|
|
82
87
|
inset-inline-start: 100%;
|
|
@@ -86,7 +91,7 @@ export function pinnedStartShadeRules(region, pinned) {
|
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
${after(':dir(rtl)')} {
|
|
89
|
-
background: linear-gradient(to left, ${
|
|
94
|
+
background: linear-gradient(to left, ${scrollShadeColor}, transparent);
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
@media (forced-colors: active) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cssTableBoundedEdgeClasses(): string;
|