@0001-labs/design-system-1 0.3.0-alpha.26 → 0.3.0-alpha.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.
@@ -1,4 +1,4 @@
1
- /* version 0.3.0-alpha.26 */
1
+ /* version 0.3.0-alpha.27 */
2
2
 
3
3
  /* Noto Sans for Japanese and Chinese, for a product that shows them. Opt in:
4
4
  link it beside one.css or fonts.css, or ask Sync 1 for "cjk": true. Without
@@ -1,4 +1,4 @@
1
- /* version 0.3.0-alpha.26 */
1
+ /* version 0.3.0-alpha.27 */
2
2
 
3
3
  /* Design system 1's faces and the typeface tokens that name them, on their
4
4
  own: a page that does not load one.css links this sheet (one.css imports
@@ -1,4 +1,4 @@
1
- /* version 0.3.0-alpha.26 */
1
+ /* version 0.3.0-alpha.27 */
2
2
 
3
3
  @import "./grid.css";
4
4
  @import "./component-tokens.css";
@@ -1,4 +1,4 @@
1
- /* DS1 — version 0.3.0-alpha.26 */
1
+ /* DS1 — version 0.3.0-alpha.27 */
2
2
  /* A classless stylesheet for native HTML. No JavaScript is required. */
3
3
 
4
4
  /* It draws on Design system 1's measures: the 20px square, 14px type on
@@ -3,11 +3,12 @@ import "../2-core/ds-text";
3
3
  import "../2-core/ds-icon";
4
4
  import "../2-core/ds-button";
5
5
  import { define } from "../0-face/define";
6
- import "./ds-row";
7
6
  import styles from "./styles/ds-accordion.css?inline";
8
7
 
9
8
  /**
10
- * Native accordion using <details>/<summary> (no JS toggle logic).
9
+ * Native accordion using <details>/<summary> (no JS toggle logic): the
10
+ * summary one square high at the start, the library's chevron-down at its
11
+ * end (turned over when open), the details from the square below.
11
12
  *
12
13
  * Usage (with translation text):
13
14
  * <ds-accordion summary="How it began" details="Designed in Hokkaido"></ds-accordion>
@@ -86,22 +87,10 @@ export class Accordion extends LitElement {
86
87
  return html`
87
88
  <details ?open=${this.open}>
88
89
  <summary>
89
- <ds-row class="summaryRow" centered>
90
- <ds-text .text=${this.summary} ?literal=${this.literal}></ds-text>
91
- <ds-icon class="chevron" aria-hidden="true">
92
- <svg
93
- viewBox="0 0 10.157 8.219"
94
- xmlns="http://www.w3.org/2000/svg"
95
- aria-hidden="true"
96
- focusable="false"
97
- >
98
- <path
99
- d="M5.078 8.219L0 3.141L1.414 1.727L5.078 5.391L8.743 1.727L10.157 3.141L5.078 8.219Z"
100
- fill="currentColor"
101
- />
102
- </svg>
103
- </ds-icon>
104
- </ds-row>
90
+ <span class="summaryRow">
91
+ <ds-text class="summaryText" .text=${this.summary} ?literal=${this.literal}></ds-text>
92
+ <ds-icon class="chevron" type="chevron-down" size="large" aria-hidden="true"></ds-icon>
93
+ </span>
105
94
  </summary>
106
95
 
107
96
  <div class="detailsBody">
@@ -145,7 +145,7 @@ const openPickers = new Set<Calendar>();
145
145
  * @fires navigate - A person moved to another month; `{ month }`.
146
146
  * @fires ds-calendar-toggle - A picker's month opened or closed; `{ open }`.
147
147
  *
148
- * A selectable calendar has Clear one square below its month, and `clear()`
148
+ * A selectable calendar shows Clear right under its dates while something is chosen, and `clear()`
149
149
  * empties the value from code; both fire `change` with an empty value.
150
150
  *
151
151
  * @example
@@ -503,9 +503,9 @@ export class Calendar extends CalendarBase {
503
503
  }
504
504
 
505
505
  private renderClear() {
506
- if (!this.selectable || this.embedded || this.required) return nothing;
506
+ if (!this.selectable || this.embedded || this.required || !this.value) return nothing;
507
507
  return html`<div class="foot" part="foot">
508
- <button class="ds-button ds-button--secondary clear-value" part="clear" type="button" ?disabled=${!this.value} @click=${() => this.clear()}>${this.words("Clear")}</button>
508
+ <button class="ds-button ds-button--secondary clear-value" part="clear" type="button" @click=${() => this.clear()}>${this.words("Clear")}</button>
509
509
  </div>`;
510
510
  }
511
511
 
@@ -609,7 +609,7 @@ export class Calendar extends CalendarBase {
609
609
  type="button"
610
610
  aria-label=${`${title}, ${this.words("Choose a month and year")}`}
611
611
  @click=${this.levelUp}
612
- ><span class="title-text" id="title" aria-live="polite">${title}</span><ds-icon type="chevron-down" size="large" aria-hidden="true"></ds-icon></button>`}
612
+ ><span class="title-text" id="title" aria-live="polite">${title}</span></button>`}
613
613
  <span class="controls">
614
614
  ${this.noToday || this.squaresPerDay < 2 ? nothing : html`<button class="ds-button today-button" part="today" type="button" @click=${() => this.showToday()}>${this.words("Today")}</button>`}
615
615
  ${arrow("previous")}
@@ -1,5 +1,8 @@
1
- /* ds-accordion.css */
2
- /* Accordion component styles using native <details>/<summary> */
1
+ /* ds-accordion.css
2
+ * The summary is a row one square high: its words at the start on the sixteen, the library's
3
+ * chevron-down (16px, in the title grey) at its end, turned over when open. The pointer fills the
4
+ * row 4px past its words and chevron, keeping them where they stand; keyboard focus rings it.
5
+ * The details start on the square below, their lines one square each. */
3
6
  @import "../../1-root/component-metrics.css";
