mancha 0.21.4 → 0.22.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/dist/browser.d.ts +4 -1
- package/dist/browser.js +3 -3
- package/dist/browser.js.map +1 -1
- package/dist/css_custom.d.ts +5 -0
- package/dist/css_custom.js +88 -12
- package/dist/css_custom.js.map +1 -1
- package/dist/css_gen_utils.d.ts +1 -0
- package/dist/css_gen_utils.js +25 -68
- package/dist/css_gen_utils.js.map +1 -1
- package/dist/mancha.js +24 -24
- package/docs/02_initialization.md +2 -2
- package/docs/05_css.md +28 -34
- package/package.json +2 -2
package/docs/05_css.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CSS Documentation
|
|
2
2
|
|
|
3
|
-
Mancha provides
|
|
3
|
+
Mancha provides two CSS modes: **minimal** for simple prose pages, and **utils** for Tailwind-style utility class development.
|
|
4
4
|
|
|
5
5
|
## Minimal CSS
|
|
6
6
|
|
|
@@ -14,22 +14,15 @@ The minimal CSS rules provide a clean, readable default style for standard HTML
|
|
|
14
14
|
- **H1-H6 Margin**: 1em 0 0.5em
|
|
15
15
|
- **P, UL, OL Margin Bottom**: 1em
|
|
16
16
|
|
|
17
|
-
## Basic CSS
|
|
18
|
-
|
|
19
|
-
The basic CSS rules provide a more comprehensive reset and set of defaults, widely based on Tailwind CSS Preflight. You can inject them using `injectCss(["basic"])` or by adding `css="basic"` to your script tag.
|
|
20
|
-
|
|
21
|
-
### Key Features
|
|
22
|
-
- **Box Sizing**: `border-box` globally
|
|
23
|
-
- **Typography**: Default sans-serif font stack, consistent line-height
|
|
24
|
-
- **Form Elements**: Inherit font styles, transparent backgrounds, `cursor: pointer` for buttons
|
|
25
|
-
- **Media**: Images/videos max-width 100%
|
|
26
|
-
- **Dialog**: Default backdrop styling
|
|
27
|
-
- **Resets**: Removes default margins/paddings from most block elements
|
|
28
|
-
|
|
29
17
|
## Utility CSS
|
|
30
18
|
|
|
31
19
|
The utility CSS rules are inspired by Tailwind CSS. You can inject them using `injectCss(["utils"])` or by adding `css="utils"` to your script tag.
|
|
32
20
|
|
|
21
|
+
This automatically includes:
|
|
22
|
+
- **CSS Reset** (Tailwind Preflight): box-sizing, typography, form resets, media defaults
|
|
23
|
+
- **Base utility classes**: spacing, sizing, colors, layout, typography, and more
|
|
24
|
+
- **On-demand scanning**: responsive variants, pseudo-state variants, color opacity, custom bracket values, and dark mode are generated on-the-fly for only the classes actually used in your markup
|
|
25
|
+
|
|
33
26
|
### Media Breakpoints
|
|
34
27
|
|
|
35
28
|
| Prefix | Min Width |
|
|
@@ -46,6 +39,24 @@ The following pseudo states are supported for all utilities:
|
|
|
46
39
|
- `focus:`
|
|
47
40
|
- `disabled:`
|
|
48
41
|
|
|
42
|
+
### Dark Mode
|
|
43
|
+
|
|
44
|
+
Use the `dark:` prefix to apply styles when the user's system prefers dark mode (`prefers-color-scheme: dark`):
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<div class="bg-white text-gray-900 dark:bg-gray-900 dark:text-white">
|
|
48
|
+
This adapts to the user's color scheme preference.
|
|
49
|
+
</div>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The `dark:` prefix can be used with any utility class, including colors, spacing, and custom bracket values:
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<div class="bg-[#fff] dark:bg-[#1a1a1a] p-4 dark:border-gray-700">
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
> **Note:** Responsive variants (`sm:`, `md:`, etc.), pseudo-state variants (`hover:`, `focus:`, `disabled:`), color opacity (`/N`), dark mode (`dark:`), and custom bracket values are all generated on-demand. Only the classes actually present in your markup are injected, keeping the CSS bundle small.
|
|
59
|
+
|
|
49
60
|
### Spacing (Margin & Padding)
|
|
50
61
|
|
|
51
62
|
Spacing utilities use a 0.25rem (4px) unit by default.
|
|
@@ -515,24 +526,7 @@ You can also control the opacity of any color utility by appending `/{opacity}`
|
|
|
515
526
|
|
|
516
527
|
## Custom Values
|
|
517
528
|
|
|
518
|
-
When you need a value outside the design scale, use bracket notation as an escape hatch.
|
|
519
|
-
|
|
520
|
-
### Enabling Custom Values
|
|
521
|
-
|
|
522
|
-
Add "custom" to your CSS injection:
|
|
523
|
-
|
|
524
|
-
```html
|
|
525
|
-
<script src="//unpkg.com/mancha" css="utils+custom" init></script>
|
|
526
|
-
```
|
|
527
|
-
|
|
528
|
-
Or programmatically:
|
|
529
|
-
|
|
530
|
-
```javascript
|
|
531
|
-
import { injectCss, initMancha } from "mancha";
|
|
532
|
-
|
|
533
|
-
injectCss(["utils", "custom"]);
|
|
534
|
-
await initMancha({ target: "body" });
|
|
535
|
-
```
|
|
529
|
+
When you need a value outside the design scale, use bracket notation as an escape hatch. Custom values are automatically supported when using `css="utils"` — no extra configuration needed.
|
|
536
530
|
|
|
537
531
|
### Syntax
|
|
538
532
|
|
|
@@ -561,10 +555,10 @@ await initMancha({ target: "body" });
|
|
|
561
555
|
|
|
562
556
|
### Variants
|
|
563
557
|
|
|
564
|
-
Custom values support pseudo-states and
|
|
558
|
+
Custom values support pseudo-states, responsive breakpoints, and dark mode:
|
|
565
559
|
|
|
566
560
|
```html
|
|
567
|
-
<div class="hover:w-[200px] md:max-w-[900px]">
|
|
561
|
+
<div class="hover:w-[200px] md:max-w-[900px] dark:bg-[#333]">
|
|
568
562
|
```
|
|
569
563
|
|
|
570
564
|
### Limitations
|
|
@@ -591,7 +585,7 @@ Custom values support pseudo-states and responsive breakpoints:
|
|
|
591
585
|
|
|
592
586
|
### Dynamic Content
|
|
593
587
|
|
|
594
|
-
For content added after initial load, call `injectCss(["custom"])` again to scan and inject new
|
|
588
|
+
For content added after initial load, call `injectCss(["custom"])` again to scan and inject new on-demand values.
|
|
595
589
|
|
|
596
590
|
---
|
|
597
591
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mancha",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Javscript HTML rendering engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "gulp build",
|
|
26
26
|
"pretest": "npm run build",
|
|
27
27
|
"test:node": "mocha 'dist/**/*.test.js' --ignore 'dist/browser.test.js'",
|
|
28
|
-
"test:browser": "web-test-runner 'dist/**/*.test.js' '!dist/cli.test.js' '!dist/ssr.test.js' '!dist/index.test.js' '!dist/worker.test.js' '!dist/type_checker.test.js'
|
|
28
|
+
"test:browser": "web-test-runner 'dist/**/*.test.js' '!dist/cli.test.js' '!dist/ssr.test.js' '!dist/index.test.js' '!dist/worker.test.js' '!dist/type_checker.test.js' --node-resolve --compatibility all --playwright --browsers chromium --no-sandbox",
|
|
29
29
|
"test": "npm run test:node && npm run test:browser",
|
|
30
30
|
"check:size": "brotli -c dist/mancha.js | wc -c",
|
|
31
31
|
"cli": "node dist/cli.js",
|