@anyblades/blades 3.1.0-alpha.1 → 3.1.0-alpha.2

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 CHANGED
@@ -89,6 +89,29 @@ Or import only the [Pico CSS](//blades.ninja/css/pico/) parts you need, e.g. per
89
89
  - Some parts build on others, e.g. `components/group` and `components/dropdown` expect `forms/basics` and `content/button`.
90
90
  - Available parts are the files under [`src/pico/`](https://github.com/anyblades/blades/tree/main/src/pico): `layout/*`, `content/*`, `forms/*`, `components/*` (or a whole category, e.g. `@anyblades/blades/pico/components`) and `utilities`.
91
91
 
92
+ #### With bundlers and component frameworks (SvelteKit, Next.js, Nuxt, Astro, …)
93
+
94
+ Import the parts from JavaScript, i.e. the root layout and the components that use them, rather than with `@import` inside a component's `<style>` block:
95
+
96
+ ```js
97
+ // root layout, once
98
+ import "@anyblades/blades/pico/variables";
99
+ import "@anyblades/blades/pico/layout/document";
100
+
101
+ // in the component that renders a <dialog>
102
+ import "@anyblades/blades/pico/components/modal";
103
+ ```
104
+
105
+ - Bundlers dedupe JS-side CSS imports and split them per route, so each part is downloaded and cached once and only where it's used.
106
+ - An `@import` inside a scoped `<style>` (Svelte, Astro, Vue `scoped`) is processed as that component's own styles. The rules get scoped to the component's markup (Svelte also prunes the unused ones) and are duplicated in every component that imports them.
107
+ - Pico's landmark padding uses `body > header`, `body > main` and `body > footer`. These don't match when the framework wraps the page in an element: SvelteKit's `<div style="display: contents">`, Next.js pages router `#__next`, Nuxt `#__nuxt`, or a SPA's `#root` / `#app`. Next.js App Router doesn't wrap the page. If you rely on the padding, add it for your wrapper, e.g.:
108
+
109
+ ```css
110
+ #__next > :is(header, main, footer) {
111
+ padding-block: var(--pico-block-spacing-vertical);
112
+ }
113
+ ```
114
+
92
115
  ### <mark>D.</mark> Official starters
93
116
 
94
117
  - https://github.com/buildawesome-one/starter
@@ -126,6 +149,26 @@ Or import only the [Pico CSS](//blades.ninja/css/pico/) parts you need, e.g. per
126
149
 
127
150
  ---
128
151
 
152
+ ## Dark mode without a flash
153
+
154
+ With the Pico-based builds, Blades follows the OS setting by default, with no JavaScript and no flash (see [Dark scheme](//blades.ninja/css/color-schemes/)). To force a theme, set `data-theme="light"` or `"dark"` on `<html>`. On a nested element it works when the element paints its own background, such as `<article>`; otherwise add `background-color: var(--pico-background-color); color: var(--pico-color);`.
155
+
156
+ If you persist the user's choice, e.g. under the `localStorage` key `theme`, set the attribute **before the first paint** with a small inline script in `<head>`, e.g. in SvelteKit's `src/app.html`:
157
+
158
+ ```html
159
+ <script>
160
+ try {
161
+ const theme = localStorage.getItem("theme");
162
+ if (theme === "light" || theme === "dark") document.documentElement.dataset.theme = theme;
163
+ } catch {}
164
+ </script>
165
+ ```
166
+
167
+ - Setting it later, e.g. in `onMount` or `useEffect`, renders the OS theme first and then switches.
168
+ - In a Next.js App Router layout, pass the same code as a template literal, ``<script dangerouslySetInnerHTML={{ __html: `try { … } catch {}` }} />``, and add `suppressHydrationWarning` to `<html>`, because the attribute changes before hydration.
169
+
170
+ ---
171
+
129
172
  ## Documentation
130
173
 
131
174
  <!-- ToC as is from https://blades.ninja/#docs -->
@@ -209,6 +252,7 @@ Or import only the [Pico CSS](//blades.ninja/css/pico/) parts you need, e.g. per
209
252
 
210
253
  - 🐍 [Flask & Jinja](https://palletsprojects.com/) community website
211
254
  - 🪐 [Grav CMS v2](https://getgrav.org/migrate-to-2#:~:text=blades) default theme [↗](https://www.followthatcar.com/)
255
+
212
256
  <!--https://pulsar-wildlife.club/-->
213
257
 
214
258
  <!--section:info-->