You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-13Lines changed: 60 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,11 @@
2
2
3
3
A web component that creates layouts by treating your HTML elements as rectangles and packing them using a best-fit 2D strip-packing algorithm.
4
4
5
-
## Why a Packing Algorithm for Web Layouts?
5
+
## ⚙️ Why a Packing Algorithm for Web Layouts?
6
6
7
7
Web browsers naturally manage elements as rectangles. `rectpackr-layout` leverages this by applying a best-fit strip-packing algorithm — the same approach used in industrial optimization problems — to web layout creation.
8
8
9
-
## Intelligent Layouts Through Automated Measurement
9
+
## 🤖 Layouts Through Automated Measurement
10
10
11
11
The algorithm intelligently works with whatever dimensional information is available:
12
12
@@ -31,7 +31,7 @@ The algorithm intelligently works with whatever dimensional information is avail
31
31
-**Production-ready precision** when you need exact control
32
32
-**Best of both worlds** — automation when you want it, control when you need it
33
33
34
-
## Installation
34
+
## 📥 Installation
35
35
36
36
### Install the package via your preferred package manager:
-`offset`: Uses CSS offset properties (`top`/`bottom` and `left`/`right`)
80
+
-`offset`: Uses CSS `inset` property for precise positioning
81
81
82
-
> **Performance Note:** The default `transform` value typically offers better performance through hardware acceleration. Use `offset` only when child elements already use `transform` for other purposes (animation etc.).
82
+
> 💡 **Performance Note:** The default `transform` value typically offers better performance through hardware acceleration. Use `offset` only when child elements already use `transform` for other purposes (animation etc.).
83
83
84
84
**`x-direction`**
85
85
@@ -97,21 +97,68 @@ Controls the vertical packing direction.
97
97
98
98
### A Note on Visual Order & Accessibility
99
99
100
-
The `x-direction` and `y-direction` attributes control visual placement, which may differ from DOM order.
100
+
The `x-direction` and `y-direction` attributes control visual placement, which may create a difference between the visual arrangement and the underlying DOM order.
101
101
102
-
-**DOM Order is Preserved:** The library never changes the underlying HTML structure, ensuring correct tab order and screen reader navigation
103
-
-**Visual Order is Optimized:** The algorithm places items for spatial efficiency, which may not match linear DOM order
102
+
-**DOM Order is Preserved:** The underlying HTML structure remains unchanged
103
+
-**Visual Order is Algorithm-Determined**: Item placement follows the packing logic and your direction settings
104
104
105
-
**Best Practice:** Ensure your HTML source reflects the logical reading order.
105
+
## 🚀 Usage Examples
106
106
107
-
## Browser Support
107
+
### Fluid, Responsive Layout
108
+
109
+
```html
110
+
<rectpackr-layout>
111
+
<div>Card 1</div>
112
+
<div>Card 2</div>
113
+
<div>Card 3</div>
114
+
</rectpackr-layout>
115
+
116
+
<style>
117
+
rectpackr-layout {
118
+
container-type: inline-size;
119
+
display: block;
120
+
}
121
+
122
+
rectpackr-layout>* {
123
+
/* Fluid width based on container queries */
124
+
width: 100%;
125
+
}
126
+
127
+
@container (min-width: 400px) {
128
+
rectpackr-layout>* {
129
+
width: 50%;
130
+
}
131
+
}
132
+
133
+
@container (min-width: 800px) {
134
+
rectpackr-layout>* {
135
+
width: 33.33%;
136
+
}
137
+
}
138
+
</style>
139
+
```
140
+
141
+
### Dynamic Content Handling
142
+
143
+
```html
144
+
<rectpackr-layoutid="dynamic-layout">
145
+
<!-- Content can be added/removed dynamically -->
146
+
</rectpackr-layout>
147
+
148
+
<script>
149
+
// The layout automatically adjusts to content changes
Copy file name to clipboardExpand all lines: package.json
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "rectpackr-layout",
3
-
"version": "0.8.0",
3
+
"version": "0.9.0",
4
4
"description": "A web component that creates layouts by packing HTML elements as rectangles using a best-fit 2D strip-packing algorithm. Automatically measures dimensions and handles mixed content.",
0 commit comments