@leabankab/component-library 6.1.0 → 7.1.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 CHANGED
@@ -1,5 +1,218 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2471d97: Accordion variant and styling updates
8
+
9
+ ## 7.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - d415e5f: Rebuild `Button`, `IconButton` and `DownloadTrigger` on Base UI with a CSS Module, and add `CloseButton`.
14
+
15
+ The buttons no longer wrap MUI, so they render styled without `LeaProvider`. All four share one stylesheet and the same `variant`, `color` and `size` props:
16
+
17
+ ```tsx
18
+ // Before
19
+ <Button variant="outlined" color="error" size="small">Delete</Button>
20
+ <Button component={NextLink} href="/about">About</Button>
21
+
22
+ // After
23
+ <Button variant="secondary" color="danger" size="sm">Delete</Button>
24
+ <Button render={<NextLink href="/about" />}>About</Button>
25
+ ```
26
+
27
+ Breaking changes to `Button`, `IconButton` and `DownloadTrigger`:
28
+
29
+ - `variant`: `"contained"` / `"outlined"` become `"primary"` / `"secondary"`, and the new `"tertiary"` is a ghost button (default `"primary"`). `"text"` is removed — use `Link` for a link inside running text.
30
+ - `color`: `"primary"`, `"secondary"`, `"info"` and `"error"` are replaced by `"accent"` (purple), `"neutral"` (black) and `"danger"` (red) (default `"accent"`).
31
+ - `size`: `"small"` / `"large"` become `"sm"` / `"md"` / `"lg"` (default `"md"`).
32
+ - `component` is replaced by Base UI's `render`. A `render` element with `href` or `to` renders as a real link without button semantics, so `<Button render={<a href="/about" />}>` announces as a link.
33
+ - `sx` and every other MUI `Button` / `IconButton` prop is gone, including `loadingPosition`, `loadingIndicator`, `fullWidth` and `disableElevation`. Use `className` or `style`.
34
+ - `IconButton` now requires exactly one of `aria-label` or `aria-labelledby` — an icon button without an accessible name no longer compiles.
35
+ - `disabled` now renders a greyscale button in every variant.
36
+
37
+ Kept: `startIcon`, `endIcon` and `loading`. While `loading`, the button is disabled, keeps its colour at reduced opacity, swaps `startIcon` for a spinner and sets `aria-busy`. The new `loadingLabel` announces the busy state through a visually-hidden `role="status"` region.
38
+
39
+ New:
40
+
41
+ - `CloseButton` — an icon button with a built-in X and a translated default accessible name ("Lukk", "Stäng", …). Pass `label` to override it.
42
+ - The buttons forward refs, so they compose with Base UI triggers: `<Dialog.Trigger render={<Button />}>`.
43
+
44
+ Unchanged:
45
+
46
+ - `ActionButton` is still an MUI button.
47
+ - The `MuiButton` and `MuiIconButton` theme overrides remain, so MUI's own `Button` and `IconButton` (and those MUI renders inside `Autocomplete` and `Alert`) look as before.
48
+
49
+ - d415e5f: Rebuild `Accordion` on Base UI with CSS Modules.
50
+
51
+ The MUI `Accordion` wrapper and its re-exported `AccordionSummary` /
52
+ `AccordionDetails` are replaced by a single `Accordion` namespace that mirrors
53
+ Base UI's composition. `src/theme/components/accordion.theme.ts` is gone —
54
+ styling now lives in `accordion.module.css` and reads the theme's CSS
55
+ variables.
56
+
57
+ The two variants are now `outline` (a `border.base` outline, default) and
58
+ `solid` (borderless with a white fill), replacing `outlined` / `filled`.
59
+
60
+ ```diff
61
+ - import { Accordion, AccordionSummary, AccordionDetails } from "@leabankab/component-library";
62
+ + import { Accordion } from "@leabankab/component-library";
63
+
64
+ - <Accordion variant="outlined" defaultExpanded>
65
+ - <AccordionSummary id="summary" aria-controls="panel">
66
+ - Question
67
+ - </AccordionSummary>
68
+ - <AccordionDetails>Answer</AccordionDetails>
69
+ - </Accordion>
70
+ + <Accordion.Root variant="outline" defaultValue={["faq"]}>
71
+ + <Accordion.Item value="faq">
72
+ + <Accordion.Header>
73
+ + <Accordion.Trigger>Question</Accordion.Trigger>
74
+ + </Accordion.Header>
75
+ + <Accordion.Panel>Answer</Accordion.Panel>
76
+ + </Accordion.Item>
77
+ + </Accordion.Root>
78
+ ```
79
+
80
+ Other changes to be aware of:
81
+
82
+ - `id` / `aria-controls` are no longer passed by hand. Base UI generates the
83
+ ids and wires `aria-expanded`, `aria-controls` and the panel's `region` role.
84
+ - `defaultExpanded` becomes `defaultValue={[itemValue]}`; `expanded` /
85
+ `onChange` become `value` / `onValueChange` on `Accordion.Root`.
86
+ - Allowing several panels open at once now needs `multiple` on
87
+ `Accordion.Root` (previously the default for separate `Accordion` elements).
88
+ - `AccordionProps`, `AccordionSummaryProps` and `AccordionDetailsProps` are
89
+ replaced by `Accordion.RootProps`, `Accordion.ItemProps`,
90
+ `Accordion.HeaderProps`, `Accordion.TriggerProps` and
91
+ `Accordion.PanelProps`.
92
+ - The library now emits a stylesheet. The ES build imports it automatically;
93
+ consumers on the UMD build should import `@leabankab/component-library/styles.css`.
94
+
95
+ - d415e5f: Rebuild `Dialog` and `Drawer` on Base UI with CSS Modules, and add a fullscreen-on-mobile option to `Dialog`.
96
+
97
+ `Dialog` and `Drawer` are no longer renderable components — they are namespaces of composable parts, matching `Accordion`:
98
+
99
+ ```tsx
100
+ // Before
101
+ <Dialog open={open} onClose={handleClose} maxWidth="xs">
102
+ <DialogTitle>Title</DialogTitle>
103
+ <DialogContent>Body</DialogContent>
104
+ </Dialog>
105
+
106
+ // After
107
+ <Dialog.Root open={open} onOpenChange={setOpen}>
108
+ <Dialog.Portal>
109
+ <Dialog.Backdrop />
110
+ <Dialog.Viewport>
111
+ <Dialog.Popup size="xs">
112
+ <Dialog.Header>
113
+ <Dialog.Title>Title</Dialog.Title>
114
+ <Dialog.CloseButton />
115
+ </Dialog.Header>
116
+ <Dialog.Content>Body</Dialog.Content>
117
+ </Dialog.Popup>
118
+ </Dialog.Viewport>
119
+ </Dialog.Portal>
120
+ </Dialog.Root>
121
+ ```
122
+
123
+ `Dialog` exposes `Root`, `Trigger`, `Portal`, `Backdrop`, `Viewport`, `Popup`, `Header`, `Title`, `Description`, `Content`, `Close` and `CloseButton`. `Drawer` exposes the same, plus `Handle`.
124
+
125
+ Breaking changes to `SimpleDialog` and `SimpleDrawer`:
126
+
127
+ - `onClose(event, reason)` is replaced by Base UI's `onOpenChange(open, eventDetails)`. The reason is on `eventDetails.reason` and now covers `"outside-press"`, `"escape-key"`, `"close-press"`, `"trigger-press"` and (for the drawer) `"swipe"`.
128
+ - `SimpleDialog`'s `maxWidth` / `fullWidth` are replaced by `size` (`"xs" | "sm" | "md" | "lg"`, default `"sm"`); the widths match the MUI values they replace.
129
+ - `SimpleDrawer`'s `anchor` is replaced by `side` (`"left" | "right" | "top" | "bottom"`, default `"right"`). `side` also sets the swipe-to-dismiss direction, so the two can never disagree.
130
+ - Every other MUI `Dialog` / `Drawer` prop is gone. Resize a drawer with the `--drawer-size` custom property instead of `slotProps.paper`.
131
+
132
+ New:
133
+
134
+ - `Dialog`'s `fullScreenOnMobile` fills the screen below 600px instead of floating as a card.
135
+ - Drawers can be swiped away, and `side="bottom"` / `"top"` render as sheets with a grab handle and a rounded inner edge.
136
+
137
+ Also:
138
+
139
+ - The `MuiDialog`, `MuiDialogTitle`, `MuiDialogContent` and `MuiDrawer` theme overrides have been removed. If you render MUI's own `Dialog` or `Drawer` with our theme, they are no longer styled.
140
+ - Side drawers are now `min(22.5rem, 100vw)` wide. The theme always intended this, but its `.MuiDrawer-paperAnchorRight` selector never matched, so panels previously sized to their content.
141
+ - `DatePicker`'s mobile sheet is built on the new `Drawer`. Its appearance is unchanged, and it can now be swiped away.
142
+
143
+ ### Minor Changes
144
+
145
+ - d415e5f: Add `Switch` and `SimpleAccordion`, and an `iconPosition` prop on the accordion.
146
+
147
+ `Switch` is a new form control built on Base UI and styled with a CSS Module.
148
+ An accessible name is required in TypeScript — exactly one of `aria-label` or
149
+ `aria-labelledby` — so it can never render nameless.
150
+
151
+ ```tsx
152
+ <Switch aria-label="Analyse-informasjonskapsler" defaultChecked />
153
+ ```
154
+
155
+ `SimpleAccordion` is the props-driven form of `Accordion` for the common
156
+ title-and-content case. It takes either a single item or an array, and
157
+ forwards every `Accordion.Root` prop.
158
+
159
+ ```tsx
160
+ <SimpleAccordion title="Levering" content="Tre til fem virkedager." />
161
+
162
+ <SimpleAccordion
163
+ multiple
164
+ items={[
165
+ { title: "Levering", content: "Tre til fem virkedager." },
166
+ { title: "Retur", content: "30 dagers angrerett." },
167
+ ]}
168
+ />
169
+ ```
170
+
171
+ `Accordion.Root` and `SimpleAccordion` gain `iconPosition` (`"start"` or
172
+ `"end"`, defaulting to `"end"`), which moves the expand arrow to the other
173
+ side of the title. Use `"start"` when the row also carries a control.
174
+
175
+ An `action` on a `SimpleAccordion` item — or any child after
176
+ `Accordion.Trigger` inside `Accordion.Header` — renders on the row beside the
177
+ title. It sits outside the trigger, because the trigger is a `<button>` and
178
+ nesting controls in it would be invalid, so it is a separate tab stop and
179
+ operating it does not open the panel.
180
+
181
+ ```tsx
182
+ <SimpleAccordion
183
+ iconPosition="start"
184
+ title="Nødvendige"
185
+ content={<Text>Alltid påskrudd.</Text>}
186
+ action={<Switch aria-label="Nødvendige" checked disabled />}
187
+ />
188
+ ```
189
+
190
+ The accordion's hover and pressed styling moved from the trigger to the header
191
+ row so it surrounds any such control. A plain accordion is unchanged visually,
192
+ but the trigger's focus ring now hugs the title and arrow rather than the full
193
+ row.
194
+
195
+ - d415e5f: Ship the design tokens as a static stylesheet, so the Base UI components render correctly without a provider.
196
+
197
+ `dist/index.css` previously referenced `--mui-*` custom properties without defining any of them — those values only existed once Emotion injected them inside `LeaProvider`. The extracted CSS was therefore inert on a server-rendered first paint, and unusable without MUI on the page at all.
198
+
199
+ The tokens are now generated from `src/theme/tokens` into a plain `:root` stylesheet under a `--lea-*` prefix, bundled into `dist/index.css`. As a result `Accordion`, `SimpleAccordion`, `Switch`, `Dialog` and `Drawer` need neither MUI, Emotion nor `LeaProvider` to be styled:
200
+
201
+ ```tsx
202
+ // Works in a server component, with only the stylesheet imported.
203
+ import "@leabankab/component-library/styles.css";
204
+ import { SimpleAccordion } from "@leabankab/component-library";
205
+ ```
206
+
207
+ Nothing breaks for existing consumers: `LeaProvider` still works exactly as before, and every component still accepts the same props. The remaining MUI-based components continue to require `LeaProvider`, because their styling still comes from the MUI theme — this is a step towards provider-free rendering, not the end of it.
208
+
209
+ Two token values changed as part of owning the emitter:
210
+
211
+ - Font weights are now unitless. MUI emitted `--mui-fontWeights-semibold` as `600px`, an invalid `font-weight` that browsers ignore, which `Dialog` and `Drawer` worked around with a hard-coded literal.
212
+ - The spacing base step is `0.5rem` rather than `8px`. Identical at a default root font size, but it now scales with the user's font-size preference, matching what `spacing()` already returned in TypeScript.
213
+
214
+ If you referenced the undocumented `--mui-*` variables directly, switch to the `--lea-*` equivalents: `--lea-palette-*` for semantic colours, `--lea-color-*` for raw scales, and `--lea-radius-*`, `--lea-shadow-*`, `--lea-font-size-*`, `--lea-font-weight-*`, `--lea-duration-*`, `--lea-easing-*`, `--lea-spacing`.
215
+
3
216
  ## 6.1.0
4
217
 
5
218
  ### Minor Changes
package/README.md CHANGED
@@ -7,6 +7,7 @@ The goal of this repo is to create a npm-package of components used for Lea Bank
7
7
  ## Development
8
8
 
9
9
  1. [Getting started](docs/development/gettingStarted.md)
10
+ 1. [How to create a component](CONTRIBUTING.md) — the two patterns, and which to use for new work
10
11
  1. [❗️ Quirks and Caveats ❗️](docs/development/quirks.md)
11
12
  1. [FAQ](docs/development/faq.md)
12
13