taffy-js 0.2.9 → 0.2.11
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 +108 -12
- package/package.json +3 -2
- package/pkg/README.md +108 -12
- package/pkg/package.json +1 -1
- package/pkg/taffy_wasm.d.ts +308 -6
- package/pkg/taffy_wasm.js +543 -12
- package/pkg/taffy_wasm_bg.wasm +0 -0
- package/pkg/taffy_wasm_bg.wasm.d.ts +32 -0
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ npm install taffy-js
|
|
|
22
22
|
|
|
23
23
|
## 🚀 Quick Start
|
|
24
24
|
|
|
25
|
-
```
|
|
25
|
+
```typescript
|
|
26
26
|
import {
|
|
27
27
|
loadTaffy,
|
|
28
28
|
TaffyTree,
|
|
@@ -147,26 +147,29 @@ class Style {
|
|
|
147
147
|
// Layout Mode
|
|
148
148
|
display: Display; // Block, Flex, Grid, None
|
|
149
149
|
position: Position; // Relative, Absolute
|
|
150
|
+
boxSizing: BoxSizing; // BorderBox, ContentBox
|
|
151
|
+
overflow: Point<Overflow>; // Overflow handling
|
|
150
152
|
|
|
151
|
-
// Flexbox
|
|
153
|
+
// Flexbox Properties
|
|
152
154
|
flexDirection: FlexDirection; // Row, Column, RowReverse, ColumnReverse
|
|
153
155
|
flexWrap: FlexWrap; // NoWrap, Wrap, WrapReverse
|
|
154
156
|
flexGrow: number; // Growth factor (default: 0)
|
|
155
157
|
flexShrink: number; // Shrink factor (default: 1)
|
|
156
158
|
flexBasis: Dimension; // Initial size
|
|
157
159
|
|
|
158
|
-
// Alignment
|
|
160
|
+
// Alignment Properties
|
|
159
161
|
alignItems: AlignItems | undefined;
|
|
160
162
|
alignSelf: AlignSelf | undefined;
|
|
161
163
|
alignContent: AlignContent | undefined;
|
|
162
164
|
justifyContent: JustifyContent | undefined;
|
|
165
|
+
justifyItems: AlignItems | undefined; // Grid container default justify
|
|
166
|
+
justifySelf: AlignSelf | undefined; // Grid item self-justify
|
|
163
167
|
|
|
164
168
|
// Sizing
|
|
165
169
|
size: Size<Dimension>; // Width and height
|
|
166
170
|
minSize: Size<Dimension>; // Minimum constraints
|
|
167
171
|
maxSize: Size<Dimension>; // Maximum constraints
|
|
168
172
|
aspectRatio: number | undefined; // Width/height ratio
|
|
169
|
-
boxSizing: BoxSizing; // BorderBox, ContentBox
|
|
170
173
|
|
|
171
174
|
// Spacing
|
|
172
175
|
margin: Rect<LengthPercentageAuto>;
|
|
@@ -175,8 +178,25 @@ class Style {
|
|
|
175
178
|
gap: Size<LengthPercentage>; // Row and column gap
|
|
176
179
|
inset: Rect<LengthPercentageAuto>; // For absolute positioning
|
|
177
180
|
|
|
178
|
-
//
|
|
179
|
-
|
|
181
|
+
// Block Layout Properties
|
|
182
|
+
itemIsTable: boolean; // Is this a table element?
|
|
183
|
+
itemIsReplaced: boolean; // Is this a replaced element (img, video)?
|
|
184
|
+
textAlign: TextAlign; // Legacy text alignment
|
|
185
|
+
scrollbarWidth: number; // Scrollbar gutter width in pixels
|
|
186
|
+
|
|
187
|
+
// CSS Grid Container Properties
|
|
188
|
+
gridAutoFlow: GridAutoFlow; // Row, Column, RowDense, ColumnDense
|
|
189
|
+
gridTemplateRows: GridTrack[]; // Track sizing for rows
|
|
190
|
+
gridTemplateColumns: GridTrack[]; // Track sizing for columns
|
|
191
|
+
gridAutoRows: TrackSizing[]; // Size for implicit rows
|
|
192
|
+
gridAutoColumns: TrackSizing[]; // Size for implicit columns
|
|
193
|
+
gridTemplateAreas: GridArea[]; // Named grid areas
|
|
194
|
+
gridTemplateRowNames: string[][]; // Named lines between rows
|
|
195
|
+
gridTemplateColumnNames: string[][]; // Named lines between columns
|
|
196
|
+
|
|
197
|
+
// CSS Grid Item Properties
|
|
198
|
+
gridRow: Line<GridPlacement>; // grid-row (start/end)
|
|
199
|
+
gridColumn: Line<GridPlacement>; // grid-column (start/end)
|
|
180
200
|
}
|
|
181
201
|
```
|
|
182
202
|
|
|
@@ -290,14 +310,26 @@ enum JustifyContent {
|
|
|
290
310
|
}
|
|
291
311
|
enum Overflow {
|
|
292
312
|
Visible,
|
|
313
|
+
Clip,
|
|
293
314
|
Hidden,
|
|
294
315
|
Scroll,
|
|
295
|
-
Auto,
|
|
296
316
|
}
|
|
297
317
|
enum BoxSizing {
|
|
298
318
|
BorderBox,
|
|
299
319
|
ContentBox,
|
|
300
320
|
}
|
|
321
|
+
enum TextAlign {
|
|
322
|
+
Auto,
|
|
323
|
+
LegacyLeft,
|
|
324
|
+
LegacyRight,
|
|
325
|
+
LegacyCenter,
|
|
326
|
+
}
|
|
327
|
+
enum GridAutoFlow {
|
|
328
|
+
Row,
|
|
329
|
+
Column,
|
|
330
|
+
RowDense,
|
|
331
|
+
ColumnDense,
|
|
332
|
+
}
|
|
301
333
|
```
|
|
302
334
|
|
|
303
335
|
### Types
|
|
@@ -327,6 +359,24 @@ interface Point<T> {
|
|
|
327
359
|
// Available space for layout computation
|
|
328
360
|
type AvailableSpace = number | "minContent" | "maxContent";
|
|
329
361
|
|
|
362
|
+
// Grid Placement (CSS grid-row-start / grid-column-start)
|
|
363
|
+
type GridPlacement = "auto" | number | { span: number };
|
|
364
|
+
|
|
365
|
+
// Grid Line (CSS grid-row / grid-column shorthand)
|
|
366
|
+
interface Line<T> {
|
|
367
|
+
start: T;
|
|
368
|
+
end: T;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Grid Template Area
|
|
372
|
+
interface GridArea {
|
|
373
|
+
name: string;
|
|
374
|
+
row_start: number;
|
|
375
|
+
row_end: number;
|
|
376
|
+
column_start: number;
|
|
377
|
+
column_end: number;
|
|
378
|
+
}
|
|
379
|
+
|
|
330
380
|
// Measure function for custom content measurement
|
|
331
381
|
type MeasureFunction = (
|
|
332
382
|
knownDimensions: Size<number | undefined>,
|
|
@@ -341,7 +391,7 @@ type MeasureFunction = (
|
|
|
341
391
|
|
|
342
392
|
For text nodes or other content that needs dynamic measurement:
|
|
343
393
|
|
|
344
|
-
```
|
|
394
|
+
```typescript
|
|
345
395
|
const textNode = tree.newLeafWithContext(textStyle, { text: "Hello, World!" });
|
|
346
396
|
|
|
347
397
|
tree.computeLayoutWithMeasure(
|
|
@@ -363,7 +413,7 @@ tree.computeLayoutWithMeasure(
|
|
|
363
413
|
|
|
364
414
|
Methods that can fail throw a `TaffyError` as a JavaScript exception. Use try-catch to handle errors:
|
|
365
415
|
|
|
366
|
-
```
|
|
416
|
+
```typescript
|
|
367
417
|
try {
|
|
368
418
|
const nodeId = tree.newLeaf(style);
|
|
369
419
|
console.log("Created node:", nodeId);
|
|
@@ -386,7 +436,7 @@ Taffy-JS works in all modern browsers that support WebAssembly:
|
|
|
386
436
|
|
|
387
437
|
### Flexbox Row Layout
|
|
388
438
|
|
|
389
|
-
```
|
|
439
|
+
```typescript
|
|
390
440
|
const rowStyle = new Style();
|
|
391
441
|
rowStyle.display = Display.Flex;
|
|
392
442
|
rowStyle.flexDirection = FlexDirection.Row;
|
|
@@ -394,9 +444,46 @@ rowStyle.justifyContent = JustifyContent.SpaceBetween;
|
|
|
394
444
|
rowStyle.gap = { width: 10, height: 0 };
|
|
395
445
|
```
|
|
396
446
|
|
|
447
|
+
### CSS Grid Layout
|
|
448
|
+
|
|
449
|
+
```typescript
|
|
450
|
+
import { Style, Display, GridAutoFlow } from "taffy-js";
|
|
451
|
+
|
|
452
|
+
const gridStyle = new Style();
|
|
453
|
+
gridStyle.display = Display.Grid;
|
|
454
|
+
gridStyle.gridAutoFlow = GridAutoFlow.Row;
|
|
455
|
+
gridStyle.gap = { width: 10, height: 10 };
|
|
456
|
+
|
|
457
|
+
// Grid item placement
|
|
458
|
+
const itemStyle = new Style();
|
|
459
|
+
itemStyle.gridRow = { start: 1, end: 3 }; // Spans 2 rows
|
|
460
|
+
itemStyle.gridColumn = { start: 1, end: { span: 2 } }; // Spans 2 columns
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### Grid Template Areas
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
const gridStyle = new Style();
|
|
467
|
+
gridStyle.display = Display.Grid;
|
|
468
|
+
gridStyle.gridTemplateAreas = [
|
|
469
|
+
{ name: "header", row_start: 1, row_end: 2, column_start: 1, column_end: 4 },
|
|
470
|
+
{ name: "sidebar", row_start: 2, row_end: 4, column_start: 1, column_end: 2 },
|
|
471
|
+
{ name: "main", row_start: 2, row_end: 4, column_start: 2, column_end: 4 },
|
|
472
|
+
{ name: "footer", row_start: 4, row_end: 5, column_start: 1, column_end: 4 },
|
|
473
|
+
];
|
|
474
|
+
|
|
475
|
+
// Named grid lines
|
|
476
|
+
gridStyle.gridTemplateRowNames = [
|
|
477
|
+
["header-start"],
|
|
478
|
+
["header-end", "content-start"],
|
|
479
|
+
["content-end", "footer-start"],
|
|
480
|
+
["footer-end"],
|
|
481
|
+
];
|
|
482
|
+
```
|
|
483
|
+
|
|
397
484
|
### Absolute Positioning
|
|
398
485
|
|
|
399
|
-
```
|
|
486
|
+
```typescript
|
|
400
487
|
const absoluteStyle = new Style();
|
|
401
488
|
absoluteStyle.position = Position.Absolute;
|
|
402
489
|
absoluteStyle.inset = { left: 10, top: 10, right: "auto", bottom: "auto" };
|
|
@@ -405,7 +492,7 @@ absoluteStyle.size = { width: 100, height: 50 };
|
|
|
405
492
|
|
|
406
493
|
### Percentage Sizing
|
|
407
494
|
|
|
408
|
-
```
|
|
495
|
+
```typescript
|
|
409
496
|
const percentStyle = new Style();
|
|
410
497
|
percentStyle.size = {
|
|
411
498
|
width: "50%", // 50% of parent
|
|
@@ -413,6 +500,15 @@ percentStyle.size = {
|
|
|
413
500
|
};
|
|
414
501
|
```
|
|
415
502
|
|
|
503
|
+
### Block Layout with Replaced Elements
|
|
504
|
+
|
|
505
|
+
```typescript
|
|
506
|
+
const imgStyle = new Style();
|
|
507
|
+
imgStyle.itemIsReplaced = true;
|
|
508
|
+
imgStyle.aspectRatio = 16 / 9; // 16:9 aspect ratio
|
|
509
|
+
imgStyle.size = { width: "100%", height: "auto" };
|
|
510
|
+
```
|
|
511
|
+
|
|
416
512
|
## 🏗️ Building from Source
|
|
417
513
|
|
|
418
514
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "taffy-js",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "WebAssembly bindings for Taffy layout library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"layout",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"build:dev": "wasm-pack build --dev --target web && npm run patch-dts && npm run build:ts",
|
|
46
46
|
"docs": "typedoc && prettier --write docs",
|
|
47
47
|
"patch-dts": "npx tsx scripts/patch-dts.ts",
|
|
48
|
-
"test": "
|
|
48
|
+
"test": "vitest run",
|
|
49
49
|
"prepare": "husky"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"typedoc": "^0.28.15",
|
|
60
60
|
"typedoc-plugin-markdown": "^4.9.0",
|
|
61
61
|
"typescript": "^5.7.0",
|
|
62
|
+
"vitest": "^4.0.16",
|
|
62
63
|
"wasm-pack": "^0.13.1"
|
|
63
64
|
},
|
|
64
65
|
"engines": {
|
package/pkg/README.md
CHANGED
|
@@ -22,7 +22,7 @@ npm install taffy-js
|
|
|
22
22
|
|
|
23
23
|
## 🚀 Quick Start
|
|
24
24
|
|
|
25
|
-
```
|
|
25
|
+
```typescript
|
|
26
26
|
import {
|
|
27
27
|
loadTaffy,
|
|
28
28
|
TaffyTree,
|
|
@@ -147,26 +147,29 @@ class Style {
|
|
|
147
147
|
// Layout Mode
|
|
148
148
|
display: Display; // Block, Flex, Grid, None
|
|
149
149
|
position: Position; // Relative, Absolute
|
|
150
|
+
boxSizing: BoxSizing; // BorderBox, ContentBox
|
|
151
|
+
overflow: Point<Overflow>; // Overflow handling
|
|
150
152
|
|
|
151
|
-
// Flexbox
|
|
153
|
+
// Flexbox Properties
|
|
152
154
|
flexDirection: FlexDirection; // Row, Column, RowReverse, ColumnReverse
|
|
153
155
|
flexWrap: FlexWrap; // NoWrap, Wrap, WrapReverse
|
|
154
156
|
flexGrow: number; // Growth factor (default: 0)
|
|
155
157
|
flexShrink: number; // Shrink factor (default: 1)
|
|
156
158
|
flexBasis: Dimension; // Initial size
|
|
157
159
|
|
|
158
|
-
// Alignment
|
|
160
|
+
// Alignment Properties
|
|
159
161
|
alignItems: AlignItems | undefined;
|
|
160
162
|
alignSelf: AlignSelf | undefined;
|
|
161
163
|
alignContent: AlignContent | undefined;
|
|
162
164
|
justifyContent: JustifyContent | undefined;
|
|
165
|
+
justifyItems: AlignItems | undefined; // Grid container default justify
|
|
166
|
+
justifySelf: AlignSelf | undefined; // Grid item self-justify
|
|
163
167
|
|
|
164
168
|
// Sizing
|
|
165
169
|
size: Size<Dimension>; // Width and height
|
|
166
170
|
minSize: Size<Dimension>; // Minimum constraints
|
|
167
171
|
maxSize: Size<Dimension>; // Maximum constraints
|
|
168
172
|
aspectRatio: number | undefined; // Width/height ratio
|
|
169
|
-
boxSizing: BoxSizing; // BorderBox, ContentBox
|
|
170
173
|
|
|
171
174
|
// Spacing
|
|
172
175
|
margin: Rect<LengthPercentageAuto>;
|
|
@@ -175,8 +178,25 @@ class Style {
|
|
|
175
178
|
gap: Size<LengthPercentage>; // Row and column gap
|
|
176
179
|
inset: Rect<LengthPercentageAuto>; // For absolute positioning
|
|
177
180
|
|
|
178
|
-
//
|
|
179
|
-
|
|
181
|
+
// Block Layout Properties
|
|
182
|
+
itemIsTable: boolean; // Is this a table element?
|
|
183
|
+
itemIsReplaced: boolean; // Is this a replaced element (img, video)?
|
|
184
|
+
textAlign: TextAlign; // Legacy text alignment
|
|
185
|
+
scrollbarWidth: number; // Scrollbar gutter width in pixels
|
|
186
|
+
|
|
187
|
+
// CSS Grid Container Properties
|
|
188
|
+
gridAutoFlow: GridAutoFlow; // Row, Column, RowDense, ColumnDense
|
|
189
|
+
gridTemplateRows: GridTrack[]; // Track sizing for rows
|
|
190
|
+
gridTemplateColumns: GridTrack[]; // Track sizing for columns
|
|
191
|
+
gridAutoRows: TrackSizing[]; // Size for implicit rows
|
|
192
|
+
gridAutoColumns: TrackSizing[]; // Size for implicit columns
|
|
193
|
+
gridTemplateAreas: GridArea[]; // Named grid areas
|
|
194
|
+
gridTemplateRowNames: string[][]; // Named lines between rows
|
|
195
|
+
gridTemplateColumnNames: string[][]; // Named lines between columns
|
|
196
|
+
|
|
197
|
+
// CSS Grid Item Properties
|
|
198
|
+
gridRow: Line<GridPlacement>; // grid-row (start/end)
|
|
199
|
+
gridColumn: Line<GridPlacement>; // grid-column (start/end)
|
|
180
200
|
}
|
|
181
201
|
```
|
|
182
202
|
|
|
@@ -290,14 +310,26 @@ enum JustifyContent {
|
|
|
290
310
|
}
|
|
291
311
|
enum Overflow {
|
|
292
312
|
Visible,
|
|
313
|
+
Clip,
|
|
293
314
|
Hidden,
|
|
294
315
|
Scroll,
|
|
295
|
-
Auto,
|
|
296
316
|
}
|
|
297
317
|
enum BoxSizing {
|
|
298
318
|
BorderBox,
|
|
299
319
|
ContentBox,
|
|
300
320
|
}
|
|
321
|
+
enum TextAlign {
|
|
322
|
+
Auto,
|
|
323
|
+
LegacyLeft,
|
|
324
|
+
LegacyRight,
|
|
325
|
+
LegacyCenter,
|
|
326
|
+
}
|
|
327
|
+
enum GridAutoFlow {
|
|
328
|
+
Row,
|
|
329
|
+
Column,
|
|
330
|
+
RowDense,
|
|
331
|
+
ColumnDense,
|
|
332
|
+
}
|
|
301
333
|
```
|
|
302
334
|
|
|
303
335
|
### Types
|
|
@@ -327,6 +359,24 @@ interface Point<T> {
|
|
|
327
359
|
// Available space for layout computation
|
|
328
360
|
type AvailableSpace = number | "minContent" | "maxContent";
|
|
329
361
|
|
|
362
|
+
// Grid Placement (CSS grid-row-start / grid-column-start)
|
|
363
|
+
type GridPlacement = "auto" | number | { span: number };
|
|
364
|
+
|
|
365
|
+
// Grid Line (CSS grid-row / grid-column shorthand)
|
|
366
|
+
interface Line<T> {
|
|
367
|
+
start: T;
|
|
368
|
+
end: T;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Grid Template Area
|
|
372
|
+
interface GridArea {
|
|
373
|
+
name: string;
|
|
374
|
+
row_start: number;
|
|
375
|
+
row_end: number;
|
|
376
|
+
column_start: number;
|
|
377
|
+
column_end: number;
|
|
378
|
+
}
|
|
379
|
+
|
|
330
380
|
// Measure function for custom content measurement
|
|
331
381
|
type MeasureFunction = (
|
|
332
382
|
knownDimensions: Size<number | undefined>,
|
|
@@ -341,7 +391,7 @@ type MeasureFunction = (
|
|
|
341
391
|
|
|
342
392
|
For text nodes or other content that needs dynamic measurement:
|
|
343
393
|
|
|
344
|
-
```
|
|
394
|
+
```typescript
|
|
345
395
|
const textNode = tree.newLeafWithContext(textStyle, { text: "Hello, World!" });
|
|
346
396
|
|
|
347
397
|
tree.computeLayoutWithMeasure(
|
|
@@ -363,7 +413,7 @@ tree.computeLayoutWithMeasure(
|
|
|
363
413
|
|
|
364
414
|
Methods that can fail throw a `TaffyError` as a JavaScript exception. Use try-catch to handle errors:
|
|
365
415
|
|
|
366
|
-
```
|
|
416
|
+
```typescript
|
|
367
417
|
try {
|
|
368
418
|
const nodeId = tree.newLeaf(style);
|
|
369
419
|
console.log("Created node:", nodeId);
|
|
@@ -386,7 +436,7 @@ Taffy-JS works in all modern browsers that support WebAssembly:
|
|
|
386
436
|
|
|
387
437
|
### Flexbox Row Layout
|
|
388
438
|
|
|
389
|
-
```
|
|
439
|
+
```typescript
|
|
390
440
|
const rowStyle = new Style();
|
|
391
441
|
rowStyle.display = Display.Flex;
|
|
392
442
|
rowStyle.flexDirection = FlexDirection.Row;
|
|
@@ -394,9 +444,46 @@ rowStyle.justifyContent = JustifyContent.SpaceBetween;
|
|
|
394
444
|
rowStyle.gap = { width: 10, height: 0 };
|
|
395
445
|
```
|
|
396
446
|
|
|
447
|
+
### CSS Grid Layout
|
|
448
|
+
|
|
449
|
+
```typescript
|
|
450
|
+
import { Style, Display, GridAutoFlow } from "taffy-js";
|
|
451
|
+
|
|
452
|
+
const gridStyle = new Style();
|
|
453
|
+
gridStyle.display = Display.Grid;
|
|
454
|
+
gridStyle.gridAutoFlow = GridAutoFlow.Row;
|
|
455
|
+
gridStyle.gap = { width: 10, height: 10 };
|
|
456
|
+
|
|
457
|
+
// Grid item placement
|
|
458
|
+
const itemStyle = new Style();
|
|
459
|
+
itemStyle.gridRow = { start: 1, end: 3 }; // Spans 2 rows
|
|
460
|
+
itemStyle.gridColumn = { start: 1, end: { span: 2 } }; // Spans 2 columns
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### Grid Template Areas
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
const gridStyle = new Style();
|
|
467
|
+
gridStyle.display = Display.Grid;
|
|
468
|
+
gridStyle.gridTemplateAreas = [
|
|
469
|
+
{ name: "header", row_start: 1, row_end: 2, column_start: 1, column_end: 4 },
|
|
470
|
+
{ name: "sidebar", row_start: 2, row_end: 4, column_start: 1, column_end: 2 },
|
|
471
|
+
{ name: "main", row_start: 2, row_end: 4, column_start: 2, column_end: 4 },
|
|
472
|
+
{ name: "footer", row_start: 4, row_end: 5, column_start: 1, column_end: 4 },
|
|
473
|
+
];
|
|
474
|
+
|
|
475
|
+
// Named grid lines
|
|
476
|
+
gridStyle.gridTemplateRowNames = [
|
|
477
|
+
["header-start"],
|
|
478
|
+
["header-end", "content-start"],
|
|
479
|
+
["content-end", "footer-start"],
|
|
480
|
+
["footer-end"],
|
|
481
|
+
];
|
|
482
|
+
```
|
|
483
|
+
|
|
397
484
|
### Absolute Positioning
|
|
398
485
|
|
|
399
|
-
```
|
|
486
|
+
```typescript
|
|
400
487
|
const absoluteStyle = new Style();
|
|
401
488
|
absoluteStyle.position = Position.Absolute;
|
|
402
489
|
absoluteStyle.inset = { left: 10, top: 10, right: "auto", bottom: "auto" };
|
|
@@ -405,7 +492,7 @@ absoluteStyle.size = { width: 100, height: 50 };
|
|
|
405
492
|
|
|
406
493
|
### Percentage Sizing
|
|
407
494
|
|
|
408
|
-
```
|
|
495
|
+
```typescript
|
|
409
496
|
const percentStyle = new Style();
|
|
410
497
|
percentStyle.size = {
|
|
411
498
|
width: "50%", // 50% of parent
|
|
@@ -413,6 +500,15 @@ percentStyle.size = {
|
|
|
413
500
|
};
|
|
414
501
|
```
|
|
415
502
|
|
|
503
|
+
### Block Layout with Replaced Elements
|
|
504
|
+
|
|
505
|
+
```typescript
|
|
506
|
+
const imgStyle = new Style();
|
|
507
|
+
imgStyle.itemIsReplaced = true;
|
|
508
|
+
imgStyle.aspectRatio = 16 / 9; // 16:9 aspect ratio
|
|
509
|
+
imgStyle.size = { width: "100%", height: "auto" };
|
|
510
|
+
```
|
|
511
|
+
|
|
416
512
|
## 🏗️ Building from Source
|
|
417
513
|
|
|
418
514
|
```bash
|