@canonical/react-ds-global 0.37.0 → 0.38.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.
Files changed (192) hide show
  1. package/README.md +72 -0
  2. package/dist/esm/lib/_work_in_progress/Announcement/styles.css +51 -47
  3. package/dist/esm/lib/_work_in_progress/CategoriesSection/common/Category/styles.css +21 -17
  4. package/dist/esm/lib/_work_in_progress/CategoriesSection/styles.css +16 -12
  5. package/dist/esm/lib/_work_in_progress/ChatSection/styles.css +22 -18
  6. package/dist/esm/lib/_work_in_progress/DescriptionSection/styles.css +14 -10
  7. package/dist/esm/lib/_work_in_progress/IconSection/styles.css +18 -14
  8. package/dist/esm/lib/_work_in_progress/Label/styles.css +36 -32
  9. package/dist/esm/lib/_work_in_progress/Link/styles.css +32 -28
  10. package/dist/esm/lib/_work_in_progress/Rule/styles.css +21 -14
  11. package/dist/esm/lib/_work_in_progress/Section/styles.css +66 -62
  12. package/dist/esm/lib/_work_in_progress/SkipLink/styles.css +35 -32
  13. package/dist/esm/lib/_work_in_progress/TSection/styles.css +26 -22
  14. package/dist/esm/lib/_work_in_progress/grid/ApplicationLayout/ApplicationLayout.js +4 -1
  15. package/dist/esm/lib/_work_in_progress/grid/ApplicationLayout/ApplicationLayout.js.map +1 -1
  16. package/dist/esm/lib/_work_in_progress/grid/ApplicationLayout/styles.css +21 -17
  17. package/dist/esm/lib/_work_in_progress/grid/GridCard/GridCard.js +4 -1
  18. package/dist/esm/lib/_work_in_progress/grid/GridCard/GridCard.js.map +1 -1
  19. package/dist/esm/lib/_work_in_progress/grid/GridCard/styles.css +8 -4
  20. package/dist/esm/lib/_work_in_progress/grid/InnerGridDemo/styles.css +38 -33
  21. package/dist/esm/lib/_work_in_progress/grid/SettingsView/SettingsView.js +4 -1
  22. package/dist/esm/lib/_work_in_progress/grid/SettingsView/SettingsView.js.map +1 -1
  23. package/dist/esm/lib/_work_in_progress/grid/SettingsView/styles.css +23 -19
  24. package/dist/esm/lib/component/Accordion/common/Item/styles.css +305 -299
  25. package/dist/esm/lib/component/Accordion/styles.css +35 -31
  26. package/dist/esm/lib/component/Badge/hooks/useBadge.js +1 -1
  27. package/dist/esm/lib/component/Badge/hooks/useBadge.js.map +1 -1
  28. package/dist/esm/lib/component/Badge/styles.css +45 -41
  29. package/dist/esm/lib/component/Breadcrumbs/Breadcrumbs.js +1 -1
  30. package/dist/esm/lib/component/Breadcrumbs/Breadcrumbs.js.map +1 -1
  31. package/dist/esm/lib/component/Breadcrumbs/common/Item/styles.css +69 -65
  32. package/dist/esm/lib/component/Breadcrumbs/styles.css +30 -26
  33. package/dist/esm/lib/component/Button/styles.css +293 -260
  34. package/dist/esm/lib/component/Card/common/Content/styles.css +27 -23
  35. package/dist/esm/lib/component/Card/common/Footer/styles.css +30 -26
  36. package/dist/esm/lib/component/Card/common/Header/styles.css +25 -21
  37. package/dist/esm/lib/component/Card/common/Image/styles.css +8 -4
  38. package/dist/esm/lib/component/Card/styles.css +77 -73
  39. package/dist/esm/lib/component/Chip/Chip.js.map +1 -1
  40. package/dist/esm/lib/component/Chip/styles.css +105 -101
  41. package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js +29 -20
  42. package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js.map +1 -1
  43. package/dist/esm/lib/component/ContextualMenu/common/Item/Item.js +25 -2
  44. package/dist/esm/lib/component/ContextualMenu/common/Item/Item.js.map +1 -1
  45. package/dist/esm/lib/component/ContextualMenu/common/Item/styles.css +116 -106
  46. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js +29 -9
  47. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js.map +1 -1
  48. package/dist/esm/lib/component/ContextualMenu/styles.css +74 -72
  49. package/dist/esm/lib/component/Icon/styles.css +24 -20
  50. package/dist/esm/lib/component/InlineCode/styles.css +19 -15
  51. package/dist/esm/lib/component/KeyboardKey/styles.css +44 -40
  52. package/dist/esm/lib/component/Popover/Popover.js.map +1 -1
  53. package/dist/esm/lib/component/Popover/styles.css +59 -52
  54. package/dist/esm/lib/component/Tabs/common/Item/styles.css +80 -76
  55. package/dist/esm/lib/component/Tabs/styles.css +36 -32
  56. package/dist/esm/lib/component/Tile/common/Content/styles.css +28 -24
  57. package/dist/esm/lib/component/Tile/common/Header/styles.css +28 -24
  58. package/dist/esm/lib/component/Tile/styles.css +31 -27
  59. package/dist/esm/lib/component/Tooltip/styles.css +213 -208
  60. package/dist/esm/lib/group/Cards/styles.css +26 -22
  61. package/dist/esm/lib/group/KeyboardKeys/styles.css +14 -10
  62. package/dist/esm/lib/hooks/useContextualMenu/index.js +1 -0
  63. package/dist/esm/lib/hooks/useContextualMenu/index.js.map +1 -1
  64. package/dist/esm/lib/hooks/useContextualMenu/isMenuSeparator.js +11 -0
  65. package/dist/esm/lib/hooks/useContextualMenu/isMenuSeparator.js.map +1 -0
  66. package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js +54 -34
  67. package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js.map +1 -1
  68. package/dist/esm/lib/hooks/useDisclosure/useDisclosure.js.map +1 -1
  69. package/dist/esm/lib/hooks/useWindowDimensions/useWindowDimensions.js +1 -1
  70. package/dist/esm/lib/hooks/useWindowDimensions/useWindowDimensions.js.map +1 -1
  71. package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js +3 -0
  72. package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js.map +1 -1
  73. package/dist/esm/lib/index.css +79 -0
  74. package/dist/esm/lib/pattern/Modal/Context.js +10 -0
  75. package/dist/esm/lib/pattern/Modal/Context.js.map +1 -0
  76. package/dist/esm/lib/pattern/Modal/Provider.js +103 -0
  77. package/dist/esm/lib/pattern/Modal/Provider.js.map +1 -0
  78. package/dist/esm/lib/pattern/Modal/common/Content/Content.js +15 -0
  79. package/dist/esm/lib/pattern/Modal/common/Content/Content.js.map +1 -0
  80. package/dist/esm/lib/pattern/Modal/common/Content/index.js +3 -0
  81. package/dist/esm/lib/pattern/Modal/common/Content/index.js.map +1 -0
  82. package/dist/esm/lib/pattern/Modal/common/Content/styles.css +37 -0
  83. package/dist/esm/lib/pattern/Modal/common/Content/types.js +2 -0
  84. package/dist/esm/lib/pattern/Modal/common/Content/types.js.map +1 -0
  85. package/dist/esm/lib/pattern/Modal/common/Footer/Footer.js +16 -0
  86. package/dist/esm/lib/pattern/Modal/common/Footer/Footer.js.map +1 -0
  87. package/dist/esm/lib/pattern/Modal/common/Footer/index.js +3 -0
  88. package/dist/esm/lib/pattern/Modal/common/Footer/index.js.map +1 -0
  89. package/dist/esm/lib/pattern/Modal/common/Footer/styles.css +57 -0
  90. package/dist/esm/lib/pattern/Modal/common/Footer/types.js +2 -0
  91. package/dist/esm/lib/pattern/Modal/common/Footer/types.js.map +1 -0
  92. package/dist/esm/lib/pattern/Modal/common/Header/Header.js +27 -0
  93. package/dist/esm/lib/pattern/Modal/common/Header/Header.js.map +1 -0
  94. package/dist/esm/lib/pattern/Modal/common/Header/index.js +3 -0
  95. package/dist/esm/lib/pattern/Modal/common/Header/index.js.map +1 -0
  96. package/dist/esm/lib/pattern/Modal/common/Header/styles.css +79 -0
  97. package/dist/esm/lib/pattern/Modal/common/Header/types.js +2 -0
  98. package/dist/esm/lib/pattern/Modal/common/Header/types.js.map +1 -0
  99. package/dist/esm/lib/pattern/Modal/common/index.js +5 -0
  100. package/dist/esm/lib/pattern/Modal/common/index.js.map +1 -0
  101. package/dist/esm/lib/pattern/Modal/hooks/useModalContext.js +11 -0
  102. package/dist/esm/lib/pattern/Modal/hooks/useModalContext.js.map +1 -0
  103. package/dist/esm/lib/pattern/Modal/hooks/useModalState.js +15 -0
  104. package/dist/esm/lib/pattern/Modal/hooks/useModalState.js.map +1 -0
  105. package/dist/esm/lib/pattern/Modal/index.js +4 -0
  106. package/dist/esm/lib/pattern/Modal/index.js.map +1 -0
  107. package/dist/esm/lib/pattern/Modal/styles.css +119 -0
  108. package/dist/esm/lib/pattern/Modal/types.js +2 -0
  109. package/dist/esm/lib/pattern/Modal/types.js.map +1 -0
  110. package/dist/esm/lib/pattern/Modal/withModal.js +102 -0
  111. package/dist/esm/lib/pattern/Modal/withModal.js.map +1 -0
  112. package/dist/esm/lib/pattern/Timeline/common/Content/styles.css +16 -12
  113. package/dist/esm/lib/pattern/Timeline/common/Event/styles.css +116 -112
  114. package/dist/esm/lib/pattern/Timeline/styles.css +16 -12
  115. package/dist/esm/lib/pattern/index.js +1 -0
  116. package/dist/esm/lib/pattern/index.js.map +1 -1
  117. package/dist/esm/lib/subcomponent/Spinner/styles.css +38 -34
  118. package/dist/types/lib/_work_in_progress/grid/ApplicationLayout/ApplicationLayout.d.ts.map +1 -1
  119. package/dist/types/lib/_work_in_progress/grid/GridCard/GridCard.d.ts.map +1 -1
  120. package/dist/types/lib/_work_in_progress/grid/SettingsView/SettingsView.d.ts.map +1 -1
  121. package/dist/types/lib/component/Badge/types.d.ts +1 -1
  122. package/dist/types/lib/component/Badge/types.d.ts.map +1 -1
  123. package/dist/types/lib/component/Breadcrumbs/types.d.ts +2 -2
  124. package/dist/types/lib/component/Breadcrumbs/types.d.ts.map +1 -1
  125. package/dist/types/lib/component/Chip/Chip.d.ts +2 -2
  126. package/dist/types/lib/component/Chip/Chip.d.ts.map +1 -1
  127. package/dist/types/lib/component/Chip/types.d.ts +10 -8
  128. package/dist/types/lib/component/Chip/types.d.ts.map +1 -1
  129. package/dist/types/lib/component/ContextualMenu/ContextualMenu.d.ts +4 -4
  130. package/dist/types/lib/component/ContextualMenu/ContextualMenu.d.ts.map +1 -1
  131. package/dist/types/lib/component/ContextualMenu/common/Item/Item.d.ts.map +1 -1
  132. package/dist/types/lib/component/ContextualMenu/common/MenuContext.d.ts +1 -1
  133. package/dist/types/lib/component/ContextualMenu/common/MenuContext.d.ts.map +1 -1
  134. package/dist/types/lib/component/ContextualMenu/common/SubMenu/SubMenu.d.ts +9 -7
  135. package/dist/types/lib/component/ContextualMenu/common/SubMenu/SubMenu.d.ts.map +1 -1
  136. package/dist/types/lib/component/ContextualMenu/types.d.ts +14 -6
  137. package/dist/types/lib/component/ContextualMenu/types.d.ts.map +1 -1
  138. package/dist/types/lib/component/Tabs/types.d.ts +2 -2
  139. package/dist/types/lib/component/Tabs/types.d.ts.map +1 -1
  140. package/dist/types/lib/hooks/useContextualMenu/index.d.ts +1 -0
  141. package/dist/types/lib/hooks/useContextualMenu/index.d.ts.map +1 -1
  142. package/dist/types/lib/hooks/useContextualMenu/isMenuSeparator.d.ts +13 -0
  143. package/dist/types/lib/hooks/useContextualMenu/isMenuSeparator.d.ts.map +1 -0
  144. package/dist/types/lib/hooks/useContextualMenu/types.d.ts +45 -15
  145. package/dist/types/lib/hooks/useContextualMenu/types.d.ts.map +1 -1
  146. package/dist/types/lib/hooks/useContextualMenu/useContextualMenu.d.ts +5 -6
  147. package/dist/types/lib/hooks/useContextualMenu/useContextualMenu.d.ts.map +1 -1
  148. package/dist/types/lib/hooks/useDisclosure/types.d.ts +7 -2
  149. package/dist/types/lib/hooks/useDisclosure/types.d.ts.map +1 -1
  150. package/dist/types/lib/hooks/useDisclosure/useDisclosure.d.ts +1 -1
  151. package/dist/types/lib/hooks/useDisclosure/useDisclosure.d.ts.map +1 -1
  152. package/dist/types/lib/hooks/useWindowFitment/types.d.ts +12 -3
  153. package/dist/types/lib/hooks/useWindowFitment/types.d.ts.map +1 -1
  154. package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts +1 -1
  155. package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts.map +1 -1
  156. package/dist/types/lib/pattern/Modal/Context.d.ts +10 -0
  157. package/dist/types/lib/pattern/Modal/Context.d.ts.map +1 -0
  158. package/dist/types/lib/pattern/Modal/Provider.d.ts +63 -0
  159. package/dist/types/lib/pattern/Modal/Provider.d.ts.map +1 -0
  160. package/dist/types/lib/pattern/Modal/common/Content/Content.d.ts +17 -0
  161. package/dist/types/lib/pattern/Modal/common/Content/Content.d.ts.map +1 -0
  162. package/dist/types/lib/pattern/Modal/common/Content/index.d.ts +3 -0
  163. package/dist/types/lib/pattern/Modal/common/Content/index.d.ts.map +1 -0
  164. package/dist/types/lib/pattern/Modal/common/Content/types.d.ts +15 -0
  165. package/dist/types/lib/pattern/Modal/common/Content/types.d.ts.map +1 -0
  166. package/dist/types/lib/pattern/Modal/common/Footer/Footer.d.ts +18 -0
  167. package/dist/types/lib/pattern/Modal/common/Footer/Footer.d.ts.map +1 -0
  168. package/dist/types/lib/pattern/Modal/common/Footer/index.d.ts +3 -0
  169. package/dist/types/lib/pattern/Modal/common/Footer/index.d.ts.map +1 -0
  170. package/dist/types/lib/pattern/Modal/common/Footer/types.d.ts +16 -0
  171. package/dist/types/lib/pattern/Modal/common/Footer/types.d.ts.map +1 -0
  172. package/dist/types/lib/pattern/Modal/common/Header/Header.d.ts +24 -0
  173. package/dist/types/lib/pattern/Modal/common/Header/Header.d.ts.map +1 -0
  174. package/dist/types/lib/pattern/Modal/common/Header/index.d.ts +3 -0
  175. package/dist/types/lib/pattern/Modal/common/Header/index.d.ts.map +1 -0
  176. package/dist/types/lib/pattern/Modal/common/Header/types.d.ts +36 -0
  177. package/dist/types/lib/pattern/Modal/common/Header/types.d.ts.map +1 -0
  178. package/dist/types/lib/pattern/Modal/common/index.d.ts +4 -0
  179. package/dist/types/lib/pattern/Modal/common/index.d.ts.map +1 -0
  180. package/dist/types/lib/pattern/Modal/hooks/useModalContext.d.ts +4 -0
  181. package/dist/types/lib/pattern/Modal/hooks/useModalContext.d.ts.map +1 -0
  182. package/dist/types/lib/pattern/Modal/hooks/useModalState.d.ts +10 -0
  183. package/dist/types/lib/pattern/Modal/hooks/useModalState.d.ts.map +1 -0
  184. package/dist/types/lib/pattern/Modal/index.d.ts +4 -0
  185. package/dist/types/lib/pattern/Modal/index.d.ts.map +1 -0
  186. package/dist/types/lib/pattern/Modal/types.d.ts +122 -0
  187. package/dist/types/lib/pattern/Modal/types.d.ts.map +1 -0
  188. package/dist/types/lib/pattern/Modal/withModal.d.ts +74 -0
  189. package/dist/types/lib/pattern/Modal/withModal.d.ts.map +1 -0
  190. package/dist/types/lib/pattern/index.d.ts +1 -0
  191. package/dist/types/lib/pattern/index.d.ts.map +1 -1
  192. package/package.json +28 -18
