Skip to content

Commit 290cfa6

Browse files
authored
feat(tasty): improved inset, outline, and textOverflow styles (#963)
1 parent d89a036 commit 290cfa6

35 files changed

Lines changed: 1572 additions & 489 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Aligned babel plugin configuration interface with runtime `TastyConfig`. The `TastyZeroConfig` now supports `plugins` and `parserCacheSize` options, and uses the shared `configure()` function internally.

.changeset/chunk-reorganization.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Reorganized internal style chunk definitions. Display-related styles (`display`, `hide`, `textOverflow`, `overflow`, `whiteSpace`, `scrollbar`) are now in a DISPLAY chunk. Layout styles (`flow`, `gap`, grid/flex properties) are in a separate LAYOUT chunk.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Consolidated style handlers to reduce redundant handler registrations:
6+
7+
- `widthStyle` now handles `minWidth`, `maxWidth` directly
8+
- `heightStyle` now handles `minHeight`, `maxHeight` directly
9+
- `presetStyle` now handles all typography props (`fontSize`, `lineHeight`, `fontWeight`, `letterSpacing`, `textTransform`, `fontStyle`, `fontFamily`, `font`) with or without `preset` defined
10+
11+
Font props support number values: `fontSize={14}``font-size: 14px`, `fontWeight={700}``font-weight: 700`.
12+
13+
The `font` prop has special handling: `font="monospace"``var(--monospace-font)`, `font={true}``var(--font)`, `font="CustomFont"``CustomFont, var(--font)`. The `fontFamily` prop is a direct value without fallback.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Refactored `inset` style handler with smart output strategy:
6+
7+
- When using the `inset` prop or `insetBlock`/`insetInline` props: outputs `inset` CSS shorthand for efficiency
8+
- When using individual `top`, `right`, `bottom`, `left` props: outputs individual CSS properties to allow proper CSS cascade with modifiers
9+
10+
This fix resolves an issue where conditional modifiers on individual direction props (e.g., `top: { '': 0, 'side=bottom': 'initial' }`) would incorrectly override all four directions instead of just the specified one.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': minor
3+
---
4+
5+
**Breaking:** Changed `outline` style syntax to use slash separator for offset: `outline: '2px solid #red / 4px'` instead of the previous space-separated format. Also added `outlineOffset` as a direct style prop.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': minor
3+
---
4+
5+
Added slash separator support in style parser. Style values can now use `/` surrounded by whitespace to define parts (e.g., `'ellipsis / 3'`, `'2px solid #red / 4px'`). Each part is available via `groups[n].parts` array for style handlers.

.changeset/text-overflow-style.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@cube-dev/ui-kit': minor
3+
---
4+
5+
**Breaking:** Enhanced `textOverflow` style handler with automatic setup for text truncation. Previously, `textOverflow: 'ellipsis'` only set `text-overflow: ellipsis` (which doesn't work without `overflow: hidden`). Now it automatically adds `overflow: hidden` and `white-space: nowrap` for single-line ellipsis, making it actually functional.
6+
7+
New features:
8+
- `textOverflow: 'ellipsis'` - single-line truncation with ellipsis (now works correctly)
9+
- `textOverflow: 'ellipsis / 3'` - multi-line truncation (3 lines) with `-webkit-line-clamp`
10+
- `textOverflow: 'clip'` - single-line clip with `overflow: hidden`
11+
12+
The `displayStyle` handler now manages `display`, `hide`, `textOverflow`, `overflow`, and `whiteSpace` together. User-provided `overflow` and `whiteSpace` values take precedence over auto-generated ones from `textOverflow`.

.size-limit.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ module.exports = [
2727
path: './dist/es/index.js',
2828
webpack: true,
2929
import: '{ Button }',
30-
limit: '55kB',
30+
limit: '56kB',
3131
},
3232
{
3333
name: 'Tree shaking (just an Icon)',
3434
path: './dist/es/index.js',
3535
webpack: true,
3636
import: '{ AiIcon }',
37-
limit: '32kB',
37+
limit: '33kB',
3838
},
3939
];

src/stories/Tasty.docs.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,19 @@ radius: '1r top', // Top corners only (top-left, top-right)
769769
// Directional modifiers: top, right, bottom, left
770770
```
771771
772+
#### `outline` - Focus/Highlight Outline
773+
Enhanced outline syntax with slash separator for offset:
774+
```jsx
775+
outline: true, // Default: '1ow solid var(--outline-color)'
776+
outline: '2px solid #purple', // Custom width, style, color
777+
outline: '2px solid #red / 4px', // With offset (slash separator)
778+
outline: '2px / 4px', // Width with offset (simpler form)
779+
outlineOffset: '4px', // Offset as separate prop
780+
781+
// Priority: slash syntax in outline takes precedence over outlineOffset prop
782+
// Available styles: none, hidden, dotted, dashed, solid, double, groove, ridge, inset, outset
783+
```
784+
772785
### Typography Properties
773786
774787
#### `preset` - Typography Presets
@@ -787,6 +800,20 @@ preset: 'h2 strong', // Bold heading 2
787800
// Captions: c1, c2, tag
788801
```
789802
803+
#### `textOverflow` - Text Truncation
804+
Automatic setup for text truncation with ellipsis or multi-line clamping:
805+
```jsx
806+
textOverflow: 'ellipsis', // Single-line truncation with ellipsis
807+
textOverflow: 'ellipsis / 3', // Multi-line clamping (3 lines)
808+
textOverflow: 'clip', // Single-line truncation without ellipsis
809+
textOverflow: 'clip / 2', // Multi-line clip (2 lines)
810+
textOverflow: true, // Reset to initial
811+
812+
// Single-line: auto-adds overflow: hidden, white-space: nowrap
813+
// Multi-line: auto-adds display: -webkit-box, -webkit-line-clamp
814+
// User-provided overflow/whiteSpace take precedence
815+
```
816+
790817
#### `align`, `justify`, & `place` - Alignment
791818
Unified alignment control for flex and grid:
792819
```jsx

src/stories/playground/Playground.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function PlaygroundComponent() {
103103

104104
const toolbar = (
105105
<>
106-
<Text preset="t3" fontWeight={600} color="#dark-02">
106+
<Text preset="h6" color="#dark-02">
107107
Tasty Playground
108108
</Text>
109109
{isModified && (

0 commit comments

Comments
 (0)