@niche-works/css-layouts 0.1.0 → 0.2.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/README.ja.md +240 -0
- package/README.md +238 -1
- package/balance/balance.cjs +0 -1
- package/balance/balance.mjs +0 -1
- package/balance/balance.scss.cjs +1 -0
- package/balance/balance.scss.d.cts +1 -0
- package/balance/balance.scss.d.mts +1 -0
- package/balance/balance.scss.mjs +3 -0
- package/flow/flow.cjs +0 -1
- package/flow/flow.mjs +0 -1
- package/flow/flow.scss.cjs +1 -0
- package/flow/flow.scss.d.cts +1 -0
- package/flow/flow.scss.d.mts +1 -0
- package/flow/flow.scss.mjs +3 -0
- package/matrix/matrix.cjs +0 -1
- package/matrix/matrix.mjs +0 -1
- package/matrix/matrix.scss.cjs +1 -0
- package/matrix/matrix.scss.d.cts +1 -0
- package/matrix/matrix.scss.d.mts +1 -0
- package/matrix/matrix.scss.mjs +3 -0
- package/pack/pack.cjs +0 -1
- package/pack/pack.mjs +0 -1
- package/pack/pack.scss.cjs +1 -0
- package/pack/pack.scss.d.cts +1 -0
- package/pack/pack.scss.d.mts +1 -0
- package/pack/pack.scss.mjs +3 -0
- package/package.json +10 -2
- package/pin/pin.cjs +0 -1
- package/pin/pin.mjs +0 -1
- package/pin/pin.scss.cjs +1 -0
- package/pin/pin.scss.d.cts +1 -0
- package/pin/pin.scss.d.mts +1 -0
- package/pin/pin.scss.mjs +3 -0
- package/stack/stack.cjs +0 -1
- package/stack/stack.mjs +0 -1
- package/stack/stack.scss.cjs +1 -0
- package/stack/stack.scss.d.cts +1 -0
- package/stack/stack.scss.d.mts +1 -0
- package/stack/stack.scss.mjs +3 -0
- package/styles.css +653 -0
- package/styles.scss.cjs +1 -0
- package/styles.scss.d.cts +1 -0
- package/styles.scss.d.mts +1 -0
- package/styles.scss.mjs +3 -0
- package/tile/tile.cjs +0 -1
- package/tile/tile.mjs +0 -1
- package/tile/tile.scss.cjs +1 -0
- package/tile/tile.scss.d.cts +1 -0
- package/tile/tile.scss.d.mts +1 -0
- package/tile/tile.scss.mjs +3 -0
- /package/balance/{styles.css → balance.css} +0 -0
- /package/flow/{styles.css → flow.css} +0 -0
- /package/matrix/{styles.css → matrix.css} +0 -0
- /package/pack/{styles.css → pack.css} +0 -0
- /package/pin/{styles.css → pin.css} +0 -0
- /package/stack/{styles.css → stack.css} +0 -0
- /package/tile/{styles.css → tile.css} +0 -0
package/README.ja.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# @niche-works/css-layouts
|
|
2
|
+
|
|
3
|
+
`@niche-works/css-layouts` は、CSSによる子要素のレイアウト制御に特化したニッチなライブラリです。\
|
|
4
|
+
オプションに応じたクラス名とCSS変数をオブジェクトとして返します。フレームワーク非依存でSSRにも対応しています。
|
|
5
|
+
|
|
6
|
+
**[English README is available here](./README.md)**
|
|
7
|
+
|
|
8
|
+
## 特徴
|
|
9
|
+
|
|
10
|
+
- フレームワーク非依存(あらゆるJS環境で動作)
|
|
11
|
+
- SSR対応(クラス名とインラインスタイルオブジェクトを返すだけ)
|
|
12
|
+
- TypeScriptによる完全な型サポート
|
|
13
|
+
|
|
14
|
+
## インストール
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @niche-works/css-layouts
|
|
18
|
+
# または
|
|
19
|
+
pnpm add @niche-works/css-layouts
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 使い方
|
|
23
|
+
|
|
24
|
+
各レイアウト関数は `{ className, style }` オブジェクトを返します。コンテナ要素に適用してください。
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { stack } from '@niche-works/css-layouts';
|
|
28
|
+
|
|
29
|
+
const { className, style } = stack({
|
|
30
|
+
direction: 'x',
|
|
31
|
+
alignX: 'center',
|
|
32
|
+
alignY: 'middle',
|
|
33
|
+
spacing: '16px',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// className: "nws-layout-stack nws-layout-direction-x ..."
|
|
37
|
+
// style: { "--nws-layout-spacingX": "16px", ... }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<div class="nws-layout-stack ..." style="--nws-layout-spacingX: 16px; ...">
|
|
42
|
+
<div>Item 1</div>
|
|
43
|
+
<div>Item 2</div>
|
|
44
|
+
</div>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
> **注意:** ライブラリのCSSを別途インポートしてください。
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
// 全レイアウトをまとめてインポート
|
|
51
|
+
import '@niche-works/css-layouts/styles.css';
|
|
52
|
+
|
|
53
|
+
// 必要なレイアウトのみインポート
|
|
54
|
+
import '@niche-works/css-layouts/stack.css';
|
|
55
|
+
import '@niche-works/css-layouts/tile.css';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## レイアウト種別
|
|
59
|
+
|
|
60
|
+
### `stack`
|
|
61
|
+
|
|
62
|
+
子要素を縦または横方向に一列に並べます。
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { stack } from '@niche-works/css-layouts';
|
|
66
|
+
|
|
67
|
+
const { className, style } = stack({
|
|
68
|
+
direction: 'x', // 'x' | 'y' — デフォルト: 'x'
|
|
69
|
+
alignX: 'left', // 'left' | 'center' | 'right'
|
|
70
|
+
alignY: 'top', // 'top' | 'middle' | 'bottom'
|
|
71
|
+
adjustX: 'grow', // 'none' | 'grow' | 'shrink' | 'fit'
|
|
72
|
+
childSizeX: '200px',
|
|
73
|
+
spacing: '8px',
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### `flow`
|
|
78
|
+
|
|
79
|
+
`stack`と同様ですが、コンテナサイズを超えた場合に子要素を折り返します。
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { flow } from '@niche-works/css-layouts';
|
|
83
|
+
|
|
84
|
+
const { className, style } = flow({
|
|
85
|
+
direction: 'x',
|
|
86
|
+
alignX: 'left',
|
|
87
|
+
alignY: 'top',
|
|
88
|
+
adjustX: 'fit',
|
|
89
|
+
childSizeX: '200px',
|
|
90
|
+
spacing: '8px',
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
> 交差軸方向の `adjust` に `grow`、`shrink`、`fit` は指定できません。
|
|
95
|
+
|
|
96
|
+
### `matrix`
|
|
97
|
+
|
|
98
|
+
列数・行数を指定して子要素を格子状に並べます。
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { matrix } from '@niche-works/css-layouts';
|
|
102
|
+
|
|
103
|
+
const { className, style } = matrix({
|
|
104
|
+
direction: 'x',
|
|
105
|
+
childCountX: 3, // 必須(または childX)
|
|
106
|
+
childCountY: 2, // 必須(または childY)
|
|
107
|
+
childSizeX: '200px',
|
|
108
|
+
adjustX: 'fit',
|
|
109
|
+
spacing: '8px',
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
各軸で `childCountX` または `childX` のどちらか一方が必須です(両方は指定不可)。
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
// グリッドトラックを直接指定する場合
|
|
117
|
+
matrix({
|
|
118
|
+
childX: ['1fr', '2fr', '1fr'],
|
|
119
|
+
childCountY: 3,
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
> **注意:** このレイアウトはコンテナのサイズが外部から確定していることを前提としています。`width: max-content` など、子要素によってサイズが決まる親要素では、パーセンテージ値が意図通りに動作しない場合があります。
|
|
124
|
+
|
|
125
|
+
### `tile`
|
|
126
|
+
|
|
127
|
+
子要素のサイズを基準にして格子状に並べます。列数は親要素のサイズと子要素のサイズに応じて自動で決まります。
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
import { tile } from '@niche-works/css-layouts';
|
|
131
|
+
|
|
132
|
+
const { className, style } = tile({
|
|
133
|
+
direction: 'x',
|
|
134
|
+
childSizeX: '200px',
|
|
135
|
+
adjustX: 'fit',
|
|
136
|
+
spacing: '8px',
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
> **注意:** `matrix` と同様に、コンテナのサイズが外部から確定していることを前提としています。
|
|
141
|
+
|
|
142
|
+
### `balance`
|
|
143
|
+
|
|
144
|
+
子要素を一列に均等に並べます。
|
|
145
|
+
|
|
146
|
+
- `adjust` なし: 子要素のサイズを維持したまま、余白を均等に配分します
|
|
147
|
+
- `adjust` あり: 子要素のサイズを調整してコンテナを満たします
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
import { balance } from '@niche-works/css-layouts';
|
|
151
|
+
|
|
152
|
+
const { className, style } = balance({
|
|
153
|
+
direction: 'x',
|
|
154
|
+
adjustX: 'grow',
|
|
155
|
+
childSizeX: '200px',
|
|
156
|
+
spacing: '8px',
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### `pack`
|
|
161
|
+
|
|
162
|
+
子要素を親要素のサイズに合わせて均等にサイズ調整し並べます。
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
import { pack } from '@niche-works/css-layouts';
|
|
166
|
+
|
|
167
|
+
const { className, style } = pack({
|
|
168
|
+
direction: 'x', // 'x' | 'y' — デフォルト: 'x'
|
|
169
|
+
spacing: '8px',
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### `pin`
|
|
174
|
+
|
|
175
|
+
子要素を指定の座標に配置します。子要素は `top` / `left` / `bottom` / `right` スタイルで位置を指定してください。
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
import { pin } from '@niche-works/css-layouts';
|
|
179
|
+
|
|
180
|
+
const { className, style } = pin({
|
|
181
|
+
childSizeX: '100px',
|
|
182
|
+
childSizeY: '80px',
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## オプション
|
|
187
|
+
|
|
188
|
+
### オプション一覧
|
|
189
|
+
|
|
190
|
+
| オプション | 型 | 説明 |
|
|
191
|
+
| ------------- | ------------------------ | ---------------------------- |
|
|
192
|
+
| `direction` | `'x' \| 'y'` | 主軸の方向 |
|
|
193
|
+
| `alignX` | [`AlignX`](#alignx-の値) | 子要素の横位置 |
|
|
194
|
+
| `alignY` | [`AlignY`](#aligny-の値) | 子要素の縦位置 |
|
|
195
|
+
| `adjustX` | [`Adjust`](#adjust-の値) | 子要素の横方向のサイズ調整 |
|
|
196
|
+
| `adjustY` | [`Adjust`](#adjust-の値) | 子要素の縦方向のサイズ調整 |
|
|
197
|
+
| `spacing` | `string \| number` | 子要素間の余白(横縦共通) |
|
|
198
|
+
| `spacingX` | `string \| number` | 子要素間の余白(横方向) |
|
|
199
|
+
| `spacingY` | `string \| number` | 子要素間の余白(縦方向) |
|
|
200
|
+
| `childSizeX` | `string \| number` | 子要素の幅 |
|
|
201
|
+
| `childSizeY` | `string \| number` | 子要素の高さ |
|
|
202
|
+
| `childCountX` | `string \| number` | 子要素の横方向の数 |
|
|
203
|
+
| `childCountY` | `string \| number` | 子要素の縦方向の数 |
|
|
204
|
+
| `childX` | `(string \| number)[]` | 子要素の横方向の個々のサイズ |
|
|
205
|
+
| `childY` | `(string \| number)[]` | 子要素の縦方向の個々のサイズ |
|
|
206
|
+
|
|
207
|
+
### `Adjust` の値
|
|
208
|
+
|
|
209
|
+
| 値 | 子が親より小さい時 | 子が親より大きい時 |
|
|
210
|
+
| -------- | ------------------ | ------------------ |
|
|
211
|
+
| `none` | そのまま | そのまま |
|
|
212
|
+
| `grow` | 伸びる | そのまま |
|
|
213
|
+
| `shrink` | そのまま | 縮む |
|
|
214
|
+
| `fit` | 伸びる | 縮む |
|
|
215
|
+
|
|
216
|
+
### `AlignX` の値
|
|
217
|
+
|
|
218
|
+
`'left'` | `'center'` | `'right'` | `'space-between'` | `'space-around'` | `'space-evenly'`
|
|
219
|
+
|
|
220
|
+
### `AlignY` の値
|
|
221
|
+
|
|
222
|
+
`'top'` | `'middle'` | `'bottom'` | `'space-between'` | `'space-around'` | `'space-evenly'`
|
|
223
|
+
|
|
224
|
+
## 戻り値
|
|
225
|
+
|
|
226
|
+
全てのレイアウト関数は `LayoutResult` を返します。
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
type LayoutResult = {
|
|
230
|
+
className?: string;
|
|
231
|
+
style?: {
|
|
232
|
+
[key: string]: string | number | undefined;
|
|
233
|
+
[key: `--${string}`]: string | number | undefined;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## ライセンス
|
|
239
|
+
|
|
240
|
+
MIT
|
package/README.md
CHANGED
|
@@ -1,3 +1,240 @@
|
|
|
1
1
|
# @niche-works/css-layouts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@niche-works/css-layouts` is a niche library specialized in controlling child element layout with CSS.
|
|
4
|
+
It returns class names and CSS custom properties as an object based on the given options. Framework-agnostic and SSR-compatible.
|
|
5
|
+
|
|
6
|
+
**[日本語のREADMEはこちら](./README.ja.md)**
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- Framework-agnostic (works with any JS environment)
|
|
11
|
+
- SSR-compatible (returns plain class names and inline style objects)
|
|
12
|
+
- Fully typed with TypeScript
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @niche-works/css-layouts
|
|
18
|
+
# or
|
|
19
|
+
pnpm add @niche-works/css-layouts
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
Each layout function returns a `{ className, style }` object. Apply them to a container element.
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { stack } from '@niche-works/css-layouts';
|
|
28
|
+
|
|
29
|
+
const { className, style } = stack({
|
|
30
|
+
direction: 'x',
|
|
31
|
+
alignX: 'center',
|
|
32
|
+
alignY: 'middle',
|
|
33
|
+
spacing: '16px',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// className: "nws-layout-stack nws-layout-direction-x ..."
|
|
37
|
+
// style: { "--nws-layout-spacingX": "16px", ... }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<div class="nws-layout-stack ..." style="--nws-layout-spacingX: 16px; ...">
|
|
42
|
+
<div>Item 1</div>
|
|
43
|
+
<div>Item 2</div>
|
|
44
|
+
</div>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
> **Note:** You need to import the CSS separately.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
// Import all layouts at once
|
|
51
|
+
import '@niche-works/css-layouts/styles.css';
|
|
52
|
+
|
|
53
|
+
// Or import only what you need
|
|
54
|
+
import '@niche-works/css-layouts/stack.css';
|
|
55
|
+
import '@niche-works/css-layouts/tile.css';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Layout Types
|
|
59
|
+
|
|
60
|
+
### `stack`
|
|
61
|
+
|
|
62
|
+
Arranges child elements in a single row or column.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { stack } from '@niche-works/css-layouts';
|
|
66
|
+
|
|
67
|
+
const { className, style } = stack({
|
|
68
|
+
direction: 'x', // 'x' | 'y' — default: 'x'
|
|
69
|
+
alignX: 'left', // 'left' | 'center' | 'right'
|
|
70
|
+
alignY: 'top', // 'top' | 'middle' | 'bottom'
|
|
71
|
+
adjustX: 'grow', // 'none' | 'grow' | 'shrink' | 'fit'
|
|
72
|
+
childSizeX: '200px',
|
|
73
|
+
spacing: '8px',
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### `flow`
|
|
78
|
+
|
|
79
|
+
Like `stack`, but wraps child elements when they exceed the container size.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { flow } from '@niche-works/css-layouts';
|
|
83
|
+
|
|
84
|
+
const { className, style } = flow({
|
|
85
|
+
direction: 'x',
|
|
86
|
+
alignX: 'left',
|
|
87
|
+
alignY: 'top',
|
|
88
|
+
adjustX: 'fit',
|
|
89
|
+
childSizeX: '200px',
|
|
90
|
+
spacing: '8px',
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
> `grow`, `shrink`, and `fit` cannot be specified for `adjust` on the cross axis.
|
|
95
|
+
|
|
96
|
+
### `matrix`
|
|
97
|
+
|
|
98
|
+
Arranges child elements in a grid with explicit column and row counts.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { matrix } from '@niche-works/css-layouts';
|
|
102
|
+
|
|
103
|
+
const { className, style } = matrix({
|
|
104
|
+
direction: 'x',
|
|
105
|
+
childCountX: 3, // required (or childX)
|
|
106
|
+
childCountY: 2, // required (or childY)
|
|
107
|
+
childSizeX: '200px',
|
|
108
|
+
adjustX: 'fit',
|
|
109
|
+
spacing: '8px',
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Either `childCountX` or `childX` is required per axis (not both).
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
// Using explicit track templates
|
|
117
|
+
matrix({
|
|
118
|
+
childX: ['1fr', '2fr', '1fr'],
|
|
119
|
+
childCountY: 3,
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
> **Note:** This layout assumes the container size is determined externally. Containers sized by their own content (e.g. `width: max-content`) may cause unexpected behavior with percentage-based values.
|
|
124
|
+
|
|
125
|
+
### `tile`
|
|
126
|
+
|
|
127
|
+
Arranges child elements in a grid based on child element size. The number of columns is determined automatically based on the container and child sizes.
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
import { tile } from '@niche-works/css-layouts';
|
|
131
|
+
|
|
132
|
+
const { className, style } = tile({
|
|
133
|
+
direction: 'x',
|
|
134
|
+
childSizeX: '200px',
|
|
135
|
+
adjustX: 'fit',
|
|
136
|
+
spacing: '8px',
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
> **Note:** Like `matrix`, this layout assumes the container size is determined externally.
|
|
141
|
+
|
|
142
|
+
### `balance`
|
|
143
|
+
|
|
144
|
+
Arranges child elements evenly in a single row or column.
|
|
145
|
+
|
|
146
|
+
- Without `adjust`: maintains child size and distributes space evenly between items
|
|
147
|
+
- With `adjust`: adjusts child size to fill the container evenly
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
import { balance } from '@niche-works/css-layouts';
|
|
151
|
+
|
|
152
|
+
const { className, style } = balance({
|
|
153
|
+
direction: 'x',
|
|
154
|
+
adjustX: 'grow',
|
|
155
|
+
childSizeX: '200px',
|
|
156
|
+
spacing: '8px',
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### `pack`
|
|
161
|
+
|
|
162
|
+
Sizes child elements equally to fill the container.
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
import { pack } from '@niche-works/css-layouts';
|
|
166
|
+
|
|
167
|
+
const { className, style } = pack({
|
|
168
|
+
direction: 'x', // 'x' | 'y' — default: 'x'
|
|
169
|
+
spacing: '8px',
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### `pin`
|
|
174
|
+
|
|
175
|
+
Positions child elements at specified coordinates. Each child element should have its position set via `top` / `left` / `bottom` / `right` styles.
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
import { pin } from '@niche-works/css-layouts';
|
|
179
|
+
|
|
180
|
+
const { className, style } = pin({
|
|
181
|
+
childSizeX: '100px',
|
|
182
|
+
childSizeY: '80px',
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Options
|
|
187
|
+
|
|
188
|
+
### Options Reference
|
|
189
|
+
|
|
190
|
+
| Option | Type | Description |
|
|
191
|
+
| ------------- | -------------------------- | ------------------------------------------ |
|
|
192
|
+
| `direction` | `'x' \| 'y'` | Main axis direction |
|
|
193
|
+
| `alignX` | [`AlignX`](#alignx-values) | Horizontal alignment of children |
|
|
194
|
+
| `alignY` | [`AlignY`](#aligny-values) | Vertical alignment of children |
|
|
195
|
+
| `adjustX` | [`Adjust`](#adjust-values) | Horizontal size adjustment of children |
|
|
196
|
+
| `adjustY` | [`Adjust`](#adjust-values) | Vertical size adjustment of children |
|
|
197
|
+
| `spacing` | `string \| number` | Gap between children (both axes) |
|
|
198
|
+
| `spacingX` | `string \| number` | Gap between children (horizontal) |
|
|
199
|
+
| `spacingY` | `string \| number` | Gap between children (vertical) |
|
|
200
|
+
| `childSizeX` | `string \| number` | Width of child elements |
|
|
201
|
+
| `childSizeY` | `string \| number` | Height of child elements |
|
|
202
|
+
| `childCountX` | `number` | Number of children in horizontal direction |
|
|
203
|
+
| `childCountY` | `number` | Number of children in vertical direction |
|
|
204
|
+
| `childX` | `(string \| number)[]` | Individual sizes of children (horizontal) |
|
|
205
|
+
| `childY` | `(string \| number)[]` | Individual sizes of children (vertical) |
|
|
206
|
+
|
|
207
|
+
### `Adjust` Values
|
|
208
|
+
|
|
209
|
+
| Value | Child smaller than parent | Child larger than parent |
|
|
210
|
+
| -------- | ------------------------- | ------------------------ |
|
|
211
|
+
| `none` | No change | No change |
|
|
212
|
+
| `grow` | Grows to fill | No change |
|
|
213
|
+
| `shrink` | No change | Shrinks to fit |
|
|
214
|
+
| `fit` | Grows to fill | Shrinks to fit |
|
|
215
|
+
|
|
216
|
+
### `AlignX` Values
|
|
217
|
+
|
|
218
|
+
`'left'` | `'center'` | `'right'` | `'space-between'` | `'space-around'` | `'space-evenly'`
|
|
219
|
+
|
|
220
|
+
### `AlignY` Values
|
|
221
|
+
|
|
222
|
+
`'top'` | `'middle'` | `'bottom'` | `'space-between'` | `'space-around'` | `'space-evenly'`
|
|
223
|
+
|
|
224
|
+
## Return Value
|
|
225
|
+
|
|
226
|
+
All layout functions return a `LayoutResult`:
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
type LayoutResult = {
|
|
230
|
+
className?: string;
|
|
231
|
+
style?: {
|
|
232
|
+
[key: string]: string | number | undefined;
|
|
233
|
+
[key: `--${string}`]: string | number | undefined;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## License
|
|
239
|
+
|
|
240
|
+
MIT
|
package/balance/balance.cjs
CHANGED
|
@@ -3,7 +3,6 @@ const require_constants = require('../constants.cjs');
|
|
|
3
3
|
const require__constants = require('../_constants.cjs');
|
|
4
4
|
const require__helpers_applyChildSize = require('../_helpers/applyChildSize.cjs');
|
|
5
5
|
const require__helpers_applySpacing = require('../_helpers/applySpacing.cjs');
|
|
6
|
-
require('./styles.cjs');
|
|
7
6
|
let _niche_works_utils_object_maybeDefault = require("@niche-works/utils/object/maybeDefault");
|
|
8
7
|
_niche_works_utils_object_maybeDefault = require_runtime.__toESM(_niche_works_utils_object_maybeDefault, 1);
|
|
9
8
|
let clsx = require("clsx");
|
package/balance/balance.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import { clsLayoutBalance } from "../constants.mjs";
|
|
|
2
2
|
import { clsLayoutAdjust, clsLayoutAlign, clsLayoutDirection } from "../_constants.mjs";
|
|
3
3
|
import applyChildSize from "../_helpers/applyChildSize.mjs";
|
|
4
4
|
import applySpacing from "../_helpers/applySpacing.mjs";
|
|
5
|
-
import "./styles.css";
|
|
6
5
|
import maybeDefault from "@niche-works/utils/object/maybeDefault";
|
|
7
6
|
import clsx from "clsx";
|
|
8
7
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('./balance.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/flow/flow.cjs
CHANGED
|
@@ -5,7 +5,6 @@ const require__helpers_hasValue = require('../_helpers/hasValue.cjs');
|
|
|
5
5
|
const require__helpers_unit = require('../_helpers/unit.cjs');
|
|
6
6
|
const require__helpers_applySpacing = require('../_helpers/applySpacing.cjs');
|
|
7
7
|
const require__helpers_mergeLayoutResults = require('../_helpers/mergeLayoutResults.cjs');
|
|
8
|
-
require('./styles.cjs');
|
|
9
8
|
let _niche_works_utils_object_maybeDefault = require("@niche-works/utils/object/maybeDefault");
|
|
10
9
|
_niche_works_utils_object_maybeDefault = require_runtime.__toESM(_niche_works_utils_object_maybeDefault, 1);
|
|
11
10
|
let clsx = require("clsx");
|
package/flow/flow.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import hasValue from "../_helpers/hasValue.mjs";
|
|
|
4
4
|
import unit from "../_helpers/unit.mjs";
|
|
5
5
|
import applySpacing from "../_helpers/applySpacing.mjs";
|
|
6
6
|
import mergeLayoutResults from "../_helpers/mergeLayoutResults.mjs";
|
|
7
|
-
import "./styles.css";
|
|
8
7
|
import maybeDefault from "@niche-works/utils/object/maybeDefault";
|
|
9
8
|
import clsx from "clsx";
|
|
10
9
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('./flow.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/matrix/matrix.cjs
CHANGED
|
@@ -5,7 +5,6 @@ const require__helpers_hasValue = require('../_helpers/hasValue.cjs');
|
|
|
5
5
|
const require__helpers_unit = require('../_helpers/unit.cjs');
|
|
6
6
|
const require__helpers_applySpacing = require('../_helpers/applySpacing.cjs');
|
|
7
7
|
const require__helpers_mergeLayoutResults = require('../_helpers/mergeLayoutResults.cjs');
|
|
8
|
-
require('./styles.cjs');
|
|
9
8
|
let _niche_works_utils_object_maybeDefault = require("@niche-works/utils/object/maybeDefault");
|
|
10
9
|
_niche_works_utils_object_maybeDefault = require_runtime.__toESM(_niche_works_utils_object_maybeDefault, 1);
|
|
11
10
|
let clsx = require("clsx");
|
package/matrix/matrix.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import hasValue from "../_helpers/hasValue.mjs";
|
|
|
4
4
|
import unit from "../_helpers/unit.mjs";
|
|
5
5
|
import applySpacing from "../_helpers/applySpacing.mjs";
|
|
6
6
|
import mergeLayoutResults from "../_helpers/mergeLayoutResults.mjs";
|
|
7
|
-
import "./styles.css";
|
|
8
7
|
import maybeDefault from "@niche-works/utils/object/maybeDefault";
|
|
9
8
|
import clsx from "clsx";
|
|
10
9
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('./matrix.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/pack/pack.cjs
CHANGED
|
@@ -2,7 +2,6 @@ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
|
2
2
|
const require_constants = require('../constants.cjs');
|
|
3
3
|
const require__constants = require('../_constants.cjs');
|
|
4
4
|
const require__helpers_applySpacing = require('../_helpers/applySpacing.cjs');
|
|
5
|
-
require('./styles.cjs');
|
|
6
5
|
let _niche_works_utils_object_maybeDefault = require("@niche-works/utils/object/maybeDefault");
|
|
7
6
|
_niche_works_utils_object_maybeDefault = require_runtime.__toESM(_niche_works_utils_object_maybeDefault, 1);
|
|
8
7
|
let clsx = require("clsx");
|
package/pack/pack.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { clsLayoutPack } from "../constants.mjs";
|
|
2
2
|
import { clsLayoutDirection } from "../_constants.mjs";
|
|
3
3
|
import applySpacing from "../_helpers/applySpacing.mjs";
|
|
4
|
-
import "./styles.css";
|
|
5
4
|
import maybeDefault from "@niche-works/utils/object/maybeDefault";
|
|
6
5
|
import clsx from "clsx";
|
|
7
6
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('./pack.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niche-works/css-layouts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"css",
|
|
6
6
|
"style",
|
|
@@ -32,7 +32,15 @@
|
|
|
32
32
|
"./*/constants": {
|
|
33
33
|
"import": "./*/constants.mjs",
|
|
34
34
|
"require": "./*/constants.cjs"
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
|
+
"./styles.css": "./styles.css",
|
|
37
|
+
"./stack.css": "./stack/stack.css",
|
|
38
|
+
"./flow.css": "./flow/flow.css",
|
|
39
|
+
"./matrix.css": "./matrix/matrix.css",
|
|
40
|
+
"./tile.css": "./tile/tile.css",
|
|
41
|
+
"./balance.css": "./balance/balance.css",
|
|
42
|
+
"./pack.css": "./pack/pack.css",
|
|
43
|
+
"./pin.css": "./pin/pin.css"
|
|
36
44
|
},
|
|
37
45
|
"main": "./index.cjs",
|
|
38
46
|
"module": "./index.mjs",
|
package/pin/pin.cjs
CHANGED
package/pin/pin.mjs
CHANGED
package/pin/pin.scss.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('./pin.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/pin/pin.scss.mjs
ADDED