@ferrlabs/ui-ng 1.68.4 → 1.69.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/README.md +23 -2
- package/fesm2022/ferrlabs-ui-ng.mjs +201 -95
- package/fesm2022/ferrlabs-ui-ng.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ferrlabs-ui-ng.d.ts +16 -18
- package/types/ferrlabs-ui-ng.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -164,8 +164,29 @@ list in place and emits `localeChange` with the chosen code. The app applies the
|
|
|
164
164
|
`ThemeService` (root) holds the preference as a signal (`preference()`, `resolved()`,
|
|
165
165
|
`setPreference()`), stores it in `localStorage` under `flr-theme`, sets `data-theme="dark"` on
|
|
166
166
|
`<html>` for dark and removes the attribute for light, and follows `prefers-color-scheme` while the
|
|
167
|
-
preference is `system`. It runs once something injects it
|
|
168
|
-
|
|
167
|
+
preference is `system`. It runs once something injects it, so every app must call `provideTheme()`
|
|
168
|
+
in its application config. Without it the stored theme is only applied when `flr-user-menu` first
|
|
169
|
+
renders, and routes outside the authenticated layout (login, callback, onboarding, public pages)
|
|
170
|
+
load light and flip to dark mid-session.
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
import { provideTheme } from '@ferrlabs/ui-ng';
|
|
174
|
+
|
|
175
|
+
export const appConfig: ApplicationConfig = {
|
|
176
|
+
providers: [provideTheme()],
|
|
177
|
+
};
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
To avoid a light frame before Angular bootstraps, paste this into the `<head>` of `index.html`,
|
|
181
|
+
before the stylesheets. It reads `localStorage['flr-theme']` and `prefers-color-scheme` and sets
|
|
182
|
+
`data-theme="dark"` on `<html>`, with the same resolution as `ThemeService`. It is exported as
|
|
183
|
+
`THEME_PREPAINT_SCRIPT` (generated from the same storage key and rule as the service), and a test
|
|
184
|
+
checks it against `ThemeService`. Under a strict CSP, allow it with a hash or nonce.
|
|
185
|
+
|
|
186
|
+
<!-- prettier-ignore -->
|
|
187
|
+
```html
|
|
188
|
+
<script>(function(){var s=null,d=false;try{s=localStorage.getItem("flr-theme")}catch(e){}try{d=matchMedia("(prefers-color-scheme: dark)").matches}catch(e){}var p=["system","light","dark"].indexOf(s)<0?"system":s;if(p==="dark"||(p==="system"&&d))document.documentElement.setAttribute("data-theme","dark")})()</script>
|
|
189
|
+
```
|
|
169
190
|
|
|
170
191
|
To add a row of your own to a `flr-menu`, provide `MENU_FOCUSABLE` (`focus()`, `disabled()`) on it so
|
|
171
192
|
the arrow keys reach it. `flr-menu-item` takes `keepOpen` (the click does not close the menu) and
|