@lobergdesign/dot-grid 1.0.2 → 1.0.3

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.
@@ -0,0 +1,26 @@
1
+ {
2
+ "content": [
3
+ "./src/**/*.{html,js,jsx,ts,tsx,vue,svelte}",
4
+ "./public/**/*.html"
5
+ ],
6
+ "css": ["./node_modules/@lobergdesign/dot-grid/dist/grid.css"],
7
+ "safelist": {
8
+ "standard": ["grid-w", "grid-r", "no-gap", "hidden"],
9
+ "greedy": [
10
+ "/^grid-c-\\d{1,2}$/",
11
+ "/^grid-c-start-\\d{1,2}$/",
12
+ "/^grid-c-(sm|md|lg|xl|xxl)-\\d{1,2}$/",
13
+ "/^grid-c-start-(sm|md|lg|xl|xxl)-\\d{1,2}$/",
14
+ "/^grid-c-vp-(sm|md|lg|xl|xxl)-\\d{1,2}$/",
15
+ "/^grid-c-start-vp-(sm|md|lg|xl|xxl)-\\d{1,2}$/",
16
+ "/^grid-[rc]-subgrid$/",
17
+ "/^grid-r-(fluid-[234]|ram|intrinsic|even|dense|flexible)$/",
18
+ "/^grid-auto-(fit|fill)$/",
19
+ "/^place-[tcb]-[lcr]$/",
20
+ "/^justify-.*$/",
21
+ "/^grid-c-(min|max|fit|auto|fluid)$/",
22
+ "/^(hidden|block|grid|flex)-(sm|md|lg|xl|xxl)$/",
23
+ "/^(hidden|block|grid|flex)-vp-(sm|md|lg|xl|xxl)$/"
24
+ ]
25
+ }
26
+ }
package/README.md CHANGED
@@ -263,6 +263,76 @@ Available: `.justify-start`, `.justify-end`, `.justify-center`, `.justify-betwee
263
263
  <div class="grid-c-auto">Auto-sized</div>
264
264
  ```
265
265
 
266
+ ## 🌲 Tree Shaking / PurgeCSS
267
+
268
+ Like Tailwind CSS, you can significantly reduce the CSS bundle size by removing unused classes using PurgeCSS or similar tools.
269
+
270
+ ### Setup with PurgeCSS
271
+
272
+ 1. **Install PurgeCSS:**
273
+
274
+ ```bash
275
+ npm install --save-dev @fullhuman/postcss-purgecss
276
+ ```
277
+
278
+ 2. **Copy the configuration:**
279
+
280
+ Copy `purgecss.config.js` from the dot-grid package to your project root, or create your own:
281
+
282
+ ```js
283
+ // purgecss.config.js
284
+ module.exports = {
285
+ content: ['./src/**/*.{html,js,jsx,ts,tsx}'],
286
+ css: ['./node_modules/@lobergdesign/dot-grid/dist/grid.css'],
287
+ safelist: {
288
+ greedy: [
289
+ /^grid-c-\d{1,2}$/,
290
+ /^grid-c-(sm|md|lg|xl|xxl)-\d{1,2}$/,
291
+ // ... see purgecss.config.js for full list
292
+ ],
293
+ },
294
+ }
295
+ ```
296
+
297
+ 3. **Add to your build process:**
298
+
299
+ ```json
300
+ // package.json
301
+ {
302
+ "scripts": {
303
+ "purge": "purgecss --config ./purgecss.config.js --output ./dist/grid.purged.css"
304
+ }
305
+ }
306
+ ```
307
+
308
+ ### With PostCSS
309
+
310
+ ```js
311
+ // postcss.config.js
312
+ module.exports = {
313
+ plugins: [
314
+ require('@fullhuman/postcss-purgecss')({
315
+ content: ['./src/**/*.{html,js,jsx,ts,tsx}'],
316
+ safelist: {
317
+ greedy: [
318
+ /^grid-c-/,
319
+ /^grid-r-/,
320
+ /^place-/,
321
+ // Add more patterns as needed
322
+ ],
323
+ },
324
+ }),
325
+ ],
326
+ }
327
+ ```
328
+
329
+ ### Expected Results
330
+
331
+ - **Full build:** ~28KB / 19KB minified
332
+ - **With PurgeCSS:** Typically 2-5KB depending on usage
333
+
334
+ See `purgecss.config.js` in the package for complete safelist patterns.
335
+
266
336
  ## 🎨 Customization
267
337
 
268
338
  Override CSS custom properties in your own stylesheet:
@@ -322,28 +392,6 @@ See the `/examples` directory for complete working examples:
322
392
  - `fluid-layout.html` - Auto-responsive fluid grids
323
393
  - `subgrid.html` - Subgrid alignment examples
324
394
 
