emily-css 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Andy Terry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,249 @@
1
+ # emily-ui
2
+
3
+ A config-driven, utility-first CSS framework for developers in constrained environments. Define brand once (colours, fonts, spacing) → generate CSS → browse and copy production-ready components.
4
+
5
+ ## Features
6
+
7
+ - **Config-driven** — Entire framework configured via `emily.config.json`
8
+ - **Utility-first** — 11,844 composable utilities covering layout, spacing, typography, colours, responsive variants, state variants
9
+ - **Responsive ready** — All utilities work with responsive prefixes (sm:, md:, lg:, xl:, 2xl:)
10
+ - **State variants** — hover, focus-visible, active, disabled states built-in
11
+ - **Accessibility first** — WCAG 2.2 AA compliance in core utilities (focus rings, contrast, motion)
12
+ - **Purge system** — Remove unused CSS automatically (97% file size reduction)
13
+ - **Framework-agnostic** — Works with Drupal, static HTML, Power Pages, Vue, Next.js, anything that accepts CSS
14
+ - **No build pipeline required** — Generate CSS, use it directly in your project
15
+
16
+ ## Quick Start
17
+
18
+ ### 1. Install
19
+ ```bash
20
+ npm install emily-ui
21
+ emily-ui init
22
+ ```
23
+
24
+ The `init` command guides you through:
25
+ - Project name
26
+ - Brand colours (primary, secondary, success, warning, error, neutral)
27
+ - Font families
28
+ - Base spacing unit
29
+
30
+ ### 2. Build CSS
31
+ ```bash
32
+ emily-ui build
33
+ ```
34
+
35
+ Output:
36
+ - `dist/emily.css` — Full CSS (1.1 MB)
37
+ - `dist/emily.min.css` — Minified (1.04 MB)
38
+
39
+ ### 2b. Run Tests (Optional)
40
+ ```bash
41
+ npm test
42
+ ```
43
+ *(Run from inside the emily-ui project folder)*
44
+
45
+ Automated validation of colour generation, utilities, variants, config integrity, and build output (66 tests, all passing). Tests confirm the generator works correctly; manual testing of real-world usage is still recommended before deploying to production.
46
+
47
+ ### 3. Use Components
48
+ Open `showcase.html` in your browser to see 8 production components (button, input, textarea, select, checkbox, radio, card, alert). Copy the HTML, paste into your project.
49
+
50
+ ### 4. Reduce File Size (Recommended for Production)
51
+ ```bash
52
+ emily-ui build --purge ./src
53
+ ```
54
+
55
+ Scans your HTML/templates for used classes, removes unused utilities. Typical reduction: 99%+ (1.1 MB → 10–50 KB).
56
+
57
+ Output:
58
+ - `dist/emily.purged.css` — Only utilities you use
59
+ - `dist/emily.purged.min.css` — Minified version
60
+
61
+ ## File Size Comparison
62
+
63
+ Emily uses a purge-based approach (generate all utilities, then remove unused). Unpurged file size: ~1.1 MB.
64
+
65
+ For context:
66
+ - **Tailwind v2** (purge-based): 2.4–8MB unpurged → <10KB purged
67
+ - **Emily v1** (purge-based): 1.1MB unpurged → 10–50KB purged
68
+ - **Tailwind v3/v4** (JIT): Generates only what you use, no purge step needed
69
+
70
+ Emily's unpurged file is roughly half the size of Tailwind v2. For production, both frameworks achieve similar post-purge sizes. JIT-style on-demand generation is planned for Emily v2.
71
+
72
+ ## File Structure
73
+
74
+ ```
75
+ emily-ui/
76
+ ├── src/
77
+ │ ├── index.js — Main build script
78
+ │ ├── generators.js — Utility generation functions
79
+ │ ├── purge.js — CSS purge system
80
+ │ └── init.js — Interactive config generator
81
+ ├── dist/
82
+ │ ├── emily.css — Generated CSS
83
+ │ ├── emily.min.css — Minified CSS
84
+ │ ├── emily.purged.css — Purged CSS (with --purge flag)
85
+ │ └── emily.purged.min.css
86
+ ├── showcase.html — Component browser
87
+ ├── emily.config.json — Framework configuration
88
+ ├── package.json
89
+ └── README.md
90
+ ```
91
+
92
+ ## Configuration
93
+
94
+ Edit `emily.config.json` to customize:
95
+
96
+ ```json
97
+ {
98
+ "name": "My Brand",
99
+ "description": "Design system",
100
+
101
+ "baseUnit": "8px",
102
+ "baseFontSize": "16px",
103
+ "fontFamily": "system-ui",
104
+
105
+ "colours": {
106
+ "primary": "#0077b6",
107
+ "secondary": "#006d9e",
108
+ "success": "#017f65",
109
+ "warning": "#ffc107",
110
+ "error": "#b20000",
111
+ "neutral": "#6b7280"
112
+ },
113
+
114
+ "breakpoints": {
115
+ "sm": "640px",
116
+ "md": "768px",
117
+ "lg": "1024px",
118
+ "xl": "1280px",
119
+ "2xl": "1536px"
120
+ },
121
+
122
+ "spacing": {
123
+ "scale": { "0": "0px", "1": "0.25rem", ... },
124
+ "borderRadius": { "sm": "4px", "base": "8px", "lg": "16px", ... }
125
+ },
126
+
127
+ "typography": {
128
+ "fontWeights": { "light": 300, "normal": 400, ... },
129
+ "fontSizes": [ { "name": "sm", "value": "14px" }, ... ]
130
+ },
131
+
132
+ "shadows": { ... },
133
+ "transitions": { ... },
134
+ "zIndex": { ... },
135
+ "opacity": [ ... ],
136
+
137
+ "purge": {
138
+ "extensions": [".html", ".jsx", ".tsx", ".vue", ...]
139
+ }
140
+ }
141
+ ```
142
+
143
+ After editing, rebuild:
144
+ ```bash
145
+ emily-ui build
146
+ ```
147
+
148
+ ## Utilities
149
+
150
+ Emily generates utilities across these categories:
151
+
152
+ - **Display** — block, inline, flex, grid, hidden
153
+ - **Spacing** — margin (m-), padding (p-), gap (gap-)
154
+ - **Sizing** — width (w-), height (h-), max-width, min-height
155
+ - **Positioning** — absolute, relative, fixed, sticky, top, right, bottom, left
156
+ - **Flexbox** — flex, flex-direction, justify-content, align-items, flex-wrap
157
+ - **Grid** — grid, grid-cols, grid-rows, grid-gap
158
+ - **Colours** — background (bg-), text, borders, accent for form controls
159
+ - **Typography** — font-size, font-weight, line-height, text-align
160
+ - **Borders** — border-width, border-style, border-colour, border-radius
161
+ - **Shadows** — box-shadow, text-shadow
162
+ - **Opacity** — opacity levels
163
+ - **Accessibility** — sr-only, focus-visible, motion-safe, forced-colors
164
+ - **State variants** — hover:, focus-visible:, active:, disabled:
165
+ - **Responsive variants** — sm:, md:, lg:, xl:, 2xl:
166
+
167
+ ## Examples
168
+
169
+ ### Button
170
+ ```html
171
+ <button class="px-4 py-2 rounded-md bg-primary-80 text-white hover:bg-primary-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-50">
172
+ Click me
173
+ </button>
174
+ ```
175
+
176
+ ### Responsive Card
177
+ ```html
178
+ <div class="w-full md:w-96 p-4 md:p-6 rounded-lg bg-neutral-10 border-1 border-neutral-30 shadow-md">
179
+ <h2 class="text-lg font-semibold text-neutral-90">Title</h2>
180
+ <p class="mt-2 text-sm text-neutral-70">Content</p>
181
+ </div>
182
+ ```
183
+
184
+ ### Accessible Form Input
185
+ ```html
186
+ <label for="email" class="block text-sm font-medium text-neutral-80">
187
+ Email
188
+ </label>
189
+ <input
190
+ id="email"
191
+ type="email"
192
+ class="mt-1 w-full px-3 py-2 border-1 border-neutral-40 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-50"
193
+ />
194
+ ```
195
+
196
+ ## Accessibility
197
+
198
+ All utilities are built with WCAG 2.2 AA in mind:
199
+
200
+ - **Focus rings** — Focus-visible states include proper colour contrast
201
+ - **Colour contrast** — All colour scales meet AA contrast ratios
202
+ - **Motion** — `motion-safe` and `motion-reduce` utilities for users with vestibular disorders
203
+ - **Semantic HTML** — Components use proper heading hierarchy and form labels
204
+ - **Screen reader support** — `.sr-only` utility for screen-reader-only content
205
+ - **Forced colours** — Utilities respect Windows High Contrast mode
206
+
207
+ ## Known Limitations
208
+
209
+ These are post-v1 priorities:
210
+ - Arbitrary values (`w-[123px]`) — deferred to v2
211
+ - Extend system for custom utilities — deferred to v2
212
+ - Pattern utilities (Wrapper, Flow, Stack) — deferred to v2
213
+ - Watch mode / HMR — deferred to v2
214
+ - Pre-built component tier — deferred to v2
215
+
216
+ ## Troubleshooting
217
+
218
+ ### Styles not applying?
219
+ 1. Check that responsive prefix is correct: `.md\:flex` not `.md:flex`
220
+ 2. Verify class name spelling in HTML
221
+ 3. Clear browser cache and rebuild CSS
222
+
223
+ ### File size too large?
224
+ Use the purge system:
225
+ ```bash
226
+ emily-ui build --purge ./src
227
+ ```
228
+
229
+ ### Config not applying?
230
+ 1. Edit `emily.config.json`
231
+ 2. Run `npm run build` to regenerate CSS
232
+ 3. No cache invalidation needed (CSS is regenerated from scratch)
233
+
234
+ ## CDN
235
+
236
+ Use emily-ui directly without npm via jsDelivr:
237
+
238
+ ```html
239
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/emily-ui/dist/emily.css">
240
+ ```
241
+
242
+ ## Support
243
+
244
+ Open an issue or start a discussion on GitHub:
245
+ https://github.com/andyjterry/emily-ui
246
+
247
+ ## License
248
+
249
+ MIT
package/bin/emilyui.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ const command = process.argv[2];
4
+
5
+ if (command === "init") {
6
+ require("../src/init.js");
7
+ } else if (command === "build") {
8
+ require("../src/index.js");
9
+ } else {
10
+ console.log(`
11
+ emily-ui — Config-driven CSS framework generator
12
+
13
+ Usage:
14
+ emily-ui init Set up a new project
15
+ emily-ui build Generate emily.css from your existing config
16
+ `);
17
+ }