@danielito1996/compose-svelted 0.0.1
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/.vscode/extensions.json +3 -0
- package/README.md +274 -0
- package/docs/assets/components/button/button.png +0 -0
- package/docs/assets/components/surface/surface_simple.png +0 -0
- package/docs/assets/components/text/text.png +0 -0
- package/docs/assets/components/textfield/textfield_simple.png +0 -0
- package/docs/assets/svelted.png +0 -0
- package/docs/assets/svelted.svg +41 -0
- package/docs/getting_started.md +116 -0
- package/docs/index.md +106 -0
- package/index.html +14 -0
- package/package.json +49 -0
- package/public/vite.svg +1 -0
- package/screenshots/Captura de pantalla 2025-12-20 022710.png +0 -0
- package/screenshots/capturas.txt +1 -0
- package/src/App.svelte +39 -0
- package/src/app.css +23 -0
- package/src/assets/img/hav3m.png +0 -0
- package/src/assets/img/vessel.jpg +0 -0
- package/src/assets/raw/boat.svg +15 -0
- package/src/assets/raw/cash.svg +39 -0
- package/src/assets/raw/police.json +1 -0
- package/src/assets/raw/svelte.svg +1 -0
- package/src/lib/Counter.svelte +10 -0
- package/src/lib/components/AppRoot.svelte +15 -0
- package/src/lib/components/ContentScale.ts +12 -0
- package/src/lib/components/Icon.svelte +47 -0
- package/src/lib/components/Image.svelte +31 -0
- package/src/lib/components/Spacer.svelte +11 -0
- package/src/lib/components/Surface.svelte +19 -0
- package/src/lib/components/Text.svelte +23 -0
- package/src/lib/components/TonalButton.svelte +34 -0
- package/src/lib/components/buttons/Button.svelte +34 -0
- package/src/lib/components/buttons/ButtonWithIcon.svelte +0 -0
- package/src/lib/components/buttons/IconButton.svelte +0 -0
- package/src/lib/components/buttons/OutlinedButton.svelte +0 -0
- package/src/lib/components/buttons/OutlinedButtonWithIcon.svelte +0 -0
- package/src/lib/components/buttons/OutlinedIconButton.svelte +0 -0
- package/src/lib/components/buttons/TextButton.svelte +0 -0
- package/src/lib/components/cards/Card.svelte +0 -0
- package/src/lib/components/cards/OutlinedCard.svelte +0 -0
- package/src/lib/components/layouts/Alignment.ts +37 -0
- package/src/lib/components/layouts/Arrangement.ts +66 -0
- package/src/lib/components/layouts/Box.svelte +25 -0
- package/src/lib/components/layouts/Column.svelte +23 -0
- package/src/lib/components/layouts/LazyColumn.svelte +0 -0
- package/src/lib/components/layouts/LazyRow.svelte +0 -0
- package/src/lib/components/layouts/Row.svelte +23 -0
- package/src/lib/components/layouts/Scafold.svelte +0 -0
- package/src/lib/components/menus/DropdownMenu.svelte +0 -0
- package/src/lib/components/menus/DropdownMenuItem.svelte +0 -0
- package/src/lib/components/textFields/BaseTextField.svelte +130 -0
- package/src/lib/components/textFields/OutlinedTextField.svelte +52 -0
- package/src/lib/components/textFields/TextField.svelte +36 -0
- package/src/lib/components/textFields/TextFieldColors.ts +11 -0
- package/src/lib/components/textFields/TextFieldDefaults.ts +48 -0
- package/src/lib/core/helpers/painterResource.ts +26 -0
- package/src/lib/core/modifier/Modifier.ts +259 -0
- package/src/lib/core/modifier/ModifierImpl.ts +275 -0
- package/src/lib/core/shapes/RoundedCornerShape.ts +53 -0
- package/src/lib/core/shapes/Shape.ts +3 -0
- package/src/lib/core/theme/ColorScheme.ts +25 -0
- package/src/lib/core/theme/ComposeTheme.svelte +22 -0
- package/src/lib/core/theme/TextStyle.ts +25 -0
- package/src/lib/core/theme/colors.ts +21 -0
- package/src/lib/core/theme/cssVars.ts +32 -0
- package/src/lib/core/theme/defaults/darkColors.ts +17 -0
- package/src/lib/core/theme/defaults/defaultTheme.ts +35 -0
- package/src/lib/core/theme/defaults/lightColors.ts +17 -0
- package/src/lib/core/theme/defaults/typography.ts +128 -0
- package/src/lib/core/theme/elevation.ts +7 -0
- package/src/lib/core/theme/getCurrentColor.ts +10 -0
- package/src/lib/core/theme/resolve.ts +29 -0
- package/src/lib/core/theme/shapes.ts +7 -0
- package/src/lib/core/theme/spacing.ts +7 -0
- package/src/lib/core/theme/store.ts +26 -0
- package/src/lib/core/theme/systemTheme.ts +20 -0
- package/src/lib/core/theme/theme.ts +15 -0
- package/src/lib/core/theme/typography.ts +29 -0
- package/src/lib/index.ts +42 -0
- package/src/main.ts +9 -0
- package/svelte.config.js +8 -0
- package/tsconfig.app.json +21 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# Compose-like UI for Svelte
|
|
2
|
+
<p align="start">
|
|
3
|
+
<a href="https://www.npmjs.com/package/compose-svelte">
|
|
4
|
+
<img src="https://img.shields.io/npm/v/svelted.svg" alt="npm version" />
|
|
5
|
+
</a>
|
|
6
|
+
<a href="https://www.npmjs.com/package/compose-svelte">
|
|
7
|
+
<img src="https://img.shields.io/npm/dm/svelted.svg" alt="npm downloads" />
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://github.com/danielitoCode/compose-svelte/blob/main/LICENSE">
|
|
10
|
+
<img src="https://img.shields.io/github/license/danielitoCode/compose-svelte" alt="license" />
|
|
11
|
+
</a>
|
|
12
|
+
<img src="https://img.shields.io/badge/status-alpha-orange" />
|
|
13
|
+
<img src="https://img.shields.io/badge/version-0.0.1-blue" />
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<img src="docs/assets/svelted.png" width="310" alt="ios" />
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
A Compose-inspired UI toolkit for **Svelte**, focused on explicit composition,
|
|
22
|
+
immutable modifiers, and theme-driven design.
|
|
23
|
+
|
|
24
|
+
Inspired by **Jetpack Compose**, built natively for the web using Svelte and
|
|
25
|
+
standard web technologies.
|
|
26
|
+
|
|
27
|
+
<p align="center">
|
|
28
|
+
<img src="https://img.shields.io/badge/Svelte-FF3E00?logo=svelte&logoColor=white" />
|
|
29
|
+
<img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white" />
|
|
30
|
+
<img src="https://img.shields.io/badge/Jetpack%20Compose-inspired-4285F4" />
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## ✨ Goals
|
|
36
|
+
|
|
37
|
+
- Explicit and predictable UI composition
|
|
38
|
+
- Immutable, chainable `Modifier`s
|
|
39
|
+
- Strong separation between core, layout and components
|
|
40
|
+
- Theme-driven design (tokens, not raw CSS)
|
|
41
|
+
- No virtual DOM abstractions
|
|
42
|
+
- No hidden magic
|
|
43
|
+
|
|
44
|
+
> This is **not** a Material clone.
|
|
45
|
+
> It is a Compose-like system that can be styled beyond Material Design.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Why Compose-like for Svelte?
|
|
50
|
+
|
|
51
|
+
Jetpack Compose introduced a clear, explicit and composable mental model for UI.
|
|
52
|
+
This project explores how that same philosophy translates to the web,
|
|
53
|
+
using Svelte as a native, compiler-driven foundation.
|
|
54
|
+
|
|
55
|
+
The goal is not to replicate Android UI,
|
|
56
|
+
but to bring Compose’s clarity and composability to modern web applications.
|
|
57
|
+
|
|
58
|
+
## 🚀 Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install compose-svelte
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 🧭 Minimal Example
|
|
67
|
+
|
|
68
|
+
```svelte
|
|
69
|
+
<script>
|
|
70
|
+
import {
|
|
71
|
+
ComposeTheme,
|
|
72
|
+
AppRoot,
|
|
73
|
+
Surface,
|
|
74
|
+
Text,
|
|
75
|
+
Modifier
|
|
76
|
+
} from "compose-svelte";
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<ComposeTheme mode="system">
|
|
80
|
+
<AppRoot>
|
|
81
|
+
<Surface modifier={Modifier.fillMaxSize()}>
|
|
82
|
+
<Text>Hello Compose</Text>
|
|
83
|
+
</Surface>
|
|
84
|
+
</AppRoot>
|
|
85
|
+
</ComposeTheme>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 🧱 Layout
|
|
91
|
+
|
|
92
|
+
### Column
|
|
93
|
+
|
|
94
|
+
```svelte
|
|
95
|
+
<Column modifier={Modifier.padding(16)}>
|
|
96
|
+
<Text textStyle="titleLarge">Title</Text>
|
|
97
|
+
<Text>Body text</Text>
|
|
98
|
+
</Column>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Row
|
|
102
|
+
|
|
103
|
+
```svelte
|
|
104
|
+
<Row horizontalArrangement={Arrangement.spacedBy(8)}>
|
|
105
|
+
<Text>Left</Text>
|
|
106
|
+
<Text>Right</Text>
|
|
107
|
+
</Row>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Box
|
|
111
|
+
|
|
112
|
+
```svelte
|
|
113
|
+
<Box modifier={Modifier.size(120)}>
|
|
114
|
+
<Text modifier={Modifier.align(Alignment.Center)}>Centered</Text>
|
|
115
|
+
</Box>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 🎨 Theme
|
|
121
|
+
|
|
122
|
+
### ComposeTheme
|
|
123
|
+
|
|
124
|
+
Provides theming for the entire app.
|
|
125
|
+
|
|
126
|
+
- Light / Dark / System modes
|
|
127
|
+
- Tokens exposed as CSS variables
|
|
128
|
+
- Inspired by MaterialTheme
|
|
129
|
+
|
|
130
|
+
```svelte
|
|
131
|
+
<ComposeTheme mode="dark">
|
|
132
|
+
<AppRoot>
|
|
133
|
+
<Surface>
|
|
134
|
+
<Text>Dark mode</Text>
|
|
135
|
+
</Surface>
|
|
136
|
+
</AppRoot>
|
|
137
|
+
</ComposeTheme>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 📝 TextField
|
|
143
|
+
|
|
144
|
+
### Filled
|
|
145
|
+
|
|
146
|
+
```svelte
|
|
147
|
+
<TextField
|
|
148
|
+
label="Email"
|
|
149
|
+
placeholder="you@email.com"
|
|
150
|
+
value={email}
|
|
151
|
+
onValueChange={(v) => email = v}
|
|
152
|
+
/>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Outlined
|
|
156
|
+
|
|
157
|
+
```svelte
|
|
158
|
+
<OutlinedTextField
|
|
159
|
+
label="Email"
|
|
160
|
+
value={email}
|
|
161
|
+
onValueChange={(v) => email = v}
|
|
162
|
+
/>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 🔘 Buttons
|
|
168
|
+
|
|
169
|
+
```svelte
|
|
170
|
+
<Button onClick={submit}>
|
|
171
|
+
Submit
|
|
172
|
+
</Button>
|
|
173
|
+
|
|
174
|
+
<TextButton onClick={cancel}>
|
|
175
|
+
Cancel
|
|
176
|
+
</TextButton>
|
|
177
|
+
|
|
178
|
+
<OutlinedButton>
|
|
179
|
+
Outlined
|
|
180
|
+
</OutlinedButton>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 🧩 Modifiers
|
|
186
|
+
|
|
187
|
+
Modifiers are immutable and chainable.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
Modifier
|
|
191
|
+
.padding(16)
|
|
192
|
+
.fillMaxWidth()
|
|
193
|
+
.background(ColorScheme.Surface)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Available categories
|
|
197
|
+
|
|
198
|
+
- Layout: `size`, `width`, `height`, `fill`, `weight`
|
|
199
|
+
- Spacing: `padding`, `margin`
|
|
200
|
+
- Drawing: `background`, `border`, `clip`
|
|
201
|
+
- Interaction: `clickable`
|
|
202
|
+
- Transform: `offset`
|
|
203
|
+
- Scroll: `verticalScroll`, `horizontalScroll`
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 🔲 Shapes
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
RoundedCornerShape(12)
|
|
211
|
+
RoundedCornerShape({ topStart: 16, topEnd: 16 })
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Shapes are value objects and reusable across components.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 🎨 Theme Tokens
|
|
219
|
+
|
|
220
|
+
### ColorScheme
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
ColorScheme.Primary
|
|
224
|
+
ColorScheme.Surface
|
|
225
|
+
ColorScheme.OnSurface
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### TextStyle
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
TextStyle.TitleLarge
|
|
232
|
+
TextStyle.BodyMedium
|
|
233
|
+
TextStyle.LabelSmall
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 🖼️ Images & Icons
|
|
239
|
+
|
|
240
|
+
```svelte
|
|
241
|
+
<Image
|
|
242
|
+
painter={painterResource(Res.image("logo.png"))}
|
|
243
|
+
contentScale={ContentScale.Fit}
|
|
244
|
+
/>
|
|
245
|
+
|
|
246
|
+
<Icon
|
|
247
|
+
painter="https://api.iconify.design/mdi/home.svg"
|
|
248
|
+
modifier={Modifier.size(24)}
|
|
249
|
+
/>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 📦 Project Status
|
|
255
|
+
|
|
256
|
+
- Core v0.0.1: stable
|
|
257
|
+
- Layout system: stable
|
|
258
|
+
- Theme system: stable
|
|
259
|
+
- Modifiers: stable
|
|
260
|
+
- Lazy layouts: experimental
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 🧠 Philosophy
|
|
265
|
+
|
|
266
|
+
Clarity over cleverness.
|
|
267
|
+
|
|
268
|
+
If something is not explicit, it is probably not part of the API.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## 📄 License
|
|
273
|
+
|
|
274
|
+
MIT
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg
|
|
3
|
+
width="256"
|
|
4
|
+
height="256"
|
|
5
|
+
viewBox="0 0 256 256"
|
|
6
|
+
fill="none"
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
>
|
|
9
|
+
<!-- Background circle -->
|
|
10
|
+
<circle cx="128" cy="128" r="112" fill="#FF3E00"/>
|
|
11
|
+
|
|
12
|
+
<!-- Inner compose-style layers -->
|
|
13
|
+
<rect
|
|
14
|
+
x="72"
|
|
15
|
+
y="72"
|
|
16
|
+
width="112"
|
|
17
|
+
height="112"
|
|
18
|
+
rx="28"
|
|
19
|
+
fill="white"
|
|
20
|
+
opacity="0.15"
|
|
21
|
+
/>
|
|
22
|
+
|
|
23
|
+
<rect
|
|
24
|
+
x="88"
|
|
25
|
+
y="88"
|
|
26
|
+
width="80"
|
|
27
|
+
height="80"
|
|
28
|
+
rx="20"
|
|
29
|
+
fill="white"
|
|
30
|
+
opacity="0.25"
|
|
31
|
+
/>
|
|
32
|
+
|
|
33
|
+
<rect
|
|
34
|
+
x="104"
|
|
35
|
+
y="104"
|
|
36
|
+
width="48"
|
|
37
|
+
height="48"
|
|
38
|
+
rx="12"
|
|
39
|
+
fill="white"
|
|
40
|
+
/>
|
|
41
|
+
</svg>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
This guide helps you go from **installation** to your **first screen**
|
|
4
|
+
using Svelted.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install compose-svelte
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
or
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add compose-svelte
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Basic Setup
|
|
23
|
+
|
|
24
|
+
Wrap your app with `ComposeTheme` and `AppRoot`.
|
|
25
|
+
|
|
26
|
+
```svelte
|
|
27
|
+
<script>
|
|
28
|
+
import {
|
|
29
|
+
ComposeTheme,
|
|
30
|
+
AppRoot,
|
|
31
|
+
Surface,
|
|
32
|
+
Text,
|
|
33
|
+
Modifier
|
|
34
|
+
} from "compose-svelte";
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<ComposeTheme mode="system">
|
|
38
|
+
<AppRoot>
|
|
39
|
+
<Surface modifier={Modifier.fillMaxSize()}>
|
|
40
|
+
<Text>Hello Svelted</Text>
|
|
41
|
+
</Surface>
|
|
42
|
+
</AppRoot>
|
|
43
|
+
</ComposeTheme>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Layout Basics
|
|
49
|
+
|
|
50
|
+
### Column
|
|
51
|
+
|
|
52
|
+
```svelte
|
|
53
|
+
<Column modifier={Modifier.padding(16)}>
|
|
54
|
+
<Text textStyle="titleLarge">Title</Text>
|
|
55
|
+
<Text>Body text</Text>
|
|
56
|
+
</Column>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Row
|
|
60
|
+
|
|
61
|
+
```svelte
|
|
62
|
+
<Row horizontalArrangement={Arrangement.spacedBy(8)}>
|
|
63
|
+
<Text>Left</Text>
|
|
64
|
+
<Text>Right</Text>
|
|
65
|
+
</Row>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Box
|
|
69
|
+
|
|
70
|
+
```svelte
|
|
71
|
+
<Box modifier={Modifier.size(120)}>
|
|
72
|
+
<Text modifier={Modifier.align(Alignment.Center)}>
|
|
73
|
+
Centered
|
|
74
|
+
</Text>
|
|
75
|
+
</Box>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## TextField
|
|
81
|
+
|
|
82
|
+
```svelte
|
|
83
|
+
<TextField
|
|
84
|
+
label="Email"
|
|
85
|
+
placeholder="you@email.com"
|
|
86
|
+
value={email}
|
|
87
|
+
onValueChange={(v) => email = v}
|
|
88
|
+
/>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```svelte
|
|
92
|
+
<OutlinedTextField
|
|
93
|
+
label="Email"
|
|
94
|
+
value={email}
|
|
95
|
+
onValueChange={(v) => email = v}
|
|
96
|
+
/>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Modifiers
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
Modifier
|
|
105
|
+
.padding(16)
|
|
106
|
+
.fillMaxWidth()
|
|
107
|
+
.clip(RoundedCornerShape(12))
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Next Steps
|
|
113
|
+
|
|
114
|
+
- Explore LazyColumn and LazyRow
|
|
115
|
+
- Customize themes
|
|
116
|
+
- Build real screens
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/svelted.png" alt="Svelted" width="480" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Svelted</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
Compose-like UI for <strong>Svelte</strong><br/>
|
|
9
|
+
Explicit composition · Immutable modifiers · Theme-driven
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<img src="https://img.shields.io/badge/status-alpha-orange" />
|
|
14
|
+
<img src="https://img.shields.io/badge/version-0.0.1-blue" />
|
|
15
|
+
<img src="https://img.shields.io/badge/Svelte-FF3E00?logo=svelte&logoColor=white" />
|
|
16
|
+
<img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white" />
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## What is Svelted?
|
|
22
|
+
|
|
23
|
+
**Svelted** is a UI toolkit for the web inspired by **Jetpack Compose**
|
|
24
|
+
and built natively on top of **Svelte**.
|
|
25
|
+
|
|
26
|
+
It brings the Compose mental model to the web:
|
|
27
|
+
|
|
28
|
+
- Explicit UI composition
|
|
29
|
+
- Immutable and chainable `Modifier`s
|
|
30
|
+
- Theme-first design
|
|
31
|
+
- No virtual DOM abstractions
|
|
32
|
+
- No hidden styling magic
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Core Principles
|
|
37
|
+
|
|
38
|
+
### 🧩 Composition over configuration
|
|
39
|
+
UI is built by composing small, predictable components.
|
|
40
|
+
|
|
41
|
+
### 🧱 Modifiers
|
|
42
|
+
Layout, drawing, interaction and behavior are controlled through immutable modifiers.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
Modifier
|
|
46
|
+
.padding(16)
|
|
47
|
+
.fillMaxWidth()
|
|
48
|
+
.background(ColorScheme.Surface)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 🎨 Theme-driven
|
|
52
|
+
Design tokens come from the theme, not from hardcoded styles.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Components (v0.0.1)
|
|
57
|
+
|
|
58
|
+
<p align="center">
|
|
59
|
+
<img src="assets/svelted.svg" width="96" />
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
### Layout
|
|
63
|
+
- Column, Row, Box, Spacer
|
|
64
|
+
- LazyColumn *(experimental)*
|
|
65
|
+
- LazyRow *(experimental)*
|
|
66
|
+
|
|
67
|
+
### Foundation
|
|
68
|
+
- Surface, Text, Image, Icon
|
|
69
|
+
|
|
70
|
+
### Inputs
|
|
71
|
+
- TextField
|
|
72
|
+
- OutlinedTextField
|
|
73
|
+
|
|
74
|
+
### Buttons
|
|
75
|
+
- Button, TextButton
|
|
76
|
+
- OutlinedButton, TonalButton
|
|
77
|
+
- IconButton
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Quick Example
|
|
82
|
+
|
|
83
|
+
```svelte
|
|
84
|
+
<ComposeTheme mode="system">
|
|
85
|
+
<AppRoot>
|
|
86
|
+
<Surface modifier={Modifier.fillMaxSize().padding(32)}>
|
|
87
|
+
<Column>
|
|
88
|
+
<Text textStyle="titleLarge">Hello Compose</Text>
|
|
89
|
+
<Text>This is Svelted.</Text>
|
|
90
|
+
</Column>
|
|
91
|
+
</Surface>
|
|
92
|
+
</AppRoot>
|
|
93
|
+
</ComposeTheme>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Get Started
|
|
99
|
+
|
|
100
|
+
👉 **[Getting Started](./getting_started.html)**
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
<p align="center">
|
|
105
|
+
Built with ❤️ for developers who value clarity and composable UI.
|
|
106
|
+
</p>
|
package/index.html
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<link href="/src/app.css" rel="stylesheet">
|
|
8
|
+
<title>compose_svelted</title>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="app"></div>
|
|
12
|
+
<script type="module" src="/src/main.ts"></script>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@danielito1996/compose-svelted",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "Compose-like UI toolkit for Svelte",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"svelte",
|
|
9
|
+
"ui",
|
|
10
|
+
"compose",
|
|
11
|
+
"design-system",
|
|
12
|
+
"material"
|
|
13
|
+
],
|
|
14
|
+
"author": "Daniel Imbert Tabares",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/danielitoCode/compose_svelted"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "vite",
|
|
27
|
+
"build": "vite build",
|
|
28
|
+
"preview": "vite preview",
|
|
29
|
+
"check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
33
|
+
"@tsconfig/svelte": "^5.0.6",
|
|
34
|
+
"@types/node": "^24.10.1",
|
|
35
|
+
"autoprefixer": "^10.4.23",
|
|
36
|
+
"postcss": "^8.5.6",
|
|
37
|
+
"svelte": "^5.43.8",
|
|
38
|
+
"svelte-check": "^4.3.4",
|
|
39
|
+
"tailwindcss": "^4.1.18",
|
|
40
|
+
"typescript": "~5.9.3",
|
|
41
|
+
"vite": "npm:rolldown-vite@7.2.5"
|
|
42
|
+
},
|
|
43
|
+
"overrides": {
|
|
44
|
+
"vite": "npm:rolldown-vite@7.2.5"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@tailwindcss/vite": "^4.1.18"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/public/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/src/App.svelte
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
AppRoot,
|
|
4
|
+
Column,
|
|
5
|
+
Surface,
|
|
6
|
+
Text,
|
|
7
|
+
OutlinedTextField,
|
|
8
|
+
ComposeTheme,
|
|
9
|
+
Icon,
|
|
10
|
+
ColorScheme,
|
|
11
|
+
RoundedCornerShape, Row, TextField, Box, Alignment, TextStyle, Button
|
|
12
|
+
} from "./lib";
|
|
13
|
+
|
|
14
|
+
import { Modifier } from "./lib";
|
|
15
|
+
import { Arrangement } from "./lib";
|
|
16
|
+
|
|
17
|
+
let name = "";
|
|
18
|
+
let email = "";
|
|
19
|
+
let bio = "";
|
|
20
|
+
let filled = "Texto inicial";
|
|
21
|
+
let notes = "";
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<ComposeTheme mode="system">
|
|
25
|
+
<AppRoot>
|
|
26
|
+
<Surface
|
|
27
|
+
color={ColorScheme.Background}
|
|
28
|
+
modifier={Modifier.fillMaxSize().verticalScroll(true)}
|
|
29
|
+
>
|
|
30
|
+
<Box
|
|
31
|
+
modifier={Modifier.fillMaxSize()}
|
|
32
|
+
contentAlignment={Alignment.Center}
|
|
33
|
+
>
|
|
34
|
+
|
|
35
|
+
<Button onClick={()=>console.log("click")}>Custom Button</Button>
|
|
36
|
+
</Box>
|
|
37
|
+
</Surface>
|
|
38
|
+
</AppRoot>
|
|
39
|
+
</ComposeTheme>
|
package/src/app.css
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
/* RESET NEUTRO — NO layout, NO tema */
|
|
3
|
+
*,
|
|
4
|
+
*::before,
|
|
5
|
+
*::after {
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
html,
|
|
10
|
+
body {
|
|
11
|
+
margin: 0;
|
|
12
|
+
padding: 0;
|
|
13
|
+
min-width: 320px;
|
|
14
|
+
min-height: 100vh;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* IMPORTANTE:
|
|
19
|
+
- NO display:flex
|
|
20
|
+
- NO centrar
|
|
21
|
+
- NO colores
|
|
22
|
+
- NO tipografía
|
|
23
|
+
*/
|
|
Binary file
|
|
Binary file
|