uswds-extended 3.14.3 → 3.14.5

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
@@ -21,18 +21,246 @@ Based on the [U.S. Web Design System (USWDS)](https://designsystem.digital.gov),
21
21
  | **Gap Utilities** | `gap-2`, `gap-x-1` | Flexbox/Grid gap control |
22
22
  | **PurgeCSS** | Production build | Remove unused CSS |
23
23
 
24
- ## Quick Start
24
+ ## Installation
25
25
 
26
- ### Installation
26
+ There are two ways to use USWDS Extended, depending on which features you need:
27
+
28
+ ### Option 1: Drop-in Replacement (Basic Extended Features)
29
+
30
+ Use with your existing `@uswds/compile` setup. Gets you all the new utility classes without changing your build process.
31
+
32
+ ```bash
33
+ npm install @uswds/uswds@npm:uswds-extended
34
+ npm install @uswds/compile
35
+ ```
36
+
37
+ Your existing gulpfile works unchanged:
38
+
39
+ ```js
40
+ const uswds = require("@uswds/compile");
41
+
42
+ uswds.settings.version = 3;
43
+ uswds.paths.dist.css = "./assets/css";
44
+ uswds.paths.dist.theme = "./sass";
45
+
46
+ exports.compile = uswds.compile;
47
+ exports.watch = uswds.watch;
48
+ ```
49
+
50
+ ### Option 2: Full Installation (All Features)
51
+
52
+ Use the bundled compile module for color opacity, arbitrary values, @apply, and PurgeCSS.
27
53
 
28
54
  ```bash
29
55
  npm install uswds-extended
56
+ ```
57
+
58
+ ```js
59
+ // gulpfile.js
60
+ const uswds = require("uswds-extended/compile");
30
61
 
31
- # Or as a drop-in replacement for @uswds/uswds:
32
- npm install uswds@npm:uswds-extended
62
+ uswds.paths.dist.css = "./assets/css";
63
+ uswds.paths.dist.theme = "./sass";
64
+
65
+ exports.init = uswds.init;
66
+ exports.compile = uswds.compile;
67
+ exports.watch = uswds.watch;
33
68
  ```
34
69
 
35
- ### Usage
70
+ ### Feature Comparison
71
+
72
+ | Feature | @uswds/compile | uswds-extended/compile |
73
+ |---------|:--------------:|:----------------------:|
74
+ | Standard USWDS components | ✅ | ✅ |
75
+ | Extended utilities (ring, gradient, space, size) | ✅ | ✅ |
76
+ | Group/peer hover variants | ✅ | ✅ |
77
+ | Responsive variants | ✅ | ✅ |
78
+ | Color opacity (`bg-primary/75`) | ❌ | ✅ |
79
+ | Arbitrary values (`w-[137px]`) | ❌ | ✅ |
80
+ | @apply directive | ❌ | ✅ |
81
+ | JIT scanning | ❌ | ✅ |
82
+ | PurgeCSS integration | ❌ | ✅ |
83
+
84
+ ---
85
+
86
+ ## uswds-extended/compile API
87
+
88
+ The compile module mirrors the `@uswds/compile` API with additional extended settings.
89
+
90
+ ### Path Configuration
91
+
92
+ ```js
93
+ const uswds = require("uswds-extended/compile");
94
+
95
+ // Same paths API as @uswds/compile
96
+ uswds.paths.dist.css = "./assets/css";
97
+ uswds.paths.dist.theme = "./sass";
98
+ uswds.paths.dist.fonts = "./assets/fonts";
99
+ uswds.paths.dist.img = "./assets/img";
100
+ uswds.paths.dist.js = "./assets/js";
101
+
102
+ // Custom CSS source (for @apply)
103
+ uswds.paths.src.customCSS = "./src/stylesheets/custom";
104
+ ```
105
+
106
+ ### Extended Settings
107
+
108
+ ```js
109
+ // Color opacity steps - generates bg-primary/25, bg-primary/50, etc.
110
+ uswds.extended.opacitySteps = [25, 50, 75, 90];
111
+
112
+ // Content patterns for JIT scanning and PurgeCSS
113
+ uswds.extended.content = [
114
+ "./src/**/*.html",
115
+ "./src/**/*.jsx",
116
+ "./templates/**/*.twig"
117
+ ];
118
+
119
+ // Manual arbitrary values safelist (merged with JIT-scanned values)
120
+ uswds.extended.arbitraryValues = {
121
+ w: ["137px", "200px"],
122
+ h: ["calc(100vh-60px)"],
123
+ "max-w": ["1200px", "80ch"]
124
+ };
125
+
126
+ // PurgeCSS safelist
127
+ uswds.extended.safelist = {
128
+ standard: [/^usa-/, /^is-/, /^has-/],
129
+ deep: [],
130
+ greedy: []
131
+ };
132
+
133
+ // Make all utilities !important
134
+ uswds.extended.important = false;
135
+ ```
136
+
137
+ ### Available Tasks
138
+
139
+ | Task | Description |
140
+ |------|-------------|
141
+ | `uswds.init` | Copy theme files, assets, and compile |
142
+ | `uswds.compile` | Compile with all extended features |
143
+ | `uswds.compileSass` | Standard compile (no PostCSS features) |
144
+ | `uswds.compileExtended` | Explicit extended compile |
145
+ | `uswds.compileCustomCSS` | Process @apply directives |
146
+ | `uswds.purgeSass` | Remove unused CSS |
147
+ | `uswds.purge` | Purge + report file size savings |
148
+ | `uswds.reportPurgeStats` | Show purge statistics |
149
+ | `uswds.watch` | Watch mode with extended compile |
150
+ | `uswds.updateUswds` | Copy assets + recompile |
151
+ | `uswds.copyTheme` | Copy theme files only |
152
+ | `uswds.copyAssets` | Copy fonts, images, JS |
153
+ | `uswds.copyAll` | Copy theme + all assets |
154
+
155
+ ### Complete Gulpfile Example
156
+
157
+ ```js
158
+ // gulpfile.js
159
+ const uswds = require("uswds-extended/compile");
160
+ const path = require("path");
161
+
162
+ // Path configuration
163
+ uswds.paths.dist.css = "./assets/css";
164
+ uswds.paths.dist.theme = "./sass";
165
+ uswds.paths.dist.fonts = "./assets/fonts";
166
+ uswds.paths.dist.img = "./assets/img";
167
+ uswds.paths.dist.js = "./assets/js";
168
+ uswds.paths.src.customCSS = "./src/css";
169
+
170
+ // Extended features
171
+ uswds.extended.opacitySteps = [10, 25, 50, 75, 90];
172
+ uswds.extended.content = [
173
+ "./src/**/*.html",
174
+ "./src/**/*.js",
175
+ "./templates/**/*.twig"
176
+ ];
177
+
178
+ // Export tasks
179
+ exports.init = uswds.init;
180
+ exports.compile = uswds.compile;
181
+ exports.customCSS = uswds.compileCustomCSS;
182
+ exports.purge = uswds.purge;
183
+ exports.watch = uswds.watch;
184
+ exports.update = uswds.updateUswds;
185
+
186
+ // Default task
187
+ exports.default = uswds.watch;
188
+ ```
189
+
190
+ Run tasks:
191
+ ```bash
192
+ npx gulp init # First-time setup
193
+ npx gulp compile # Compile CSS
194
+ npx gulp customCSS # Process @apply
195
+ npx gulp purge # Production build
196
+ npx gulp watch # Development mode
197
+ ```
198
+
199
+ ---
200
+
201
+ ## Naming Conventions
202
+
203
+ > **Important**: USWDS Extended uses **USWDS naming conventions** for core utilities, not Tailwind shorthand.
204
+
205
+ ### Core Utilities (USWDS Style)
206
+
207
+ | Tailwind | USWDS Extended | Property |
208
+ |----------|----------------|----------|
209
+ | `m-4` | `margin-4` | margin |
210
+ | `mx-4` | `margin-x-4` | margin-left/right |
211
+ | `p-4` | `padding-4` | padding |
212
+ | `w-full` | `width-full` | width |
213
+ | `h-screen` | `height-viewport` | height |
214
+ | `flex` | `display-flex` | display |
215
+ | `items-center` | `flex-align-center` | align-items |
216
+ | `justify-between` | `flex-justify` | justify-content |
217
+ | `text-lg` | `font-size-lg` | font-size |
218
+ | `min-w-0` | `minw-0` | min-width |
219
+ | `max-w-lg` | `maxw-lg` | max-width |
220
+
221
+ ### Extended Utilities (Tailwind Style)
222
+
223
+ New utilities use Tailwind-style naming:
224
+
225
+ | Category | Classes | Example |
226
+ |----------|---------|---------|
227
+ | Flex Grow/Shrink | `grow`, `grow-0`, `shrink`, `shrink-0` | `<div class="grow">` |
228
+ | Flex Basis | `basis-0`, `basis-1/2`, `basis-full` | `<div class="basis-1/2">` |
229
+ | Size | `size-0` to `size-96`, `size-full` | `<img class="size-12">` |
230
+ | Aspect Ratio | `aspect-auto`, `aspect-square`, `aspect-video` | `<div class="aspect-video">` |
231
+ | Ring | `ring`, `ring-2`, `ring-primary` | `<button class="focus:ring-2">` |
232
+ | Gradients | `bg-gradient-to-r`, `from-primary`, `to-secondary` | `<div class="bg-gradient-to-r from-primary to-accent-warm">` |
233
+
234
+ ### Responsive Breakpoints
235
+
236
+ Use USWDS breakpoint prefixes (not Tailwind's `sm:`, `md:`, `lg:`):
237
+
238
+ | Breakpoint | Prefix | Min Width |
239
+ |------------|--------|-----------|
240
+ | Mobile Large | `mobile-lg:` | 480px |
241
+ | Tablet | `tablet:` | 640px |
242
+ | Tablet Large | `tablet-lg:` | 880px |
243
+ | Desktop | `desktop:` | 1024px |
244
+ | Desktop Large | `desktop-lg:` | 1200px |
245
+ | Widescreen | `widescreen:` | 1400px |
246
+
247
+ ```html
248
+ <div class="display-flex flex-column tablet:flex-row desktop:grid-cols-3">
249
+ ```
250
+
251
+ ### State Variants
252
+
253
+ | Variant | Selector | Example |
254
+ |---------|----------|---------|
255
+ | `hover:` | `:hover` | `hover:bg-primary-dark` |
256
+ | `focus:` | `:focus` | `focus:ring-2` |
257
+ | `active:` | `:active` | `active:opacity-80` |
258
+ | `visited:` | `:visited` | `visited:text-violet` |
259
+ | `group-hover:` | `.group:hover` | `group-hover:text-white` |
260
+
261
+ ---
262
+
263
+ ## Usage Examples
36
264
 
37
265
  ```html
38
266
  <!-- Color opacity -->
@@ -70,42 +298,51 @@ Compose utilities in custom CSS (`src/stylesheets/custom/*.css`):
70
298
  }
71
299
  ```
72
300
 
73
- Build with: `npx gulp compileCustomCSS`
301
+ Build with: `npx gulp customCSS`
74
302
 
75
303
  ### Production Build
76
304
 
77
- Remove unused CSS:
305
+ Remove unused CSS for smaller file sizes:
78
306
 
79
307
  ```bash
80
- npx gulp purgeSass
81
- npx gulp reportPurgeStats
308
+ npx gulp purge
82
309
  ```
83
310
 
84
- ## Configuration
311
+ This runs PurgeCSS and reports the file size savings.
85
312
 
86
- **`uswds.config.js`** - Configure arbitrary values and opacity steps:
313
+ ---
87
314
 
88
- ```js
89
- module.exports = {
90
- arbitraryValues: {
91
- w: ['137px', '200px'],
92
- h: ['calc(100vh-60px)'],
93
- 'max-w': ['1200px', '80ch'],
94
- },
95
- opacitySteps: [5, 10, 20, 25, 30, 40, 50, 60, 70, 75, 80, 90, 95],
96
- };
315
+ ## Migration
316
+
317
+ ### From Tailwind CSS
318
+
319
+ Replace Tailwind shorthand with USWDS verbose names:
320
+
321
+ ```html
322
+ <!-- Tailwind -->
323
+ <div class="m-4 p-2 flex items-center w-full min-h-screen">
324
+
325
+ <!-- USWDS Extended -->
326
+ <div class="margin-4 padding-2 display-flex flex-align-center width-full minh-viewport">
97
327
  ```
98
328
 
99
- **`purgecss.config.js`** - Configure CSS purging for production.
329
+ Extended utilities (grow, shrink, basis, ring, etc.) use familiar Tailwind naming.
100
330
 
101
- ## Gulp Tasks
331
+ ### From Standard USWDS
102
332
 
103
- | Task | Description |
104
- |------|-------------|
105
- | `compileSass` | Compile USWDS + extended utilities |
106
- | `compileCustomCSS` | Process custom CSS with @apply |
107
- | `purgeSass` | Remove unused CSS for production |
108
- | `reportPurgeStats` | Show size comparison |
333
+ Extended utilities work alongside existing USWDS components:
334
+
335
+ ```html
336
+ <div class="usa-card">
337
+ <div class="usa-card__body padding-4">
338
+ <!-- Mix USWDS components with extended utilities -->
339
+ <div class="display-flex gap-2">
340
+ <p class="grow basis-1/2">Content</p>
341
+ <button class="usa-button focus:ring-2">Action</button>
342
+ </div>
343
+ </div>
344
+ </div>
345
+ ```
109
346
 
110
347
  ---
111
348