@tooark/tokens 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 +201 -0
- package/NOTICE +12 -0
- package/README.md +129 -0
- package/README.pt-BR.md +129 -0
- package/dist/index.cjs +90 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +38 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +84 -0
- package/dist/index.js.map +1 -0
- package/package.json +85 -0
- package/tokens.css +190 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Tooark
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Tooark Web Components
|
|
2
|
+
Copyright 2026 Tooark
|
|
3
|
+
|
|
4
|
+
This product includes software developed as part of the Tooark project
|
|
5
|
+
(https://github.com/Tooark/web-components).
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0.
|
|
8
|
+
|
|
9
|
+
This product does not bundle third-party source code in its distributed
|
|
10
|
+
artifacts; all runtime dependencies are declared as external packages and
|
|
11
|
+
installed separately by consumers under their own licenses. See
|
|
12
|
+
THIRD-PARTY-NOTICES.md for an overview of those dependencies and licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# @tooark/tokens
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@tooark/tokens)
|
|
4
|
+
[](https://github.com/Tooark/web-components/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
Design primitives of the Tooark design system: colors by intent, size scale, radii and motion tokens as CSS custom properties, a Tailwind v4 `@theme` and TypeScript types.
|
|
7
|
+
|
|
8
|
+
🌍 **Languages:**  **English (this file)** · [ Português](./README.pt-BR.md)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Contents
|
|
13
|
+
|
|
14
|
+
- [Overview](#-overview)
|
|
15
|
+
- [Installation](#-installation)
|
|
16
|
+
- [Configuration](#️-configuration)
|
|
17
|
+
- [Components](#-components)
|
|
18
|
+
- [Usage examples](#-usage-examples)
|
|
19
|
+
- [Dependencies](#-dependencies)
|
|
20
|
+
- [Contributing](#-contributing)
|
|
21
|
+
- [License](#-license)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 📖 Overview
|
|
26
|
+
|
|
27
|
+
The `@tooark/tokens` package provides:
|
|
28
|
+
|
|
29
|
+
- `tokens.css`: a `@theme static` block with semantic colors (`primary`, `secondary`, `success`, `warning`, `danger`, `info`, `neutral`, plus `surface*`, `fg*`, `border*`) as `light-dark()` values, the size scale (`--size-xs…xl`), the `--text-2xs` step and Tailwind's radii;
|
|
30
|
+
- motion tokens outside `@theme`: `--ark-duration-*` (eight steps), `--ark-ease-*` (`linear`, `standard`, `in`, `out`, `in-out`, `overshoot`, `sheet`) and `--ark-motion-distance`, zeroed under `prefers-reduced-motion`;
|
|
31
|
+
- JS mirrors of the motion tokens (`ARK_DURATION_MS`, `ARK_EASING_CSS`, `ARK_MOTION_DISTANCE`) for WAAPI fallbacks;
|
|
32
|
+
- `resolveColorScheme(element)` and `observeColorScheme(element, onChange)` to resolve and follow the page theme;
|
|
33
|
+
- the primitive types every package shares: `ArkIntent`, `ArkSize`, `ArkRounded`, `ArkTheme`, `ArkDuration`, `ArkEasing`.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🔧 Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pnpm add @tooark/tokens
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Not needed directly when you use `@tooark/web-components`: its `styles.css` already bundles the tokens.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## ⚙️ Configuration
|
|
48
|
+
|
|
49
|
+
Import the stylesheet in your own CSS or Tailwind entry and declare the page's `color-scheme` (the tokens are `light-dark()` values, so the theme is pure CSS):
|
|
50
|
+
|
|
51
|
+
```css
|
|
52
|
+
@import "@tooark/tokens/tokens.css";
|
|
53
|
+
|
|
54
|
+
:root {
|
|
55
|
+
color-scheme: light dark; /* follow the system; or "light" / "dark" to force a side */
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 📦 Components
|
|
62
|
+
|
|
63
|
+
### CSS custom properties
|
|
64
|
+
|
|
65
|
+
- Colors: `--ark-color-<intent>`, `-fg`, `-hover`, `-soft`, `-soft-fg`, `-border`, `-ring`; neutrals `--ark-color-surface`, `-surface-muted`, `-fg`, `-fg-soft`, `-fg-muted`, `-border`, `-ring`.
|
|
66
|
+
- Sizes: `--ark-size-xs…xl` (1.5 / 1.75 / 2.25 / 2.75 / 3.25 rem, the min-height of form controls); `--ark-text-2xs` (0.6875 rem) for micro-labels.
|
|
67
|
+
- Motion: `--ark-duration-none|instant|quick|default|moderate|gentle|slow|long`, `--ark-ease-*`, `--ark-motion-distance`.
|
|
68
|
+
|
|
69
|
+
### JavaScript
|
|
70
|
+
|
|
71
|
+
- `resolveColorScheme(element?)` → `"light" | "dark"` from the element's computed `color-scheme` (system preference when the page leaves it at `light dark`).
|
|
72
|
+
- `observeColorScheme(element, onChange)` → dispose function; watches `class`, `style`, `data-theme` and `theme` on `<html>`/`<body>` plus the system preference.
|
|
73
|
+
- `ARK_DURATION_MS`, `ARK_EASING_CSS`, `ARK_MOTION_DISTANCE`.
|
|
74
|
+
- Types: `ArkIntent`, `ArkSize`, `ArkRounded`, `ArkStyleVariant`, `ArkTheme`, `ArkThemeSelected`, `ArkDuration`, `ArkEasing`.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 📝 Usage examples
|
|
79
|
+
|
|
80
|
+
### Styling your own component with the tokens
|
|
81
|
+
|
|
82
|
+
```css
|
|
83
|
+
.card {
|
|
84
|
+
background: var(--ark-color-surface);
|
|
85
|
+
color: var(--ark-color-fg);
|
|
86
|
+
border: 1px solid var(--ark-color-border);
|
|
87
|
+
border-radius: var(--ark-radius-lg);
|
|
88
|
+
transition: opacity var(--ark-duration-quick) var(--ark-ease-out);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.card--danger {
|
|
92
|
+
background: var(--ark-color-danger-soft);
|
|
93
|
+
color: var(--ark-color-danger-soft-fg);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Following the page theme from JavaScript
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { observeColorScheme, resolveColorScheme } from "@tooark/tokens";
|
|
101
|
+
|
|
102
|
+
const host = document.querySelector("#chart")!;
|
|
103
|
+
applyTheme(resolveColorScheme(host)); // "light" | "dark"
|
|
104
|
+
|
|
105
|
+
const stop = observeColorScheme(host, (theme) => applyTheme(theme)); // runtime toggles
|
|
106
|
+
// later: stop();
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 📋 Dependencies
|
|
112
|
+
|
|
113
|
+
Installed automatically unless marked as peer; peer dependencies are yours to install (the ranges are what the package declares).
|
|
114
|
+
|
|
115
|
+
| Package | Version | Description |
|
|
116
|
+
| ---------------------------------------------- | ------- | -------------------------- |
|
|
117
|
+
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | TypeScript runtime helpers |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 🪪 Contributing
|
|
122
|
+
|
|
123
|
+
Contributions are welcome! Open issues and pull requests in the [Tooark/web-components](https://github.com/Tooark/web-components/issues) repository; [CONTRIBUTING.md](https://github.com/Tooark/web-components/blob/main/CONTRIBUTING.md) covers the workflow, the commit convention and the checklist. `@tooark/tokens` is released in lockstep with every other `@tooark/*` package.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 📄 License
|
|
128
|
+
|
|
129
|
+
This project is licensed under the Apache License 2.0. See the [LICENSE](https://github.com/Tooark/web-components/blob/main/LICENSE) file for details.
|
package/README.pt-BR.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# @tooark/tokens
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@tooark/tokens)
|
|
4
|
+
[](https://github.com/Tooark/web-components/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
Primitivas de design do design system Tooark: cores por intent, escala de tamanhos, raios e tokens de motion como custom properties CSS, um `@theme` do Tailwind v4 e tipos TypeScript.
|
|
7
|
+
|
|
8
|
+
🌍 **Idiomas:** [ English](./README.md) ·  **Português (este arquivo)**
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Conteúdo
|
|
13
|
+
|
|
14
|
+
- [Visão Geral](#-visão-geral)
|
|
15
|
+
- [Instalação](#-instalação)
|
|
16
|
+
- [Configuração](#️-configuração)
|
|
17
|
+
- [Componentes](#-componentes)
|
|
18
|
+
- [Exemplos de Uso](#-exemplos-de-uso)
|
|
19
|
+
- [Dependências](#-dependências)
|
|
20
|
+
- [Contribuição](#-contribuição)
|
|
21
|
+
- [Licença](#-licença)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 📖 Visão Geral
|
|
26
|
+
|
|
27
|
+
O pacote `@tooark/tokens` fornece:
|
|
28
|
+
|
|
29
|
+
- `tokens.css`: um bloco `@theme static` com as cores semânticas (`primary`, `secondary`, `success`, `warning`, `danger`, `info`, `neutral`, mais `surface*`, `fg*`, `border*`) em `light-dark()`, a escala de tamanhos (`--size-xs…xl`), o degrau `--text-2xs` e os raios do Tailwind;
|
|
30
|
+
- tokens de motion fora do `@theme`: `--ark-duration-*` (oito passos), `--ark-ease-*` (`linear`, `standard`, `in`, `out`, `in-out`, `overshoot`, `sheet`) e `--ark-motion-distance`, zerados sob `prefers-reduced-motion`;
|
|
31
|
+
- espelhos JS dos tokens de motion (`ARK_DURATION_MS`, `ARK_EASING_CSS`, `ARK_MOTION_DISTANCE`) para fallback em WAAPI;
|
|
32
|
+
- `resolveColorScheme(element)` e `observeColorScheme(element, onChange)` para resolver e acompanhar o tema da página;
|
|
33
|
+
- os tipos primitivos que todos os pacotes compartilham: `ArkIntent`, `ArkSize`, `ArkRounded`, `ArkTheme`, `ArkDuration`, `ArkEasing`.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🔧 Instalação
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pnpm add @tooark/tokens
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Não é necessário diretamente quando você usa o `@tooark/web-components`: o `styles.css` dele já traz os tokens.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## ⚙️ Configuração
|
|
48
|
+
|
|
49
|
+
Importe a folha de estilo no seu CSS ou na entrada do Tailwind e declare o `color-scheme` da página (os tokens são `light-dark()`, então o tema é puro CSS):
|
|
50
|
+
|
|
51
|
+
```css
|
|
52
|
+
@import "@tooark/tokens/tokens.css";
|
|
53
|
+
|
|
54
|
+
:root {
|
|
55
|
+
color-scheme: light dark; /* segue o sistema; ou "light" / "dark" para forçar um lado */
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 📦 Componentes
|
|
62
|
+
|
|
63
|
+
### Custom properties CSS
|
|
64
|
+
|
|
65
|
+
- Cores: `--ark-color-<intent>`, `-fg`, `-hover`, `-soft`, `-soft-fg`, `-border`, `-ring`; neutros `--ark-color-surface`, `-surface-muted`, `-fg`, `-fg-soft`, `-fg-muted`, `-border`, `-ring`.
|
|
66
|
+
- Tamanhos: `--ark-size-xs…xl` (1,5 / 1,75 / 2,25 / 2,75 / 3,25 rem, a altura mínima dos controles); `--ark-text-2xs` (0,6875 rem) para micro-rótulos.
|
|
67
|
+
- Motion: `--ark-duration-none|instant|quick|default|moderate|gentle|slow|long`, `--ark-ease-*`, `--ark-motion-distance`.
|
|
68
|
+
|
|
69
|
+
### JavaScript
|
|
70
|
+
|
|
71
|
+
- `resolveColorScheme(element?)` → `"light" | "dark"` pelo `color-scheme` computado do elemento (preferência do sistema quando a página deixa em `light dark`).
|
|
72
|
+
- `observeColorScheme(element, onChange)` → função de dispose; observa `class`, `style`, `data-theme` e `theme` em `<html>`/`<body>` mais a preferência do sistema.
|
|
73
|
+
- `ARK_DURATION_MS`, `ARK_EASING_CSS`, `ARK_MOTION_DISTANCE`.
|
|
74
|
+
- Tipos: `ArkIntent`, `ArkSize`, `ArkRounded`, `ArkStyleVariant`, `ArkTheme`, `ArkThemeSelected`, `ArkDuration`, `ArkEasing`.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 📝 Exemplos de Uso
|
|
79
|
+
|
|
80
|
+
### Estilizando um componente seu com os tokens
|
|
81
|
+
|
|
82
|
+
```css
|
|
83
|
+
.card {
|
|
84
|
+
background: var(--ark-color-surface);
|
|
85
|
+
color: var(--ark-color-fg);
|
|
86
|
+
border: 1px solid var(--ark-color-border);
|
|
87
|
+
border-radius: var(--ark-radius-lg);
|
|
88
|
+
transition: opacity var(--ark-duration-quick) var(--ark-ease-out);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.card--danger {
|
|
92
|
+
background: var(--ark-color-danger-soft);
|
|
93
|
+
color: var(--ark-color-danger-soft-fg);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Acompanhando o tema da página pelo JavaScript
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { observeColorScheme, resolveColorScheme } from "@tooark/tokens";
|
|
101
|
+
|
|
102
|
+
const host = document.querySelector("#chart")!;
|
|
103
|
+
aplicarTema(resolveColorScheme(host)); // "light" | "dark"
|
|
104
|
+
|
|
105
|
+
const parar = observeColorScheme(host, (tema) => aplicarTema(tema)); // troca em tempo de execução
|
|
106
|
+
// depois: parar();
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 📋 Dependências
|
|
112
|
+
|
|
113
|
+
Instaladas automaticamente, salvo as marcadas como peer, que ficam por sua conta (os ranges são os que o pacote declara).
|
|
114
|
+
|
|
115
|
+
| Pacote | Versão | Descrição |
|
|
116
|
+
| ---------------------------------------------- | ------ | -------------------------------- |
|
|
117
|
+
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | Helpers de runtime do TypeScript |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 🪪 Contribuição
|
|
122
|
+
|
|
123
|
+
Contribuições são bem-vindas! Abra issues e pull requests no repositório [Tooark/web-components](https://github.com/Tooark/web-components/issues); o [CONTRIBUTING.md](https://github.com/Tooark/web-components/blob/main/CONTRIBUTING.md) cobre o fluxo, a convenção de commits e o checklist. O `@tooark/tokens` é publicado em conjunto com todos os outros pacotes `@tooark/*`, numa única versão.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 📄 Licença
|
|
128
|
+
|
|
129
|
+
Este projeto está licenciado sob a licença Apache 2.0. Veja o arquivo [LICENSE](https://github.com/Tooark/web-components/blob/main/LICENSE) para mais detalhes.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Valores canônicos dos motion tokens (espelham tokens.css).
|
|
4
|
+
// Servem de fallback em JS/WAAPI quando as custom properties --ark-* não
|
|
5
|
+
// estão disponíveis no elemento (ex.: CSS de tokens não importado).
|
|
6
|
+
/** Durações em milissegundos — espelho de --ark-duration-*. */
|
|
7
|
+
const ARK_DURATION_MS = {
|
|
8
|
+
none: 0,
|
|
9
|
+
instant: 75,
|
|
10
|
+
quick: 150,
|
|
11
|
+
default: 250,
|
|
12
|
+
moderate: 350,
|
|
13
|
+
gentle: 500,
|
|
14
|
+
slow: 700,
|
|
15
|
+
long: 1000
|
|
16
|
+
};
|
|
17
|
+
/** Easings como strings CSS — espelho de --ark-ease-*. */
|
|
18
|
+
const ARK_EASING_CSS = {
|
|
19
|
+
linear: "linear",
|
|
20
|
+
standard: "cubic-bezier(0.2, 0, 0, 1)",
|
|
21
|
+
in: "cubic-bezier(0.4, 0, 1, 1)",
|
|
22
|
+
out: "cubic-bezier(0, 0, 0.2, 1)",
|
|
23
|
+
"in-out": "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
24
|
+
overshoot: "cubic-bezier(0.34, 1.56, 0.64, 1)",
|
|
25
|
+
sheet: "cubic-bezier(0.32, 0.72, 0, 1)"
|
|
26
|
+
};
|
|
27
|
+
/** Deslocamento padrão de slides — espelho de --ark-motion-distance. */
|
|
28
|
+
const ARK_MOTION_DISTANCE = "0.75rem";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Resolve o tema efetivo ("light" | "dark") de um elemento pelo seu color-scheme computado: a página (ou um ancestral
|
|
32
|
+
* com theme="dark") decide, e só "light dark"/"normal" caem na preferência do sistema. Sem DOM devolve "light".
|
|
33
|
+
*/
|
|
34
|
+
function resolveColorScheme(element) {
|
|
35
|
+
// Sem DOM devolve "light".
|
|
36
|
+
if (typeof window === "undefined") {
|
|
37
|
+
return "light";
|
|
38
|
+
}
|
|
39
|
+
// Tenta resolver pelo color-scheme computado do elemento.
|
|
40
|
+
if (element && typeof window.getComputedStyle === "function") {
|
|
41
|
+
const scheme = window.getComputedStyle(element).colorScheme || "";
|
|
42
|
+
const dark = scheme.includes("dark");
|
|
43
|
+
const light = scheme.includes("light");
|
|
44
|
+
// Se o color-scheme inclui apenas "dark" ou apenas "light", retorna o tema correspondente.
|
|
45
|
+
if (dark && !light) {
|
|
46
|
+
return "dark";
|
|
47
|
+
}
|
|
48
|
+
if (light && !dark) {
|
|
49
|
+
return "light";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Se não conseguiu resolver pelo color-scheme do elemento, usa a preferência do sistema.
|
|
53
|
+
const prefersDark = typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
54
|
+
return prefersDark ? "dark" : "light";
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Observa o tema efetivo de um elemento e chama `onChange` quando `resolveColorScheme(element)` passa a devolver
|
|
58
|
+
* outro valor: atributos de `<html>` e `<body>` (`class`, `style`, `data-theme`, `theme`, onde os apps trocam o
|
|
59
|
+
* tema) e a preferência do sistema via `matchMedia`. Devolve a função que para de observar. No-op sem DOM.
|
|
60
|
+
*/
|
|
61
|
+
function observeColorScheme(element, onChange) {
|
|
62
|
+
if (typeof window === "undefined" || typeof MutationObserver === "undefined")
|
|
63
|
+
return () => undefined;
|
|
64
|
+
let current = resolveColorScheme(element);
|
|
65
|
+
const check = () => {
|
|
66
|
+
const next = resolveColorScheme(element);
|
|
67
|
+
if (next === current)
|
|
68
|
+
return;
|
|
69
|
+
current = next;
|
|
70
|
+
onChange(next);
|
|
71
|
+
};
|
|
72
|
+
const observer = new MutationObserver(check);
|
|
73
|
+
const options = { attributes: true, attributeFilter: ["class", "style", "data-theme", "theme"] };
|
|
74
|
+
observer.observe(document.documentElement, options);
|
|
75
|
+
if (document.body)
|
|
76
|
+
observer.observe(document.body, options);
|
|
77
|
+
const media = typeof window.matchMedia === "function" ? window.matchMedia("(prefers-color-scheme: dark)") : null;
|
|
78
|
+
media?.addEventListener("change", check);
|
|
79
|
+
return () => {
|
|
80
|
+
observer.disconnect();
|
|
81
|
+
media?.removeEventListener("change", check);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
exports.ARK_DURATION_MS = ARK_DURATION_MS;
|
|
86
|
+
exports.ARK_EASING_CSS = ARK_EASING_CSS;
|
|
87
|
+
exports.ARK_MOTION_DISTANCE = ARK_MOTION_DISTANCE;
|
|
88
|
+
exports.observeColorScheme = observeColorScheme;
|
|
89
|
+
exports.resolveColorScheme = resolveColorScheme;
|
|
90
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/motion.ts","../src/theme.ts"],"sourcesContent":["// Valores canônicos dos motion tokens (espelham tokens.css).\n// Servem de fallback em JS/WAAPI quando as custom properties --ark-* não\n// estão disponíveis no elemento (ex.: CSS de tokens não importado).\n\nimport type { ArkDuration, ArkEasing } from \"./types\";\n\n/** Durações em milissegundos — espelho de --ark-duration-*. */\nexport const ARK_DURATION_MS: Record<ArkDuration, number> = {\n none: 0,\n instant: 75,\n quick: 150,\n default: 250,\n moderate: 350,\n gentle: 500,\n slow: 700,\n long: 1000\n};\n\n/** Easings como strings CSS — espelho de --ark-ease-*. */\nexport const ARK_EASING_CSS: Record<ArkEasing, string> = {\n linear: \"linear\",\n standard: \"cubic-bezier(0.2, 0, 0, 1)\",\n in: \"cubic-bezier(0.4, 0, 1, 1)\",\n out: \"cubic-bezier(0, 0, 0.2, 1)\",\n \"in-out\": \"cubic-bezier(0.4, 0, 0.2, 1)\",\n overshoot: \"cubic-bezier(0.34, 1.56, 0.64, 1)\",\n sheet: \"cubic-bezier(0.32, 0.72, 0, 1)\"\n};\n\n/** Deslocamento padrão de slides — espelho de --ark-motion-distance. */\nexport const ARK_MOTION_DISTANCE = \"0.75rem\";\n","import type { ArkThemeSelected } from \"./types\";\n\n/**\n * Resolve o tema efetivo (\"light\" | \"dark\") de um elemento pelo seu color-scheme computado: a página (ou um ancestral\n * com theme=\"dark\") decide, e só \"light dark\"/\"normal\" caem na preferência do sistema. Sem DOM devolve \"light\".\n */\nexport function resolveColorScheme(element?: Element | null): ArkThemeSelected {\n // Sem DOM devolve \"light\".\n if (typeof window === \"undefined\") {\n return \"light\";\n }\n\n // Tenta resolver pelo color-scheme computado do elemento.\n if (element && typeof window.getComputedStyle === \"function\") {\n const scheme = window.getComputedStyle(element).colorScheme || \"\";\n const dark = scheme.includes(\"dark\");\n const light = scheme.includes(\"light\");\n\n // Se o color-scheme inclui apenas \"dark\" ou apenas \"light\", retorna o tema correspondente.\n if (dark && !light) {\n return \"dark\";\n }\n if (light && !dark) {\n return \"light\";\n }\n }\n\n // Se não conseguiu resolver pelo color-scheme do elemento, usa a preferência do sistema.\n const prefersDark =\n typeof window.matchMedia === \"function\" && window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n\n return prefersDark ? \"dark\" : \"light\";\n}\n\n/**\n * Observa o tema efetivo de um elemento e chama `onChange` quando `resolveColorScheme(element)` passa a devolver\n * outro valor: atributos de `<html>` e `<body>` (`class`, `style`, `data-theme`, `theme`, onde os apps trocam o\n * tema) e a preferência do sistema via `matchMedia`. Devolve a função que para de observar. No-op sem DOM.\n */\nexport function observeColorScheme(element: Element, onChange: (theme: ArkThemeSelected) => void): () => void {\n if (typeof window === \"undefined\" || typeof MutationObserver === \"undefined\") return () => undefined;\n\n let current = resolveColorScheme(element);\n const check = (): void => {\n const next = resolveColorScheme(element);\n if (next === current) return;\n current = next;\n onChange(next);\n };\n\n const observer = new MutationObserver(check);\n const options = { attributes: true, attributeFilter: [\"class\", \"style\", \"data-theme\", \"theme\"] };\n observer.observe(document.documentElement, options);\n if (document.body) observer.observe(document.body, options);\n\n const media = typeof window.matchMedia === \"function\" ? window.matchMedia(\"(prefers-color-scheme: dark)\") : null;\n media?.addEventListener(\"change\", check);\n\n return () => {\n observer.disconnect();\n media?.removeEventListener(\"change\", check);\n };\n}\n"],"names":[],"mappings":"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"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Intenções semânticas de cor. */
|
|
2
|
+
type ArkIntent = "primary" | "secondary" | "success" | "warning" | "danger" | "info" | "neutral";
|
|
3
|
+
/** Escala de tamanho dos controles (altura mínima via --size-*). */
|
|
4
|
+
type ArkSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
5
|
+
/** Variantes de estilo visual. */
|
|
6
|
+
type ArkStyleVariant = "solid" | "outline" | "ghost";
|
|
7
|
+
/** Escala de arredondamento de borda ("full" transforma quadrados em círculos). */
|
|
8
|
+
type ArkRounded = "none" | "xs" | "sm" | "md" | "lg" | "xl" | "full";
|
|
9
|
+
/** Escala de duração de animações. */
|
|
10
|
+
type ArkDuration = "none" | "instant" | "quick" | "default" | "moderate" | "gentle" | "slow" | "long";
|
|
11
|
+
/** Curvas de easing de animações. */
|
|
12
|
+
type ArkEasing = "linear" | "standard" | "in" | "out" | "in-out" | "overshoot" | "sheet";
|
|
13
|
+
/** Tema resolvido (sem "auto"). */
|
|
14
|
+
type ArkThemeSelected = "light" | "dark";
|
|
15
|
+
/** Tema; "auto" herda o color-scheme da página. */
|
|
16
|
+
type ArkTheme = "auto" | ArkThemeSelected;
|
|
17
|
+
|
|
18
|
+
/** Durações em milissegundos — espelho de --ark-duration-*. */
|
|
19
|
+
declare const ARK_DURATION_MS: Record<ArkDuration, number>;
|
|
20
|
+
/** Easings como strings CSS — espelho de --ark-ease-*. */
|
|
21
|
+
declare const ARK_EASING_CSS: Record<ArkEasing, string>;
|
|
22
|
+
/** Deslocamento padrão de slides — espelho de --ark-motion-distance. */
|
|
23
|
+
declare const ARK_MOTION_DISTANCE = "0.75rem";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Resolve o tema efetivo ("light" | "dark") de um elemento pelo seu color-scheme computado: a página (ou um ancestral
|
|
27
|
+
* com theme="dark") decide, e só "light dark"/"normal" caem na preferência do sistema. Sem DOM devolve "light".
|
|
28
|
+
*/
|
|
29
|
+
declare function resolveColorScheme(element?: Element | null): ArkThemeSelected;
|
|
30
|
+
/**
|
|
31
|
+
* Observa o tema efetivo de um elemento e chama `onChange` quando `resolveColorScheme(element)` passa a devolver
|
|
32
|
+
* outro valor: atributos de `<html>` e `<body>` (`class`, `style`, `data-theme`, `theme`, onde os apps trocam o
|
|
33
|
+
* tema) e a preferência do sistema via `matchMedia`. Devolve a função que para de observar. No-op sem DOM.
|
|
34
|
+
*/
|
|
35
|
+
declare function observeColorScheme(element: Element, onChange: (theme: ArkThemeSelected) => void): () => void;
|
|
36
|
+
|
|
37
|
+
export { ARK_DURATION_MS, ARK_EASING_CSS, ARK_MOTION_DISTANCE, observeColorScheme, resolveColorScheme };
|
|
38
|
+
export type { ArkDuration, ArkEasing, ArkIntent, ArkRounded, ArkSize, ArkStyleVariant, ArkTheme, ArkThemeSelected };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Intenções semânticas de cor. */
|
|
2
|
+
type ArkIntent = "primary" | "secondary" | "success" | "warning" | "danger" | "info" | "neutral";
|
|
3
|
+
/** Escala de tamanho dos controles (altura mínima via --size-*). */
|
|
4
|
+
type ArkSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
5
|
+
/** Variantes de estilo visual. */
|
|
6
|
+
type ArkStyleVariant = "solid" | "outline" | "ghost";
|
|
7
|
+
/** Escala de arredondamento de borda ("full" transforma quadrados em círculos). */
|
|
8
|
+
type ArkRounded = "none" | "xs" | "sm" | "md" | "lg" | "xl" | "full";
|
|
9
|
+
/** Escala de duração de animações. */
|
|
10
|
+
type ArkDuration = "none" | "instant" | "quick" | "default" | "moderate" | "gentle" | "slow" | "long";
|
|
11
|
+
/** Curvas de easing de animações. */
|
|
12
|
+
type ArkEasing = "linear" | "standard" | "in" | "out" | "in-out" | "overshoot" | "sheet";
|
|
13
|
+
/** Tema resolvido (sem "auto"). */
|
|
14
|
+
type ArkThemeSelected = "light" | "dark";
|
|
15
|
+
/** Tema; "auto" herda o color-scheme da página. */
|
|
16
|
+
type ArkTheme = "auto" | ArkThemeSelected;
|
|
17
|
+
|
|
18
|
+
/** Durações em milissegundos — espelho de --ark-duration-*. */
|
|
19
|
+
declare const ARK_DURATION_MS: Record<ArkDuration, number>;
|
|
20
|
+
/** Easings como strings CSS — espelho de --ark-ease-*. */
|
|
21
|
+
declare const ARK_EASING_CSS: Record<ArkEasing, string>;
|
|
22
|
+
/** Deslocamento padrão de slides — espelho de --ark-motion-distance. */
|
|
23
|
+
declare const ARK_MOTION_DISTANCE = "0.75rem";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Resolve o tema efetivo ("light" | "dark") de um elemento pelo seu color-scheme computado: a página (ou um ancestral
|
|
27
|
+
* com theme="dark") decide, e só "light dark"/"normal" caem na preferência do sistema. Sem DOM devolve "light".
|
|
28
|
+
*/
|
|
29
|
+
declare function resolveColorScheme(element?: Element | null): ArkThemeSelected;
|
|
30
|
+
/**
|
|
31
|
+
* Observa o tema efetivo de um elemento e chama `onChange` quando `resolveColorScheme(element)` passa a devolver
|
|
32
|
+
* outro valor: atributos de `<html>` e `<body>` (`class`, `style`, `data-theme`, `theme`, onde os apps trocam o
|
|
33
|
+
* tema) e a preferência do sistema via `matchMedia`. Devolve a função que para de observar. No-op sem DOM.
|
|
34
|
+
*/
|
|
35
|
+
declare function observeColorScheme(element: Element, onChange: (theme: ArkThemeSelected) => void): () => void;
|
|
36
|
+
|
|
37
|
+
export { ARK_DURATION_MS, ARK_EASING_CSS, ARK_MOTION_DISTANCE, observeColorScheme, resolveColorScheme };
|
|
38
|
+
export type { ArkDuration, ArkEasing, ArkIntent, ArkRounded, ArkSize, ArkStyleVariant, ArkTheme, ArkThemeSelected };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Valores canônicos dos motion tokens (espelham tokens.css).
|
|
2
|
+
// Servem de fallback em JS/WAAPI quando as custom properties --ark-* não
|
|
3
|
+
// estão disponíveis no elemento (ex.: CSS de tokens não importado).
|
|
4
|
+
/** Durações em milissegundos — espelho de --ark-duration-*. */
|
|
5
|
+
const ARK_DURATION_MS = {
|
|
6
|
+
none: 0,
|
|
7
|
+
instant: 75,
|
|
8
|
+
quick: 150,
|
|
9
|
+
default: 250,
|
|
10
|
+
moderate: 350,
|
|
11
|
+
gentle: 500,
|
|
12
|
+
slow: 700,
|
|
13
|
+
long: 1000
|
|
14
|
+
};
|
|
15
|
+
/** Easings como strings CSS — espelho de --ark-ease-*. */
|
|
16
|
+
const ARK_EASING_CSS = {
|
|
17
|
+
linear: "linear",
|
|
18
|
+
standard: "cubic-bezier(0.2, 0, 0, 1)",
|
|
19
|
+
in: "cubic-bezier(0.4, 0, 1, 1)",
|
|
20
|
+
out: "cubic-bezier(0, 0, 0.2, 1)",
|
|
21
|
+
"in-out": "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
22
|
+
overshoot: "cubic-bezier(0.34, 1.56, 0.64, 1)",
|
|
23
|
+
sheet: "cubic-bezier(0.32, 0.72, 0, 1)"
|
|
24
|
+
};
|
|
25
|
+
/** Deslocamento padrão de slides — espelho de --ark-motion-distance. */
|
|
26
|
+
const ARK_MOTION_DISTANCE = "0.75rem";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Resolve o tema efetivo ("light" | "dark") de um elemento pelo seu color-scheme computado: a página (ou um ancestral
|
|
30
|
+
* com theme="dark") decide, e só "light dark"/"normal" caem na preferência do sistema. Sem DOM devolve "light".
|
|
31
|
+
*/
|
|
32
|
+
function resolveColorScheme(element) {
|
|
33
|
+
// Sem DOM devolve "light".
|
|
34
|
+
if (typeof window === "undefined") {
|
|
35
|
+
return "light";
|
|
36
|
+
}
|
|
37
|
+
// Tenta resolver pelo color-scheme computado do elemento.
|
|
38
|
+
if (element && typeof window.getComputedStyle === "function") {
|
|
39
|
+
const scheme = window.getComputedStyle(element).colorScheme || "";
|
|
40
|
+
const dark = scheme.includes("dark");
|
|
41
|
+
const light = scheme.includes("light");
|
|
42
|
+
// Se o color-scheme inclui apenas "dark" ou apenas "light", retorna o tema correspondente.
|
|
43
|
+
if (dark && !light) {
|
|
44
|
+
return "dark";
|
|
45
|
+
}
|
|
46
|
+
if (light && !dark) {
|
|
47
|
+
return "light";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Se não conseguiu resolver pelo color-scheme do elemento, usa a preferência do sistema.
|
|
51
|
+
const prefersDark = typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
52
|
+
return prefersDark ? "dark" : "light";
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Observa o tema efetivo de um elemento e chama `onChange` quando `resolveColorScheme(element)` passa a devolver
|
|
56
|
+
* outro valor: atributos de `<html>` e `<body>` (`class`, `style`, `data-theme`, `theme`, onde os apps trocam o
|
|
57
|
+
* tema) e a preferência do sistema via `matchMedia`. Devolve a função que para de observar. No-op sem DOM.
|
|
58
|
+
*/
|
|
59
|
+
function observeColorScheme(element, onChange) {
|
|
60
|
+
if (typeof window === "undefined" || typeof MutationObserver === "undefined")
|
|
61
|
+
return () => undefined;
|
|
62
|
+
let current = resolveColorScheme(element);
|
|
63
|
+
const check = () => {
|
|
64
|
+
const next = resolveColorScheme(element);
|
|
65
|
+
if (next === current)
|
|
66
|
+
return;
|
|
67
|
+
current = next;
|
|
68
|
+
onChange(next);
|
|
69
|
+
};
|
|
70
|
+
const observer = new MutationObserver(check);
|
|
71
|
+
const options = { attributes: true, attributeFilter: ["class", "style", "data-theme", "theme"] };
|
|
72
|
+
observer.observe(document.documentElement, options);
|
|
73
|
+
if (document.body)
|
|
74
|
+
observer.observe(document.body, options);
|
|
75
|
+
const media = typeof window.matchMedia === "function" ? window.matchMedia("(prefers-color-scheme: dark)") : null;
|
|
76
|
+
media?.addEventListener("change", check);
|
|
77
|
+
return () => {
|
|
78
|
+
observer.disconnect();
|
|
79
|
+
media?.removeEventListener("change", check);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { ARK_DURATION_MS, ARK_EASING_CSS, ARK_MOTION_DISTANCE, observeColorScheme, resolveColorScheme };
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/motion.ts","../src/theme.ts"],"sourcesContent":["// Valores canônicos dos motion tokens (espelham tokens.css).\n// Servem de fallback em JS/WAAPI quando as custom properties --ark-* não\n// estão disponíveis no elemento (ex.: CSS de tokens não importado).\n\nimport type { ArkDuration, ArkEasing } from \"./types\";\n\n/** Durações em milissegundos — espelho de --ark-duration-*. */\nexport const ARK_DURATION_MS: Record<ArkDuration, number> = {\n none: 0,\n instant: 75,\n quick: 150,\n default: 250,\n moderate: 350,\n gentle: 500,\n slow: 700,\n long: 1000\n};\n\n/** Easings como strings CSS — espelho de --ark-ease-*. */\nexport const ARK_EASING_CSS: Record<ArkEasing, string> = {\n linear: \"linear\",\n standard: \"cubic-bezier(0.2, 0, 0, 1)\",\n in: \"cubic-bezier(0.4, 0, 1, 1)\",\n out: \"cubic-bezier(0, 0, 0.2, 1)\",\n \"in-out\": \"cubic-bezier(0.4, 0, 0.2, 1)\",\n overshoot: \"cubic-bezier(0.34, 1.56, 0.64, 1)\",\n sheet: \"cubic-bezier(0.32, 0.72, 0, 1)\"\n};\n\n/** Deslocamento padrão de slides — espelho de --ark-motion-distance. */\nexport const ARK_MOTION_DISTANCE = \"0.75rem\";\n","import type { ArkThemeSelected } from \"./types\";\n\n/**\n * Resolve o tema efetivo (\"light\" | \"dark\") de um elemento pelo seu color-scheme computado: a página (ou um ancestral\n * com theme=\"dark\") decide, e só \"light dark\"/\"normal\" caem na preferência do sistema. Sem DOM devolve \"light\".\n */\nexport function resolveColorScheme(element?: Element | null): ArkThemeSelected {\n // Sem DOM devolve \"light\".\n if (typeof window === \"undefined\") {\n return \"light\";\n }\n\n // Tenta resolver pelo color-scheme computado do elemento.\n if (element && typeof window.getComputedStyle === \"function\") {\n const scheme = window.getComputedStyle(element).colorScheme || \"\";\n const dark = scheme.includes(\"dark\");\n const light = scheme.includes(\"light\");\n\n // Se o color-scheme inclui apenas \"dark\" ou apenas \"light\", retorna o tema correspondente.\n if (dark && !light) {\n return \"dark\";\n }\n if (light && !dark) {\n return \"light\";\n }\n }\n\n // Se não conseguiu resolver pelo color-scheme do elemento, usa a preferência do sistema.\n const prefersDark =\n typeof window.matchMedia === \"function\" && window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n\n return prefersDark ? \"dark\" : \"light\";\n}\n\n/**\n * Observa o tema efetivo de um elemento e chama `onChange` quando `resolveColorScheme(element)` passa a devolver\n * outro valor: atributos de `<html>` e `<body>` (`class`, `style`, `data-theme`, `theme`, onde os apps trocam o\n * tema) e a preferência do sistema via `matchMedia`. Devolve a função que para de observar. No-op sem DOM.\n */\nexport function observeColorScheme(element: Element, onChange: (theme: ArkThemeSelected) => void): () => void {\n if (typeof window === \"undefined\" || typeof MutationObserver === \"undefined\") return () => undefined;\n\n let current = resolveColorScheme(element);\n const check = (): void => {\n const next = resolveColorScheme(element);\n if (next === current) return;\n current = next;\n onChange(next);\n };\n\n const observer = new MutationObserver(check);\n const options = { attributes: true, attributeFilter: [\"class\", \"style\", \"data-theme\", \"theme\"] };\n observer.observe(document.documentElement, options);\n if (document.body) observer.observe(document.body, options);\n\n const media = typeof window.matchMedia === \"function\" ? window.matchMedia(\"(prefers-color-scheme: dark)\") : null;\n media?.addEventListener(\"change\", check);\n\n return () => {\n observer.disconnect();\n media?.removeEventListener(\"change\", check);\n };\n}\n"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tooark/tokens",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Tooark Tokens — design primitives (colors by intent, sizes, radii, motion) as CSS tokens and TypeScript types",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tooark",
|
|
7
|
+
"web-components",
|
|
8
|
+
"custom-elements",
|
|
9
|
+
"design-system",
|
|
10
|
+
"tailwindcss",
|
|
11
|
+
"design-tokens",
|
|
12
|
+
"tokens",
|
|
13
|
+
"theme",
|
|
14
|
+
"css-variables"
|
|
15
|
+
],
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Paulo Sergio de Freitas Junior",
|
|
19
|
+
"email": "paulo.freitas@tooark.com",
|
|
20
|
+
"url": "https://paulofreitas.tooark.com"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/Tooark/web-components#readme",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/Tooark/web-components.git",
|
|
26
|
+
"directory": "packages/tokens"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/Tooark/web-components/issues"
|
|
30
|
+
},
|
|
31
|
+
"funding": [
|
|
32
|
+
{
|
|
33
|
+
"type": "github",
|
|
34
|
+
"url": "https://github.com/sponsors/paulosfjunior"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"type": "ko-fi",
|
|
38
|
+
"url": "https://ko-fi.com/paulosfjunior"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"type": "module",
|
|
42
|
+
"main": "./dist/index.cjs",
|
|
43
|
+
"module": "./dist/index.js",
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"import": {
|
|
48
|
+
"types": "./dist/index.d.ts",
|
|
49
|
+
"default": "./dist/index.js"
|
|
50
|
+
},
|
|
51
|
+
"require": {
|
|
52
|
+
"types": "./dist/index.d.cts",
|
|
53
|
+
"default": "./dist/index.cjs"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"./tokens.css": {
|
|
57
|
+
"default": "./tokens.css"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"files": [
|
|
61
|
+
"NOTICE",
|
|
62
|
+
"README.pt-BR.md",
|
|
63
|
+
"dist",
|
|
64
|
+
"tokens.css"
|
|
65
|
+
],
|
|
66
|
+
"sideEffects": [
|
|
67
|
+
"*.css",
|
|
68
|
+
"**/*.css"
|
|
69
|
+
],
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public",
|
|
72
|
+
"registry": "https://registry.npmjs.org/"
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"tslib": "^2.8.1"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@types/node": "^22.20.1"
|
|
79
|
+
},
|
|
80
|
+
"scripts": {
|
|
81
|
+
"build": "rollup -c",
|
|
82
|
+
"dev": "rollup -c -w",
|
|
83
|
+
"clean": "rimraf dist"
|
|
84
|
+
}
|
|
85
|
+
}
|
package/tokens.css
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Design tokens do Tooark (Tailwind v4 @theme).
|
|
3
|
+
*
|
|
4
|
+
* Importe este arquivo no entry Tailwind do seu projeto OU diretamente no app:
|
|
5
|
+
* @import "@tooark/tokens/tokens.css";
|
|
6
|
+
*
|
|
7
|
+
* Os valores ficam disponíveis como CSS custom properties (--color-*, --size-*, ...)
|
|
8
|
+
* e como utilitários Tailwind (bg-primary, text-primary-fg, border-border, ...).
|
|
9
|
+
*
|
|
10
|
+
* Todas as cores são SEMÂNTICAS e resolvem claro/escuro sozinhas via
|
|
11
|
+
* light-dark(): o tema é decidido pela propriedade `color-scheme` do elemento
|
|
12
|
+
* (os componentes Ark herdam o da página por padrão e `theme="light|dark"`
|
|
13
|
+
* força um lado). Para trocar a marca, sobrescreva os tokens no seu CSS —
|
|
14
|
+
* dentro do CSS dos componentes eles têm o prefixo "ark":
|
|
15
|
+
*
|
|
16
|
+
* :root {
|
|
17
|
+
* --ark-color-primary: light-dark(oklch(45% 0.2 264), oklch(80% 0.15 264));
|
|
18
|
+
* --ark-color-primary-fg: #fff;
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* Papéis de cada intent (primary, secondary, success, warning, danger, info, neutral):
|
|
22
|
+
* <intent> fundo sólido (botão solid, seleção, track ligado, eventos)
|
|
23
|
+
* <intent>-fg texto/ícone sobre o fundo sólido
|
|
24
|
+
* <intent>-hover fundo sólido em hover
|
|
25
|
+
* <intent>-soft fundo suave (hover de outline/ghost, toggle pressionado, toast rich)
|
|
26
|
+
* <intent>-soft-fg texto sobre o fundo suave e texto de outline/ghost
|
|
27
|
+
* <intent>-border borda de outline / anel do "hoje"
|
|
28
|
+
* <intent>-ring anel de foco
|
|
29
|
+
*
|
|
30
|
+
* Superfícies e texto neutros:
|
|
31
|
+
* surface / surface-muted / surface-strong / surface-raised
|
|
32
|
+
* fg / fg-soft / fg-muted / fg-faint / fg-placeholder
|
|
33
|
+
* border / border-strong / muted (controles apagados) / ring (foco padrão)
|
|
34
|
+
*/
|
|
35
|
+
@theme static {
|
|
36
|
+
/* ---------- primary (amber, cor do Tooark: themes/tooark.css) ---------- */
|
|
37
|
+
--color-primary: light-dark(#b45309, #f59e0b);
|
|
38
|
+
--color-primary-fg: light-dark(#fff, oklch(12.9% 0.042 264.695));
|
|
39
|
+
--color-primary-hover: light-dark(#92400e, #fbbf24);
|
|
40
|
+
--color-primary-soft: light-dark(#fffbeb, color-mix(in oklab, #78350f 40%, transparent));
|
|
41
|
+
--color-primary-soft-fg: light-dark(#b45309, #fbbf24);
|
|
42
|
+
--color-primary-border: light-dark(#d97706, #f59e0b);
|
|
43
|
+
--color-primary-ring: light-dark(#d97706, #f59e0b);
|
|
44
|
+
|
|
45
|
+
/* ---------- secondary (slate, "tinta": era o primary) ---------- */
|
|
46
|
+
--color-secondary: light-dark(oklch(20.8% 0.042 265.755), oklch(96.8% 0.007 247.896));
|
|
47
|
+
--color-secondary-fg: light-dark(#fff, oklch(20.8% 0.042 265.755));
|
|
48
|
+
--color-secondary-hover: light-dark(oklch(27.9% 0.041 260.031), #fff);
|
|
49
|
+
--color-secondary-soft: light-dark(oklch(98.4% 0.003 247.858), oklch(27.9% 0.041 260.031));
|
|
50
|
+
--color-secondary-soft-fg: light-dark(oklch(20.8% 0.042 265.755), oklch(96.8% 0.007 247.896));
|
|
51
|
+
--color-secondary-border: light-dark(oklch(86.9% 0.022 252.894), oklch(44.6% 0.043 257.281));
|
|
52
|
+
--color-secondary-ring: light-dark(oklch(70.4% 0.04 256.788), oklch(55.4% 0.046 257.417));
|
|
53
|
+
|
|
54
|
+
/* ---------- success (emerald) ---------- */
|
|
55
|
+
--color-success: light-dark(oklch(50.8% 0.118 165.612), oklch(69.6% 0.17 162.48));
|
|
56
|
+
--color-success-fg: light-dark(#fff, oklch(12.9% 0.042 264.695));
|
|
57
|
+
--color-success-hover: light-dark(oklch(59.6% 0.145 163.225), oklch(76.5% 0.177 163.223));
|
|
58
|
+
--color-success-soft: light-dark(
|
|
59
|
+
oklch(97.9% 0.021 166.113),
|
|
60
|
+
color-mix(in oklab, oklch(26.2% 0.051 172.552) 40%, transparent)
|
|
61
|
+
);
|
|
62
|
+
--color-success-soft-fg: light-dark(oklch(50.8% 0.118 165.612), oklch(84.5% 0.143 164.978));
|
|
63
|
+
--color-success-border: light-dark(oklch(84.5% 0.143 164.978), oklch(59.6% 0.145 163.225));
|
|
64
|
+
--color-success-ring: light-dark(oklch(76.5% 0.177 163.223), oklch(69.6% 0.17 162.48));
|
|
65
|
+
|
|
66
|
+
/* ---------- warning (yellow) ---------- */
|
|
67
|
+
--color-warning: light-dark(oklch(79.5% 0.184 86.047), oklch(85.2% 0.199 91.936));
|
|
68
|
+
--color-warning-fg: light-dark(oklch(20.8% 0.042 265.755), oklch(12.9% 0.042 264.695));
|
|
69
|
+
--color-warning-hover: light-dark(oklch(85.2% 0.199 91.936), oklch(90.5% 0.182 98.111));
|
|
70
|
+
--color-warning-soft: light-dark(
|
|
71
|
+
oklch(98.7% 0.026 102.212),
|
|
72
|
+
color-mix(in oklab, oklch(42.1% 0.095 57.708) 40%, transparent)
|
|
73
|
+
);
|
|
74
|
+
--color-warning-soft-fg: light-dark(oklch(55.4% 0.135 66.442), oklch(90.5% 0.182 98.111));
|
|
75
|
+
--color-warning-border: light-dark(oklch(90.5% 0.182 98.111), oklch(68.1% 0.162 75.834));
|
|
76
|
+
--color-warning-ring: light-dark(oklch(85.2% 0.199 91.936), oklch(79.5% 0.184 86.047));
|
|
77
|
+
|
|
78
|
+
/* ---------- danger (red) ---------- */
|
|
79
|
+
--color-danger: light-dark(oklch(57.7% 0.245 27.325), oklch(63.7% 0.237 25.331));
|
|
80
|
+
--color-danger-fg: light-dark(#fff, oklch(12.9% 0.042 264.695));
|
|
81
|
+
--color-danger-hover: light-dark(oklch(63.7% 0.237 25.331), oklch(70.4% 0.191 22.216));
|
|
82
|
+
--color-danger-soft: light-dark(
|
|
83
|
+
oklch(97.1% 0.013 17.38),
|
|
84
|
+
color-mix(in oklab, oklch(25.8% 0.092 26.042) 40%, transparent)
|
|
85
|
+
);
|
|
86
|
+
--color-danger-soft-fg: light-dark(oklch(50.5% 0.213 27.518), oklch(80.8% 0.114 19.571));
|
|
87
|
+
--color-danger-border: light-dark(oklch(80.8% 0.114 19.571), oklch(57.7% 0.245 27.325));
|
|
88
|
+
--color-danger-ring: light-dark(oklch(70.4% 0.191 22.216), oklch(63.7% 0.237 25.331));
|
|
89
|
+
|
|
90
|
+
/* ---------- info (sky) ---------- */
|
|
91
|
+
--color-info: light-dark(oklch(50% 0.134 242.749), oklch(68.5% 0.169 237.323));
|
|
92
|
+
--color-info-fg: light-dark(#fff, oklch(12.9% 0.042 264.695));
|
|
93
|
+
--color-info-hover: light-dark(oklch(58.8% 0.158 241.966), oklch(74.6% 0.16 232.661));
|
|
94
|
+
--color-info-soft: light-dark(
|
|
95
|
+
oklch(97.7% 0.013 236.62),
|
|
96
|
+
color-mix(in oklab, oklch(29.3% 0.066 243.157) 40%, transparent)
|
|
97
|
+
);
|
|
98
|
+
--color-info-soft-fg: light-dark(oklch(50% 0.134 242.749), oklch(82.8% 0.111 230.318));
|
|
99
|
+
--color-info-border: light-dark(oklch(82.8% 0.111 230.318), oklch(58.8% 0.158 241.966));
|
|
100
|
+
--color-info-ring: light-dark(oklch(74.6% 0.16 232.661), oklch(68.5% 0.169 237.323));
|
|
101
|
+
|
|
102
|
+
/* ---------- neutral (zinc) ---------- */
|
|
103
|
+
--color-neutral: light-dark(oklch(37% 0.013 285.805), oklch(92% 0.004 286.32));
|
|
104
|
+
--color-neutral-fg: light-dark(#fff, oklch(21% 0.006 285.885));
|
|
105
|
+
--color-neutral-hover: light-dark(oklch(44.2% 0.017 285.786), oklch(96.7% 0.001 286.375));
|
|
106
|
+
--color-neutral-soft: light-dark(oklch(98.5% 0 none), oklch(27.4% 0.006 286.033));
|
|
107
|
+
--color-neutral-soft-fg: light-dark(oklch(37% 0.013 285.805), oklch(92% 0.004 286.32));
|
|
108
|
+
--color-neutral-border: light-dark(oklch(87.1% 0.006 286.286), oklch(44.2% 0.017 285.786));
|
|
109
|
+
--color-neutral-ring: light-dark(oklch(70.5% 0.015 286.067), oklch(55.2% 0.016 285.938));
|
|
110
|
+
|
|
111
|
+
/* ---------- superfícies ---------- */
|
|
112
|
+
--color-surface: light-dark(#fff, oklch(20.8% 0.042 265.755));
|
|
113
|
+
--color-surface-muted: light-dark(oklch(98.4% 0.003 247.858), oklch(27.9% 0.041 260.031));
|
|
114
|
+
--color-surface-strong: light-dark(oklch(96.8% 0.007 247.896), oklch(37.2% 0.044 257.287));
|
|
115
|
+
--color-surface-raised: light-dark(#fff, oklch(37.2% 0.044 257.287));
|
|
116
|
+
|
|
117
|
+
/* ---------- texto ---------- */
|
|
118
|
+
--color-fg: light-dark(oklch(20.8% 0.042 265.755), oklch(96.8% 0.007 247.896));
|
|
119
|
+
--color-fg-soft: light-dark(oklch(37.2% 0.044 257.287), oklch(92.9% 0.013 255.508));
|
|
120
|
+
--color-fg-muted: light-dark(oklch(55.4% 0.046 257.417), oklch(70.4% 0.04 256.788));
|
|
121
|
+
--color-fg-faint: light-dark(oklch(86.9% 0.022 252.894), oklch(37.2% 0.044 257.287));
|
|
122
|
+
--color-fg-placeholder: light-dark(oklch(70.4% 0.04 256.788), oklch(55.4% 0.046 257.417));
|
|
123
|
+
|
|
124
|
+
/* ---------- bordas, controles apagados e foco ---------- */
|
|
125
|
+
--color-border: light-dark(oklch(92.9% 0.013 255.508), oklch(37.2% 0.044 257.287));
|
|
126
|
+
--color-border-strong: light-dark(oklch(86.9% 0.022 252.894), oklch(44.6% 0.043 257.281));
|
|
127
|
+
--color-muted: light-dark(oklch(86.9% 0.022 252.894), oklch(44.6% 0.043 257.281));
|
|
128
|
+
--color-ring: light-dark(oklch(70.4% 0.04 256.788), oklch(55.4% 0.046 257.417));
|
|
129
|
+
|
|
130
|
+
/* Escala de tamanho: altura mínima dos controles (button, input e toggle aplicam como min-height) */
|
|
131
|
+
--size-xs: 1.5rem;
|
|
132
|
+
--size-sm: 1.75rem;
|
|
133
|
+
--size-md: 2.25rem;
|
|
134
|
+
--size-lg: 2.75rem;
|
|
135
|
+
--size-xl: 3.25rem;
|
|
136
|
+
|
|
137
|
+
/*
|
|
138
|
+
* Um passo abaixo de text-xs para os micro-rótulos (rótulo flutuante dos
|
|
139
|
+
* campos xs/sm, chips do calendário e do scheduler, rótulos de coluna do
|
|
140
|
+
* clock): pela escala, para a densidade do app valer neles. Sem line-height
|
|
141
|
+
* próprio, o texto herda a altura de linha do contexto.
|
|
142
|
+
*/
|
|
143
|
+
--text-2xs: 0.6875rem;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/*
|
|
147
|
+
* Tokens fora do @theme: custom properties puras, com o mesmo nome em
|
|
148
|
+
* qualquer build (consumidas pelos presets do @tooark/core e por WAAPI).
|
|
149
|
+
*/
|
|
150
|
+
:root {
|
|
151
|
+
/* Durações — escala de 8 passos (uso previsto de cada token documentado no README, "Motion system") */
|
|
152
|
+
--ark-duration-none: 0ms;
|
|
153
|
+
--ark-duration-instant: 75ms;
|
|
154
|
+
--ark-duration-quick: 150ms;
|
|
155
|
+
--ark-duration-default: 250ms;
|
|
156
|
+
--ark-duration-moderate: 350ms;
|
|
157
|
+
--ark-duration-gentle: 500ms;
|
|
158
|
+
--ark-duration-slow: 700ms;
|
|
159
|
+
--ark-duration-long: 1000ms;
|
|
160
|
+
|
|
161
|
+
/* Easings */
|
|
162
|
+
--ark-ease-linear: linear;
|
|
163
|
+
--ark-ease-standard: cubic-bezier(0.2, 0, 0, 1);
|
|
164
|
+
--ark-ease-in: cubic-bezier(0.4, 0, 1, 1);
|
|
165
|
+
--ark-ease-out: cubic-bezier(0, 0, 0.2, 1);
|
|
166
|
+
--ark-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
|
|
167
|
+
--ark-ease-overshoot: cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
168
|
+
--ark-ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
|
|
169
|
+
|
|
170
|
+
/* Deslocamento padrão de slides (enter/exit) */
|
|
171
|
+
--ark-motion-distance: 0.75rem;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/*
|
|
175
|
+
* Acessibilidade: zera todas as durações quando o usuário reduz movimento.
|
|
176
|
+
* Com !important para evitar que seja sobrescrita por um override do app.
|
|
177
|
+
*/
|
|
178
|
+
@media (prefers-reduced-motion: reduce) {
|
|
179
|
+
:root {
|
|
180
|
+
/* biome-ignore-start lint/complexity/noImportantStyles: preferência do usuário deve vencer override de :root do app */
|
|
181
|
+
--ark-duration-instant: 0ms !important;
|
|
182
|
+
--ark-duration-quick: 0ms !important;
|
|
183
|
+
--ark-duration-default: 0ms !important;
|
|
184
|
+
--ark-duration-moderate: 0ms !important;
|
|
185
|
+
--ark-duration-gentle: 0ms !important;
|
|
186
|
+
--ark-duration-slow: 0ms !important;
|
|
187
|
+
--ark-duration-long: 0ms !important;
|
|
188
|
+
/* biome-ignore-end lint/complexity/noImportantStyles: preferência do usuário deve vencer override de :root do app */
|
|
189
|
+
}
|
|
190
|
+
}
|