@danielito1996/compose-svelted 0.2.7 → 0.2.8-alpha01
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 +196 -113
- package/dist/components/AppRoot.svelte +26 -14
- package/dist/components/Surface.svelte +29 -19
- package/dist/components/Text.svelte +37 -23
- package/dist/components/buttons/Button.svelte +66 -34
- package/dist/components/buttons/CheckButton.svelte +2 -2
- package/dist/components/layouts/Alignment.d.ts +40 -18
- package/dist/components/layouts/Alignment.js +40 -18
- package/dist/components/layouts/Arrangement.d.ts +27 -11
- package/dist/components/layouts/Arrangement.js +34 -41
- package/dist/components/layouts/Box.svelte +54 -25
- package/dist/components/layouts/Box.svelte.d.ts +8 -1
- package/dist/components/layouts/Column.svelte +52 -23
- package/dist/components/layouts/Column.svelte.d.ts +10 -2
- package/dist/components/layouts/LayoutContext.d.ts +1 -0
- package/dist/components/layouts/LayoutContext.js +1 -0
- package/dist/components/layouts/LazyColumn.svelte +12 -12
- package/dist/components/layouts/LazyRow.svelte +81 -45
- package/dist/components/layouts/LazyRow.svelte.d.ts +3 -6
- package/dist/components/layouts/Row.svelte +52 -23
- package/dist/components/layouts/Row.svelte.d.ts +10 -2
- package/dist/components/layouts/Scaffold.svelte +86 -73
- package/dist/components/layouts/Scaffold.svelte.d.ts +5 -1
- package/dist/components/layouts/resolveAlignment.d.ts +25 -0
- package/dist/components/layouts/resolveAlignment.js +48 -0
- package/dist/components/layouts/resolveFlexAlignSelf.d.ts +6 -0
- package/dist/components/layouts/resolveFlexAlignSelf.js +8 -0
- package/dist/components/motion/motion/AnimatedContent.svelte +41 -0
- package/dist/components/motion/{AnimatedContent.svelte.d.ts → motion/AnimatedContent.svelte.d.ts} +1 -1
- package/dist/components/motion/{AnimatedVisibility.svelte → motion/AnimatedVisibility.svelte} +3 -3
- package/dist/components/motion/{AnimatedVisibility.svelte.d.ts → motion/AnimatedVisibility.svelte.d.ts} +1 -1
- package/dist/components/motion/motion/AnimationSpec.d.ts +6 -0
- package/dist/components/motion/motion/AnimationSpec.js +1 -0
- package/dist/components/motion/motion/ContentTransition.d.ts +5 -0
- package/dist/components/motion/motion/ContentTransition.js +1 -0
- package/dist/components/motion/motion/applyAnimation.d.ts +0 -0
- package/dist/components/motion/motion/applyAnimation.js +0 -0
- package/dist/components/motion/motion/contentTransitions.d.ts +4 -0
- package/dist/components/motion/motion/contentTransitions.js +22 -0
- package/dist/components/motion/motion/transitions.d.ts +7 -0
- package/dist/components/motion/motion/transitions.js +70 -0
- package/dist/components/textFields/BaseTextField.svelte +4 -3
- package/dist/components/textFields/BaseTextField.svelte.d.ts +1 -0
- package/dist/components/textFields/OutlinedTextField.svelte +8 -7
- package/dist/components/textFields/TextField.svelte +8 -8
- package/dist/core/modifier/Modifier.d.ts +11 -171
- package/dist/core/modifier/Modifier.js +8 -170
- package/dist/core/modifier/ModifierImpl.d.ts +29 -17
- package/dist/core/modifier/ModifierImpl.js +112 -151
- package/dist/core/motion/AnimationSpec.d.ts +1 -6
- package/dist/core/motion/ContentTransition.d.ts +1 -5
- package/dist/core/motion/applyAnimation.d.ts +2 -0
- package/dist/core/motion/applyAnimation.js +3 -0
- package/dist/core/motion/contentTransitions.d.ts +1 -4
- package/dist/core/motion/contentTransitions.js +1 -22
- package/dist/core/motion/transitions.d.ts +1 -7
- package/dist/core/motion/transitions.js +1 -70
- package/dist/core/navigation/NavHost.svelte +46 -45
- package/dist/core/styles/baseline-safe.css +34 -0
- package/dist/core/styles/baseline.css +45 -0
- package/dist/core/theme/ColorScheme.d.ts +2 -0
- package/dist/core/theme/ColorScheme.js +2 -0
- package/dist/core/theme/ComposeTheme.svelte +36 -21
- package/dist/core/theme/colors.d.ts +2 -0
- package/dist/core/theme/defaults/darkColors.js +2 -0
- package/dist/core/theme/defaults/lightColors.js +2 -0
- package/dist/index.d.ts +48 -129
- package/dist/index.js +7 -2
- package/package.json +73 -58
- package/dist/components/motion/AnimatedContent.svelte +0 -34
package/README.md
CHANGED
|
@@ -1,113 +1,196 @@
|
|
|
1
|
-
# compose-svelted
|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<img src="docs/assets/svelted.png" width="960" alt="compose-svelted" />
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
8
|
-
<b>Compose-inspired UI framework for Svelte</b><br/>
|
|
9
|
-
Declarative layout · Immutable modifiers · Structural motion · Compose-like navigation
|
|
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/Svelte-FF3E00?logo=svelte&logoColor=white" />
|
|
15
|
-
<img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white" />
|
|
16
|
-
</p>
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## ✨ What is compose-svelted?
|
|
21
|
-
|
|
22
|
-
**compose-svelted** is an experimental but ambitious UI framework that brings the
|
|
23
|
-
**Jetpack Compose mental model** to the Svelte ecosystem.
|
|
24
|
-
|
|
25
|
-
It is **not** a Material Design clone, and it is **not** a thin component library.
|
|
26
|
-
|
|
27
|
-
Instead, it focuses on:
|
|
28
|
-
- explicit UI composition
|
|
29
|
-
- predictable layout
|
|
30
|
-
- declarative motion
|
|
31
|
-
- navigation as state
|
|
32
|
-
|
|
33
|
-
All built on top of **Svelte**, without virtual DOM abstractions or hidden magic.
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## 🧠 Core Philosophy
|
|
38
|
-
|
|
39
|
-
> UI is a function of state.
|
|
40
|
-
> Layout, motion, and navigation must be explicit and predictable.
|
|
41
|
-
|
|
42
|
-
Key ideas:
|
|
43
|
-
- No implicit behavior
|
|
44
|
-
- No global side effects
|
|
45
|
-
- No magic context you cannot reason about
|
|
46
|
-
- Everything composes
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
## 🧱 Library Structure (High-Level)
|
|
51
|
-
|
|
52
|
-
### Core V1 – Layout & Styling
|
|
53
|
-
- Column, Row, Box
|
|
54
|
-
- Modifier (immutable, chainable)
|
|
55
|
-
- Shapes
|
|
56
|
-
- Theme system
|
|
57
|
-
- Typography
|
|
58
|
-
|
|
59
|
-
### Core V2 – Motion & Navigation (CLOSED)
|
|
60
|
-
- AnimatedVisibility
|
|
61
|
-
- AnimatedContent
|
|
62
|
-
- Declarative motion
|
|
63
|
-
- NavController
|
|
64
|
-
- NavHost
|
|
65
|
-
- Internal backstack
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
## 💪 Strengths
|
|
70
|
-
|
|
71
|
-
### Explicit Layout
|
|
72
|
-
Layouts are predictable and composable.
|
|
73
|
-
|
|
74
|
-
### Immutable Modifiers
|
|
75
|
-
Describe intent, not CSS.
|
|
76
|
-
|
|
77
|
-
### Structural Motion
|
|
78
|
-
Motion is part of the UI structure.
|
|
79
|
-
|
|
80
|
-
### Compose-like Navigation
|
|
81
|
-
Navigation without external routers.
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## 🚀 Innovation
|
|
86
|
-
|
|
87
|
-
- Compose mental model on the web
|
|
88
|
-
- Navigation as state
|
|
89
|
-
- Motion as structure
|
|
90
|
-
- No virtual DOM abstraction
|
|
91
|
-
|
|
92
|
-
---
|
|
93
|
-
|
|
94
|
-
## 📦 Status
|
|
95
|
-
|
|
96
|
-
- Alpha
|
|
97
|
-
- Core V2 closed
|
|
98
|
-
- Core V3 planned
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
1
|
+
# compose-svelted
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="docs/assets/svelted.png" width="960" alt="compose-svelted" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<b>Compose-inspired UI framework for Svelte</b><br/>
|
|
9
|
+
Declarative layout · Immutable modifiers · Structural motion · Compose-like navigation
|
|
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/Svelte-FF3E00?logo=svelte&logoColor=white" />
|
|
15
|
+
<img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white" />
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## ✨ What is compose-svelted?
|
|
21
|
+
|
|
22
|
+
**compose-svelted** is an experimental but ambitious UI framework that brings the
|
|
23
|
+
**Jetpack Compose mental model** to the Svelte ecosystem.
|
|
24
|
+
|
|
25
|
+
It is **not** a Material Design clone, and it is **not** a thin component library.
|
|
26
|
+
|
|
27
|
+
Instead, it focuses on:
|
|
28
|
+
- explicit UI composition
|
|
29
|
+
- predictable layout
|
|
30
|
+
- declarative motion
|
|
31
|
+
- navigation as state
|
|
32
|
+
|
|
33
|
+
All built on top of **Svelte**, without virtual DOM abstractions or hidden magic.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🧠 Core Philosophy
|
|
38
|
+
|
|
39
|
+
> UI is a function of state.
|
|
40
|
+
> Layout, motion, and navigation must be explicit and predictable.
|
|
41
|
+
|
|
42
|
+
Key ideas:
|
|
43
|
+
- No implicit behavior
|
|
44
|
+
- No global side effects
|
|
45
|
+
- No magic context you cannot reason about
|
|
46
|
+
- Everything composes
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 🧱 Library Structure (High-Level)
|
|
51
|
+
|
|
52
|
+
### Core V1 – Layout & Styling
|
|
53
|
+
- Column, Row, Box
|
|
54
|
+
- Modifier (immutable, chainable)
|
|
55
|
+
- Shapes
|
|
56
|
+
- Theme system
|
|
57
|
+
- Typography
|
|
58
|
+
|
|
59
|
+
### Core V2 – Motion & Navigation (CLOSED)
|
|
60
|
+
- AnimatedVisibility
|
|
61
|
+
- AnimatedContent
|
|
62
|
+
- Declarative motion
|
|
63
|
+
- NavController
|
|
64
|
+
- NavHost
|
|
65
|
+
- Internal backstack
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 💪 Strengths
|
|
70
|
+
|
|
71
|
+
### Explicit Layout
|
|
72
|
+
Layouts are predictable and composable.
|
|
73
|
+
|
|
74
|
+
### Immutable Modifiers
|
|
75
|
+
Describe intent, not CSS.
|
|
76
|
+
|
|
77
|
+
### Structural Motion
|
|
78
|
+
Motion is part of the UI structure.
|
|
79
|
+
|
|
80
|
+
### Compose-like Navigation
|
|
81
|
+
Navigation without external routers.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 🚀 Innovation
|
|
86
|
+
|
|
87
|
+
- Compose mental model on the web
|
|
88
|
+
- Navigation as state
|
|
89
|
+
- Motion as structure
|
|
90
|
+
- No virtual DOM abstraction
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 📦 Status
|
|
95
|
+
|
|
96
|
+
- Alpha
|
|
97
|
+
- Core V2 closed
|
|
98
|
+
- Core V3 planned
|
|
99
|
+
|
|
100
|
+
## Project Zones
|
|
101
|
+
|
|
102
|
+
- `src/lib`: publishable library source.
|
|
103
|
+
- `playground`: local app for developing and validating the library against live source changes.
|
|
104
|
+
- `src/App.svelte` and `src/samples`: legacy examples, not part of the active library/playground workflow.
|
|
105
|
+
|
|
106
|
+
## Development Commands
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npm install
|
|
110
|
+
npm run dev
|
|
111
|
+
npm run build
|
|
112
|
+
npm run check
|
|
113
|
+
npm run playground:build
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- `npm run dev`: starts the playground.
|
|
117
|
+
- `npm run build`: packages the library into `dist/`.
|
|
118
|
+
- `npm run check`: type-checks the playground against the current library source.
|
|
119
|
+
- `playground/vite.config.ts` aliases `@danielito1996/compose-svelted` to `src/lib/index.ts`, so playground changes reflect library source immediately.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 🔮 Roadmap
|
|
124
|
+
|
|
125
|
+
### Core V3
|
|
126
|
+
- Nested navigation
|
|
127
|
+
- Directional transitions
|
|
128
|
+
- Shared elements
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## ⚠️ CSS Baseline (Required)
|
|
133
|
+
|
|
134
|
+
Compose Svelted is **layout-deterministic**, assumes a neutral CSS baseline.
|
|
135
|
+
|
|
136
|
+
You MUST include the following reset in your app:
|
|
137
|
+
|
|
138
|
+
To avoid layout regressions in existing apps, use one of these two paths:
|
|
139
|
+
|
|
140
|
+
### Path A (Primary): import baseline from the package
|
|
141
|
+
|
|
142
|
+
- **Strict baseline** (Compose-like deterministic behavior):
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import "@danielito1996/compose-svelted/baseline.css";
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- **Safe baseline** (less intrusive for existing projects):
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import "@danielito1996/compose-svelted/baseline-safe.css";
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Use `baseline-safe.css` if your app already has strong global styles and you want minimal interference.
|
|
155
|
+
|
|
156
|
+
### Path B (Alternative): do not import baseline, adapt your own `app.css`
|
|
157
|
+
|
|
158
|
+
If you prefer full control, keep your app stylesheet and ensure at least:
|
|
159
|
+
|
|
160
|
+
```css
|
|
161
|
+
*,
|
|
162
|
+
*::before,
|
|
163
|
+
*::after {
|
|
164
|
+
box-sizing: border-box;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
html, body, #app {
|
|
168
|
+
width: 100%;
|
|
169
|
+
height: 100%;
|
|
170
|
+
margin: 0;
|
|
171
|
+
padding: 0;
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
To guarantee consistent and predictable behavior of layout components such as
|
|
176
|
+
`Box`, `Column`, `Row`, `Surface`, `Scaffold`, and navigation containers,
|
|
177
|
+
a **neutral CSS baseline is required** in the host application.
|
|
178
|
+
|
|
179
|
+
This is **intentional** and mirrors the contract-based approach of **Jetpack Compose**.
|
|
180
|
+
|
|
181
|
+
### Why this matters
|
|
182
|
+
|
|
183
|
+
Compose Svelted does **not**:
|
|
184
|
+
- force global CSS
|
|
185
|
+
- inject layout styles silently
|
|
186
|
+
- assume browser defaults
|
|
187
|
+
|
|
188
|
+
Instead, it expects a minimal, explicit layout contract.
|
|
189
|
+
Without this baseline, layout behavior may vary between browsers or projects.
|
|
190
|
+
|
|
191
|
+
### Tailwind CSS
|
|
192
|
+
|
|
193
|
+
Compose Svelted **does not require Tailwind CSS**.
|
|
194
|
+
|
|
195
|
+
Tailwind is used internally as an implementation detail for predictable styling,
|
|
196
|
+
but consumers of the library are **not required** to install or configure Tailwind.
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
-
|
|
4
|
-
export let modifier: Modifier = Modifier.empty();
|
|
5
|
-
</script>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
+
|
|
4
|
+
export let modifier: Modifier = Modifier.empty();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<!--
|
|
8
|
+
AppRoot — ancla de toda la aplicación.
|
|
9
|
+
|
|
10
|
+
Ocupa el 100% del contenedor padre (que gracias a baseline.css es el viewport).
|
|
11
|
+
overflow:hidden garantiza que ningún hijo desborde el viewport accidentalmente.
|
|
12
|
+
position:relative es el contexto de posicionamiento para capas absolutas internas.
|
|
13
|
+
Se añade display:flex para actuar como raíz sólida para el crecimiento de hijos.
|
|
14
|
+
-->
|
|
15
|
+
<div
|
|
16
|
+
class="cs-relative"
|
|
17
|
+
style={`
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
${modifier.toStyle()}
|
|
24
|
+
`}
|
|
25
|
+
>
|
|
26
|
+
<slot />
|
|
15
27
|
</div>
|
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
-
import { resolveColor } from "../core/theme/resolve";
|
|
4
|
-
import type { ColorToken } from "../core/theme/ColorScheme";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
+
import { resolveColor } from "../core/theme/resolve";
|
|
4
|
+
import type { ColorToken } from "../core/theme/ColorScheme";
|
|
5
|
+
|
|
6
|
+
export let modifier: Modifier = Modifier.empty();
|
|
7
|
+
export let color: ColorToken = "surface";
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<!--
|
|
11
|
+
Surface — Contenedor base de Material 3.
|
|
12
|
+
Sin dependencias de Tailwind.
|
|
13
|
+
-->
|
|
14
|
+
<div
|
|
15
|
+
class="cs-surface"
|
|
16
|
+
style={`
|
|
17
|
+
background:${resolveColor(color)};
|
|
18
|
+
${modifier.toStyle()}
|
|
19
|
+
`}
|
|
20
|
+
>
|
|
21
|
+
<slot />
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
.cs-surface {
|
|
26
|
+
display: block;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
-
import { resolveTextStyle, resolveColor } from "../core/theme/resolve";
|
|
4
|
-
import type { TextStyleToken } from "../core/theme/TextStyle";
|
|
5
|
-
import { ColorScheme, type ColorToken } from "../core/theme/ColorScheme";
|
|
6
|
-
|
|
7
|
-
export let modifier: Modifier = Modifier.empty();
|
|
8
|
-
export let textStyle: TextStyleToken = "bodyMedium";
|
|
9
|
-
|
|
10
|
-
// Aceptamos token o string directo
|
|
11
|
-
export let color: ColorToken | string = "onSurface";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
+
import { resolveTextStyle, resolveColor } from "../core/theme/resolve";
|
|
4
|
+
import type { TextStyleToken } from "../core/theme/TextStyle";
|
|
5
|
+
import { ColorScheme, type ColorToken } from "../core/theme/ColorScheme";
|
|
6
|
+
|
|
7
|
+
export let modifier: Modifier = Modifier.empty();
|
|
8
|
+
export let textStyle: TextStyleToken = "bodyMedium";
|
|
9
|
+
|
|
10
|
+
// Aceptamos token o string directo
|
|
11
|
+
export let color: ColorToken | string = "onSurface";
|
|
12
|
+
|
|
13
|
+
$: resolvedColor = typeof color === "string" ? resolveColor(color as ColorToken) : color;
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<!--
|
|
17
|
+
Text — Componente Material 3 independiente.
|
|
18
|
+
No depende de Tailwind.
|
|
19
|
+
-->
|
|
20
|
+
<p
|
|
21
|
+
class="cs-text"
|
|
22
|
+
style={`
|
|
23
|
+
${resolveTextStyle(textStyle)};
|
|
24
|
+
color: ${resolvedColor};
|
|
25
|
+
${modifier.toStyle()}
|
|
26
|
+
`}
|
|
27
|
+
>
|
|
28
|
+
<slot />
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.cs-text {
|
|
33
|
+
display: block;
|
|
34
|
+
margin: 0;
|
|
35
|
+
padding: 0;
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
@@ -1,34 +1,66 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Modifier } from "../../core/modifier/Modifier";
|
|
3
|
-
import { resolveColor } from "../../core/theme/resolve";
|
|
4
|
-
import { ColorScheme, type ColorToken } from "../../core/theme/ColorScheme";
|
|
5
|
-
|
|
6
|
-
export let onClick: () => void = () => {};
|
|
7
|
-
export let modifier: Modifier = Modifier.empty();
|
|
8
|
-
|
|
9
|
-
export let color: ColorToken | string = "primary";
|
|
10
|
-
export let onColor: ColorToken | string = "onPrimary";
|
|
11
|
-
|
|
12
|
-
export let shape: "none" | "extraSmall" | "small" | "medium" | "large" = "large";
|
|
13
|
-
export let elevation: "level0" | "level1" | "level2" | "level3" | "level4" = "level1";
|
|
14
|
-
|
|
15
|
-
$: backgroundColor = typeof color === "string" ? resolveColor(color as ColorToken) : color;
|
|
16
|
-
$: contentColor = typeof onColor === "string" ? resolveColor(onColor as ColorToken) : onColor;
|
|
17
|
-
$: borderRadius = `var(--md-sys-shape-${shape})`;
|
|
18
|
-
$: boxShadow = `var(--md-sys-elevation-${elevation})`;
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
${
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Modifier } from "../../core/modifier/Modifier";
|
|
3
|
+
import { resolveColor } from "../../core/theme/resolve";
|
|
4
|
+
import { ColorScheme, type ColorToken } from "../../core/theme/ColorScheme";
|
|
5
|
+
|
|
6
|
+
export let onClick: () => void = () => {};
|
|
7
|
+
export let modifier: Modifier = Modifier.empty();
|
|
8
|
+
|
|
9
|
+
export let color: ColorToken | string = "primary";
|
|
10
|
+
export let onColor: ColorToken | string = "onPrimary";
|
|
11
|
+
|
|
12
|
+
export let shape: "none" | "extraSmall" | "small" | "medium" | "large" = "large";
|
|
13
|
+
export let elevation: "level0" | "level1" | "level2" | "level3" | "level4" = "level1";
|
|
14
|
+
|
|
15
|
+
$: backgroundColor = typeof color === "string" ? resolveColor(color as ColorToken) : color;
|
|
16
|
+
$: contentColor = typeof onColor === "string" ? resolveColor(onColor as ColorToken) : onColor;
|
|
17
|
+
$: borderRadius = `var(--md-sys-shape-${shape})`;
|
|
18
|
+
$: boxShadow = `var(--md-sys-elevation-${elevation})`;
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<!--
|
|
22
|
+
Button — Componente Material 3 independiente.
|
|
23
|
+
No depende de Tailwind.
|
|
24
|
+
-->
|
|
25
|
+
<button
|
|
26
|
+
on:click={onClick}
|
|
27
|
+
class="cs-button"
|
|
28
|
+
style={`
|
|
29
|
+
background: ${backgroundColor};
|
|
30
|
+
color: ${contentColor};
|
|
31
|
+
border-radius: ${borderRadius};
|
|
32
|
+
box-shadow: ${boxShadow};
|
|
33
|
+
${modifier.toStyle()}
|
|
34
|
+
`}
|
|
35
|
+
>
|
|
36
|
+
<slot />
|
|
37
|
+
</button>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
.cs-button {
|
|
41
|
+
display: inline-flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
border: none;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
padding: 10px 24px;
|
|
47
|
+
gap: 8px;
|
|
48
|
+
font-family: inherit;
|
|
49
|
+
font-weight: 500;
|
|
50
|
+
letter-spacing: 0.1px;
|
|
51
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
52
|
+
user-select: none;
|
|
53
|
+
-webkit-tap-highlight-color: transparent;
|
|
54
|
+
outline: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.cs-button:hover {
|
|
58
|
+
opacity: 0.92;
|
|
59
|
+
box-shadow: var(--md-sys-elevation-level2);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.cs-button:active {
|
|
63
|
+
transform: scale(0.97);
|
|
64
|
+
opacity: 0.85;
|
|
65
|
+
}
|
|
66
|
+
</style>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { ColorScheme } from "../../core/theme/ColorScheme";
|
|
4
4
|
import { resolveColor } from "../../core/theme/resolve";
|
|
5
5
|
import { RoundedCornerShape } from "../../core/shapes/RoundedCornerShape";
|
|
6
|
-
import AnimatedVisibility from "../motion/AnimatedVisibility.svelte";
|
|
6
|
+
import AnimatedVisibility from "../motion/motion/AnimatedVisibility.svelte";
|
|
7
7
|
import { scaleIn, scaleOut } from "../../core/motion/transitions";
|
|
8
8
|
import type { Shape } from "../../core/shapes/Shape";
|
|
9
9
|
|
|
@@ -74,4 +74,4 @@
|
|
|
74
74
|
|
|
75
75
|
<!-- Content -->
|
|
76
76
|
<slot />
|
|
77
|
-
</button>
|
|
77
|
+
</button>
|
|
@@ -1,20 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alignment — tokens de alineación type-safe con branded types.
|
|
3
|
+
*
|
|
4
|
+
* Los objetos son opacos: nunca se puede pasar un VerticalAlignment donde
|
|
5
|
+
* se espera un HorizontalAlignment, aunque ambos representen "center" en CSS.
|
|
6
|
+
*
|
|
7
|
+
* Filosofía Jetpack Compose:
|
|
8
|
+
* - HorizontalAlignment → eje cross de Column
|
|
9
|
+
* - VerticalAlignment → eje cross de Row
|
|
10
|
+
* - BoxAlignment → alineación compuesta para Box (stack)
|
|
11
|
+
*/
|
|
12
|
+
export type HorizontalAlignment = {
|
|
13
|
+
readonly _brand: 'HorizontalAlignment';
|
|
14
|
+
readonly cssValue: string;
|
|
15
|
+
};
|
|
16
|
+
export type VerticalAlignment = {
|
|
17
|
+
readonly _brand: 'VerticalAlignment';
|
|
18
|
+
readonly cssValue: string;
|
|
19
|
+
};
|
|
20
|
+
/** Alineación compuesta para Box — encapsula horizontal + vertical */
|
|
21
|
+
export type BoxAlignment = {
|
|
22
|
+
readonly _brand: 'BoxAlignment';
|
|
23
|
+
readonly horizontal: string;
|
|
24
|
+
readonly vertical: string;
|
|
25
|
+
};
|
|
1
26
|
export declare const Alignment: {
|
|
2
|
-
readonly Start:
|
|
3
|
-
readonly CenterHorizontally:
|
|
4
|
-
readonly End:
|
|
5
|
-
readonly Top:
|
|
6
|
-
readonly CenterVertically:
|
|
7
|
-
readonly Bottom:
|
|
8
|
-
readonly TopStart:
|
|
9
|
-
readonly TopCenter:
|
|
10
|
-
readonly TopEnd:
|
|
11
|
-
readonly CenterStart:
|
|
12
|
-
readonly Center:
|
|
13
|
-
readonly CenterEnd:
|
|
14
|
-
readonly BottomStart:
|
|
15
|
-
readonly BottomCenter:
|
|
16
|
-
readonly BottomEnd:
|
|
27
|
+
readonly Start: HorizontalAlignment;
|
|
28
|
+
readonly CenterHorizontally: HorizontalAlignment;
|
|
29
|
+
readonly End: HorizontalAlignment;
|
|
30
|
+
readonly Top: VerticalAlignment;
|
|
31
|
+
readonly CenterVertically: VerticalAlignment;
|
|
32
|
+
readonly Bottom: VerticalAlignment;
|
|
33
|
+
readonly TopStart: BoxAlignment;
|
|
34
|
+
readonly TopCenter: BoxAlignment;
|
|
35
|
+
readonly TopEnd: BoxAlignment;
|
|
36
|
+
readonly CenterStart: BoxAlignment;
|
|
37
|
+
readonly Center: BoxAlignment;
|
|
38
|
+
readonly CenterEnd: BoxAlignment;
|
|
39
|
+
readonly BottomStart: BoxAlignment;
|
|
40
|
+
readonly BottomCenter: BoxAlignment;
|
|
41
|
+
readonly BottomEnd: BoxAlignment;
|
|
17
42
|
};
|
|
18
|
-
export type HorizontalAlignment = typeof Alignment.Start | typeof Alignment.CenterHorizontally | typeof Alignment.End;
|
|
19
|
-
export type VerticalAlignment = typeof Alignment.Top | typeof Alignment.CenterVertically | typeof Alignment.Bottom;
|
|
20
|
-
export type BoxAlignment = typeof Alignment[keyof typeof Alignment];
|