|
11 | 11 | [](https://npmjs.com/package/svelte-bricks)
|
12 | 12 | [](https://app.netlify.com/sites/svelte-bricks/deploys)
|
13 | 13 | [](https://results.pre-commit.ci/latest/github/janosh/svelte-bricks/main)
|
14 |
| -[](https://stackblitz.com/github/janosh/svelte-bricks) |
| 14 | +[](https://stackblitz.com/github/janosh/svelte-bricks) |
15 | 15 |
|
16 | 16 | </h4>
|
17 | 17 |
|
|
67 | 67 |
|
68 | 68 | Additional optional props are:
|
69 | 69 |
|
70 |
| -- `items: (string | number | object)[]`: required |
71 |
| -- `minColWidth: number = 330` (in `px`) |
72 |
| -- `maxColWidth: number = 500` (in `px`) |
73 |
| -- `gap: number = 20` (in `px`) |
74 |
| -- `masonryWidth: number = 0`: Bound to the masonry `div`s width (in `px`). |
75 |
| -- `masonryHeight: number = 0`: Bound to the masonry `div`s height (in `px`). |
76 |
| -- `idKey: string = 'id'`: Name of the attribute to use as identifier if items are objects. |
77 |
| -- `getId: (item) => string | number`: Custom function that maps masonry items to unique IDs. |
78 |
| -- `animate: boolean = true`: Whether to [FLIP-animate](https://svelte.dev/tutorial/animate) masonry items when viewport resizing or other events cause `items` to rearrange. |
79 |
| -- `style: string = ''`: Inline styles that will be applied to the top-level `div.masonry`. |
80 |
| -- `duration: number = 200`: Transition duration in milli seconds when masonry items are rearranged or added/removed. Set to 0 to disable transitions. |
81 |
| -- `class: string = ''`: Applies to the outer `div` wrapping all masonry columns. For use with CSS frameworks like Tailwind. |
82 |
| -- `columnClass: string = ''`: Applies to each column `div`. |
| 70 | +1. ```ts |
| 71 | + animate: boolean = true |
| 72 | + ``` |
| 73 | + |
| 74 | + Whether to [FLIP-animate](https://svelte.dev/tutorial/animate) masonry items when viewport resizing or other events cause `items` to rearrange. |
| 75 | + |
| 76 | +1. ```ts |
| 77 | + class: string = '' |
| 78 | + ``` |
| 79 | + |
| 80 | + Applies to the outer `div` wrapping all masonry columns. For use with CSS frameworks like Tailwind. |
| 81 | + |
| 82 | +1. ```ts |
| 83 | + columnClass: string = '' |
| 84 | + ``` |
| 85 | + |
| 86 | + Applies to each column `div`. |
| 87 | + |
| 88 | +1. ```ts |
| 89 | + duration: number = 200 |
| 90 | + ``` |
| 91 | + |
| 92 | + Transition duration in milli seconds when masonry items are rearranged or added/removed. Set to 0 to disable transitions. |
| 93 | + |
| 94 | +1. ```ts |
| 95 | + gap: number = 20 |
| 96 | + ``` |
| 97 | + |
| 98 | + Gap between columns and items within each column in `px`. |
| 99 | + |
| 100 | +1. ```ts |
| 101 | + getId: (Item) => string | number = (item: Item) => { |
| 102 | + if (typeof item === `number`) return item |
| 103 | + if (typeof item === `string`) return item |
| 104 | + return (item as Record<string, unknown>)[idKey] |
| 105 | + } |
| 106 | + ``` |
| 107 | + |
| 108 | + Custom function that maps masonry items to unique IDs of type `string` or `number`. |
| 109 | + |
| 110 | +1. ```ts |
| 111 | + idKey: string = 'id' |
| 112 | + ``` |
| 113 | + |
| 114 | + Name of the attribute to use as identifier if items are objects. |
| 115 | + |
| 116 | +1. ```ts |
| 117 | + items: (string | number | object)[] |
| 118 | + ``` |
| 119 | + |
| 120 | + required |
| 121 | + |
| 122 | +1. ```ts |
| 123 | + masonryHeight: number = 0 |
| 124 | + ``` |
| 125 | + |
| 126 | + The masonry `div`s height in `px`. |
| 127 | + |
| 128 | +1. ```ts |
| 129 | + masonryWidth: number = 0 |
| 130 | + ``` |
| 131 | + |
| 132 | + The masonry `div`s width in `px`. |
| 133 | + |
| 134 | +1. ```ts |
| 135 | + maxColWidth: number = 500 |
| 136 | + ``` |
| 137 | + |
| 138 | + Maximum column width in `px`. |
| 139 | + |
| 140 | +1. ```ts |
| 141 | + minColWidth: number = 330 |
| 142 | + ``` |
| 143 | + |
| 144 | + Minimum column width in `px`. |
| 145 | + |
| 146 | +1. ```ts |
| 147 | + style: string = '' |
| 148 | + ``` |
| 149 | + |
| 150 | + Inline styles that will be applied to the top-level `div.masonry`. |
83 | 151 |
|
84 | 152 | ## Styling
|
85 | 153 |
|
|
0 commit comments