325
- ## 🆚 Migration from Original CodePen
326
-
327
- ### Breaking Changes
328
-
329
- 1. **Class names updated** - All core classes have been renamed for better clarity:
330
-
331
- - `.wrap` → `.grid-w`
332
- - `.row` → `.grid-r`
333
- - `.col-*` → `.grid-c-*`
334
- - **Migration:** Update all class names in your HTML
335
-
336
- 2. **Container queries by default** - Responsive classes now use `@container` instead of `@media`
337
-
338
- - **Migration:** Use `.grid-c-vp-{size}-{num}` if you need viewport-based behavior
339
-
340
- 3. **Placement utilities fixed** - `align-items: top` → `align-items: start`
341
-
342
- - **Migration:** No action needed, now uses correct CSS values
343
-
344
- 4. **New breakpoints** - Added `xxl` (1536px), adjusted `lg` from 1025px to 1024px
345
- - **Migration:** Update breakpoints in your HTML if using exact pixel values
346
-
347
395
  ### New Features (Additive)
348
396
 
349
397
  - Subgrid support
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobergdesign/dot-grid",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A modern, flexible 12-column CSS Grid system with container queries, fluid layouts, and subgrid support",
5
5
  "main": "dist/grid.css",
6
6
  "style": "dist/grid.css",
@@ -19,7 +19,9 @@
19
19
  "dist",
20
20
  "src",
21
21
  "README.md",
22
- "LICENSE"
22
+ "LICENSE",
23
+ "purgecss.config.js",
24
+ ".purgecssrc.json"
23
25
  ],
24
26
  "scripts": {
25
27
  "build": "npm run build:css && npm run build:min",
@@ -0,0 +1,77 @@
1
+ // PurgeCSS Configuration for dot-grid
2
+ // This is an example configuration for end-users
3
+ // Copy this to your project root and customize as needed
4
+
5
+ module.exports = {
6
+ content: [
7
+ // Scan your source files for class names
8
+ './src/**/*.{html,js,jsx,ts,tsx,vue,svelte}',
9
+ './public/**/*.html',
10
+ // Add more paths as needed
11
+ ],
12
+
13
+ css: [
14
+ // Path to your compiled dot-grid CSS
15
+ './node_modules/@lobergdesign/dot-grid/dist/grid.css',
16
+ // Or if you import the source:
17
+ // './path/to/compiled/css/with/dot-grid.css'
18
+ ],
19
+
20
+ // Safelist: patterns that should never be purged
21
+ safelist: {
22
+ // Safelist all dot-grid core classes
23
+ standard: [
24
+ 'grid-w',
25
+ 'grid-r',
26
+ 'no-gap',
27
+ 'hidden',
28
+ ],
29
+
30
+ // Safelist patterns using regex
31
+ greedy: [
32
+ // Grid column classes: grid-c-1 through grid-c-12
33
+ /^grid-c-\d{1,2}$/,
34
+
35
+ // Grid column start: grid-c-start-1 through grid-c-start-12
36
+ /^grid-c-start-\d{1,2}$/,
37
+
38
+ // Responsive column classes: grid-c-sm-6, grid-c-md-4, etc.
39
+ /^grid-c-(sm|md|lg|xl|xxl)-\d{1,2}$/,
40
+
41
+ // Responsive start: grid-c-start-sm-1, etc.
42
+ /^grid-c-start-(sm|md|lg|xl|xxl)-\d{1,2}$/,
43
+
44
+ // Viewport-based: grid-c-vp-md-6, etc.
45
+ /^grid-c-vp-(sm|md|lg|xl|xxl)-\d{1,2}$/,
46
+ /^grid-c-start-vp-(sm|md|lg|xl|xxl)-\d{1,2}$/,
47
+
48
+ // Subgrid classes
49
+ /^grid-[rc]-subgrid$/,
50
+
51
+ // Fluid row classes
52
+ /^grid-r-(fluid-[234]|ram|intrinsic|even|dense|flexible)$/,
53
+
54
+ // Grid auto classes
55
+ /^grid-auto-(fit|fill)$/,
56
+
57
+ // Placement utilities: place-t-l, place-c-c, etc.
58
+ /^place-[tcb]-[lcr]$/,
59
+
60
+ // Justify utilities
61
+ /^justify-(start|end|center|between|around|evenly|space-).*$/,
62
+
63
+ // Sizing utilities
64
+ /^grid-c-(min|max|fit|auto|fluid)$/,
65
+
66
+ // Display utilities (responsive)
67
+ /^(hidden|block|grid|flex)-(sm|md|lg|xl|xxl)$/,
68
+ /^(hidden|block|grid|flex)-vp-(sm|md|lg|xl|xxl)$/,
69
+ ],
70
+ },
71
+
72
+ // Extract dynamic class names from JavaScript strings
73
+ defaultExtractor: (content) => {
74
+ // Match class names in strings, including dynamically generated ones
75
+ return content.match(/[A-Za-z0-9-_:/]+/g) || [];
76
+ },
77
+ };