Skip to content

Commit 5ba72cf

Browse files
committed
Update background-clip and gradient-text utilities for consistency and remove deprecated properties
1 parent bf887c3 commit 5ba72cf

12 files changed

Lines changed: 27 additions & 23 deletions

File tree

internal

packages/core/src/config/rules.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ const rules = {
340340
values: ['underline', 'overline', 'line-through'],
341341
unit: 'rem',
342342
type: SyntaxRuleType.NativeShorthand,
343-
namespaces: ['color.text'],
343+
namespaces: ['color', 'color.text'],
344344
declarations: ['-webkit-text-decoration', 'text-decoration']
345345
},
346346
'text-underline-offset': {
@@ -1011,8 +1011,7 @@ const rules = {
10111011
},
10121012
'background-clip': {
10131013
key: 'bg-clip',
1014-
type: SyntaxRuleType.Native,
1015-
declarations: ['-webkit-background-clip', 'background-clip']
1014+
type: SyntaxRuleType.Native
10161015
},
10171016
'background-origin': {
10181017
key: 'bg-origin',

packages/core/src/config/utilities.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ const utilities = {
9494
'transform-fill': { 'transform-box': 'fill-box' },
9595
'transform-stroke': { 'transform-box': 'stroke-box' },
9696
'transform-view': { 'transform-box': 'view-box' },
97-
'bg-clip-content': { '-webkit-background-clip': 'content-box', 'background-clip': 'content-box' },
98-
'bg-clip-padding': { '-webkit-background-clip': 'padding-box', 'background-clip': 'padding-box' },
99-
'bg-clip-border': { '-webkit-background-clip': 'border-box', 'background-clip': 'border-box' },
100-
'bg-clip-text': { '-webkit-background-clip': 'text', 'background-clip': 'text' },
97+
'bg-clip-content': { 'background-clip': 'content-box' },
98+
'bg-clip-padding': { 'background-clip': 'padding-box' },
99+
'bg-clip-border': { 'background-clip': 'border-box' },
100+
'bg-clip-text': { 'background-clip': 'text' },
101101
'bg-origin-content': { 'background-origin': 'content-box' },
102102
'bg-origin-padding': { 'background-origin': 'padding-box' },
103103
'bg-origin-border': { 'background-origin': 'border-box' },
@@ -134,7 +134,7 @@ const utilities = {
134134
'wrap-break-word': { 'overflow-wrap': 'break-word' },
135135
'wrap-anywhere': { 'overflow-wrap': 'anywhere' },
136136
'wrap-normal': { 'overflow-wrap': 'normal' },
137-
'gradient-text': { '-webkit-text-fill-color': 'transparent', '-webkit-background-clip': 'text', 'background-clip': 'text' },
137+
'gradient-text': { '-webkit-text-fill-color': 'transparent', 'background-clip': 'text' },
138138
'fit': { 'width': 'fit-content', 'height': 'fit-content' },
139139
'font-antialiased': { '-webkit-font-smoothing': 'antialiased', '-moz-osx-font-smoothing': 'grayscale' },
140140
'font-subpixel-antialiased': { '-webkit-font-smoothing': 'auto', '-moz-osx-font-smoothing': 'auto' },

packages/core/tests/rules/background-clip.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { it, test, expect } from 'vitest'
22
import { createCSS } from '../../src'
33

44
it.concurrent('background clip', () => {
5-
expect(createCSS().create('bg-clip:text')?.text).toContain('-webkit-background-clip:text;background-clip:text')
5+
expect(createCSS().create('bg-clip:text')?.text).toContain('background-clip:text')
66
})

packages/core/tests/rules/background.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test.concurrent('background', () => {
88
expect(createCSS().create('bg:black:hover@md&landscape')?.text).toBe('@media (width>=64rem) and (orientation:landscape){.bg\\:black\\:hover\\@md\\&landscape:hover{background-color:oklch(0% 0 none)}}')
99
expect(createCSS().create('bg:transparent')?.text).toContain('background-color:transparent')
1010
expect(createCSS().create('bg:current')?.text).toContain('background-color:currentColor')
11-
expect(createCSS().create('bg-clip-border')?.text).toContain('-webkit-background-clip:border-box;background-clip:border-box')
11+
expect(createCSS().create('bg-clip-border')?.text).toContain('background-clip:border-box')
1212
expect(createCSS().create('bg:url(\'#test\')')?.text).toContain('background-image:url(\'#test\')')
1313
expect(createCSS().create('bg:black|url(\'/images/wallpaper.jpg\')|no-repeat|top|left/cover')?.text).toContain('background:oklch(0% 0 none) url(\'/images/wallpaper.jpg\') no-repeat top left/cover')
1414
expect(createCSS().create('gradient(45deg,#f3ec78,#af4261)')?.text).toContain('background-image:linear-gradient(45deg,#f3ec78,#af4261)')

packages/core/tests/semantics.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { expectLayers } from './test'
55

66
test.concurrent('utilities', () => {
77
expect(createCSS(config).create('show')?.text).toBe('.show{display:block}')
8-
expect(createCSS().create('gradient-text')?.text).toBe('.gradient-text{-webkit-text-fill-color:transparent;-webkit-background-clip:text;background-clip:text}')
8+
expect(createCSS().create('gradient-text')?.text).toBe('.gradient-text{-webkit-text-fill-color:transparent;background-clip:text}')
99

1010
expectLayers(
1111
{

packages/validator/src/validate-css.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export function validateAtrulePrelude(atrule: string, prelude: any) {
9494
{ details: error.message, message: 'Invalid value for `@' + atrule + '` prelude' }
9595
}))
9696
}
97-
9897
return errors
9998
}
10099

@@ -134,11 +133,14 @@ export function validateDeclaration(property: string, value: any) {
134133
property
135134
}))
136135
} else if (error = isTargetError(lexer.matchProperty(property, value).error)) {
137-
errors.push(Object.assign(error, {
138-
property,
139-
...error.rawMessage === 'Mismatch' &&
140-
{ details: error.message, message: 'Invalid value for `' + property + '` property' }
141-
}))
136+
// TODO: https://github.com/master-co/css/issues/405
137+
if (!error.css?.includes('min(') && !error.css?.includes('max(') && !error.css?.includes('clamp(')) {
138+
errors.push(Object.assign(error, {
139+
property,
140+
...error.rawMessage === 'Mismatch' &&
141+
{ details: error.message, message: 'Invalid value for `' + property + '` property' }
142+
}))
143+
}
142144
}
143145

144146
return errors

packages/validator/tests/css.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ import validateCSS from '../src/validate-css'
33

44
it('selector', () => {
55
expect(validateCSS('.foo:fuck { font-size: 1rem }')).toEqual([])
6+
})
7+
8+
it('min fn', ()=> {
9+
expect(validateCSS('.foo { width: min(50vw, 200px) }')).toEqual([])
610
})

site/app/[locale]/guide/spacing/components/Overview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default () => {
2323
<td>{value / 16}rem</td>
2424
<td>
2525
<div className='inline-flex bg:stripe-pink outline:1|lighter outline-offset:-1 v:middle w:fit' style={{ gap: value / 16 + 'rem' }}>
26-
{Array.from({ length: 14 - index }, (_, index) => <div className='inline-block bg:base size:1.5em'></div>)}
26+
{Array.from({ length: 14 - index }, (_, index) => <div key={index} className='inline-block size:1.5em bg:base'></div>)}
2727
</div>
2828
</td>
2929
</tr>

site/app/[locale]/play/Play.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ export default function Play(props: any) {
519519
const width = useMemo(() => (!layout || layout === '2') ? '50%' : '100%', [layout])
520520
const height = useMemo(() => (!layout || layout === '2') ? '100%' : '50%', [layout])
521521
return (
522-
<div className="abs flex full flex-col">
522+
<div className="abs flex flex-col full">
523523
<Header fixed={false}>
524524
<HeaderContent>
525525
<Link href={'/'}>
@@ -737,7 +737,7 @@ export default function Play(props: any) {
737737
srcDoc={previewHTML}
738738
/>
739739
<div className={clsx('flex flex-col h:full', { 'hidden!': preview !== 'css' })}>
740-
<div className='flex bb:1|lightest flex:0|0|auto px:5x px:10x@sm align-items:center font:12 h:48 justify-content:space-between'>
740+
<div className='flex bb:1|lightest flex:0|0|auto px:5x align-items:center font:12 h:48 justify-content:space-between px:10x@sm'>
741741
<div>Generated CSS</div>
742742
<div className="fg:light">{generatedCSSSize}</div>
743743
</div>

0 commit comments

Comments
 (0)