4
7
 
5
8
  :host {
@@ -15,37 +18,47 @@ details {
15
18
  }
16
19
 
17
20
  summary {
21
+ display: block;
22
+ margin-inline: calc(-4px * var(--ds-sf, 1));
23
+ padding-inline: calc(4px * var(--ds-sf, 1));
24
+ border-radius: var(--ds-radius);
18
25
  cursor: pointer;
19
26
  user-select: none;
20
27
  list-style: none;
21
28
  outline: none;
22
29
  }
23
-
24
30
  summary::-webkit-details-marker {
25
31
  display: none;
26
32
  }
33
+ summary:hover { background: var(--ds-row-fill-hover, var(--ds-fill)); }
34
+ summary:focus-visible { outline: 2px solid var(--ds-focus-ring); outline-offset: -2px; }
27
35
 
28
36
  .summaryRow {
29
- width: 100%;
37
+ display: flex;
38
+ align-items: flex-end;
39
+ gap: calc(4px * var(--ds-sf, 1));
40
+ min-height: var(--ds-unit);
41
+ line-height: var(--ds-type-lineheight-default);
30
42
  }
43
+ .summaryText { flex: 1 1 auto; min-width: 0; }
31
44
 
32
- ds-icon.chevron {
33
- transform: rotate(0deg);
34
- transition: transform 140ms ease;
45
+ .chevron {
46
+ flex: 0 0 auto;
47
+ color: var(--ds-title-color);
35
48
  }
36
-
37
- details[open] ds-icon.chevron {
38
- transform: rotate(180deg);
49
+ details[open] .chevron { transform: rotate(180deg); }
50
+ @media (prefers-reduced-motion: no-preference) {
51
+ .chevron { transition: transform 140ms ease; }
39
52
  }
40
53
 
41
54
  .detailsBody {
42
- padding-top: calc(var(--half) * var(--sf));
55
+ padding: 0;
43
56
  }
44
57
 
45
58
  .detailsText {
46
59
  display: block;
47
60
  white-space: normal;
48
- text-align: left;
61
+ text-align: start;
49
62
  }
50
63
 
51
64
  :host([control="slotted"]) { width: 100%; }
@@ -6,7 +6,7 @@
6
6
  * on the grid lines; today is a red disc nine tenths of a square across.
7
7
  *
8
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
9
+ * as wide as its words (it hugs them, as a button does), its words 4px in and the chevron-down icon
10
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
@@ -93,9 +93,9 @@
93
93
  .nav:hover:not(:disabled) { background: var(--ds-fill); color: var(--ds-text-color); }
94
94
  :host(:dir(rtl)) .nav > ds-icon { transform: scaleX(-1); }
95
95
 
96
- /* The title as a button: pressing it travels up to the months of the year, then to twelve years.
97
- * One control high at the square's foot, the words on the sixteen where the title stands, the
98
- * pointer filling it 4px past them. */
96
+ /* The title as a plain button, its words alone: pressing it travels up to the months of the year,
97
+ * then to twelve years. One control high at the square's foot, the words on the sixteen where the
98
+ * title stands, the pointer filling it 4px past them at each side. */
99
99
  .title-button {
100
100
  display: inline-flex;
101
101
  flex: 0 1 auto;
@@ -104,7 +104,7 @@
104
104
  max-width: 100%;
105
105
  height: var(--ds-control-height);
106
106
  margin: 0 0 0 calc(-4px * var(--ds-sf, 1));
107
- padding: 0 0 0 calc(4px * var(--ds-sf, 1));
107
+ padding: 0 calc(4px * var(--ds-sf, 1));
108
108
  border: 0;
109
109
  border-radius: var(--ds-radius);
110
110
  background: transparent;
@@ -115,11 +115,10 @@
115
115
  letter-spacing: inherit;
116
116
  cursor: pointer;
117
117
  }
118
- :host(:dir(rtl)) .title-button { margin: 0 calc(-4px * var(--ds-sf, 1)) 0 0; padding: 0 calc(4px * var(--ds-sf, 1)) 0 0; }
118
+ :host(:dir(rtl)) .title-button { margin: 0 calc(-4px * var(--ds-sf, 1)) 0 0; }
119
119
  .title-button:hover { background: var(--ds-fill); }
120
120
  .title-button:focus-visible { outline: 2px solid var(--ds-focus-ring); outline-offset: -2px; }
121
121
  .title-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
122
- .title-button > ds-icon { flex: 0 0 auto; color: var(--ds-title-color); }
123
122
 
124
123
  /* The months of a year, or twelve years: cells whole squares wide, three across a narrow month
125
124
  * and four across a wider one, each row one square, one square apart. The area keeps the days'
@@ -170,12 +169,12 @@
170
169
  .pick[data-selected] .pick-mark { background: var(--ds-calendar-selected); color: var(--ds-calendar-selected-ink); }
171
170
  .pick:disabled { color: var(--ds-title-color); cursor: default; opacity: 0.5; }
172
171
 
173
- /* Clear: a button one control high at the foot of the square below the month's, one square apart. */
172
+ /* Clear, only while something is chosen: a button one control high, centred on the square right under the dates. */
174
173
  .foot {
175
174
  display: flex;
176
175
  align-items: flex-end;
176
+ justify-content: center;
177
177
  height: var(--ds-unit);
178
- margin-block-start: var(--ds-unit);
179
178
  }
180
179
 
181
180
  @media (prefers-reduced-motion: no-preference) {
@@ -378,8 +377,8 @@
378
377
 
379
378
  /* The picker: a field that opens the small month. */
380
379
  :host([picker]) {
381
- --ds-calendar-picker-width: calc(10 * var(--ds-unit));
382
380
  display: inline-flex;
381
+ max-width: 100%;
383
382
  align-items: flex-end;
384
383
  vertical-align: bottom;
385
384
  height: var(--ds-unit);
@@ -389,7 +388,8 @@
389
388
  display: inline-flex;
390
389
  align-items: center;
391
390
  gap: calc(4px * var(--ds-sf, 1));
392
- width: var(--ds-calendar-picker-width);
391
+ width: var(--ds-calendar-picker-width, max-content);
392
+ max-width: 100%;
393
393
  padding-inline: calc(4px * var(--ds-sf, 1)) calc(2px * var(--ds-sf, 1));
394
394
  text-align: start;
395
395
  cursor: pointer;
@@ -27,7 +27,7 @@ export const Accordion = forwardRef<AccordionElement, AccordionProps>(function A
27
27
  ref: (element: AccordionElement | null) => {host.current = element; if (typeof ref === "function") ref(element); else if (ref) ref.current = element;},
28
28
  }, h("ds-button", {slot: "trigger", control: "slotted", choice: true, disabled},
29
29
  h("button", {type: "button", role: triggerRole, disabled, "aria-expanded": expanded, "aria-controls": id}, summary,
30
- h("ds-icon", {type: expanded ? "up" : "down", "aria-hidden": "true", style: {marginInlineStart: "auto", flex: "0 0 auto"}}))),
30
+ h("ds-icon", {type: "chevron-down", size: "large", "aria-hidden": "true", style: {marginInlineStart: "auto", flex: "0 0 auto", color: "var(--ds-title-color)", transform: expanded ? "rotate(180deg)" : undefined}}))),
31
31
  actions == null ? null : h("div", {slot: "actions"}, actions),
32
32
  h("div", {slot: "details", id, hidden: !expanded}, children));
33
33
  });
