@0001-labs/design-system-1 0.3.0-alpha.21 → 0.3.0-alpha.23
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/DS1/0-face/bento.ts +13 -4
- package/DS1/0-face/calendar.ts +23 -0
- package/DS1/1-root/bento.css +25 -12
- package/DS1/1-root/cjk.css +1 -1
- package/DS1/1-root/controls.css +22 -32
- package/DS1/1-root/fonts.css +1 -1
- package/DS1/1-root/one.css +1 -1
- package/DS1/1-root/one.semantic.css +1 -1
- package/DS1/2-core/ds-switch.ts +2 -2
- package/DS1/2-core/styles/ds-checkbox.css +11 -7
- package/DS1/2-core/styles/ds-radio.css +5 -2
- package/DS1/2-core/styles/ds-switch.css +7 -23
- package/DS1/3-unit/ds-bento.ts +8 -1
- package/DS1/3-unit/ds-calendar.ts +21 -4
- package/DS1/3-unit/styles/ds-bento.css +16 -10
- package/DS1/3-unit/styles/ds-calendar.css +30 -8
- package/dist/0-face/bento.d.ts +6 -2
- package/dist/0-face/bento.d.ts.map +1 -1
- package/dist/0-face/bento.js +12 -4
- package/dist/0-face/calendar.d.ts +11 -0
- package/dist/0-face/calendar.d.ts.map +1 -1
- package/dist/0-face/calendar.js +19 -0
- package/dist/2-core/ds-switch.d.ts +2 -2
- package/dist/2-core/ds-switch.d.ts.map +1 -1
- package/dist/2-core/ds-switch.js +2 -2
- package/dist/3-unit/ds-bento.d.ts +12 -0
- package/dist/3-unit/ds-bento.d.ts.map +1 -1
- package/dist/3-unit/ds-bento.js +4 -1
- package/dist/3-unit/ds-calendar.d.ts +17 -0
- package/dist/3-unit/ds-calendar.d.ts.map +1 -1
- package/dist/3-unit/ds-calendar.js +18 -5
- package/dist/design-system-1.bundle.js +66 -15
- package/dist/design-system-1.bundle.js.map +1 -1
- package/dist/design-system-1.bundle.min.js +903 -872
- package/dist/design-system-1.bundle.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* stands on the lower sixteen of its square. The boxes are hairlines centred
|
|
6
6
|
* on the grid lines; today is a red disc nine tenths of a square across.
|
|
7
7
|
*
|
|
8
|
-
* A picker is
|
|
9
|
-
* ten squares wide by default,
|
|
10
|
-
*
|
|
8
|
+
* A picker is a field's face: one control high at the foot of its square,
|
|
9
|
+
* ten squares wide by default, its words 4px in and the chevron-down icon
|
|
10
|
+
* (16px, 2px from the end) at its end; a range is one value. Its month opens on the menu's frame, half a square from
|
|
11
11
|
* the field: a 1px line, half a square inside it, no shadow, so eight squares
|
|
12
12
|
* wide. Inside, on whole squares: the first and last day to type (each with
|
|
13
13
|
* its time below when times are on), one square spare, the compact month one
|
|
@@ -25,6 +25,17 @@
|
|
|
25
25
|
--ds-calendar-band: color-mix(in srgb, var(--ds-calendar-selected) 16%, var(--ds-paper));
|
|
26
26
|
--ds-calendar-mark: calc(var(--ds-unit) * 0.9);
|
|
27
27
|
--ds-calendar-pad: calc(4px * var(--ds-sf, 1));
|
|
28
|
+
/* Heat, in four steps of the accent: its pastel, between, the colour, and
|
|
29
|
+
past it (deepened with the ink on light paper, the full colour on dark).
|
|
30
|
+
The words are the ink on every step but the two darkest on dark paper. */
|
|
31
|
+
--ds-calendar-heat-1: var(--one-apple-green-pastel, color-mix(in srgb, var(--ds-apple-green) 40%, var(--ds-paper)));
|
|
32
|
+
--ds-calendar-heat-3: var(--one-apple-green, var(--ds-apple-green));
|
|
33
|
+
--ds-calendar-heat-2: color-mix(in srgb, var(--ds-calendar-heat-1), var(--ds-calendar-heat-3));
|
|
34
|
+
--ds-calendar-heat-4: light-dark(color-mix(in srgb, var(--ds-apple-green) 60%, var(--ds-slate)), var(--ds-apple-green));
|
|
35
|
+
--ds-calendar-heat-ink-1: light-dark(var(--ds-slate), var(--ds-white));
|
|
36
|
+
--ds-calendar-heat-ink-2: light-dark(var(--ds-slate), var(--ds-white));
|
|
37
|
+
--ds-calendar-heat-ink-3: var(--ds-slate);
|
|
38
|
+
--ds-calendar-heat-ink-4: var(--ds-slate);
|
|
28
39
|
box-sizing: border-box;
|
|
29
40
|
display: inline-block;
|
|
30
41
|
vertical-align: top;
|
|
@@ -175,6 +186,20 @@
|
|
|
175
186
|
|
|
176
187
|
.day[aria-disabled="true"] .date { color: var(--ds-title-color); opacity: 0.5; }
|
|
177
188
|
|
|
189
|
+
/* Heat: the date's mark filled by its step, a picture's corners, inside the day's square; today and the selection draw over it. */
|
|
190
|
+
.day[data-heat]:not([data-today], [data-selected]) .date-line { align-items: center; padding-inline-end: calc(var(--ds-unit) * 0.05); }
|
|
191
|
+
.day[data-heat]:not([data-today], [data-selected]) .date {
|
|
192
|
+
min-width: var(--ds-calendar-mark);
|
|
193
|
+
height: var(--ds-calendar-mark);
|
|
194
|
+
border-radius: var(--ds-radius);
|
|
195
|
+
letter-spacing: 0;
|
|
196
|
+
}
|
|
197
|
+
.day[data-heat="1"]:not([data-today], [data-selected]) .date { background: var(--ds-calendar-heat-1); color: var(--ds-calendar-heat-ink-1); }
|
|
198
|
+
.day[data-heat="2"]:not([data-today], [data-selected]) .date { background: var(--ds-calendar-heat-2); color: var(--ds-calendar-heat-ink-2); }
|
|
199
|
+
.day[data-heat="3"]:not([data-today], [data-selected]) .date { background: var(--ds-calendar-heat-3); color: var(--ds-calendar-heat-ink-3); }
|
|
200
|
+
.day[data-heat="4"]:not([data-today], [data-selected]) .date { background: var(--ds-calendar-heat-4); color: var(--ds-calendar-heat-ink-4); }
|
|
201
|
+
:host([compact]) .day[data-heat]:not([data-today], [data-selected]) .date-line { padding: 0; }
|
|
202
|
+
|
|
178
203
|
/* Events: one square each, stacked edge to edge on the day's lines, drawn one pixel short. */
|
|
179
204
|
.events {
|
|
180
205
|
display: flex;
|
|
@@ -257,15 +282,14 @@
|
|
|
257
282
|
|
|
258
283
|
.trigger {
|
|
259
284
|
display: inline-flex;
|
|
260
|
-
align-items:
|
|
285
|
+
align-items: center;
|
|
261
286
|
gap: calc(4px * var(--ds-sf, 1));
|
|
262
287
|
width: var(--ds-calendar-picker-width);
|
|
263
|
-
padding-inline:
|
|
288
|
+
padding-inline: calc(4px * var(--ds-sf, 1)) calc(2px * var(--ds-sf, 1));
|
|
264
289
|
text-align: start;
|
|
265
290
|
cursor: pointer;
|
|
266
291
|
}
|
|
267
292
|
.trigger:disabled { cursor: default; }
|
|
268
|
-
.trigger .icon,
|
|
269
293
|
.trigger .arrow { flex: 0 0 auto; }
|
|
270
294
|
.trigger .text {
|
|
271
295
|
flex: 1 1 auto;
|
|
@@ -275,7 +299,6 @@
|
|
|
275
299
|
white-space: nowrap;
|
|
276
300
|
}
|
|
277
301
|
.trigger[data-empty] .text { color: var(--ds-title-color); }
|
|
278
|
-
.trigger[aria-expanded="true"] .arrow { transform: rotate(180deg); }
|
|
279
302
|
|
|
280
303
|
/* The month's panel, on the menu's frame. */
|
|
281
304
|
.popover {
|
|
@@ -348,7 +371,6 @@
|
|
|
348
371
|
.popover:popover-open {
|
|
349
372
|
animation: ds-calendar-picker-in 140ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
350
373
|
}
|
|
351
|
-
.trigger .arrow { transition: transform 140ms ease; }
|
|
352
374
|
}
|
|
353
375
|
@keyframes ds-calendar-picker-in {
|
|
354
376
|
from { opacity: 0; transform: translateY(calc(-4px * var(--ds-sf, 1))); }
|
package/dist/0-face/bento.d.ts
CHANGED
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
* A tile's `data-place` is its square across, its square down, its width and
|
|
20
20
|
* its height, in whole squares counted from 0. Tiles are placed a square
|
|
21
21
|
* apart; a tile a square away from another, with the two overlapping along
|
|
22
|
-
* that side, reaches towards it.
|
|
22
|
+
* that side, reaches towards it. A tile can have a place per layout,
|
|
23
|
+
* `data-place-phone="0 0 12 7"`, taken while the bento says
|
|
24
|
+
* `data-layout="phone"`; the page sets the layout and the columns for it.
|
|
23
25
|
*/
|
|
24
26
|
/** A tile's place in squares: across, down, wide, high. */
|
|
25
27
|
export type BentoPlace = readonly [x: number, y: number, w: number, h: number];
|
|
@@ -34,7 +36,9 @@ export interface BentoReach {
|
|
|
34
36
|
export declare function bentoPlace(value: string | null | undefined): BentoPlace | undefined;
|
|
35
37
|
/** For each place, the sides that face another tile across a one-square gap. */
|
|
36
38
|
export declare function bentoReach(places: readonly BentoPlace[]): BentoReach[];
|
|
37
|
-
/**
|
|
39
|
+
/** A tile's place in the bento's layout: `data-place-<layout>` where the bento names one and the tile has it, else `data-place`. */
|
|
40
|
+
export declare function tilePlace(tile: HTMLElement, layout?: string): BentoPlace | undefined;
|
|
41
|
+
/** Places one squares bento's tiles: their squares and their reach, as custom properties. The bento's `data-layout` (or `layout`) picks each tile's place for that layout. */
|
|
38
42
|
export declare function placeBento(bento: HTMLElement): void;
|
|
39
43
|
/** Places every squares bento on the page (or under `root`), and again when its tiles change. */
|
|
40
44
|
export declare function placeBentos(root?: ParentNode): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bento.d.ts","sourceRoot":"","sources":["../../DS1/0-face/bento.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"bento.d.ts","sourceRoot":"","sources":["../../DS1/0-face/bento.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,2DAA2D;AAC3D,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAE/E,gEAAgE;AAChE,MAAM,WAAW,UAAU;IAAG,KAAK,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE;AAE3F,+FAA+F;AAC/F,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAKnF;AAID,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,EAAE,CAUtE;AAED,oIAAoI;AACpI,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,SAAK,GAAG,UAAU,GAAG,SAAS,CAGhF;AAED,8KAA8K;AAC9K,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAanD;AAED,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,IAAI,GAAE,UAAqB,GAAG,MAAM,IAAI,CAcnE"}
|
package/dist/0-face/bento.js
CHANGED
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
* A tile's `data-place` is its square across, its square down, its width and
|
|
20
20
|
* its height, in whole squares counted from 0. Tiles are placed a square
|
|
21
21
|
* apart; a tile a square away from another, with the two overlapping along
|
|
22
|
-
* that side, reaches towards it.
|
|
22
|
+
* that side, reaches towards it. A tile can have a place per layout,
|
|
23
|
+
* `data-place-phone="0 0 12 7"`, taken while the bento says
|
|
24
|
+
* `data-layout="phone"`; the page sets the layout and the columns for it.
|
|
23
25
|
*/
|
|
24
26
|
/** Reads `data-place` ("x y w h"); `undefined` unless it is four whole numbers with a size. */
|
|
25
27
|
export function bentoPlace(value) {
|
|
@@ -42,10 +44,16 @@ export function bentoReach(places) {
|
|
|
42
44
|
};
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
|
-
/**
|
|
47
|
+
/** A tile's place in the bento's layout: `data-place-<layout>` where the bento names one and the tile has it, else `data-place`. */
|
|
48
|
+
export function tilePlace(tile, layout = "") {
|
|
49
|
+
const own = layout ? tile.getAttribute(`data-place-${layout}`) : null;
|
|
50
|
+
return bentoPlace(own ?? tile.dataset.place);
|
|
51
|
+
}
|
|
52
|
+
/** Places one squares bento's tiles: their squares and their reach, as custom properties. The bento's `data-layout` (or `layout`) picks each tile's place for that layout. */
|
|
46
53
|
export function placeBento(bento) {
|
|
54
|
+
const layout = bento.dataset.layout ?? bento.getAttribute("layout") ?? "";
|
|
47
55
|
const tiles = [...bento.children].filter((child) => child instanceof HTMLElement && !child.hidden);
|
|
48
|
-
const placed = tiles.map(tile => ({ tile, place:
|
|
56
|
+
const placed = tiles.map(tile => ({ tile, place: tilePlace(tile, layout) })).filter((entry) => !!entry.place);
|
|
49
57
|
const reach = bentoReach(placed.map(entry => entry.place));
|
|
50
58
|
placed.forEach(({ tile, place: [x, y, w, h] }, index) => {
|
|
51
59
|
const sides = reach[index];
|
|
@@ -69,7 +77,7 @@ export function placeBentos(root = document) {
|
|
|
69
77
|
});
|
|
70
78
|
for (const bento of bentos) {
|
|
71
79
|
placeBento(bento);
|
|
72
|
-
observer.observe(bento, { childList: true, subtree: false, attributes: true, attributeFilter: ["data-place", "hidden"] });
|
|
80
|
+
observer.observe(bento, { childList: true, subtree: false, attributes: true, attributeFilter: ["data-place", "data-layout", "hidden"] });
|
|
73
81
|
for (const tile of bento.children)
|
|
74
82
|
observer.observe(tile, { attributes: true, attributeFilter: ["data-place", "hidden"] });
|
|
75
83
|
}
|
|
@@ -69,7 +69,18 @@ export type CalendarEvent = {
|
|
|
69
69
|
time?: string;
|
|
70
70
|
/** A colour token or value for the event's fill (`var(--ds-zenith-blue)`). */
|
|
71
71
|
color?: string;
|
|
72
|
+
/** How much it counts for in a calendar's heat (commits, purchases, hours); 1 when left out. */
|
|
73
|
+
count?: number;
|
|
72
74
|
};
|
|
75
|
+
/** A day's heat: 1 (a little) to 4 (the most). */
|
|
76
|
+
export type HeatLevel = 1 | 2 | 3 | 4;
|
|
77
|
+
/**
|
|
78
|
+
* How strongly each day is lit, as a contribution graph lights it: the
|
|
79
|
+
* amounts of its events added up, in four steps of the busiest day (or of
|
|
80
|
+
* `max`, for a scale that stays put from month to month). A day with nothing
|
|
81
|
+
* has no level.
|
|
82
|
+
*/
|
|
83
|
+
export declare function heatLevels(byDay: ReadonlyMap<Day, readonly CalendarEvent[]>, max?: number): Map<Day, HeatLevel>;
|
|
73
84
|
/** The events that touch each day between `from` and `to`, in order: longest first, then by time. */
|
|
74
85
|
export declare function eventsByDay(events: readonly CalendarEvent[], from: Day, to: Day): Map<Day, CalendarEvent[]>;
|
|
75
86
|
//# sourceMappingURL=calendar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../DS1/0-face/calendar.ts"],"names":[],"mappings":"AASA,0CAA0C;AAC1C,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AAEzB,qEAAqE;AACrE,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAIhD,6FAA6F;AAC7F,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAO9G;AAED,0DAA0D;AAC1D,eAAO,MAAM,KAAK,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,GAA2D,CAAC;AAE5G,8EAA8E;AAC9E,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAIpE;AAED,qDAAqD;AACrD,eAAO,MAAM,KAAK,GAAI,QAAQ,IAAI,KAAG,GAA2E,CAAC;AAEjH,kCAAkC;AAClC,eAAO,MAAM,KAAK,QAAO,GAAwB,CAAC;AAQlD,0DAA0D;AAC1D,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,CAGpD;AAED,mGAAmG;AACnG,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,CAOtD;AAED,oCAAoC;AACpC,eAAO,MAAM,YAAY,GAAI,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AAC;AAEtC;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,SAAS,aAAa,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAU/G;AAED,qGAAqG;AACrG,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,GAAG,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,CAAC,CAe3G"}
|
package/dist/0-face/calendar.js
CHANGED
|
@@ -129,6 +129,25 @@ export function isoWeek(day) {
|
|
|
129
129
|
const firstThursday = addDays(january4, 3 - ((weekdayOf(january4) + 6) % 7));
|
|
130
130
|
return 1 + Math.round((noon(thursday) - noon(firstThursday)) / (7 * 864e5));
|
|
131
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* How strongly each day is lit, as a contribution graph lights it: the
|
|
134
|
+
* amounts of its events added up, in four steps of the busiest day (or of
|
|
135
|
+
* `max`, for a scale that stays put from month to month). A day with nothing
|
|
136
|
+
* has no level.
|
|
137
|
+
*/
|
|
138
|
+
export function heatLevels(byDay, max) {
|
|
139
|
+
const amounts = new Map();
|
|
140
|
+
for (const [day, events] of byDay) {
|
|
141
|
+
const amount = events.reduce((sum, event) => sum + (typeof event.count === "number" && Number.isFinite(event.count) ? Math.max(0, event.count) : 1), 0);
|
|
142
|
+
if (amount > 0)
|
|
143
|
+
amounts.set(day, amount);
|
|
144
|
+
}
|
|
145
|
+
const top = typeof max === "number" && Number.isFinite(max) && max > 0 ? max : Math.max(0, ...amounts.values());
|
|
146
|
+
const levels = new Map();
|
|
147
|
+
for (const [day, amount] of amounts)
|
|
148
|
+
levels.set(day, Math.min(4, Math.max(1, Math.ceil((amount / top) * 4))));
|
|
149
|
+
return levels;
|
|
150
|
+
}
|
|
132
151
|
/** The events that touch each day between `from` and `to`, in order: longest first, then by time. */
|
|
133
152
|
export function eventsByDay(events, from, to) {
|
|
134
153
|
const days = new Map();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
|
-
/** The
|
|
3
|
-
|
|
2
|
+
/** The switch: a pill with a white round thumb, grey when off and the darker green when on,
|
|
3
|
+
whatever the page's accent. The slotted button retains native activation and refs. */
|
|
4
4
|
export declare class Switch extends LitElement {
|
|
5
5
|
static styles: import("lit").CSSResult;
|
|
6
6
|
focus(options?: FocusOptions): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ds-switch.d.ts","sourceRoot":"","sources":["../../DS1/2-core/ds-switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAIlD
|
|
1
|
+
{"version":3,"file":"ds-switch.d.ts","sourceRoot":"","sources":["../../DS1/2-core/ds-switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAIlD;yFACyF;AACzF,qBAAa,MAAO,SAAQ,UAAU;IACpC,MAAM,CAAC,MAAM,0BAAqB;IAClC,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY;IAC5B,MAAM;CACP;AAGD,OAAO,CAAC,MAAM,CAAC;IAAE,UAAU,qBAAqB;QAAG,WAAW,EAAE,MAAM,CAAA;KAAE;CAAE"}
|
package/dist/2-core/ds-switch.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LitElement, html, unsafeCSS } from "lit";
|
|
2
2
|
import { define } from "../0-face/define";
|
|
3
3
|
import styles from "./styles/ds-switch.css?inline";
|
|
4
|
-
/** The
|
|
5
|
-
|
|
4
|
+
/** The switch: a pill with a white round thumb, grey when off and the darker green when on,
|
|
5
|
+
whatever the page's accent. The slotted button retains native activation and refs. */
|
|
6
6
|
export class Switch extends LitElement {
|
|
7
7
|
focus(options) { this.querySelector(":scope > button")?.focus(options); }
|
|
8
8
|
render() { return html `<slot></slot>`; }
|
|
@@ -9,11 +9,23 @@ export declare class Bento extends LitElement {
|
|
|
9
9
|
type: BooleanConstructor;
|
|
10
10
|
reflect: boolean;
|
|
11
11
|
};
|
|
12
|
+
fit: {
|
|
13
|
+
type: BooleanConstructor;
|
|
14
|
+
reflect: boolean;
|
|
15
|
+
};
|
|
16
|
+
layout: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
reflect: boolean;
|
|
19
|
+
};
|
|
12
20
|
};
|
|
13
21
|
/** The number of columns (flow, three by default), or the squares across (`squares`, 48 by default). */
|
|
14
22
|
columns: number | undefined;
|
|
15
23
|
/** Places every tile on whole squares by its `data-place`. */
|
|
16
24
|
squares: boolean;
|
|
25
|
+
/** With `squares`, lets the columns share a measure other than the squares. */
|
|
26
|
+
fit: boolean;
|
|
27
|
+
/** Takes each tile's `data-place-<layout>` where it has one (say `phone`). */
|
|
28
|
+
layout: string | undefined;
|
|
17
29
|
static styles: import("lit").CSSResult[];
|
|
18
30
|
private observer?;
|
|
19
31
|
constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ds-bento.d.ts","sourceRoot":"","sources":["../../DS1/3-unit/ds-bento.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAMlD,qBAAa,KAAM,SAAQ,UAAU;IACnC,MAAM,CAAC,UAAU
|
|
1
|
+
{"version":3,"file":"ds-bento.d.ts","sourceRoot":"","sources":["../../DS1/3-unit/ds-bento.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAMlD,qBAAa,KAAM,SAAQ,UAAU;IACnC,MAAM,CAAC,UAAU;;;;;;;;;;;;;;;;;MAKf;IAEF,wGAAwG;IAChG,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,8DAA8D;IACtD,OAAO,EAAE,OAAO,CAAC;IACzB,+EAA+E;IACvE,GAAG,EAAE,OAAO,CAAC;IACrB,8EAA8E;IACtE,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC,MAAM,CAAC,MAAM,4BAA2C;IAExD,OAAO,CAAC,QAAQ,CAAC,CAAmB;;IAQpC,iBAAiB;IAMjB,oBAAoB;IAKpB,SAAS,CAAC,OAAO;IAMjB,OAAO,CAAC,KAAK;IAIb,MAAM;CAGP;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,KAAK,CAAC;KACnB;CACF"}
|
package/dist/3-unit/ds-bento.js
CHANGED
|
@@ -14,11 +14,12 @@ export class Bento extends LitElement {
|
|
|
14
14
|
constructor() {
|
|
15
15
|
super();
|
|
16
16
|
this.squares = false;
|
|
17
|
+
this.fit = false;
|
|
17
18
|
}
|
|
18
19
|
connectedCallback() {
|
|
19
20
|
super.connectedCallback();
|
|
20
21
|
this.observer = new MutationObserver(() => this.place());
|
|
21
|
-
this.observer.observe(this, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-place", "hidden"] });
|
|
22
|
+
this.observer.observe(this, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-place", "hidden"], attributeOldValue: false });
|
|
22
23
|
}
|
|
23
24
|
disconnectedCallback() {
|
|
24
25
|
this.observer?.disconnect();
|
|
@@ -42,6 +43,8 @@ export class Bento extends LitElement {
|
|
|
42
43
|
Bento.properties = {
|
|
43
44
|
columns: { type: Number, reflect: true },
|
|
44
45
|
squares: { type: Boolean, reflect: true },
|
|
46
|
+
fit: { type: Boolean, reflect: true },
|
|
47
|
+
layout: { type: String, reflect: true },
|
|
45
48
|
};
|
|
46
49
|
Bento.styles = [unsafeCSS(metrics), unsafeCSS(styles)];
|
|
47
50
|
define("ds-bento", Bento);
|
|
@@ -44,6 +44,12 @@ export declare function parseTypedDay(text: string): Day | null;
|
|
|
44
44
|
* @prop {boolean} fixed - Always draw six weeks, so the month keeps its height.
|
|
45
45
|
* @prop {boolean} outsideDays - Draw the days of the months before and after
|
|
46
46
|
* in the title grey (`outside-days`); pressing one moves there.
|
|
47
|
+
* @prop {boolean} heat - Light each day by how much happens on it, as a
|
|
48
|
+
* contribution graph does: the events' `count`s added up (one each by
|
|
49
|
+
* default), in four steps of the busiest day shown.
|
|
50
|
+
* @prop {number} heatMax - The amount that lights a day fully (`heat-max`),
|
|
51
|
+
* for a scale that stays put from month to month; the busiest day shown
|
|
52
|
+
* by default.
|
|
47
53
|
* @prop {boolean} noHeader - Leave out the title and arrows (`no-header`).
|
|
48
54
|
* @prop {boolean} noToday - Leave out the Today button (`no-today`).
|
|
49
55
|
* @prop {string} min - The first day a person may choose.
|
|
@@ -120,6 +126,14 @@ export declare class Calendar extends CalendarBase {
|
|
|
120
126
|
attribute: string;
|
|
121
127
|
reflect: boolean;
|
|
122
128
|
};
|
|
129
|
+
heat: {
|
|
130
|
+
type: BooleanConstructor;
|
|
131
|
+
reflect: boolean;
|
|
132
|
+
};
|
|
133
|
+
heatMax: {
|
|
134
|
+
type: NumberConstructor;
|
|
135
|
+
attribute: string;
|
|
136
|
+
};
|
|
123
137
|
picker: {
|
|
124
138
|
type: BooleanConstructor;
|
|
125
139
|
reflect: boolean;
|
|
@@ -204,6 +218,8 @@ export declare class Calendar extends CalendarBase {
|
|
|
204
218
|
outsideDays: boolean;
|
|
205
219
|
noHeader: boolean;
|
|
206
220
|
noToday: boolean;
|
|
221
|
+
heat: boolean;
|
|
222
|
+
heatMax: number | undefined;
|
|
207
223
|
picker: boolean;
|
|
208
224
|
name: string | undefined;
|
|
209
225
|
placeholder: string | undefined;
|
|
@@ -216,6 +232,7 @@ export declare class Calendar extends CalendarBase {
|
|
|
216
232
|
unfolded: Day | undefined;
|
|
217
233
|
protected readonly weeksRun: "rows";
|
|
218
234
|
private byDay;
|
|
235
|
+
private heatByDay;
|
|
219
236
|
private readonly internals;
|
|
220
237
|
/** The value the field started with, for a form's reset. */
|
|
221
238
|
private initial;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ds-calendar.d.ts","sourceRoot":"","sources":["../../DS1/3-unit/ds-calendar.ts"],"names":[],"mappings":"AAcA,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGpE,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,
|
|
1
|
+
{"version":3,"file":"ds-calendar.d.ts","sourceRoot":"","sources":["../../DS1/3-unit/ds-calendar.ts"],"names":[],"mappings":"AAcA,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGpE,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAaL,KAAK,aAAa,EAClB,KAAK,GAAG,EAET,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAmD,MAAM,iBAAiB,CAAC;AAChG,OAAO,mBAAmB,CAAC;AAK3B,cAAc,iBAAiB,CAAC;AAKhC,qFAAqF;AACrF,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;CACd;AAID,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG;IAAE,KAAK,CAAC,EAAE,WAAW,CAAC;IAAC,GAAG,CAAC,EAAE,WAAW,CAAA;CAAE,CAW1G;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,GAAG,EAAE,WAAW,GAAG,SAAS,EAAE,OAAO,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAI/H;AAED,8GAA8G;AAC9G,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAKtD;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,qBAAa,Q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CAAC,YAAY,CAQlB;IAEF,OAAO,CAAC,UAAU,CAMhB;IAEF,OAAO,CAAC,eAAe,CAGrB;IAEF,qCAAqC;IACrC,OAAO,CAAC,MAAM;IAUd,OAAO,CAAC,KAAK;IAIb;;;OAGG;IACH,OAAO,CAAC,MAAM,CAWZ;IAEF,+EAA+E;IAC/E,OAAO,CAAC,KAAK;IAqBb,OAAO,CAAC,KAAK;IAOb,OAAO,CAAC,OAAO,CAKb;IAEF,sEAAsE;IACtE,OAAO,CAAC,SAAS,CAIf;IAEF,OAAO,CAAC,KAAK,CAGX;IAEF,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,SAAS;IAIjB,sGAAsG;IACtG,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,SAAS;IA4BjB,OAAO,CAAC,YAAY;CA0DrB;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,QAAQ,CAAC;KACzB;CACF"}
|
|
@@ -15,7 +15,7 @@ import { html, nothing, unsafeCSS } from "lit";
|
|
|
15
15
|
import { define } from "../0-face/define";
|
|
16
16
|
import { getText } from "../0-face/i18n";
|
|
17
17
|
import { dateFormatter } from "../0-face/format";
|
|
18
|
-
import { addMonths, dateNumber, dayOf, eventsByDay, isDay, isoWeek, monthTitle, monthWeeks, sameMonth, startOfMonth, weekdayNames, } from "../0-face/calendar";
|
|
18
|
+
import { addMonths, dateNumber, dayOf, eventsByDay, heatLevels, isDay, isoWeek, monthTitle, monthWeeks, sameMonth, startOfMonth, weekdayNames, } from "../0-face/calendar";
|
|
19
19
|
import { CalendarBase, readMonth, readRange } from "./calendar-base";
|
|
20
20
|
import "../2-core/ds-icon";
|
|
21
21
|
import metrics from "../1-root/component-metrics.css?inline";
|
|
@@ -79,6 +79,12 @@ const openPickers = new Set();
|
|
|
79
79
|
* @prop {boolean} fixed - Always draw six weeks, so the month keeps its height.
|
|
80
80
|
* @prop {boolean} outsideDays - Draw the days of the months before and after
|
|
81
81
|
* in the title grey (`outside-days`); pressing one moves there.
|
|
82
|
+
* @prop {boolean} heat - Light each day by how much happens on it, as a
|
|
83
|
+
* contribution graph does: the events' `count`s added up (one each by
|
|
84
|
+
* default), in four steps of the busiest day shown.
|
|
85
|
+
* @prop {number} heatMax - The amount that lights a day fully (`heat-max`),
|
|
86
|
+
* for a scale that stays put from month to month; the busiest day shown
|
|
87
|
+
* by default.
|
|
82
88
|
* @prop {boolean} noHeader - Leave out the title and arrows (`no-header`).
|
|
83
89
|
* @prop {boolean} noToday - Leave out the Today button (`no-today`).
|
|
84
90
|
* @prop {string} min - The first day a person may choose.
|
|
@@ -118,6 +124,7 @@ export class Calendar extends CalendarBase {
|
|
|
118
124
|
super();
|
|
119
125
|
this.weeksRun = "rows";
|
|
120
126
|
this.byDay = new Map();
|
|
127
|
+
this.heatByDay = new Map();
|
|
121
128
|
this.internals = typeof this.attachInternals === "function" ? this.attachInternals() : null;
|
|
122
129
|
/** The value the field started with, for a form's reset. */
|
|
123
130
|
this.initial = "";
|
|
@@ -280,6 +287,7 @@ export class Calendar extends CalendarBase {
|
|
|
280
287
|
this.outsideDays = false;
|
|
281
288
|
this.noHeader = false;
|
|
282
289
|
this.noToday = false;
|
|
290
|
+
this.heat = false;
|
|
283
291
|
this.picker = false;
|
|
284
292
|
this.time = false;
|
|
285
293
|
this.required = false;
|
|
@@ -416,7 +424,8 @@ export class Calendar extends CalendarBase {
|
|
|
416
424
|
const unfolded = this.unfolded === day;
|
|
417
425
|
const shown = unfolded || events.length <= lines ? events : events.slice(0, Math.max(0, lines - 1));
|
|
418
426
|
const hidden = events.length - shown.length;
|
|
419
|
-
const
|
|
427
|
+
const heat = this.heatByDay.get(day);
|
|
428
|
+
const parts = ["day", isToday ? "today" : "", selected ? "selected" : "", heat ? "heat" : ""].filter(Boolean).join(" ");
|
|
420
429
|
return html `<div
|
|
421
430
|
role="gridcell"
|
|
422
431
|
class="day"
|
|
@@ -434,6 +443,7 @@ export class Calendar extends CalendarBase {
|
|
|
434
443
|
?data-last=${last}
|
|
435
444
|
?data-outside=${outside}
|
|
436
445
|
?data-busy=${events.length > 0}
|
|
446
|
+
data-heat=${heat ?? nothing}
|
|
437
447
|
?data-open=${unfolded}
|
|
438
448
|
>
|
|
439
449
|
<span class="date-line" aria-hidden="true">
|
|
@@ -460,6 +470,8 @@ export class Calendar extends CalendarBase {
|
|
|
460
470
|
const first = this.firstDay;
|
|
461
471
|
const weeks = monthWeeks(month, first, this.fixed);
|
|
462
472
|
this.byDay = eventsByDay(this.events ?? [], weeks[0][0], weeks.at(-1)[6]);
|
|
473
|
+
// Heat is measured over the days of the month shown, so the neighbours' days never set its scale.
|
|
474
|
+
this.heatByDay = this.heat ? heatLevels(new Map([...this.byDay].filter(([day]) => sameMonth(day, month))), this.heatMax) : new Map();
|
|
463
475
|
// A compact month names its days in a letter (one square) or two (wider); a full month in short.
|
|
464
476
|
const short = this.compact
|
|
465
477
|
? this.squaresPerDay < 2
|
|
@@ -664,7 +676,7 @@ export class Calendar extends CalendarBase {
|
|
|
664
676
|
const name = this.label ? this.pickerWords(this.label, this.label) : this.pickerWords(undefined, "Date");
|
|
665
677
|
const days = start ? (end ? `${start.day}/${end.day}` : start.day) : "";
|
|
666
678
|
return html `<button
|
|
667
|
-
class="ds-
|
|
679
|
+
class="ds-input trigger"
|
|
668
680
|
part="trigger"
|
|
669
681
|
type="button"
|
|
670
682
|
aria-haspopup="dialog"
|
|
@@ -675,9 +687,8 @@ export class Calendar extends CalendarBase {
|
|
|
675
687
|
@click=${this.toggle}
|
|
676
688
|
@keydown=${this.onTriggerKey}
|
|
677
689
|
>
|
|
678
|
-
<ds-icon class="icon" type="calendar" aria-hidden="true"></ds-icon>
|
|
679
690
|
<span class="text">${text}</span>
|
|
680
|
-
<ds-icon class="arrow" type="down" aria-hidden="true"></ds-icon>
|
|
691
|
+
<ds-icon class="arrow" type="chevron-down" size="large" aria-hidden="true"></ds-icon>
|
|
681
692
|
</button>
|
|
682
693
|
<div
|
|
683
694
|
class="popover"
|
|
@@ -730,6 +741,8 @@ Calendar.properties = {
|
|
|
730
741
|
outsideDays: { type: Boolean, attribute: "outside-days", reflect: true },
|
|
731
742
|
noHeader: { type: Boolean, attribute: "no-header", reflect: true },
|
|
732
743
|
noToday: { type: Boolean, attribute: "no-today", reflect: true },
|
|
744
|
+
heat: { type: Boolean, reflect: true },
|
|
745
|
+
heatMax: { type: Number, attribute: "heat-max" },
|
|
733
746
|
picker: { type: Boolean, reflect: true },
|
|
734
747
|
name: { type: String, reflect: true },
|
|
735
748
|
placeholder: { type: String },
|