Skip to content

Commit

Permalink
fix: unot.strictHyphen
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-He95 committed Apr 22, 2024
1 parent 84ff149 commit 6fb2c14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ export const rules: any = [
return `${prefix}${v}-${v1}`
}
return v2.trim() === ''
? ['max-w', 'max-h', 'w', 'h', 'gap', 'gap-x', 'gap-y', 'mx', 'my', 'mt', 'mr', 'mb', 'ml', 'm', 'px', 'py', 'pt', 'pr', 'pb', 'pl', 'p'].includes(v)
? `${prefix}${v}${v1}${v2}`
: `${prefix}${v}-${v1}${v2}`
? strictVariable
? `${prefix}${v}-${v1}${v2}`
: ['max-w', 'max-h', 'w', 'h', 'gap', 'gap-x', 'gap-y', 'mx', 'my', 'mt', 'mr', 'mb', 'ml', 'm', 'px', 'py', 'pt', 'pr', 'pb', 'pl', 'p'].includes(v)
? `${prefix}${v}${v1}${v2}`
: `${prefix}${v}-${v1}${v2}`
: strictVariable
? `${prefix}${v}-[${v1}${v2}]`
: `${prefix}${v}-${v1}${v2}`
Expand Down
14 changes: 9 additions & 5 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('should', () => {
xx-col flex-col-x"`)).toMatchInlineSnapshot(`
"class=\\"
xxmax-w
max-w1
max-w-1
xx-col flex-col-x\\""
`)
})
Expand Down Expand Up @@ -70,17 +70,17 @@ describe('should', () => {
it('hover:(flex-center)', () => {
expect(
transform(':class="hover:(flex-center) w10"'),
).toMatchInlineSnapshot('":class=\\"hover:flex hover:justify-center hover:items-center w10\\""')
).toMatchInlineSnapshot('":class=\\"hover:flex hover:justify-center hover:items-center w-10\\""')
})
it('hover:(flex-center) w10', () => {
expect(
transform(':class="hover:(flex-center) w10"'),
).toMatchInlineSnapshot('":class=\\"hover:flex hover:justify-center hover:items-center w10\\""')
).toMatchInlineSnapshot('":class=\\"hover:flex hover:justify-center hover:items-center w-10\\""')
})
it('w10 !(flex-center w10) w20', () => {
expect(
transform(':class=" w10 !(flex-center w10) w20"'),
).toMatchInlineSnapshot('":class=\\" w10 !flex-center !w10 w20\\""')
).toMatchInlineSnapshot('":class=\\" w-10 !flex-center !w-10 w-20\\""')
})
it('top10', () => {
expect(
Expand All @@ -93,7 +93,7 @@ describe('should', () => {
it('w', () => {
expect(
transform(':class=" w15!"'),
).toMatchInlineSnapshot('":class=\\" !w15\\""')
).toMatchInlineSnapshot('":class=\\" !w-15\\""')

expect(
transform(':class=" border#fff"'),
Expand All @@ -120,4 +120,8 @@ describe('should', () => {
transform(':class=" shadow-[0px_5px_10px_1px_rgba(1,1,1,1)] bg-rgba(1,1,1,1) bg#eee"'),
).toMatchInlineSnapshot('":class=\\" shadow-[0px_5px_10px_1px_rgba(1,1,1,1)] bg-[rgba(1,1,1,1)] bg-[#eee]\\""')
})
it('magic transform strictHyphen', () => {
expect(transform(':class=" w-1"')).toMatchInlineSnapshot('":class=\\" w-1\\""')
expect(transform(':class=" pt-8"')).toMatchInlineSnapshot('":class=\\" pt-8\\""')
})
})

0 comments on commit 6fb2c14

Please sign in to comment.