@@ -2,9 +2,10 @@ import { LitElement } from "lit";
2
2
  import "../2-core/ds-text";
3
3
  import "../2-core/ds-icon";
4
4
  import "../2-core/ds-button";
5
- import "./ds-row";
6
5
  /**
7
- * Native accordion using <details>/<summary> (no JS toggle logic).
6
+ * Native accordion using <details>/<summary> (no JS toggle logic): the
7
+ * summary one square high at the start, the library's chevron-down at its
8
+ * end (turned over when open), the details from the square below.
8
9
  *
9
10
  * Usage (with translation text):
10
11
  * <ds-accordion summary="How it began" details="Designed in Hokkaido"></ds-accordion>
@@ -1 +1 @@
1
- {"version":3,"file":"ds-accordion.d.ts","sourceRoot":"","sources":["../../DS1/3-unit/ds-accordion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAClD,OAAO,mBAAmB,CAAC;AAC3B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,qBAAqB,CAAC;AAE7B,OAAO,UAAU,CAAC;AAGlB;;;;;;;;;;;;;GAaG;AACH,qBAAa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ACF"}
@@ -3,10 +3,11 @@ import "../2-core/ds-text";
3
3
  import "../2-core/ds-icon";
4
4
  import "../2-core/ds-button";
5
5
  import { define } from "../0-face/define";
6
- import "./ds-row";
7
6
  import styles from "./styles/ds-accordion.css?inline";
8
7
  /**
9
- * Native accordion using <details>/<summary> (no JS toggle logic).
8
+ * Native accordion using <details>/<summary> (no JS toggle logic): the
9
+ * summary one square high at the start, the library's chevron-down at its
10
+ * end (turned over when open), the details from the square below.
10
11
  *
11
12
  * Usage (with translation text):
12
13
  * <ds-accordion summary="How it began" details="Designed in Hokkaido"></ds-accordion>
@@ -67,22 +68,10 @@ export class Accordion extends LitElement {
67
68
  return html `
68
69
  <details ?open=${this.open}>
69
70
  <summary>
70
- <ds-row class="summaryRow" centered>
71
- <ds-text .text=${this.summary} ?literal=${this.literal}></ds-text>
72
- <ds-icon class="chevron" aria-hidden="true">
73
- <svg
74
- viewBox="0 0 10.157 8.219"
75
- xmlns="http://www.w3.org/2000/svg"
76
- aria-hidden="true"
77
- focusable="false"
78
- >
79
- <path
80
- d="M5.078 8.219L0 3.141L1.414 1.727L5.078 5.391L8.743 1.727L10.157 3.141L5.078 8.219Z"
81
- fill="currentColor"
82
- />
83
- </svg>
84
- </ds-icon>
85
- </ds-row>
71
+ <span class="summaryRow">
72
+ <ds-text class="summaryText" .text=${this.summary} ?literal=${this.literal}></ds-text>
73
+ <ds-icon class="chevron" type="chevron-down" size="large" aria-hidden="true"></ds-icon>
74
+ </span>
86
75
  </summary>
87
76
 
88
77
  <div class="detailsBody">
@@ -81,7 +81,7 @@ export declare function parseTypedDay(text: string): Day | null;
81
81
  * @fires navigate - A person moved to another month; `{ month }`.
82
82
  * @fires ds-calendar-toggle - A picker's month opened or closed; `{ open }`.
83
83
  *
84
- * A selectable calendar has Clear one square below its month, and `clear()`
84
+ * A selectable calendar shows Clear right under its dates while something is chosen, and `clear()`
85
85
  * empties the value from code; both fire `change` with an empty value.
86
86
  *
87
87
  * @example
@@ -116,7 +116,7 @@ const openPickers = new Set();
116
116
  * @fires navigate - A person moved to another month; `{ month }`.
117
117
  * @fires ds-calendar-toggle - A picker's month opened or closed; `{ open }`.
118
118
  *
119
- * A selectable calendar has Clear one square below its month, and `clear()`
119
+ * A selectable calendar shows Clear right under its dates while something is chosen, and `clear()`
120
120
  * empties the value from code; both fire `change` with an empty value.
121
121
  *
122
122
  * @example
@@ -553,10 +553,10 @@ export class Calendar extends CalendarBase {
553
553
  ><span class="pick-mark">${name(value)}</span></button>`)}</div>`)}</div>`;
554
554
  }
555
555
  renderClear() {
556
- if (!this.selectable || this.embedded || this.required)
556
+ if (!this.selectable || this.embedded || this.required || !this.value)
557
557
  return nothing;
558
558
  return html `<div class="foot" part="foot">
559
- <button class="ds-button ds-button--secondary clear-value" part="clear" type="button" ?disabled=${!this.value} @click=${() => this.clear()}>${this.words("Clear")}</button>
559
+ <button class="ds-button ds-button--secondary clear-value" part="clear" type="button" @click=${() => this.clear()}>${this.words("Clear")}</button>
560
560
  </div>`;
561
561
  }
562
562
  /** The day holding the Tab stop: the one moved to, the selected day, today, or the first. */
@@ -605,7 +605,7 @@ export class Calendar extends CalendarBase {
605
605
  type="button"
606
606
  aria-label=${`${title}, ${this.words("Choose a month and year")}`}
607
607
  @click=${this.levelUp}
608
- ><span class="title-text" id="title" aria-live="polite">${title}</span><ds-icon type="chevron-down" size="large" aria-hidden="true"></ds-icon></button>`}
608
+ ><span class="title-text" id="title" aria-live="polite">${title}</span></button>`}
609
609
  <span class="controls">
610
610
  ${this.noToday || this.squaresPerDay < 2 ? nothing : html `<button class="ds-button today-button" part="today" type="button" @click=${() => this.showToday()}>${this.words("Today")}</button>`}
611
611
  ${arrow("previous")}