@@ -1,294 +1,327 @@
1
- /* Component tokens — sourced from @canonical/design-tokens */
2
- :root {
3
- /* Channel fallbacks used when no importance modifier is applied. Primary is
4
- the default hierarchy, so a bare `<button class="ds button">` reads as the
5
- filled primary look: the primary foreground fills the background and the
6
- label takes the on-fill contrast colour. */
7
- --button-color-background: var(
8
- --modifier-color-foreground-primary,
9
- var(--color-foreground-primary)
10
- );
11
- --button-color-background-hover: var(--color-foreground-primary-hover);
12
- --button-color-background-active: var(--color-foreground-primary-active);
13
- --button-color-background-disabled: var(--color-foreground-primary-disabled);
14
- /* Neutral text is the normal text colour. The filled default reads as
15
- contrast on the fill because `.primary` (the default importance, applied by
16
- the component) overrides text/icon to the on-fill contrast tokens; ghost
17
- importances keep this normal colour, so they stay visible. */
18
- --button-color-text: var(--color-text);
19
- --button-color-border: var(--color-border-highlighted, var(--color-border));
1
+ /* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
20
2
 
21
- /* Inline padding (Figma):
22
- - end (right): always dimension-200 (16px) — the label always sits 16px
23
- from the trailing edge.
24
- - start (left): dimension-200 (16px) with no icon; dimension-100 (8px) when
25
- an icon leads (the icon then sits closer to the edge), with a
26
- dimension-100 (8px) gap between the icon and the label. */
27
- --button-padding-inline-end: var(--dimension-200);
28
- --button-padding-inline-start: var(--dimension-200);
29
- --button-gap: var(--dimension-100);
30
- --button-border-width: var(--dimension-stroke-thickness-medium);
31
- /* Label weight — the button label is medium, not the `.p` body weight. */
32
- --button-font-weight: var(--typography-weight-medium);
33
- /* Label size — the button label is the text-secondary tier (14px), not the
34
- `.p` text-primary tier (16px). The line-height snaps up to the baseline
35
- grid exactly as the typography mapper does, so the box stays 32px tall
36
- (24px line + 8px of baseline nudges) around 14px text. */
37
- --button-font-size: var(--typography-text-secondary-font-size);
38
- --button-line-height: round(
39
- up,
40
- calc(
41
- var(--button-font-size) *
42
- var(--typography-text-secondary-line-height)
43
- ),
44
- var(--baseline-height)
45
- );
46
- }
47
-
48
- /* ==========================================================================
49
- Button Component Styles
50
- ========================================================================== */
51
-
52
- /*
53
- The button reads the modifier CHANNEL generically — it is not aware of any
54
- particular importance/anticipation class or combination:
55
-
56
- --modifier-surface which foreground fills the background (importance:
57
- filled for primary, ghost for secondary/tertiary).
58
- --modifier-outline 1 when a border shows, 0 when it does not (importance).
59
- --modifier-color-* the colour itself (anticipation/emphasis): text, icon,
60
- border. `.primary` overrides text/icon with the on-fill
61
- contrast tokens.
62
-
63
- Interaction states read the per-state surface/text/border channels supplied
64
- by the states shim (`--modifier-surface-{hover,active,disabled}`,
65
- `--modifier-color-text-disabled`, `--modifier-color-border-disabled`), which
66
- resolve to the explicit state tokens and recolour per anticipation.
67
- */
3
+ @layer ds.components.global {
4
+ /* Component tokens — sourced from @canonical/design-tokens */
5
+ :root {
6
+ /* Channel fallbacks used when no importance modifier is applied. Primary is
7
+ the default hierarchy, so a bare `<button class="ds button">` reads as the
8
+ filled primary look: the primary foreground fills the background and the
9
+ label takes the on-fill contrast colour. */
10
+ --button-color-background: var(
11
+ --modifier-color-foreground-primary,
12
+ var(--color-foreground-primary)
13
+ );
14
+ --button-color-background-hover: var(--color-foreground-primary-hover);
15
+ --button-color-background-active: var(--color-foreground-primary-active);
16
+ --button-color-background-disabled: var(
17
+ --color-foreground-primary-disabled
18
+ );
19
+ /* Neutral text is the normal text colour. The filled default reads as
20
+ contrast on the fill because `.primary` (the default importance, applied by
21
+ the component) overrides text/icon to the on-fill contrast tokens; ghost
22
+ importances keep this normal colour, so they stay visible. */
23
+ --button-color-text: var(--color-text);
24
+ --button-color-border: var(--color-border-highlighted, var(--color-border));
68
25
 
69
- .ds.button {
70
- position: relative;
71
- display: inline-flex;
72
- align-items: center;
73
- justify-content: center;
74
- gap: var(--button-gap);
75
- cursor: pointer;
26
+ /* Inline padding (Figma):
27
+ - end (right): always dimension-200 (16px) — the label always sits 16px
28
+ from the trailing edge.
29
+ - start (left): dimension-200 (16px) with no icon; dimension-100 (8px) when
30
+ an icon leads (the icon then sits closer to the edge), with a
31
+ dimension-100 (8px) gap between the icon and the label. */
32
+ --button-padding-inline-end: var(--dimension-200);
33
+ --button-padding-inline-start: var(--dimension-200);
34
+ --button-gap: var(--dimension-100);
35
+ --button-border-width: var(--dimension-stroke-thickness-medium);
36
+ /* Label weight — the button label is medium, not the `.p` body weight. */
37
+ --button-font-weight: var(--typography-weight-medium);
38
+ /* Label size — the button label is the text-secondary tier (14px), not the
39
+ `.p` text-primary tier (16px). The line-height snaps up to the baseline
40
+ grid exactly as the typography mapper does, so the box stays 32px tall
41
+ (24px line + 8px of baseline nudges) around 14px text. */
42
+ --button-font-size: var(--typography-text-secondary-font-size);
43
+ --button-line-height: round(
44
+ up,
45
+ calc(
46
+ var(--button-font-size) *
47
+ var(--typography-text-secondary-line-height)
48
+ ),
49
+ var(--baseline-height)
50
+ );
51
+ }
76
52
 
77
- color: var(--modifier-color-text, var(--button-color-text));
78
- background-color: var(--modifier-surface, var(--button-color-background));
79
- /* The outline flag (0/1) toggles the border's COLOUR, not its width: the
80
- border is ALWAYS present at the nominal width (transparent when hidden), so
81
- a bordered and a borderless importance share byte-identical geometry and
82
- the density seat below subtracts one constant. (The previous
83
- width-multiplied toggle left the primary 2px shorter than the secondary
84
- and seated its label ~1px high.) */
85
- border-color: color-mix(
86
- in srgb,
87
- var(--modifier-color-border, var(--button-color-border))
88
- calc(var(--modifier-outline, 0) * 100%),
89
- transparent
90
- );
91
- border-style: solid;
92
- border-width: var(--button-border-width);
53
+ /* ==========================================================================
54
+ Button Component Styles
55
+ ========================================================================== */
93
56
 
94
- /* Label typography tokens (text-secondary tier, 14px). The block placement that
95
- lands the label on the baseline grid comes from the density seat at the end of
96
- this file (the button no longer carries `.p`, so the engine's on-element nudges
97
- don't apply — without the seat the label is flat/unaligned). --font-size /
98
- --line-height are still exposed for any consumer that reads them. */
99
- --font-size: var(--button-font-size);
100
- --line-height: var(--button-line-height);
101
- font-weight: var(--button-font-weight);
102
- padding-inline: var(--button-padding-inline-start)
103
- var(--button-padding-inline-end);
57
+ /*
58
+ The button reads the modifier CHANNEL generically — it is not aware of any
59
+ particular importance/anticipation class or combination:
104
60
 
105
- text-align: center;
106
- text-decoration: none;
61
+ --modifier-surface which foreground fills the background (importance:
62
+ filled for primary, ghost for secondary/tertiary).
63
+ --modifier-outline 1 when a border shows, 0 when it does not (importance).
64
+ --modifier-color-* the colour itself (anticipation/emphasis): text, icon,
65
+ border. `.primary` overrides text/icon with the on-fill
66
+ contrast tokens.
107
67
 
108
- /* Fast colour transition on state change (hover/active/disabled). */
109
- transition:
110
- background-color var(--motion-duration-fast) var(--motion-easing-standard),
111
- color var(--motion-duration-fast) var(--motion-easing-standard),
112
- border-color var(--motion-duration-fast) var(--motion-easing-standard);
68
+ Interaction states read the per-state surface/text/border channels supplied
69
+ by the states shim (`--modifier-surface-{hover,active,disabled}`,
70
+ `--modifier-color-text-disabled`, `--modifier-color-border-disabled`), which
71
+ resolve to the explicit state tokens and recolour per anticipation.
72
+ */
113
73
 
114
- /* A leading icon tightens the start padding to dimension-100; the gap between
115
- the icon and label is already dimension-100. */
116
- &:has(> .icon) {
117
- --button-padding-inline-start: var(--dimension-100);
118
- }
74
+ .ds.button {
75
+ position: relative;
76
+ display: inline-flex;
77
+ align-items: center;
78
+ justify-content: center;
79
+ gap: var(--button-gap);
80
+ cursor: pointer;
119
81
 
120
- /* State fallbacks resolve to the default (primary) surface states when no
121
- importance modifier supplies `--modifier-surface-*`. */
122
- &:hover:not(:disabled) {
123
- background-color: var(
124
- --modifier-surface-hover,
125
- var(--button-color-background-hover)
82
+ color: var(--modifier-color-text, var(--button-color-text));
83
+ background-color: var(--modifier-surface, var(--button-color-background));
84
+ /* The outline flag (0/1) toggles the border's COLOUR, not its width: the
85
+ border is ALWAYS present at the nominal width (transparent when hidden), so
86
+ a bordered and a borderless importance share byte-identical geometry and
87
+ the density seat below subtracts one constant. (The previous
88
+ width-multiplied toggle left the primary 2px shorter than the secondary
89
+ and seated its label ~1px high.) */
90
+ border-color: color-mix(
91
+ in srgb,
92
+ var(--modifier-color-border, var(--button-color-border))
93
+ calc(var(--modifier-outline, 0) * 100%),
94
+ transparent
126
95
  );
127
- }
96
+ border-style: solid;
97
+ border-width: var(--button-border-width);
128
98
 
129
- &:active:not(:disabled) {
130
- background-color: var(
131
- --modifier-surface-active,
132
- var(--button-color-background-active)
133
- );
134
- }
99
+ /* Label typography tokens (text-secondary tier, 14px). The block placement that
100
+ lands the label on the baseline grid comes from the density seat at the end of
101
+ this file (the button no longer carries `.p`, so the engine's on-element nudges
102
+ don't apply — without the seat the label is flat/unaligned). --font-size /
103
+ --line-height are still exposed for any consumer that reads them. */
104
+ --font-size: var(--button-font-size);
105
+ --line-height: var(--button-line-height);
106
+ font-weight: var(--button-font-weight);
107
+ padding-inline: var(--button-padding-inline-start)
108
+ var(--button-padding-inline-end);
135
109
 
136
- /* Keyboard focus ring — driven by the modifier focusRing channel so it
137
- recolours per anticipation; falls back to the base focus ring token. */
138
- &:focus-visible {
139
- outline: var(--focus-outline-width, 2px) solid
140
- var(--modifier-color-focusRing, var(--color-focusRing, currentColor));
141
- outline-offset: var(--focus-outline-offset, 2px);
142
- }
110
+ text-align: center;
111
+ text-decoration: none;
143
112
 
144
- /* Disabled — explicit disabled tokens (not the computed deltas): the surface,
145
- text and border each resolve to their `-disabled` token. Primary supplies
146
- the on-fill disabled text via `--modifier-color-text-disabled`; ghost
147
- importances fall back to the plain disabled text colour. The border reads
148
- the disabled border channel, so it stays on the same highlighted ramp as
149
- the enabled border and recolours per anticipation. */
150
- &:disabled {
151
- cursor: not-allowed;
152
- color: var(--modifier-color-text-disabled, var(--color-text-disabled));
153
- background-color: var(
154
- --modifier-surface-disabled,
155
- var(--button-color-background-disabled)
156
- );
157
- border-color: var(
158
- --modifier-color-border-disabled,
159
- var(--color-border-highlighted-disabled)
160
- );
161
- }
162
- }
113
+ /* Fast colour transition on state change (hover/active/disabled). */
114
+ transition:
115
+ background-color var(--motion-duration-fast) var(--motion-easing-standard),
116
+ color var(--motion-duration-fast) var(--motion-easing-standard),
117
+ border-color var(--motion-duration-fast) var(--motion-easing-standard);
163
118
 
164
- /* ==========================================================================
165
- Icon Slot
166
- ========================================================================== */
119
+ /* A leading icon tightens the start padding to dimension-100; the gap between
120
+ the icon and label is already dimension-100. */
121
+ &:has(> .icon) {
122
+ --button-padding-inline-start: var(--dimension-100);
123
+ }
167
124
 
168
- .ds.button > .icon {
169
- display: inline-flex;
170
- align-items: center;
171
- justify-content: center;
172
- flex-shrink: 0;
173
- width: var(--icon-size, 1em);
174
- height: var(--icon-size, 1em);
125
+ /* State fallbacks resolve to the default (primary) surface states when no
126
+ importance modifier supplies `--modifier-surface-*`. */
127
+ &:hover:not(:disabled) {
128
+ background-color: var(
129
+ --modifier-surface-hover,
130
+ var(--button-color-background-hover)
131
+ );
132
+ }
175
133
 
176
- /* The icon has its own colour channel (distinct from the label text): on a
177
- filled primary it is the on-fill contrast icon, on ghost importances the
178
- modifier icon colour. Icons drawn with `currentColor` follow this. */
179
- color: var(--modifier-color-icon, var(--modifier-color-text, currentColor));
180
- }
181
-
182
- .ds.button:disabled > .icon {
183
- color: var(--modifier-color-icon-disabled, var(--color-icon-disabled));
184
- }
134
+ &:active:not(:disabled) {
135
+ background-color: var(
136
+ --modifier-surface-active,
137
+ var(--button-color-background-active)
138
+ );
139
+ }
185
140
 
186
- /* ==========================================================================
187
- Loading State
188
- ========================================================================== */
141
+ /* Keyboard focus ring — driven by the modifier focus-ring channel so it
142
+ recolours per anticipation; falls back to the base focus ring token. */
143
+ &:focus-visible {
144
+ outline: var(--focus-outline-width, 2px) solid
145
+ var(--modifier-color-focus-ring, var(--color-focus-ring, currentColor));
146
+ outline-offset: var(--focus-outline-offset, 2px);
147
+ }
189
148
 
190
- /* Loading replaces the label with a Spinner but keeps the button's width: the
191
- icon and label stay in the DOM (hidden, so their box still reserves space)
192
- and the Spinner is overlaid centred on top. A loading button is disabled (so
193
- it can't be re-triggered), but it must not *read* as disabled — it is
194
- working, not unavailable — so it keeps the enabled surface, text and border
195
- colours, overriding the :disabled greying above. */
196
- .ds.button.loading {
197
- color: var(--modifier-color-text, var(--button-color-text));
198
- background-color: var(--modifier-surface, var(--button-color-background));
199
- border-color: var(--modifier-color-border, var(--button-color-border));
200
-
201
- & > .icon,
202
- & > .label {
203
- visibility: hidden;
149
+ /* Disabled — explicit disabled tokens (not the computed deltas): the surface,
150
+ text and border each resolve to their `-disabled` token. Primary supplies
151
+ the on-fill disabled text via `--modifier-color-text-disabled`; ghost
152
+ importances fall back to the plain disabled text colour. The border reads
153
+ the disabled border channel, so it stays on the same highlighted ramp as
154
+ the enabled border and recolours per anticipation. */
155
+ &:disabled {
156
+ cursor: not-allowed;
157
+ color: var(--modifier-color-text-disabled, var(--color-text-disabled));
158
+ background-color: var(
159
+ --modifier-surface-disabled,
160
+ var(--button-color-background-disabled)
161
+ );
162
+ border-color: var(
163
+ --modifier-color-border-disabled,
164
+ var(--color-border-highlighted-disabled)
165
+ );
166
+ }
204
167
  }
205
168
 
206
- & > .loading-spinner {
207
- position: absolute;
208
- inset: 0;
169
+ /* ==========================================================================
170
+ Icon Slot
171
+ ========================================================================== */
172
+
173
+ .ds.button > .icon {
209
174
  display: inline-flex;
210
175
  align-items: center;
176
+ align-self: center;
211
177
  justify-content: center;
178
+ flex-shrink: 0;
179
+ width: var(--icon-size, 1em);
180
+ height: var(--icon-size, 1em);
181
+
182
+ /* The icon has its own colour channel (distinct from the label text): on a
183
+ filled primary it is the on-fill contrast icon, on ghost importances the
184
+ modifier icon colour. Icons drawn with `currentColor` follow this. */
185
+ color: var(--modifier-color-icon, var(--modifier-color-text, currentColor));
212
186
  }
213
- }
214
187
 
215
- /* ==========================================================================
216
- Link Variant
217
- ========================================================================== */
188
+ .ds.button:disabled > .icon {
189
+ color: var(--modifier-color-icon-disabled, var(--color-icon-disabled));
190
+ }
218
191
 
219
- .ds.button.link {
220
- background-color: transparent;
221
- border-color: transparent;
222
- border-width: 0;
223
- padding-inline: 0;
224
- color: var(--color-text-link, currentColor);
225
- text-decoration: underline;
226
- text-underline-offset: var(--tmp-dimension-underline-offset-link, 0.075em);
192
+ /* ==========================================================================
193
+ Loading State
194
+ ========================================================================== */
227
195
 
228
- &:hover:not(:disabled) {
229
- background-color: transparent;
230
- border-color: transparent;
231
- text-decoration-thickness: var(
232
- --tmp-dimension-decoration-thickness-link,
233
- 1px
234
- );
196
+ /* Loading replaces the label with a Spinner but keeps the button's width: the
197
+ icon and label stay in the DOM (hidden, so their box still reserves space)
198
+ and the Spinner is overlaid centred on top. A loading button is disabled (so
199
+ it can't be re-triggered), but it must not *read* as disabled — it is
200
+ working, not unavailable — so it keeps the enabled surface, text and border
201
+ colours, overriding the :disabled greying above. */
202
+ .ds.button.loading {
203
+ color: var(--modifier-color-text, var(--button-color-text));
204
+ background-color: var(--modifier-surface, var(--button-color-background));
205
+ border-color: var(--modifier-color-border, var(--button-color-border));
206
+
207
+ & > .icon,
208
+ & > .label {
209
+ visibility: hidden;
210
+ }
211
+
212
+ & > .loading-spinner {
213
+ position: absolute;
214
+ inset: 0;
215
+ display: inline-flex;
216
+ align-items: center;
217
+ justify-content: center;
218
+ }
235
219
  }
236
220
 
237
- &:active:not(:disabled) {
221
+ /* ==========================================================================
222
+ Link Variant
223
+ ========================================================================== */
224
+
225
+ .ds.button.link {
238
226
  background-color: transparent;
239
227
  border-color: transparent;
228
+ border-width: 0;
229
+ padding-inline: 0;
230
+ color: var(--color-text-link, currentColor);
231
+ text-decoration: underline;
232
+ text-underline-offset: var(--tmp-dimension-underline-offset-link, 0.075em);
233
+
234
+ &:hover:not(:disabled) {
235
+ background-color: transparent;
236
+ border-color: transparent;
237
+ text-decoration-thickness: var(
238
+ --tmp-dimension-decoration-thickness-link,
239
+ 1px
240
+ );
241
+ }
242
+
243
+ &:active:not(:disabled) {
244
+ background-color: transparent;
245
+ border-color: transparent;
246
+ }
240
247
  }
241
- }
242
248
 
243
- /* ── Density seat (apps 32 / sites 36, dense 24 / 28) — intrinsic ────────────
244
- * The button consumes the SHARED control seat from @canonical/styles
245
- * (modifiers.density.css): the label's own line box (cell − 2 baselines) is the
246
- * button interior, `--control-seat-before` puts its baseline on the density
247
- * target, `--control-seat-after` closes the box to EXACTLY the density cell.
248
- * The height is INTRINSIC — no block-size: border + pads + line-height add up
249
- * to the cell, and both outer edges land on grid lines.
250
- *
251
- * This lives HERE (ds-global) and not in ds-global-form's density.css, because
252
- * the Button is a ds-global component: an app that ships ds-global without the
253
- * form package must still get a seated button. The seat vars come from the
254
- * shared styles layer, so there is no form dependency.
255
- *
256
- * The seat subtracts the NOMINAL --button-border-width for BOTH importances —
257
- * the border is constant width and transparent when not shown (the
258
- * --modifier-outline pattern), so a bordered and a borderless button share one
259
- * geometry; no per-importance branch.
260
- *
261
- * `:is()` on the density scope (0,1,0) so `:is(...) .ds.button` (0,2,0) beats
262
- * the button's own `.ds.button { align-items: center }` (0,1,0) — otherwise the
263
- * label stays flex-CENTRED and the padding-based seat can't govern. */
264
- :is(.comfortable, .dense, .app, .site, .docs) .ds.button {
265
- /* Fold the button's own border into the shared basis HERE (a var() inside a
266
- custom property substitutes at its declaring element, so the shared layer
267
- cannot read this border). `1cap` in the basis resolves against the button's
268
- own label font. */
269
- /* Rounded to ¼px so the pad is exactly representable in the browser's 1/64px
270
- layout units — the fractional 1cap term otherwise leaves ~1/60px residues
271
- on the box height. */
272
- --seat-before: round(
273
- nearest,
274
- max(0px, calc(var(--control-seat-basis) - var(--button-border-width, 0px))),
275
- 0.25px
276
- );
277
- --seat-after: max(
278
- 0px,
279
- calc(
280
- var(--density-line-height-effective) -
281
- var(--control-seat-line) -
282
- var(--seat-before) -
283
- 2 *
284
- var(--button-border-width, 0px)
285
- )
286
- );
249
+ /* ── Density seat (apps 32 / sites 36, dense 24 / 28) — intrinsic ────────────
250
+ * The button consumes the SHARED control seat from @canonical/styles
251
+ * (modifiers.density.css): the label's own line box (cell − 2 baselines) is the
252
+ * button interior, `--control-seat-before` puts its baseline on the density
253
+ * target, `--control-seat-after` closes the box to EXACTLY the density cell.
254
+ * The height is INTRINSIC — no block-size: border + pads + line-height add up
255
+ * to the cell, and both outer edges land on grid lines.
256
+ *
257
+ * This lives HERE (ds-global) and not in ds-global-form's density.css, because
258
+ * the Button is a ds-global component: an app that ships ds-global without the
259
+ * form package must still get a seated button. The seat vars come from the
260
+ * shared styles layer, so there is no form dependency.
261
+ *
262
+ * The seat subtracts the NOMINAL --button-border-width for BOTH importances —
263
+ * the border is constant width and transparent when not shown (the
264
+ * --modifier-outline pattern), so a bordered and a borderless button share one
265
+ * geometry; no per-importance branch.
266
+ *
267
+ * ORDER, NOT SPECIFICITY, arbitrates here. The seat selects the component root
268
+ * at the base rule's own specificity — `.ds.button`, (0,2,0) — and is the LAST
269
+ * rule in this sheet, so it beats `.ds.button { align-items: center }` above by
270
+ * source order. Inside one layer, order is the only tie-break left: every
271
+ * GLOBAL-TIER package writes its component sheets into ONE layer,
272
+ * `ds.components.global` (an application tier has its own, `ds.components.app`,
273
+ * which sorts above it). So a selector lengthened purely to out-specify this
274
+ * file's own earlier rule also out-specifies the other global-tier packages'
275
+ * legitimate (0,2,0) rules in that same layer — measured: with the seat at
276
+ * (0,3,0) the form package's `.ds.combobox-reset-button` lost `line-height`,
277
+ * `box-sizing`, `align-items`, `justify-content` and `padding-block-end` to it,
278
+ * and its glyph rose 1.5 to 3px by cell and left-aligned. See
279
+ * `cs:css.selectors.specificity` and `cs:css.layers.components` ("a component
280
+ * never escalates its selector to win against another component").
281
+ *
282
+ * Order is a tie-break, not a guarantee: which of two packages' sheets a
283
+ * bundler emits first is not fixed. So nothing in the global tier should
284
+ * redeclare the seat's properties on a `.ds.button` at all; the tier layers
285
+ * settle everything else.
286
+ *
287
+ * `:where()` keeps what the prefix MEANS while contributing nothing to
288
+ * specificity: the seat's inputs (`--control-seat-basis`, `--control-seat-line`,
289
+ * `--density-line-height-effective`) are declared only on a density or context
290
+ * scope, so outside one the seat has no numbers to work with — measured, an
291
+ * ungated seat left an unscoped button at `align-items: flex-start` with a
292
+ * `normal` line box and no block padding. */
293
+ :where(.comfortable, .dense, .app, .site, .docs) .ds.button {
294
+ /* Fold the button's own border into the shared basis HERE (a var() inside a
295
+ custom property substitutes at its declaring element, so the shared layer
296
+ cannot read this border). `1cap` in the basis resolves against the button's
297
+ own label font. */
298
+ /* Rounded to ¼px so the pad is exactly representable in the browser's 1/64px
299
+ layout units — the fractional 1cap term otherwise leaves ~1/60px residues
300
+ on the box height. */
301
+ --seat-before: round(
302
+ nearest,
303
+ max(
304
+ 0px,
305
+ calc(var(--control-seat-basis) - var(--button-border-width, 0px))
306
+ ),
307
+ 0.25px
308
+ );
309
+ --seat-after: max(
310
+ 0px,
311
+ calc(
312
+ var(--density-line-height-effective) -
313
+ var(--control-seat-line) -
314
+ var(--seat-before) -
315
+ 2 *
316
+ var(--button-border-width, 0px)
317
+ )
318
+ );
287
319
 
288
- box-sizing: border-box;
289
- block-size: auto;
290
- align-items: flex-start;
291
- justify-content: flex-start;
292
- line-height: var(--control-seat-line);
293
- padding-block: var(--seat-before) var(--seat-after);
320
+ box-sizing: border-box;
321
+ block-size: auto;
322
+ align-items: flex-start;
323
+ justify-content: flex-start;
324
+ line-height: var(--control-seat-line);
325
+ padding-block: var(--seat-before) var(--seat-after);
326
+ }
294
327
  }