@lobergdesign/dot-grid 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 +21 -0
- package/README.md +383 -0
- package/dist/grid.css +1400 -0
- package/dist/grid.min.css +71 -0
- package/package.json +62 -0
- package/src/_base.scss +77 -0
- package/src/_fluid.scss +152 -0
- package/src/_responsive.scss +119 -0
- package/src/_utilities.scss +203 -0
- package/src/_variables.scss +67 -0
- package/src/grid.scss +83 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Jean Loberg
|
|
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,383 @@
|
|
|
1
|
+
# dot-grid
|
|
2
|
+
|
|
3
|
+
A modern, flexible 12-column CSS Grid system with container queries, fluid layouts, and subgrid support.
|
|
4
|
+
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
- **Modern CSS Grid** - Built on native CSS Grid (not flexbox or floats)
|
|
8
|
+
- **Container Queries** - Responsive classes based on container size, not viewport
|
|
9
|
+
- **Fluid Layouts** - Auto-responsive utilities that adapt without breakpoints
|
|
10
|
+
- **Subgrid Support** - Perfect alignment for nested grids
|
|
11
|
+
- **CSS Custom Properties** - Easy customization via CSS variables
|
|
12
|
+
- **Cascade Layers** - Better specificity control
|
|
13
|
+
- **Logical Properties** - Automatic RTL support
|
|
14
|
+
- **Zero JavaScript** - Pure CSS solution
|
|
15
|
+
- **28KB / 19KB minified** - Lightweight and performant
|
|
16
|
+
|
|
17
|
+
## 📦 Installation
|
|
18
|
+
|
|
19
|
+
### npm
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install dot-grid
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Then import in your CSS/SCSS:
|
|
26
|
+
|
|
27
|
+
```css
|
|
28
|
+
@import 'dot-grid';
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or in your HTML:
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<link rel="stylesheet" href="node_modules/dot-grid/dist/grid.min.css">
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### CDN
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<link rel="stylesheet" href="https://unpkg.com/dot-grid@latest/dist/grid.min.css">
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 🚀 Quick Start
|
|
44
|
+
|
|
45
|
+
### Basic Grid
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<div class="wrap">
|
|
49
|
+
<div class="row">
|
|
50
|
+
<div class="col-12 col-md-6 col-lg-4">Column 1</div>
|
|
51
|
+
<div class="col-12 col-md-6 col-lg-4">Column 2</div>
|
|
52
|
+
<div class="col-12 col-md-6 col-lg-4">Column 3</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Fluid/Auto Grid (No Breakpoints Needed!)
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<div class="wrap">
|
|
61
|
+
<div class="grid-auto-fit">
|
|
62
|
+
<div>Card 1</div>
|
|
63
|
+
<div>Card 2</div>
|
|
64
|
+
<div>Card 3</div>
|
|
65
|
+
<!-- Automatically wraps based on available space -->
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 📖 Documentation
|
|
71
|
+
|
|
72
|
+
### Core Classes
|
|
73
|
+
|
|
74
|
+
#### Container
|
|
75
|
+
|
|
76
|
+
- `.wrap` - Centers content with max-width and responsive padding
|
|
77
|
+
|
|
78
|
+
#### Grid Container
|
|
79
|
+
|
|
80
|
+
- `.row` - Creates a 12-column grid container with container query support
|
|
81
|
+
|
|
82
|
+
### Column Classes
|
|
83
|
+
|
|
84
|
+
#### Basic Columns
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<div class="col-1">...</div> <!-- Spans 1 column -->
|
|
88
|
+
<div class="col-6">...</div> <!-- Spans 6 columns (50%) -->
|
|
89
|
+
<div class="col-12">...</div> <!-- Spans 12 columns (100%) -->
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
All classes from `.col-1` through `.col-12` are available.
|
|
93
|
+
|
|
94
|
+
#### Container Query Responsive (Modern, Recommended)
|
|
95
|
+
|
|
96
|
+
Responds to the **container width**, not viewport:
|
|
97
|
+
|
|
98
|
+
```html
|
|
99
|
+
<div class="col-12 col-sm-6 col-md-4 col-lg-3">
|
|
100
|
+
Responsive column
|
|
101
|
+
</div>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Breakpoints:**
|
|
105
|
+
- `sm`: 640px
|
|
106
|
+
- `md`: 768px
|
|
107
|
+
- `lg`: 1024px
|
|
108
|
+
- `xl`: 1280px
|
|
109
|
+
- `xxl`: 1536px
|
|
110
|
+
|
|
111
|
+
#### Viewport-based Responsive (Alternative)
|
|
112
|
+
|
|
113
|
+
If you need viewport-based responsive behavior instead:
|
|
114
|
+
|
|
115
|
+
```html
|
|
116
|
+
<div class="col-vp-md-6 col-vp-lg-4">
|
|
117
|
+
Responds to viewport size
|
|
118
|
+
</div>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Column Positioning
|
|
122
|
+
|
|
123
|
+
#### Start Position
|
|
124
|
+
|
|
125
|
+
```html
|
|
126
|
+
<div class="col-3 col-start-4">
|
|
127
|
+
Starts at column 4, spans 3 columns
|
|
128
|
+
</div>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Responsive start positions:
|
|
132
|
+
|
|
133
|
+
```html
|
|
134
|
+
<div class="col-6 col-start-md-7 col-start-lg-4">
|
|
135
|
+
Different start positions at different sizes
|
|
136
|
+
</div>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Gap Utilities
|
|
140
|
+
|
|
141
|
+
```html
|
|
142
|
+
<!-- Different gap sizes -->
|
|
143
|
+
<div class="row gap-none">...</div> <!-- No gap -->
|
|
144
|
+
<div class="row gap-xs">...</div> <!-- 0.5rem -->
|
|
145
|
+
<div class="row gap-sm">...</div> <!-- 1rem -->
|
|
146
|
+
<div class="row gap-md">...</div> <!-- clamp(1rem, 2vw, 2rem) - default -->
|
|
147
|
+
<div class="row gap-lg">...</div> <!-- 3rem -->
|
|
148
|
+
<div class="row gap-xl">...</div> <!-- 4rem -->
|
|
149
|
+
|
|
150
|
+
<!-- Directional gaps -->
|
|
151
|
+
<div class="row gap-b-none">...</div> <!-- No row gap -->
|
|
152
|
+
<div class="row gap-sides-none">...</div> <!-- No column gap -->
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Responsive gaps:
|
|
156
|
+
|
|
157
|
+
```html
|
|
158
|
+
<div class="row gap-sm gap-md-lg gap-lg-xl">
|
|
159
|
+
Different gaps at different sizes
|
|
160
|
+
</div>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Subgrid
|
|
164
|
+
|
|
165
|
+
Perfect alignment for nested grids:
|
|
166
|
+
|
|
167
|
+
```html
|
|
168
|
+
<div class="row">
|
|
169
|
+
<div class="col-12 row-subgrid">
|
|
170
|
+
<!-- These inherit the parent's column tracks -->
|
|
171
|
+
<div class="col-4">Aligned 1</div>
|
|
172
|
+
<div class="col-4">Aligned 2</div>
|
|
173
|
+
<div class="col-4">Aligned 3</div>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Fluid/Automatic Layouts
|
|
179
|
+
|
|
180
|
+
#### Auto-fit Grid
|
|
181
|
+
|
|
182
|
+
Automatically fits as many columns as possible:
|
|
183
|
+
|
|
184
|
+
```html
|
|
185
|
+
<div class="grid-auto-fit">
|
|
186
|
+
<div>Item 1</div>
|
|
187
|
+
<div>Item 2</div>
|
|
188
|
+
<div>Item 3</div>
|
|
189
|
+
<!-- Items wrap automatically when space runs out -->
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<!-- Customize minimum column width -->
|
|
193
|
+
<div class="grid-auto-fit" style="--grid-auto-min: 300px">
|
|
194
|
+
<div>Wider items</div>
|
|
195
|
+
</div>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### Fluid Row Patterns
|
|
199
|
+
|
|
200
|
+
```html
|
|
201
|
+
<!-- Adapts to 2 columns on larger screens -->
|
|
202
|
+
<div class="row-fluid-2">
|
|
203
|
+
<div>Item 1</div>
|
|
204
|
+
<div>Item 2</div>
|
|
205
|
+
<div>Item 3</div>
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
<!-- Also available: row-fluid-3, row-fluid-4 -->
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### RAM Pattern (Repeat Auto Minmax)
|
|
212
|
+
|
|
213
|
+
```html
|
|
214
|
+
<div class="row-ram" style="--col-min: 250px">
|
|
215
|
+
<div>Equal column 1</div>
|
|
216
|
+
<div>Equal column 2</div>
|
|
217
|
+
<div>Equal column 3</div>
|
|
218
|
+
</div>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
#### Other Fluid Patterns
|
|
222
|
+
|
|
223
|
+
- `.row-intrinsic` - Columns size based on content
|
|
224
|
+
- `.row-even` - Even columns sharing space equally
|
|
225
|
+
- `.row-dense` - Fills gaps in the grid (masonry style)
|
|
226
|
+
|
|
227
|
+
### Content Placement
|
|
228
|
+
|
|
229
|
+
Align content within a column:
|
|
230
|
+
|
|
231
|
+
```html
|
|
232
|
+
<!-- Pattern: place-{vertical}-{horizontal} -->
|
|
233
|
+
<div class="col-6 place-t-l">Top Left</div>
|
|
234
|
+
<div class="col-6 place-c-c">Center Center</div>
|
|
235
|
+
<div class="col-6 place-b-r">Bottom Right</div>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Vertical options:** `t` (top), `c` (center), `b` (bottom)
|
|
239
|
+
**Horizontal options:** `l` (left), `c` (center), `r` (right)
|
|
240
|
+
|
|
241
|
+
### Flexbox Utilities
|
|
242
|
+
|
|
243
|
+
For flex-based alignment within columns:
|
|
244
|
+
|
|
245
|
+
```html
|
|
246
|
+
<div class="col-12 justify-between">
|
|
247
|
+
<span>Left</span>
|
|
248
|
+
<span>Right</span>
|
|
249
|
+
</div>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Available: `.justify-start`, `.justify-end`, `.justify-center`, `.justify-between`, `.justify-around`, `.justify-evenly`
|
|
253
|
+
|
|
254
|
+
### Aspect Ratio
|
|
255
|
+
|
|
256
|
+
```html
|
|
257
|
+
<div class="col-4 aspect-square">Square</div>
|
|
258
|
+
<div class="col-8 aspect-video">16:9 Video</div>
|
|
259
|
+
<div class="col-6 aspect-4-3">4:3</div>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Display Utilities
|
|
263
|
+
|
|
264
|
+
```html
|
|
265
|
+
<!-- Static -->
|
|
266
|
+
<div class="hidden">Always hidden</div>
|
|
267
|
+
|
|
268
|
+
<!-- Responsive (container-based) -->
|
|
269
|
+
<div class="hidden-md">Hidden on medium+ containers</div>
|
|
270
|
+
<div class="block-lg">Shows as block on large+ containers</div>
|
|
271
|
+
|
|
272
|
+
<!-- Responsive (viewport-based) -->
|
|
273
|
+
<div class="hidden-vp-md">Hidden on medium+ viewports</div>
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Sizing Utilities
|
|
277
|
+
|
|
278
|
+
```html
|
|
279
|
+
<div class="col-min">Shrinks to min content</div>
|
|
280
|
+
<div class="col-max">Expands to max content</div>
|
|
281
|
+
<div class="col-fit">Fits content</div>
|
|
282
|
+
<div class="col-auto">Auto-sized</div>
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Order
|
|
286
|
+
|
|
287
|
+
```html
|
|
288
|
+
<div class="col-6 order-last">Appears last</div>
|
|
289
|
+
<div class="col-6 order-first">Appears first</div>
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## 🎨 Customization
|
|
293
|
+
|
|
294
|
+
Override CSS custom properties in your own stylesheet:
|
|
295
|
+
|
|
296
|
+
```css
|
|
297
|
+
:root {
|
|
298
|
+
/* Change default gap */
|
|
299
|
+
--grid-gap: 1.5rem;
|
|
300
|
+
|
|
301
|
+
/* Change column count (affects all calculations) */
|
|
302
|
+
--grid-columns: 16;
|
|
303
|
+
|
|
304
|
+
/* Change container max width */
|
|
305
|
+
--grid-wrap-max-width: 1400px;
|
|
306
|
+
--grid-wrap-width: 95vw;
|
|
307
|
+
|
|
308
|
+
/* Customize gap scale */
|
|
309
|
+
--grid-gap-sm: 0.75rem;
|
|
310
|
+
--grid-gap-lg: 4rem;
|
|
311
|
+
|
|
312
|
+
/* Customize fluid layouts */
|
|
313
|
+
--grid-auto-min: 300px; /* For grid-auto-fit */
|
|
314
|
+
--col-min-width: 250px; /* For col-fluid */
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Using SCSS Source
|
|
319
|
+
|
|
320
|
+
For advanced customization, import the SCSS source:
|
|
321
|
+
|
|
322
|
+
```scss
|
|
323
|
+
// Override variables before import
|
|
324
|
+
$grid-columns: 16;
|
|
325
|
+
$grid-gap-default: 2rem;
|
|
326
|
+
$breakpoints: (
|
|
327
|
+
sm: 576px,
|
|
328
|
+
md: 768px,
|
|
329
|
+
lg: 992px,
|
|
330
|
+
xl: 1200px,
|
|
331
|
+
xxl: 1600px
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
@use 'dot-grid/src/grid';
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## 🌐 Browser Support
|
|
338
|
+
|
|
339
|
+
- **Container Queries:** Chrome 105+, Safari 16+, Firefox 110+ (Feb 2023+)
|
|
340
|
+
- **Subgrid:** Chrome 117+, Safari 16+, Firefox 71+ (2023+)
|
|
341
|
+
- **CSS Grid:** All modern browsers (2017+)
|
|
342
|
+
- **Cascade Layers:** Chrome 99+, Safari 15.4+, Firefox 97+ (2022+)
|
|
343
|
+
|
|
344
|
+
For older browsers, the basic grid system will still work. Container queries will fall back to mobile-first behavior.
|
|
345
|
+
|
|
346
|
+
## 📝 Examples
|
|
347
|
+
|
|
348
|
+
See the `/examples` directory for complete working examples:
|
|
349
|
+
|
|
350
|
+
- `basic.html` - Core grid features
|
|
351
|
+
- `container-queries.html` - Container query responsive layouts
|
|
352
|
+
- `fluid-layout.html` - Auto-responsive fluid grids
|
|
353
|
+
- `subgrid.html` - Subgrid alignment examples
|
|
354
|
+
|
|
355
|
+
## 🆚 Migration from Original CodePen
|
|
356
|
+
|
|
357
|
+
### Breaking Changes
|
|
358
|
+
|
|
359
|
+
1. **Container queries by default** - Responsive classes now use `@container` instead of `@media`
|
|
360
|
+
- **Migration:** Use `.col-vp-{size}-{num}` if you need viewport-based behavior
|
|
361
|
+
|
|
362
|
+
2. **Placement utilities fixed** - `align-items: top` → `align-items: start`
|
|
363
|
+
- **Migration:** No action needed, now uses correct CSS values
|
|
364
|
+
|
|
365
|
+
3. **New breakpoints** - Added `xxl` (1536px), adjusted `lg` from 1025px to 1024px
|
|
366
|
+
- **Migration:** Update breakpoints in your HTML if using exact pixel values
|
|
367
|
+
|
|
368
|
+
### New Features (Additive)
|
|
369
|
+
|
|
370
|
+
- Subgrid support
|
|
371
|
+
- Fluid layout utilities
|
|
372
|
+
- More gap utilities
|
|
373
|
+
- Aspect ratio utilities
|
|
374
|
+
- Display utilities
|
|
375
|
+
- CSS custom properties
|
|
376
|
+
|
|
377
|
+
## 📄 License
|
|
378
|
+
|
|
379
|
+
MIT © Jean Loberg
|
|
380
|
+
|
|
381
|
+
## 🤝 Contributing
|
|
382
|
+
|
|
383
|
+
Issues and pull requests welcome at [github.com/lobergdesign/dot-grid](https://github.com/lobergdesign/dot-grid)
|