@scalewing/react 1.38.0 → 1.40.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 +155 -1
- package/dist/calendar-month.d.ts +6 -0
- package/dist/calendar-month.js +15 -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 +6 -6
- package/dist/components/DateRangeButton.d.ts +65 -0
- package/dist/components/DateRangeButton.js +54 -0
- package/dist/components/LineChart.d.ts +83 -0
- package/dist/components/LineChart.js +77 -0
- package/dist/components/ListGroup.d.ts +33 -0
- package/dist/components/ListGroup.js +19 -0
- package/dist/components/ListRow.d.ts +51 -0
- package/dist/components/ListRow.js +59 -0
- package/dist/components/NavCount.d.ts +21 -0
- package/dist/components/NavCount.js +23 -0
- package/dist/components/SectionNav.js +1 -8
- package/dist/components/StatTile.d.ts +11 -4
- package/dist/components/StatTile.js +11 -4
- package/dist/components/{date-field → calendar}/CalendarGrid.d.ts +17 -2
- package/dist/components/{date-field → calendar}/CalendarGrid.js +11 -3
- package/dist/components/calendar/CalendarPopover.d.ts +25 -0
- package/dist/components/calendar/CalendarPopover.js +22 -0
- package/dist/components/calendar/MonthStep.d.ts +16 -0
- package/dist/components/calendar/MonthStep.js +17 -0
- package/dist/components/calendar/use-grid-focus.d.ts +18 -0
- package/dist/components/calendar/use-grid-focus.js +35 -0
- package/dist/components/calendar/wrap-tab.d.ts +7 -0
- package/dist/components/calendar/wrap-tab.js +29 -0
- 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/date-field/CalendarDialog.js +9 -67
- package/dist/components/date-field/CalendarHeader.js +2 -11
- package/dist/components/date-range/DateRangePopover.d.ts +7 -0
- package/dist/components/date-range/DateRangePopover.js +17 -0
- package/dist/components/date-range/DateRangeSheet.d.ts +7 -0
- package/dist/components/date-range/DateRangeSheet.js +15 -0
- package/dist/components/date-range/RangeMonths.d.ts +28 -0
- package/dist/components/date-range/RangeMonths.js +50 -0
- package/dist/components/date-range/RangePresets.d.ts +16 -0
- package/dist/components/date-range/RangePresets.js +10 -0
- package/dist/components/date-range/RangeSummary.d.ts +15 -0
- package/dist/components/date-range/RangeSummary.js +11 -0
- package/dist/components/date-range/range-panel-props.d.ts +31 -0
- package/dist/components/date-range/range-panel-props.js +1 -0
- package/dist/components/date-range/use-range-popup.d.ts +21 -0
- package/dist/components/date-range/use-range-popup.js +53 -0
- package/dist/components/line-chart/LineChartDrawing.d.ts +17 -0
- package/dist/components/line-chart/LineChartDrawing.js +16 -0
- package/dist/components/link-press.d.ts +7 -0
- package/dist/components/link-press.js +13 -0
- package/dist/components/list/ListRowAccessoryMark.d.ts +5 -0
- package/dist/components/list/ListRowAccessoryMark.js +7 -0
- package/dist/components/list/ListRowContent.d.ts +20 -0
- package/dist/components/list/ListRowContent.js +10 -0
- package/dist/components/list/list-row-container.d.ts +5 -0
- package/dist/components/list/list-row-container.js +6 -0
- package/dist/components/use-media-query.d.ts +5 -0
- package/dist/components/use-media-query.js +18 -0
- 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 -0
- package/dist/css/chevron.js +14 -0
- 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-button-group-attached.js +8 -4
- package/dist/css/css-button-group-track.js +1 -1
- 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-checkbox.js +2 -2
- package/dist/css/css-components.js +23 -2
- package/dist/css/css-count-pill.d.ts +2 -0
- package/dist/css/css-count-pill.js +54 -0
- package/dist/css/css-data-bar.d.ts +4 -9
- package/dist/css/css-data-bar.js +15 -31
- package/dist/css/css-date-field.js +3 -2
- package/dist/css/css-date-range-presets.d.ts +2 -0
- package/dist/css/css-date-range-presets.js +109 -0
- package/dist/css/css-date-range.d.ts +2 -0
- package/dist/css/css-date-range.js +197 -0
- package/dist/css/css-line-chart.d.ts +2 -0
- package/dist/css/css-line-chart.js +31 -0
- package/dist/css/css-list-row.d.ts +2 -0
- package/dist/css/css-list-row.js +193 -0
- package/dist/css/css-list.d.ts +3 -0
- package/dist/css/css-list.js +85 -0
- package/dist/css/css-scroll-region.d.ts +18 -0
- package/dist/css/css-scroll-region.js +41 -0
- package/dist/css/css-section-nav-filled.js +2 -25
- package/dist/css/css-stat-tile.d.ts +7 -0
- package/dist/css/css-stat-tile.js +16 -0
- package/dist/css/css-steps.js +2 -2
- package/dist/css/css-table-bounded-edges.js +4 -27
- package/dist/css/range-band.d.ts +2 -0
- package/dist/css/range-band.js +7 -0
- package/dist/css/stacking.js +2 -2
- package/dist/css/stylesheet.js +16 -2
- package/dist/date-range-draft.d.ts +26 -0
- package/dist/date-range-draft.js +36 -0
- package/dist/date-range-input.d.ts +26 -0
- package/dist/date-range-input.js +58 -0
- package/dist/date-range-labels.d.ts +22 -0
- package/dist/date-range-labels.js +26 -0
- package/dist/date-range-view.d.ts +12 -0
- package/dist/date-range-view.js +29 -0
- package/dist/date-range-words.d.ts +11 -0
- package/dist/date-range-words.js +40 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +9 -1
- 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/list-options.d.ts +70 -0
- package/dist/list-options.js +77 -0
- package/dist/styles.css +726 -26
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { typographyVariants } from '@scalewing/tokens';
|
|
2
|
+
const caption = typographyVariants.caption;
|
|
3
|
+
/** The counts drawn as the pill: SectionNav's and a Nav word's. */
|
|
4
|
+
const pills = ['sw-section-nav-count', 'sw-nav-count'];
|
|
5
|
+
/*
|
|
6
|
+
* A count after a destination's words (a number waiting there, such as
|
|
7
|
+
* tasks to do) is a filled pill: the danger colour with its on-colour
|
|
8
|
+
* figures (4.5:1 in every palette, as a danger Button's label), caption
|
|
9
|
+
* size at weight 700, a space-5 less space-1 (20) high and at least as
|
|
10
|
+
* wide. Forced colours draw its edge. SectionNav's item count and Nav's
|
|
11
|
+
* NavCount share it, so an area's count reads the same in both.
|
|
12
|
+
*/
|
|
13
|
+
export function cssCountPillClasses() {
|
|
14
|
+
const selector = pills.map((name) => `[data-theme] .${name}`).join(',\n');
|
|
15
|
+
return `${selector} {
|
|
16
|
+
align-items: center;
|
|
17
|
+
background: var(--sw-color-danger);
|
|
18
|
+
border-radius: var(--sw-radius-pill);
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
color: var(--sw-color-onDanger);
|
|
21
|
+
display: inline-flex;
|
|
22
|
+
font-size: ${caption.fontSize}px;
|
|
23
|
+
font-variant-numeric: tabular-nums;
|
|
24
|
+
font-weight: 700;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
letter-spacing: ${caption.letterSpacing}px;
|
|
27
|
+
line-height: 1;
|
|
28
|
+
min-height: calc(var(--sw-space-5) - var(--sw-space-1));
|
|
29
|
+
min-width: calc(var(--sw-space-5) - var(--sw-space-1));
|
|
30
|
+
padding-inline: var(--sw-space-1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* A Nav link holding a count lays out as SectionNav's link does: the words
|
|
35
|
+
* and the pill centred on one line a space-2 apart (the space text node
|
|
36
|
+
* that keeps the name collapses), so the link is as tall as its siblings
|
|
37
|
+
* and its words stay level with theirs. A Button already does this. At
|
|
38
|
+
* zero specificity, so a link's \`hideBelow\` or \`hideFrom\` still hides it.
|
|
39
|
+
* In forced colours a current link's underline runs under the pill's
|
|
40
|
+
* figure too, as the pill is a flex item of the link.
|
|
41
|
+
*/
|
|
42
|
+
:where(.sw-nav a:has(> .sw-nav-count)) {
|
|
43
|
+
align-items: center;
|
|
44
|
+
display: inline-flex;
|
|
45
|
+
gap: var(--sw-space-2);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@media (forced-colors: active) {
|
|
49
|
+
${selector.replaceAll('\n', '\n ')} { border: 1px solid CanvasText; }
|
|
50
|
+
}`;
|
|
51
|
+
}
|
|
52
|
+
export function countPillClassCatalog() {
|
|
53
|
+
return [...pills];
|
|
54
|
+
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What a range bar's fill means: the start or a carried figure (`neutral`),
|
|
3
3
|
* money in (`success`), money out (`muted`, never danger: an outflow is not
|
|
4
|
-
* an error), a subtotal (`strong`)
|
|
5
|
-
* (`accent`)
|
|
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).
|
|
6
7
|
*/
|
|
7
|
-
export declare const dataBarTones: readonly ["neutral", "success", "muted", "strong", "accent"];
|
|
8
|
+
export declare const dataBarTones: readonly ["neutral", "success", "muted", "strong", "accent", "danger"];
|
|
8
9
|
export type DataBarTone = (typeof dataBarTones)[number];
|
|
9
|
-
export declare const dataBarToneMixes: Record<DataBarTone, {
|
|
10
|
-
color: 'muted' | 'success' | 'text' | 'accent';
|
|
11
|
-
share: number;
|
|
12
|
-
}>;
|
|
13
|
-
/** A tone's fill: its colour, mixed into the surface by its share. */
|
|
14
|
-
export declare function dataBarToneFill(tone: DataBarTone): string;
|
|
15
10
|
export declare function cssDataBarClasses(): string;
|
|
16
11
|
export declare function dataBarClassCatalog(): string[];
|
package/dist/css/css-data-bar.js
CHANGED
|
@@ -1,42 +1,26 @@
|
|
|
1
|
+
import { chartFill, statementFillTones } from './chart-tones.js';
|
|
1
2
|
/**
|
|
2
3
|
* What a range bar's fill means: the start or a carried figure (`neutral`),
|
|
3
4
|
* money in (`success`), money out (`muted`, never danger: an outflow is not
|
|
4
|
-
* an error), a subtotal (`strong`)
|
|
5
|
-
* (`accent`)
|
|
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).
|
|
6
8
|
*/
|
|
7
|
-
export const dataBarTones =
|
|
8
|
-
'neutral',
|
|
9
|
-
'success',
|
|
10
|
-
'muted',
|
|
11
|
-
'strong',
|
|
12
|
-
'accent',
|
|
13
|
-
];
|
|
9
|
+
export const dataBarTones = statementFillTones;
|
|
14
10
|
/*
|
|
15
|
-
* Each tone is a
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
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 %.
|
|
22
20
|
*/
|
|
23
|
-
export const dataBarToneMixes = {
|
|
24
|
-
neutral: { color: 'muted', share: 0.65 },
|
|
25
|
-
success: { color: 'success', share: 0.55 },
|
|
26
|
-
muted: { color: 'muted', share: 0.35 },
|
|
27
|
-
strong: { color: 'text', share: 0.85 },
|
|
28
|
-
accent: { color: 'accent', share: 1 },
|
|
29
|
-
};
|
|
30
|
-
/** A tone's fill: its colour, mixed into the surface by its share. */
|
|
31
|
-
export function dataBarToneFill(tone) {
|
|
32
|
-
const { color, share } = dataBarToneMixes[tone];
|
|
33
|
-
if (share === 1)
|
|
34
|
-
return `var(--sw-color-${color})`;
|
|
35
|
-
return `color-mix(in srgb, var(--sw-color-${color}) ${Math.round(share * 100)}%, var(--sw-color-surface))`;
|
|
36
|
-
}
|
|
37
21
|
function toneRules() {
|
|
38
22
|
return dataBarTones
|
|
39
|
-
.map((tone) => `.sw-data-bar-${tone} > .sw-data-bar-fill { background: ${
|
|
23
|
+
.map((tone) => `.sw-data-bar-${tone} > .sw-data-bar-fill { background: ${chartFill(tone)}; }`)
|
|
40
24
|
.join('\n');
|
|
41
25
|
}
|
|
42
26
|
/*
|
|
@@ -2,6 +2,7 @@ import { typographyVariants } from '@scalewing/tokens';
|
|
|
2
2
|
import { disabledControlForcedColors, disabledControlSurface, } from './css-document.js';
|
|
3
3
|
import { zIndex } from './stacking.js';
|
|
4
4
|
import { quietFill } from './quiet-fill.js';
|
|
5
|
+
import { rangeBand, rangeBandHover } from './range-band.js';
|
|
5
6
|
const body = typographyVariants.body;
|
|
6
7
|
const label = typographyVariants.label;
|
|
7
8
|
const caption = typographyVariants.caption;
|
|
@@ -241,7 +242,7 @@ function calendarRules() {
|
|
|
241
242
|
* accent ring (3:1 or more on the band). The selected day sits on top.
|
|
242
243
|
*/
|
|
243
244
|
.sw-date-field-day-in-range {
|
|
244
|
-
background:
|
|
245
|
+
background: ${rangeBand};
|
|
245
246
|
border-radius: 0;
|
|
246
247
|
color: var(--sw-color-text);
|
|
247
248
|
}
|
|
@@ -267,7 +268,7 @@ function calendarRules() {
|
|
|
267
268
|
}
|
|
268
269
|
|
|
269
270
|
.sw-date-field-day-in-range:hover:not([aria-disabled='true']) {
|
|
270
|
-
background:
|
|
271
|
+
background: ${rangeBandHover};
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
.sw-date-field-day[aria-selected='true'],
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { typographyVariants } from '@scalewing/tokens';
|
|
2
|
+
import { breakpointQuery } from './breakpoints.js';
|
|
3
|
+
import { quietFill } from './quiet-fill.js';
|
|
4
|
+
import { coarsePointerQuery, touchTarget } from './touch-target.js';
|
|
5
|
+
const label = typographyVariants.label;
|
|
6
|
+
const body = typographyVariants.body;
|
|
7
|
+
/*
|
|
8
|
+
* DateRangeButton's presets. In the popover they are a list beside the
|
|
9
|
+
* months from `lg` up, the pressed one on the quiet fill in the label
|
|
10
|
+
* weight; from `md` to `lg`, where two months and a list do not fit side
|
|
11
|
+
* by side, the same list wraps in a row above the months and takes no
|
|
12
|
+
* width of its own. In the sheet they are one row of pills that scrolls
|
|
13
|
+
* sideways, the pressed one in the text colour.
|
|
14
|
+
*/
|
|
15
|
+
export function cssDateRangePresetsClasses() {
|
|
16
|
+
return `.sw-date-range-presets {
|
|
17
|
+
contain: inline-size;
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-wrap: wrap;
|
|
20
|
+
gap: var(--sw-space-1);
|
|
21
|
+
padding: var(--sw-space-3) var(--sw-space-3) 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@media ${breakpointQuery('from', 'lg')} {
|
|
25
|
+
.sw-date-range-presets:not(.sw-date-range-presets-row) {
|
|
26
|
+
border-inline-end: 1px solid var(--sw-color-border);
|
|
27
|
+
contain: none;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
flex-wrap: nowrap;
|
|
30
|
+
padding: var(--sw-space-3) var(--sw-space-2);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.sw-date-range-preset {
|
|
35
|
+
appearance: none;
|
|
36
|
+
background: transparent;
|
|
37
|
+
border: 1px solid transparent;
|
|
38
|
+
border-radius: var(--sw-radius-sm);
|
|
39
|
+
box-sizing: border-box;
|
|
40
|
+
color: var(--sw-color-text);
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
flex: none;
|
|
43
|
+
font-family: var(--sw-font-sans);
|
|
44
|
+
font-size: ${label.fontSize}px;
|
|
45
|
+
font-weight: ${body.fontWeight};
|
|
46
|
+
line-height: ${label.lineHeight}px;
|
|
47
|
+
margin: 0;
|
|
48
|
+
min-height: var(--sw-control-sm-min-height);
|
|
49
|
+
padding: 0 var(--sw-control-sm-padding-inline);
|
|
50
|
+
text-align: start;
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.sw-date-range-preset:hover,
|
|
55
|
+
.sw-date-range-preset[aria-pressed='true'] {
|
|
56
|
+
background: ${quietFill};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.sw-date-range-preset[aria-pressed='true'] {
|
|
60
|
+
font-weight: ${label.fontWeight};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.sw-date-range-preset:focus { outline: none; }
|
|
64
|
+
|
|
65
|
+
.sw-date-range-preset:focus-visible {
|
|
66
|
+
outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
|
|
67
|
+
outline-offset: var(--sw-focus-ring-offset);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.sw-date-range-presets-row {
|
|
71
|
+
contain: none;
|
|
72
|
+
flex-wrap: nowrap;
|
|
73
|
+
gap: var(--sw-space-2);
|
|
74
|
+
overflow-x: auto;
|
|
75
|
+
padding: var(--sw-focus-ring-width) var(--sw-focus-ring-offset);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.sw-date-range-presets-row .sw-date-range-preset {
|
|
79
|
+
background: ${quietFill};
|
|
80
|
+
border-radius: var(--sw-radius-pill);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.sw-date-range-presets-row .sw-date-range-preset[aria-pressed='true'] {
|
|
84
|
+
background: var(--sw-color-text);
|
|
85
|
+
color: var(--sw-color-surface);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@media ${coarsePointerQuery} {
|
|
89
|
+
.sw-date-range-preset { min-height: ${touchTarget}; }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@media (forced-colors: active) {
|
|
93
|
+
.sw-date-range-presets { border-color: CanvasText; }
|
|
94
|
+
.sw-date-range-presets-row .sw-date-range-preset { border-color: ButtonText; }
|
|
95
|
+
.sw-date-range-preset[aria-pressed='true'],
|
|
96
|
+
.sw-date-range-presets-row .sw-date-range-preset[aria-pressed='true'] {
|
|
97
|
+
background: Highlight;
|
|
98
|
+
color: HighlightText;
|
|
99
|
+
forced-color-adjust: none;
|
|
100
|
+
}
|
|
101
|
+
}`;
|
|
102
|
+
}
|
|
103
|
+
export function dateRangePresetsClassCatalog() {
|
|
104
|
+
return [
|
|
105
|
+
'sw-date-range-presets',
|
|
106
|
+
'sw-date-range-presets-row',
|
|
107
|
+
'sw-date-range-preset',
|
|
108
|
+
];
|
|
109
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { typographyVariants } from '@scalewing/tokens';
|
|
2
|
+
import { breakpointQuery } from './breakpoints.js';
|
|
3
|
+
import { rangeBand, rangeBandHover } from './range-band.js';
|
|
4
|
+
import { cssDateRangePresetsClasses, dateRangePresetsClassCatalog, } from './css-date-range-presets.js';
|
|
5
|
+
import { coarsePointerQuery, touchTarget } from './touch-target.js';
|
|
6
|
+
const label = typographyVariants.label;
|
|
7
|
+
const caption = typographyVariants.caption;
|
|
8
|
+
/* The steps and days are one square control wide, as in DateField's calendar. */
|
|
9
|
+
const square = 'var(--sw-control-md-min-height)';
|
|
10
|
+
/* A day between a picked range's ends: selected, but drawn as the band. */
|
|
11
|
+
const between = ".sw-date-range-months .sw-date-field-day-in-range[aria-selected='true']:not(.sw-date-field-day-range-start, .sw-date-field-day-range-end)";
|
|
12
|
+
function buttonRules() {
|
|
13
|
+
return `.sw-date-range-button {
|
|
14
|
+
font-variant-numeric: tabular-nums;
|
|
15
|
+
white-space: nowrap;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.sw-date-range-button:not(.sw-button-md) .sw-date-field-glyph {
|
|
19
|
+
height: var(--sw-space-4);
|
|
20
|
+
width: var(--sw-space-4);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@media ${coarsePointerQuery} {
|
|
24
|
+
.sw-button.sw-date-range-button,
|
|
25
|
+
.sw-date-range-actions > .sw-button { min-height: ${touchTarget}; }
|
|
26
|
+
}`;
|
|
27
|
+
}
|
|
28
|
+
/*
|
|
29
|
+
* The popover is DateField's calendar surface with no padding of its own:
|
|
30
|
+
* the presets, then the months, then a footer under a hairline. Below
|
|
31
|
+
* `lg` the presets sit above the months; from `lg` beside them.
|
|
32
|
+
*/
|
|
33
|
+
function popoverRules() {
|
|
34
|
+
return `.sw-date-field-calendar.sw-date-range-popover {
|
|
35
|
+
gap: 0;
|
|
36
|
+
padding: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.sw-date-range-body {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@media ${breakpointQuery('from', 'lg')} {
|
|
45
|
+
.sw-date-range-body { flex-direction: row; }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.sw-date-range-footer {
|
|
49
|
+
align-items: center;
|
|
50
|
+
border-top: 1px solid var(--sw-color-border);
|
|
51
|
+
contain: inline-size;
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-wrap: wrap;
|
|
54
|
+
gap: var(--sw-space-2) var(--sw-space-4);
|
|
55
|
+
padding: var(--sw-space-3);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.sw-date-range-summary {
|
|
59
|
+
color: var(--sw-color-muted);
|
|
60
|
+
flex: 1 1 auto;
|
|
61
|
+
font-size: ${caption.fontSize}px;
|
|
62
|
+
line-height: ${caption.lineHeight}px;
|
|
63
|
+
min-width: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.sw-date-range-status { display: inline; }
|
|
67
|
+
|
|
68
|
+
.sw-date-range-line {
|
|
69
|
+
color: var(--sw-color-text);
|
|
70
|
+
display: block;
|
|
71
|
+
font-size: ${label.fontSize}px;
|
|
72
|
+
font-weight: ${label.fontWeight};
|
|
73
|
+
line-height: ${label.lineHeight}px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.sw-date-range-actions {
|
|
77
|
+
display: flex;
|
|
78
|
+
gap: var(--sw-space-2);
|
|
79
|
+
margin-inline-start: auto;
|
|
80
|
+
}`;
|
|
81
|
+
}
|
|
82
|
+
function monthRules() {
|
|
83
|
+
return `.sw-date-range-months {
|
|
84
|
+
display: flex;
|
|
85
|
+
gap: var(--sw-space-5);
|
|
86
|
+
justify-content: center;
|
|
87
|
+
padding: var(--sw-space-3);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.sw-date-range-month {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
gap: var(--sw-space-1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.sw-date-range-month-header {
|
|
97
|
+
align-items: center;
|
|
98
|
+
display: grid;
|
|
99
|
+
grid-template-columns: ${square} 1fr ${square};
|
|
100
|
+
min-height: ${square};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.sw-date-range-month-title {
|
|
104
|
+
font-size: ${label.fontSize}px;
|
|
105
|
+
font-weight: ${label.fontWeight};
|
|
106
|
+
grid-column: 2;
|
|
107
|
+
line-height: ${label.lineHeight}px;
|
|
108
|
+
text-align: center;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
${between} {
|
|
112
|
+
background: ${rangeBand};
|
|
113
|
+
border-color: transparent;
|
|
114
|
+
border-radius: 0;
|
|
115
|
+
color: var(--sw-color-text);
|
|
116
|
+
font-weight: inherit;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
${between}:hover:not([aria-disabled='true']) { background: ${rangeBandHover}; }
|
|
120
|
+
|
|
121
|
+
${between}[aria-current='date'] { border-color: var(--sw-color-accent); }`;
|
|
122
|
+
}
|
|
123
|
+
/*
|
|
124
|
+
* Below \`md\` the range is a Dialog bottom sheet: the presets in a
|
|
125
|
+
* scrolling row, one month, and a footer with the hint over Cancel and
|
|
126
|
+
* Apply, the primary twice as wide.
|
|
127
|
+
*/
|
|
128
|
+
function sheetRules() {
|
|
129
|
+
return `.sw-date-range-sheet .sw-date-range-months { padding: 0; }
|
|
130
|
+
|
|
131
|
+
.sw-date-range-sheet .sw-dialog-footer-actions {
|
|
132
|
+
flex: 1 1 100%;
|
|
133
|
+
margin-inline-start: 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.sw-date-range-sheet-footer {
|
|
137
|
+
display: flex;
|
|
138
|
+
flex: 1 1 100%;
|
|
139
|
+
flex-direction: column;
|
|
140
|
+
gap: var(--sw-space-2);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.sw-date-range-sheet-footer .sw-date-range-hint {
|
|
144
|
+
color: var(--sw-color-muted);
|
|
145
|
+
font-size: ${caption.fontSize}px;
|
|
146
|
+
line-height: ${caption.lineHeight}px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.sw-date-range-sheet-footer .sw-date-range-actions {
|
|
150
|
+
display: grid;
|
|
151
|
+
grid-template-columns: 1fr 2fr;
|
|
152
|
+
margin-inline-start: 0;
|
|
153
|
+
}`;
|
|
154
|
+
}
|
|
155
|
+
function forcedColorRules() {
|
|
156
|
+
return `@media (forced-colors: active) {
|
|
157
|
+
.sw-date-range-footer { border-top-color: CanvasText; }
|
|
158
|
+
${between},
|
|
159
|
+
${between}:hover:not([aria-disabled='true']) {
|
|
160
|
+
background: Mark;
|
|
161
|
+
color: MarkText;
|
|
162
|
+
forced-color-adjust: none;
|
|
163
|
+
}
|
|
164
|
+
}`;
|
|
165
|
+
}
|
|
166
|
+
export function cssDateRangeClasses() {
|
|
167
|
+
return [
|
|
168
|
+
buttonRules(),
|
|
169
|
+
popoverRules(),
|
|
170
|
+
monthRules(),
|
|
171
|
+
sheetRules(),
|
|
172
|
+
cssDateRangePresetsClasses(),
|
|
173
|
+
forcedColorRules(),
|
|
174
|
+
].join('\n\n');
|
|
175
|
+
}
|
|
176
|
+
export function dateRangeClassCatalog() {
|
|
177
|
+
return [
|
|
178
|
+
'sw-date-range-button',
|
|
179
|
+
'sw-date-range-popover',
|
|
180
|
+
'sw-date-range-body',
|
|
181
|
+
'sw-date-range-months',
|
|
182
|
+
'sw-date-range-month',
|
|
183
|
+
'sw-date-range-month-header',
|
|
184
|
+
'sw-date-range-month-title',
|
|
185
|
+
'sw-date-range-footer',
|
|
186
|
+
'sw-date-range-summary',
|
|
187
|
+
'sw-date-range-status',
|
|
188
|
+
'sw-date-range-line',
|
|
189
|
+
'sw-date-range-count',
|
|
190
|
+
'sw-date-range-separator',
|
|
191
|
+
'sw-date-range-hint',
|
|
192
|
+
'sw-date-range-actions',
|
|
193
|
+
'sw-date-range-sheet',
|
|
194
|
+
'sw-date-range-sheet-footer',
|
|
195
|
+
...dateRangePresetsClassCatalog(),
|
|
196
|
+
];
|
|
197
|
+
}
|
|
@@ -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
|
+
}
|