@anydigital/blades 0.27.0-alpha.16 → 0.27.0-beta

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!--section:hero-->
4
4
 
5
- <hgroup>Framework-agnostic,<wbr> class-light CSS+ blade kit.</hgroup>
5
+ <hgroup>Framework-agnostic,<wbr> class-light CSS blade kit.</hgroup>
6
6
 
7
7
  <big>Use with Pico, Tailwind, or any other CSS reset/framework.</big>
8
8
 
@@ -10,322 +10,129 @@
10
10
 
11
11
  Nunjucks/Liquid batteries included (for 11ty/Build Awesome, Jekyll, etc.) 🥷
12
12
 
13
- <!--section:css-h2-->
13
+ ---
14
14
 
15
- ## CSS 'blades' <br><sub>from https://github.com/anydigital/blades</sub> <a id="blades"></a>
15
+ <!--section:index-->
16
16
 
17
- ### Install CSS
17
+ <hgroup id="css">
18
+ <small>Class-light</small>
19
+ <h2>CSS blades</h2>
20
+ <p>inspired by Pico.css</p>
21
+ </hgroup>
18
22
 
19
- Via CDN:
23
+ <big>
20
24
 
21
- ```html
22
- <link href="https://cdn.jsdelivr.net/npm/@anydigital/blades@0/dist/blades.min.css" rel="stylesheet" />
23
- ```
24
-
25
- Or import source styles via npm:
26
-
27
- ```sh
28
- npm install @anydigital/blades
29
- ```
30
-
31
- ```css {data-caption=.css}
32
- @import "@anydigital/blades";
33
- ```
34
-
35
- <details><summary>
36
-
37
- ### `_base.css` styles
38
-
39
- </summary>
25
+ - [Typography](https://blades.ninja/css/typography/)
26
+ - [Table](https://blades.ninja/css/table/)
27
+ - [Responsive table without wrapper](https://blades.ninja/css/table/#responsive-table-without-wrapper) {data-marker=🥷}
28
+ - [Heading anchors](https://blades.ninja/css/typography/#heading-anchors)
29
+ - [List markers](https://blades.ninja/css/typography/#list-markers) {data-marker=🥷}
30
+ - [Link [fav]icons](https://blades.ninja/css/typography/#link-fav-icons)
31
+ - [Code](https://blades.ninja/css/code/)
32
+ - [Layout](https://blades.ninja/css/layout/)
33
+ - [Breakout elements](https://blades.ninja/css/breakout/) {data-marker=🥷}
34
+ - [Utilities](https://blades.ninja/css/utilities/)
35
+ - [Jump to top](https://blades.ninja/css/utilities/#jump-to-top)
36
+ - [Table of contents](https://blades.ninja/css/utilities/#table-of-contents)
37
+ - [Auto-columns](https://blades.ninja/css/utilities/#auto-columns)
38
+ - [Auto-dark](https://blades.ninja/css/utilities/#auto-dark)
40
39
 
41
- #### Overflow Control
40
+ {.columns}
42
41
 
43
- Prevents horizontal overflow and scrolling on the entire page:
42
+ </big>
44
43
 
45
- ```css
46
- html,
47
- body {
48
- overflow-x: clip;
49
- }
50
- ```
51
-
52
- This is automatically applied when you include the stylesheet.
53
-
54
- #### Full Viewport Height
44
+ <details><summary role="button" class="outline">Install CSS blades</summary>
55
45
 
56
- Ensures the body element takes at least the full height of the viewport using dynamic viewport height for better mobile support:
57
-
58
- ```css
59
- body {
60
- min-height: 100dvh;
61
- }
62
- ```
46
+ <mark>Option 1.</mark> From CDN:
63
47
 
64
- This is automatically applied when you include the stylesheet.
65
-
66
- #### Flexbox Layout
67
-
68
- Sets up a flexible column layout structure:
69
-
70
- ```css
71
- body {
72
- display: flex;
73
- flex-direction: column;
74
- }
75
-
76
- body > main {
77
- flex-grow: 1;
78
- }
48
+ <!--prettier-ignore-->
49
+ ```html
50
+ <link href="https://cdn.jsdelivr.net/npm/@anydigital/blades@^0.27.0-alpha/assets/blades.min.css" rel="stylesheet" />
51
+ <link href="https://cdn.jsdelivr.net/npm/@anydigital/blades@^0.27.0-alpha/assets/blades.theme.min.css" rel="stylesheet" /><!-- optional -->
79
52
  ```
80
53
 
81
- The body becomes a flex container with column direction, and `main` elements automatically grow to fill available space. This is useful for creating sticky footers and full-height layouts.
82
-
83
- This is automatically applied when you include the stylesheet.
54
+ <mark>Option 2.</mark> Via npm:
84
55
 
85
- #### Typography Enhancements
86
-
87
- Improves text rendering and readability:
88
-
89
- ```css
90
- body {
91
- hyphens: auto;
92
- -webkit-font-smoothing: antialiased;
93
- -moz-osx-font-smoothing: grayscale;
94
- }
56
+ ```sh
57
+ npm install @anydigital/blades
95
58
  ```
96
59
 
97
- - Automatic hyphenation for better text flow
98
- - Font smoothing for cleaner text rendering across browsers
99
- - Hyphenation is disabled for links and tables to prevent awkward breaks
100
-
101
- This is automatically applied when you include the stylesheet.
102
-
103
- </details>
104
-
105
- <details><summary>
106
-
107
- ### `_prose.css` Tailwind Typography enhancements
108
-
109
- </summary>
110
-
111
- The `.prose` class provides enhanced typography for article content and long-form text with container-like behavior:
112
-
113
- **Container:**
114
-
115
- - Full width
116
- - Centered with automatic inline margins
117
-
118
- **Typography Helpers:**
119
-
120
- - `sub` elements: styled for multi-line subtitles with top vertical alignment, `1.1` line height, lighter weight (`300`), and displayed as `inline-block` with `100%` width to prevent underline decoration inside links
121
-
122
- **Links:**
123
-
124
- - Custom underline offset (`0.1em`) and thickness (`1px` default, `2px` on hover)
125
- - Anchor links (starting with `#`) have no text decoration
126
- - Icon helper: `i` elements inside links are displayed as `inline-block` with normal font style to prevent underline decoration, with `1em` height and `0.25em` right margin. Nested `img` elements are styled with `100%` height, no margin, and positioned `0.15em` from the bottom for proper alignment
127
-
128
- **Headings:**
129
-
130
- - `h1` elements have a `0.5em` bottom margin
131
- - `h1 sub` elements get reduced font size (`50%`)
132
- - Support for heading anchors via `.header-anchor` class (displayed on hover to the left of the heading)
133
-
134
- **Tables:**
135
-
136
- - Tables within `.breakout` containers are automatically styled for full-bleed display and horizontal scrolling
137
- - Table cells (`th` and `td`) have padding of `1rem 2rem 1rem 0` (extra space on the right for better horizontal scroll on mobile) and `top` vertical alignment
138
- - Table headers (`th`) have `bottom` vertical alignment
139
- - Workaround for widening columns using hidden `hr` elements (width: `12ch`, with zero margin and hidden visibility)
140
- - Support for headings in Markdown tables using `big` elements (styled as bold)
141
- - Images in table cells have no top margin and `1em` bottom margin
142
-
143
- **Blockquotes:**
144
-
145
- - Lighter font weight (`300`)
146
- - Adjacent `figcaption` elements (using `+ figcaption` selector) are styled with italic text, right alignment, lighter weight (`300`), negative top margin (`-1em`), and an em dash prefix (`—`) with `0.25em` right margin
147
-
148
- **Code Blocks:**
149
-
150
- - Code blocks with `data-caption` attribute display the caption above the code block (styled with 50% opacity, italic, and `1.5em` bottom margin)
151
-
152
- </details>
153
-
154
- ### `_prism.css` enhancements
155
-
156
- Includes specialized styling for Prism.js, specifically focusing on treeview components:
157
-
158
- - Custom styling for `.token.treeview-part`
159
- - Reduced opacity for entry lines (25%) and names (50%) to create a hierarchical visual effect
160
- - Entry lines have a fixed width of `2.5em`
161
- - Last-child entry names have no `::before` pseudo-element
162
- - Supports complex file tree visualizations out of the box
163
-
164
- <details><summary>
165
-
166
- ### `_util.css` helpers
167
-
168
- </summary>
169
-
170
- #### Scrollbar Inversion
171
-
172
- The `.invert` class can be used to invert the scrollbar colors, which is particularly useful for dark themes or specific UI components:
60
+ Then import in your .css:
173
61
 
174
62
  ```css
175
- .invert {
176
- ::-webkit-scrollbar {
177
- filter: invert(1) !important;
178
- }
179
- }
180
- ```
181
-
182
- #### Link Whitespace Control
183
-
184
- The `.whitespace-nowrap` class can be applied to links to prevent them from wrapping, which is particularly useful when links contain icons that should stay with the text:
185
-
186
- ```html
187
- <a href="#" class="whitespace-nowrap">
188
- <i><img src="icon.svg" alt="" /></i>Stay with me
189
- </a>
190
- ```
191
-
192
- This ensures the icon and the text stay together on the same line. If you need nested elements to allow wrapping, they are automatically reset to `white-space: normal`.
193
-
194
- **Usage:**
195
-
196
- ```html
197
- <article class="prose">
198
- <h1>Article Title</h1>
199
- <p>Your content here...</p>
200
- </article>
63
+ @import "@anydigital/blades";
64
+ @import "@anydigital/blades.theme"; /* optional */
201
65
  ```
202
66
 
203
- This is automatically included when you import the stylesheet.
67
+ Living example: https://github.com/anydigital/build-awesome-starter/blob/main/_styles/styles.css
204
68
 
205
69
  </details>
206
70
 
207
- ### `breakout-css` included
208
-
209
- Includes [breakout-css](https://github.com/anydigital/breakout-css) utilities for breaking out images and figures beyond their container width. Use the `.breakout` class to allow elements to extend beyond their parent container:
71
+ ---
210
72
 
211
- ```html
212
- <div class="breakout">
213
- <img src="image.jpg" alt="Description" />
214
- </div>
215
- ```
73
+ <hgroup>
74
+ <small>Nunjucks / Liquid</small>
75
+ <h2>HTML blades</h2>
76
+ <p>for 11ty/Build Awesome, Jekyll, etc.</p>
77
+ </hgroup>
216
78
 
217
- The breakout container has `10%` inline padding and a max-width of `calc(10% + 65ch + 10%)`. The breakout utilities support images, pictures, figures, canvas, audio, video, tables, pre, iframe, and other media elements. Tables inside `.breakout` are specifically enhanced for horizontal scrolling and full-bleed mobile display. This is automatically included when you import the stylesheet.
79
+ <big>
218
80
 
219
- <!--section:njk-liquid-h2-->
81
+ - [Base HTML](https://blades.ninja/html/) {data-marker=🥷}
82
+ - [Links](https://blades.ninja/html/links/)
83
+ - [Google Tag Manager](https://blades.ninja/html/gtm/)
220
84
 
221
- ## Universal Template 'blades' <small>(`.njk` & `.liquid`)</small> <br><sub>from https://github.com/anydigital/blades</sub>
85
+ {.columns}
222
86
 
223
- The package includes reusable templates in the `./src/blades/` directory. These are useful for common web development patterns.
87
+ </big>
224
88
 
225
- ### Install Templates
89
+ <details><summary role="button" class="outline">Install HTML blades</summary>
226
90
 
227
91
  ```sh
228
92
  npm install @anydigital/blades
229
- cd ./src/_includes
230
- ln -s ../../node_modules/@anydigital/blades/src/blades
93
+ cd ./_includes # or where your includes dir is
94
+ ln -s ../node_modules/@anydigital/blades/_includes/blades
231
95
  ```
232
96
 
233
- ### Base HTML Template <small>(`__html.*`)</small>
234
-
235
- A unified base HTML template `blades/__html.{njk|liquid}` that provides the essential document structure with built-in support for modern web best practices.
97
+ That's it! Now you can use HTML blades in your templates like this:
236
98
 
237
- **Usage:**
238
-
239
- ```jinja2 {data-caption="in .njk layout:"}
240
- {% extends 'blades/__html.njk' %}
241
-
242
- {% block body %}
243
- <!-- YOUR page content -->
244
- {% endblock %}
99
+ ```jinja2
100
+ {% extends 'blades/html.njk' %}
101
+ {% include 'blades/gtm.njk' %}
245
102
  ```
246
103
 
247
- Example: https://github.com/anydigital/sveleven/blob/main/src/_theme/__layout.njk
104
+ or:
248
105
 
249
- ```liquid {data-caption="in .liquid layout:"}
250
- {% capture body %}
251
- <!-- YOUR page content -->
252
- {% endcapture %}
253
-
254
- {% include 'blades/__html' %}
106
+ ```liquid
107
+ {% include blades/html.liquid %}
108
+ {% include blades/gtm.liquid for_body=true %}
109
+ {% render blades/links, links: site.links, current_url: page.url %}
255
110
  ```
256
111
 
257
- Example: https://github.com/anydigital/sveleven/blob/main/src/_theme/__layout.liquid
258
-
259
- **Features:**
260
-
261
- - HTML5 DOCTYPE with language attribute (defaults to `en`, configurable via `site.lang`)
262
- - UTF-8 charset and comprehensive viewport meta tag with `viewport-fit=cover` for notched devices
263
- - Dynamic title generation with site title suffix (title is stripped of HTML tags and separated with `|`)
264
- - Favicon link (to `/favicon.ico`)
265
- - Automatic stylesheet linking from `site.styles` array
266
- - Inline styles from `site.inline_styles` array (joined with newlines in a `<style>` tag)
267
- - Automatic script loading from `site.scripts` array (with `defer` attribute)
268
- - Inline module scripts from `site.inline_scripts` array (joined with newlines in a `<script type="module">` tag)
269
- - Custom header content via `content_for_header`
270
- - Google Tag Manager integration (automatically rendered via `_gtm.{njk|liquid}` template for both `<head>` and `<body>` when `site.prod` and `site.gtm_id` are set)
271
-
272
- **Variables:**
273
-
274
- - `body` - The page content to be rendered inside the `<body>` tag (required)
275
- - `title` - Page title (optional, will be stripped of HTML tags)
276
- - `site.title` - Site title for the title suffix
277
- - `site.lang` - Language code (optional, defaults to `'en'`)
278
- - `site.styles` - Array of stylesheet URLs (optional)
279
- - `site.inline_styles` - Array of inline CSS strings (optional)
280
- - `site.scripts` - Array of script URLs (optional)
281
- - `site.inline_scripts` - Array of inline JavaScript strings (optional)
282
- - `content_for_header` - Custom HTML for the head section (optional)
283
- - `site.gtm_id` - Google Tag Manager ID (optional)
284
- - `site.prod` - Boolean flag for production environment (optional)
285
-
286
- ### Navigation <small>(`_nav.*`)</small>
287
-
288
- A navigation template `blades/_nav.{njk|liquid}` that renders a list of navigation links with proper accessibility attributes.
289
-
290
- **Parameters:**
291
-
292
- - `nav_pages` - Array of navigation page objects with `url` and `title` properties
293
- - `current_url` - The URL of the current page (used to set `aria-current="page"`)
294
-
295
- **Usage example with [Eleventy Navigation plugin](https://www.11ty.dev/docs/plugins/navigation/#bring-your-own-html-render-the-menu-items-manually):**
296
-
297
- ```liquid {data-caption="in .liquid:"}
298
- {% assign nav_pages = collections.all | eleventyNavigation %}
299
- {% render 'blades/_nav', nav_pages: nav_pages, current_url: page.url %}
300
- ```
301
-
302
- **Output:**
112
+ </details>
303
113
 
304
- ```html
305
- <nav>
306
- <a href="/">Home</a>
307
- <a href="/about" aria-current="page">About</a>
308
- <a href="/contact">Contact</a>
114
+ ---
115
+
116
+ <hgroup>
117
+ <small>Open-source</small>
118
+ <h2>Starter blades</h2><i></i>
119
+ </hgroup>
120
+
121
+ <nav class="grid">
122
+ <a role="button" class="outline" href="https://github.com/anydigital/build-awesome-starter">
123
+ <big>Blades with Tailwind</big><br>
124
+ using Eleventy and Nunjucks <br>
125
+ <small>(Build Awesome Starter)</small>
126
+ </a>
127
+ <a role="button" class="outline" href="https://github.com/anydigital/bladeswitch">
128
+ <big>Blades with Pico</big><br>
129
+ using Jekyll and Liquid <br>
130
+ <small>(Bladeswitch Starter)</small>
131
+ </a>
309
132
  </nav>
310
- ```
311
-
312
- <details><summary>
313
133
 
314
- ### Google Tag Manager <small>(`_gtm.*`)</small>
134
+ ---
315
135
 
316
- </summary>
136
+ Featured by:
317
137
 
318
- A template `blades/_gtm.{njk|liquid}` for embedding Google Tag Manager scripts in your pages.
319
-
320
- **Parameters:**
321
-
322
- - `site.gtm_id` - Your Google Tag Manager container ID (e.g., `GTM-XXXXXXX`)
323
- - `site.prod` - Boolean flag to enable GTM only in production
324
- - `for_body` - Boolean flag (default: `false`). When `false`, renders the script tag for the `<head>`. When `true`, renders the noscript fallback for the `<body>`.
325
-
326
- **Note:** This template is automatically included when using `__html.liquid`. You only need to manually render it if you're not using that base template, see examples:
327
-
328
- - https://github.com/anydigital/blades/blob/main/blades/__html.njk
329
- - https://github.com/anydigital/blades/blob/main/blades/__html.liquid
330
-
331
- </details>
138
+ - https://github.com/uhub/awesome-css
@@ -1,3 +1,4 @@
1
+ {% comment %}<!--section:code-->```liquid{% endcomment %}
1
2
  {% if site.prod and site.gtm_id %}
2
3
  {% capture _ %}
3
4
  {% unless for_body %}
@@ -21,3 +22,18 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
21
22
  {% endcapture %}
22
23
  {{ _ | strip }}
23
24
  {% endif %}
25
+ {% # prettier-ignore %}
26
+ {% comment %}```
27
+ <!--section:docs-->
28
+ Usage in Liquid:
29
+ ```liquid
30
+ ...
31
+ {% include blades/gtm.liquid %}
32
+ </head>
33
+ <body>
34
+ {% include blades/gtm.liquid for_body=true %}
35
+ ...
36
+ ```
37
+
38
+ Living example: https://github.com/anydigital/blades/blob/main/_includes/blades/html.liquid
39
+ <!--section-->{% endcomment %}
@@ -1,3 +1,4 @@
1
+ {# <!--section:code-->```jinja2 #}
1
2
  {% if site.prod and site.gtm_id %}
2
3
  {# prettier-ignore-start #}
3
4
  {% if not for_body %}
@@ -20,3 +21,22 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
20
21
  {% endif %}
21
22
  {# prettier-ignore-end #}
22
23
  {% endif %}
24
+ {#```
25
+ <!--section:docs-->
26
+ Usage in Nunjucks:
27
+ ```jinja2
28
+ ...
29
+ {% include 'blades/gtm.njk' %}
30
+ </head>
31
+ <body>
32
+ {% set for_body = true %}{% include 'blades/gtm.njk' %}
33
+ ...
34
+ ```
35
+
36
+ Living example: https://github.com/anydigital/blades/blob/main/_includes/blades/html.njk
37
+
38
+ Parameters:
39
+ - `site.gtm_id` - Your Google Tag Manager container ID (e.g., `GTM-XXXXXXX`)
40
+ - `site.prod` - Boolean flag to enable GTM only in production
41
+ - `for_body` - Boolean flag (default: `false`). When `false`, renders the script tag for the `<head>`. When `true`, renders the noscript fallback for the `<body>`.
42
+ <!--section--> #}
@@ -1,4 +1,4 @@
1
- {% comment %} <!--section:code-->```liquid {% endcomment %}
1
+ {% comment %}<!--section:code-->```liquid{% endcomment %}
2
2
  <!doctype html>
3
3
  <html lang="{{ site.lang | default: 'en' }}">
4
4
  <head>
@@ -36,17 +36,14 @@
36
36
  </body>
37
37
  </html>
38
38
  {% comment %}```
39
-
40
39
  <!--section:docs-->
40
+ Usage in Liquid layout:
41
41
 
42
- To use in your layout:
43
-
44
- ```liquid {data-caption=default.liquid}
42
+ ```liquid
45
43
  {% capture body %}...{% endcapture %}
46
44
 
47
45
  {% include blades/html.liquid %}
48
46
  ```
49
47
 
50
48
  Living example: https://github.com/anydigital/bladeswitch/blob/main/_includes/default.liquid
51
-
52
- <!--section--> {% endcomment %}
49
+ <!--section-->{% endcomment %}
@@ -36,19 +36,16 @@
36
36
  </body>
37
37
  </html>
38
38
  {#```
39
-
40
39
  - `title | string` avoids error with `| striptags` when you pass a pure number.
41
40
 
42
41
  <!--section:docs-->
42
+ Usage in Nunjucks layout:
43
43
 
44
- To use in your layout:
45
-
46
- ```jinja2 {data-caption=default.njk}
44
+ ```jinja2
47
45
  {% extends 'blades/html.njk' %}
48
46
 
49
47
  {% block body %}...{% endblock %}
50
48
  ```
51
49
 
52
50
  Living example: https://github.com/anydigital/build-awesome-starter/blob/main/_includes/default.njk
53
-
54
51
  <!--section--> #}
@@ -1,3 +1,4 @@
1
+ {% comment %}<!--section:code-->```liquid{% endcomment %}
1
2
  <ul>
2
3
  {%- for link in links %}
3
4
  <li>
@@ -8,9 +9,19 @@
8
9
  </li>
9
10
  {%- endfor %}
10
11
  </ul>
12
+ {% # prettier-ignore %}
13
+ {% comment %}```
14
+ <!--section:docs-->
15
+ Usage with [Eleventy Navigation plugin](https://www.11ty.dev/docs/plugins/navigation/#bring-your-own-html-render-the-menu-items-manually):
11
16
 
12
- {%- comment %}
13
- Compatible with:
14
- - https://picocss.com/docs/nav
15
- - https://www.11ty.dev/docs/plugins/navigation/#bring-your-own-html-render-the-menu-items-manually
16
- {%- endcomment %}
17
+ ```liquid
18
+ {% assign links = collections.all | eleventyNavigation %}
19
+ {% render blades/links, links: links, current_url: page.url %}
20
+ ```
21
+
22
+ Usage inside Pico's Navar:
23
+
24
+ ```jinja2
25
+ TBD
26
+ ```
27
+ <!--section-->{% endcomment %}