@dynshift/layr 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 +268 -0
- package/dist/index.cjs +838 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1222 -0
- package/dist/index.d.ts +1222 -0
- package/dist/index.js +807 -0
- package/dist/index.js.map +1 -0
- package/package.json +95 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 DynShift & Nishan Bhuiya
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# @dynshift/layr
|
|
4
|
+
|
|
5
|
+
> **Flutter-inspired layout primitives for React**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@dynshift/layr)
|
|
8
|
+
[](https://www.npmjs.com/package/@dynshift/layr)
|
|
9
|
+
[](https://github.com/nishanbhuinya/layr/blob/main/LICENSE)
|
|
10
|
+
[](https://www.typescriptlang.org/)
|
|
11
|
+
|
|
12
|
+
<img src="https://github.com/nishanbhuinya/layr/blob/main/packages/layr/layr.gif" alt="Layr" width="150" />
|
|
13
|
+
|
|
14
|
+
[Documentation](https://layr.dynshift.com) · [GitHub](https://github.com/nishanbhuinya/layr) · [npm](https://www.npmjs.com/package/@dynshift/layr)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- **Flutter-inspired API** — Familiar patterns for Flutter developers transitioning to React
|
|
21
|
+
- **Zero dependencies** — Lightweight and fully tree-shakeable
|
|
22
|
+
- **TypeScript-first** — Complete type definitions out of the box
|
|
23
|
+
- **React 18 & 19** — Optimized for modern React with full compatibility
|
|
24
|
+
- **Comprehensive styling** — Decorations, shadows, gradients, and borders built-in
|
|
25
|
+
- **Flexible layouts** — Stack, Row, Column with powerful alignment controls
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @dynshift/layr
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Using other package managers
|
|
35
|
+
pnpm add @dynshift/layr
|
|
36
|
+
yarn add @dynshift/layr
|
|
37
|
+
bun add @dynshift/layr
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { Container, Column, Row } from '@dynshift/layr';
|
|
44
|
+
|
|
45
|
+
export function Card() {
|
|
46
|
+
return (
|
|
47
|
+
<Container
|
|
48
|
+
width={320}
|
|
49
|
+
padding={24}
|
|
50
|
+
decoration={{
|
|
51
|
+
color: '#1a1a1a',
|
|
52
|
+
borderRadius: 16,
|
|
53
|
+
boxShadow: [{ color: 'rgba(0,0,0,0.2)', blurRadius: 12 }],
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
<Column spacing={12}>
|
|
57
|
+
<Row spacing={8}>
|
|
58
|
+
<Container width={40} height={40} color="#3b82f6" decoration={{ borderRadius: 8 }} />
|
|
59
|
+
<span>Welcome to Layr</span>
|
|
60
|
+
</Row>
|
|
61
|
+
<p>Build layouts the Flutter way.</p>
|
|
62
|
+
</Column>
|
|
63
|
+
</Container>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Components
|
|
69
|
+
|
|
70
|
+
### Container
|
|
71
|
+
|
|
72
|
+
A versatile box with comprehensive styling options including padding, margin, decoration, shadows, gradients, and borders.
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
<Container
|
|
76
|
+
width={200}
|
|
77
|
+
height={100}
|
|
78
|
+
padding={16}
|
|
79
|
+
margin={8}
|
|
80
|
+
color="#1a1a1a"
|
|
81
|
+
decoration={{
|
|
82
|
+
borderRadius: 12,
|
|
83
|
+
boxShadow: [{ color: 'rgba(0,0,0,0.1)', blurRadius: 10 }],
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
{children}
|
|
87
|
+
</Container>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Column
|
|
91
|
+
|
|
92
|
+
Displays children in a vertical arrangement with spacing and alignment controls.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<Column
|
|
96
|
+
spacing={16}
|
|
97
|
+
mainAxisAlignment={MainAxisAlignment.center}
|
|
98
|
+
crossAxisAlignment={CrossAxisAlignment.start}
|
|
99
|
+
>
|
|
100
|
+
{children}
|
|
101
|
+
</Column>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Row
|
|
105
|
+
|
|
106
|
+
Displays children in a horizontal arrangement with spacing and alignment controls.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
<Row
|
|
110
|
+
spacing={12}
|
|
111
|
+
mainAxisAlignment={MainAxisAlignment.spaceBetween}
|
|
112
|
+
crossAxisAlignment={CrossAxisAlignment.center}
|
|
113
|
+
>
|
|
114
|
+
{children}
|
|
115
|
+
</Row>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Stack
|
|
119
|
+
|
|
120
|
+
Positions children in layers, enabling overlapping elements. Children are painted in order (first = bottom, last = top).
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
<Stack fit={StackFit.expand}>
|
|
124
|
+
<Container color="#000" />
|
|
125
|
+
<Positioned top={10} left={10}>
|
|
126
|
+
<Container width={50} height={50} color="#fff" />
|
|
127
|
+
</Positioned>
|
|
128
|
+
</Stack>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Positioned & PositionedFill
|
|
132
|
+
|
|
133
|
+
Absolute positioning within a Stack.
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
<Positioned top={0} right={0} bottom={0} left={0}>
|
|
137
|
+
{children}
|
|
138
|
+
</Positioned>
|
|
139
|
+
|
|
140
|
+
<PositionedFill>
|
|
141
|
+
{children}
|
|
142
|
+
</PositionedFill>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### SizedBox
|
|
146
|
+
|
|
147
|
+
Constrains its child to a specific width and height. Useful as a spacer or for fixed-size containers.
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
<SizedBox width={100} height={100}>
|
|
151
|
+
{children}
|
|
152
|
+
</SizedBox>
|
|
153
|
+
|
|
154
|
+
{/* As a spacer */}
|
|
155
|
+
<SizedBox height={20} />
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Padding
|
|
159
|
+
|
|
160
|
+
A lightweight wrapper that applies padding to its child.
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
<Padding padding={16}>
|
|
164
|
+
{children}
|
|
165
|
+
</Padding>
|
|
166
|
+
|
|
167
|
+
<Padding padding={{ horizontal: 20, vertical: 10 }}>
|
|
168
|
+
{children}
|
|
169
|
+
</Padding>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Centre / Center
|
|
173
|
+
|
|
174
|
+
Centers its child both horizontally and vertically. Both spellings are supported.
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
<Centre>
|
|
178
|
+
{children}
|
|
179
|
+
</Centre>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Advanced Usage
|
|
183
|
+
|
|
184
|
+
### Edge Insets Helpers
|
|
185
|
+
|
|
186
|
+
Utility functions for creating padding and margin values in Flutter style.
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
import { EdgeInsetsAll, EdgeInsetsSymmetric, EdgeInsetsOnly } from '@dynshift/layr';
|
|
190
|
+
|
|
191
|
+
<Container padding={EdgeInsetsAll(16)} />
|
|
192
|
+
<Container padding={EdgeInsetsSymmetric({ horizontal: 20, vertical: 10 })} />
|
|
193
|
+
<Container margin={EdgeInsetsOnly({ top: 10, left: 20 })} />
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Border Helpers
|
|
197
|
+
|
|
198
|
+
```tsx
|
|
199
|
+
import { BorderAll, BorderRadiusCircular } from '@dynshift/layr';
|
|
200
|
+
|
|
201
|
+
<Container
|
|
202
|
+
decoration={{
|
|
203
|
+
border: BorderAll({ width: 2, color: '#3b82f6', style: 'solid' }),
|
|
204
|
+
borderRadius: BorderRadiusCircular(12),
|
|
205
|
+
}}
|
|
206
|
+
/>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Box Shapes
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
import { BoxShape } from '@dynshift/layr';
|
|
213
|
+
|
|
214
|
+
<Container
|
|
215
|
+
width={100}
|
|
216
|
+
height={100}
|
|
217
|
+
decoration={{
|
|
218
|
+
color: '#3b82f6',
|
|
219
|
+
shape: BoxShape.circle,
|
|
220
|
+
}}
|
|
221
|
+
/>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Alignment Enums
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
import { MainAxisAlignment, CrossAxisAlignment, StackFit } from '@dynshift/layr';
|
|
228
|
+
|
|
229
|
+
<Column mainAxisAlignment={MainAxisAlignment.spaceBetween}>
|
|
230
|
+
{children}
|
|
231
|
+
</Column>
|
|
232
|
+
|
|
233
|
+
<Row crossAxisAlignment={CrossAxisAlignment.stretch}>
|
|
234
|
+
{children}
|
|
235
|
+
</Row>
|
|
236
|
+
|
|
237
|
+
<Stack fit={StackFit.expand}>
|
|
238
|
+
{children}
|
|
239
|
+
</Stack>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## TypeScript Support
|
|
243
|
+
|
|
244
|
+
Full type definitions are included for all components and utilities:
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
import type {
|
|
248
|
+
ContainerProps,
|
|
249
|
+
ColumnProps,
|
|
250
|
+
RowProps,
|
|
251
|
+
StackProps,
|
|
252
|
+
EdgeInsets,
|
|
253
|
+
BoxDecoration,
|
|
254
|
+
Alignment,
|
|
255
|
+
} from '@dynshift/layr';
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Documentation
|
|
259
|
+
|
|
260
|
+
For complete documentation, examples, and API reference, visit [layr.dynshift.com](https://layr.dynshift.com).
|
|
261
|
+
|
|
262
|
+
## Contributing
|
|
263
|
+
|
|
264
|
+
Contributions are welcome. Please see the [GitHub repository](https://github.com/nishanbhuinya/layr) for guidelines.
|
|
265
|
+
|
|
266
|
+
## License
|
|
267
|
+
|
|
268
|
+
MIT © 2025 [DynShift](https://dynshift.com) & [Nishan Bhuiya](https://nishanbhuinya.com)
|