You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(react): migrate SCSS imports to local variables and fix Popup positioning (#101)
* fix(react): migrate SCSS imports to local variables and fix Popup positioning
- Move all component SCSS imports from @tiny-design/tokens/scss/variables
to local ../../style/variables, decoupling component styles from the
tokens package SCSS source
- Slim down @tiny-design/tokens by removing legacy SCSS files in favour
of the v2 CSS-variable + runtime approach
- Fix Popup component scroll-following by adding a useLayoutEffect that
calls Popper forceUpdate after every render, ensuring position stays
in sync with layout changes
* chore: remove pro app
Copy file name to clipboardExpand all lines: apps/docs/guides/customise-theme.md
+14-60Lines changed: 14 additions & 60 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,11 @@
1
1
# Customise Theme
2
2
3
-
Tiny UI now uses a v2 token system with one primary runtime model:
3
+
Tiny UI uses a token-driven runtime theme model:
4
4
5
5
1.**CSS custom properties** for direct runtime overrides.
6
6
2.**ThemeDocument** for portable theme JSON.
7
7
3.**ConfigProvider `theme.tokens`** for React-scoped theming.
8
8
9
-
SCSS constants still exist, but they are only for compile-time structural overrides.
10
-
11
9
## Theme Editor
12
10
13
11
The built-in [Theme Editor](/theme/theme-studio) lets you visually customise design tokens in real time. You can:
@@ -20,7 +18,7 @@ The built-in [Theme Editor](/theme/theme-studio) lets you visually customise des
20
18
21
19
Changes are applied instantly via CSS custom properties — no rebuild required.
22
20
23
-
The editor exports the same v2 token model used by the runtime, so the result can be applied as CSS variables, stored as a `ThemeDocument`, or passed into `ConfigProvider`.
21
+
The editor exports the same token model used by the runtime, so the result can be applied as CSS variables, stored as a `ThemeDocument`, or passed into `ConfigProvider`.
|`--ty-border-radius`|`2px`| Global border radius |
106
-
|`--ty-font-size-base`|`1rem`| Base font size |
103
+
|`--ty-border-radius`|`6px`| Global border radius |
104
+
|`--ty-font-size-base`|`14px`| Base font size |
107
105
|`--ty-height-sm`|`24px`| Small control height |
108
-
|`--ty-height-md`|`32px`| Medium control height |
109
-
|`--ty-height-lg`|`42px`| Large control height |
106
+
|`--ty-height-md`|`35px`| Medium control height |
107
+
|`--ty-height-lg`|`44px`| Large control height |
110
108
111
-
Every component also has its own tokens for fine-grained control. For example, Button uses `--ty-button-bg-default`, `--ty-button-text-default`, and `--ty-button-radius`. The full list of supported tokens is generated from the v2 registry and component sources:
109
+
Every component also has its own tokens for fine-grained control. For example, Button uses `--ty-button-bg-default`, `--ty-button-text-default`, and `--ty-button-radius`. The full list of supported tokens is generated from the token registry and component sources:
- popup / portal content to inherit the same token scope
180
178
181
-
`ConfigProvider` no longer uses the old `theme.token` or `theme.components` API. Use `theme.tokens.semantic` and `theme.tokens.components` only.
182
-
183
-
## SCSS constants
184
-
185
-
If you import Tiny UI's SCSS source instead of the pre-built CSS, you can override compile-time structural constants such as padding, transitions, and arrow sizes. These are values that don't need to change at runtime.
186
-
187
-
Every constant uses the `!default` flag, so your overrides take precedence.
188
-
189
-
### 1. Install Sass
190
-
191
-
```bash
192
-
$ npm install sass --save-dev
193
-
```
194
-
195
-
### 2. Create your overrides file
196
-
197
-
Create a file, e.g. `theme-overrides.scss`. Your overrides **must come before** the Tiny UI import:
179
+
Use `theme.tokens.semantic` and `theme.tokens.components` as the supported React theme shape.
198
180
199
-
```scss
200
-
// Override structural constants
201
-
$btn-padding-md: 020px;
202
-
$card-body-padding: 20px;
203
-
$tooltip-arrow-size: 6px;
181
+
## Sass source styles
204
182
205
-
// Import Tiny UI styles (applies your overrides via !default)
206
-
@use"@tiny-design/react/es/style/index"as*;
207
-
```
208
-
209
-
### 3. Import in your entry file
210
-
211
-
```js
212
-
import'./theme-overrides.scss';
213
-
```
214
-
215
-
The full list of SCSS constants can be found in [_constants.scss](https://github.com/wangdicoder/tiny-design/blob/master/packages/tokens/scss/_constants.scss).
183
+
Tiny UI still ships Sass source files for bundlers that compile library styles directly, but Sass variables are not a theme API. Treat `@tiny-design/react/es/style/*.scss` and component `style/*.scss` files as implementation source, not as supported customisation contracts.
216
184
217
-
Some commonly overridden constants:
218
-
219
-
```scss
220
-
// Button
221
-
$btn-padding-sm: 010px!default;
222
-
$btn-padding-md: 015px!default;
223
-
$btn-padding-lg: 028px!default;
224
-
225
-
// Card
226
-
$card-header-padding: 13px16px!default;
227
-
$card-body-padding: 16px!default;
228
-
229
-
// Notification
230
-
$notification-width: 380px!default;
231
-
```
185
+
Use tokens for visual changes such as colour, typography, radii, shadows, spacing, sizing, and component states. If a value is not exposed as a token yet, prefer adding it to the token registry instead of adding a new public Sass variable.
232
186
233
-
> **Note:** Colours, typography, radii, shadows, and all other visual tokens should be customised through v2 tokens, not SCSS variables. SCSS constants are only for compile-time structural values like padding and sizing.
187
+
The full token list is generated from `packages/tokens/dist/registry.json`.
234
188
235
189
## Recommended approach
236
190
237
191
- Use CSS variables when you want the simplest runtime override.
238
192
- Use `ThemeDocument` when you need a portable JSON theme format.
239
193
- Use `ConfigProvider` when you need scoped theming in React.
240
-
-Use SCSS constants only when a value must be decided at build time.
194
+
-Avoid treating Sass variables as public theme configuration; add missing customisation points as tokens.
241
195
242
-
Please report an issue if the existing list of tokens or constants is not enough for you.
196
+
Please report an issue if the existing list of tokens is not enough for you.
0 commit comments