Skip to content

Commit d74a1f5

Browse files
committed
feat(parser): new style parser * 6
1 parent b93f994 commit d74a1f5

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

src/components/layout/Prefix.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const Prefix = forwardRef(function Prefix(
5555
styles={styles}
5656
style={{
5757
// @ts-ignore
58-
'--prefix-gap': parseStyle(outerGap).value,
58+
'--prefix-gap': parseStyle(outerGap).output,
5959
}}
6060
>
6161
{children}

src/components/layout/Suffix.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const Suffix = forwardRef(function Suffix(
5353
ref={ref}
5454
styles={styles}
5555
style={{
56-
'--suffix-gap': parseStyle(outerGap).value,
56+
'--suffix-gap': parseStyle(outerGap).output,
5757
}}
5858
>
5959
{children}

src/parser/const.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const VALUE_KEYWORDS = new Set([
55
'min-content',
66
'fit-content',
77
'stretch',
8+
'initial',
89
]);
910

1011
export const COLOR_FUNCS = new Set([

src/tasty/styles/dimension.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ describe('dimensionStyle – width & height helpers', () => {
3232
expect(res['max-width']).toBe('calc(2 * var(--gap))');
3333
});
3434

35+
test('width three args', () => {
36+
const res = widthStyle({ width: 'initial 36x max-content' }) as any;
37+
expect(res.width).toBe('calc(36 * var(--gap))');
38+
expect(res['min-width']).toBe('initial');
39+
expect(res['max-width']).toBe('max-content');
40+
});
41+
3542
test('stretch width keyword', () => {
3643
const res = widthStyle({ width: 'stretch' }) as any;
3744
expect(res.width).toEqual([
@@ -60,7 +67,7 @@ describe('dimensionStyle – width & height helpers', () => {
6067
expect(res['max-height']).toBe('initial');
6168
});
6269

63-
test('min value height three args', () => {
70+
test('height three args', () => {
6471
const res = heightStyle({ height: '1x 5x 10x' }) as any;
6572
expect(res.height).toBe('calc(5 * var(--gap))');
6673
expect(res['min-height']).toBe('var(--gap)');
@@ -71,4 +78,9 @@ describe('dimensionStyle – width & height helpers', () => {
7178
const res = heightStyle({ height: true }) as any;
7279
expect(res.height).toBe('auto');
7380
});
81+
82+
test('stretch height keyword', () => {
83+
const res = heightStyle({ height: 'stretch' }) as any;
84+
expect(res.height).toBe('auto');
85+
});
7486
});

src/tasty/styles/dimension.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ export function dimensionStyle(name) {
6565
}
6666

6767
if (styles[name] === 'stretch') {
68-
styles[name] = ['stretch', '-webkit-fill-available', '-moz-available'];
68+
if (name === 'width') {
69+
styles[name] = ['stretch', '-webkit-fill-available', '-moz-available'];
70+
} else {
71+
styles[name] = 'auto';
72+
}
6973
}
7074

7175
return styles;

0 commit comments

Comments
 (0)