Skip to content

Commit 0909b21

Browse files
authored
Add(CSS): Shorthand touch: for touch-action property (#421)
Adds touch: as the short-key prefix for the touch-action property, matching the convention used by m (margin), p (padding), fg (color) etc. - One-line change in config/rules.ts: key: 'touch' - Updates site syntaxes.ts for the reference page - 11 test cases covering every value listed in the issue: auto, none, pan-x, pan-y, pan-left, pan-right, pan-up, pan-down, pinch-zoom, manipulation + long-form regression - Real Chrome verification: touch:none → getComputedStyle === "none" Closes #215
1 parent dfdda9d commit 0909b21

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

‎packages/core/src/config/rules.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ const rules = {
605605
type: SyntaxRuleType.Native
606606
},
607607
'touch-action': {
608+
key: 'touch',
608609
type: SyntaxRuleType.Native
609610
},
610611
'word-break': {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { describe, test, expect } from 'vitest'
2+
import { MasterCSS, config as defaultConfig } from '../src'
3+
4+
describe('issue #215: touch: shorthand for touch-action', () => {
5+
const cases: [string, string][] = [
6+
['touch:auto', 'touch-action:auto'],
7+
['touch:none', 'touch-action:none'],
8+
['touch:pan-x', 'touch-action:pan-x'],
9+
['touch:pan-y', 'touch-action:pan-y'],
10+
['touch:pan-left', 'touch-action:pan-left'],
11+
['touch:pan-right', 'touch-action:pan-right'],
12+
['touch:pan-up', 'touch-action:pan-up'],
13+
['touch:pan-down', 'touch-action:pan-down'],
14+
['touch:pinch-zoom', 'touch-action:pinch-zoom'],
15+
['touch:manipulation', 'touch-action:manipulation']
16+
]
17+
18+
test.each(cases)('%s → %s', (input, expected) => {
19+
const css = new MasterCSS(undefined, defaultConfig)
20+
const rule = css.create(input)
21+
expect(rule).toBeDefined()
22+
expect(rule?.text).toContain(expected)
23+
})
24+
25+
test('touch-action: long form still works (regression)', () => {
26+
const css = new MasterCSS(undefined, defaultConfig)
27+
const rule = css.create('touch-action:none')
28+
expect(rule?.text).toContain('touch-action:none')
29+
})
30+
})

0 commit comments

Comments
 (0)