Skip to content

Commit c0dc59d

Browse files
authored
Merge pull request #6 from bkrmendy/rounded-corner-classes
Add support for rounded corner classes
2 parents 70aaae1 + bef1913 commit c0dc59d

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"scripts": {
1717
"dev": "vite",
1818
"build": "vite build",
19-
"preview": "vite preview"
19+
"preview": "vite preview",
20+
"test": "vitest"
2021
},
2122
"types": "./dist/tailwindcss-class-parser.es.d.ts",
2223
"main": "./dist/tailwindcss-class-parser.umd.cjs",

src/plugins.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ export const functionalPlugins = new Map<string, FunctionalPlugin[]>([
148148
["rounded", [
149149
{scaleKey: "borderRadius", ns: 'borderRadius', class: ['border-radius'], type: 'length'},
150150
]],
151+
["rounded-tl", [
152+
{scaleKey: "borderRadius", ns: 'borderTopLeftRadius', class: ['border-top-left-radius'], type: 'length'},
153+
]],
154+
["rounded-tr", [
155+
{scaleKey: "borderRadius", ns: 'borderTopRightRadius', class: ['border-top-right-radius'], type: 'length'},
156+
]],
157+
["rounded-br", [
158+
{scaleKey: "borderRadius", ns: 'borderBottomRightRadius', class: ['border-bottom-right-radius'], type: 'length'},
159+
]],
160+
["rounded-bl", [
161+
{scaleKey: "borderRadius", ns: 'borderBottomLeftRadius', class: ['border-bottom-left-radius'], type: 'length'},
162+
]],
151163
["flex", [
152164
{scaleKey: "flex", ns: 'flex', class: ['flex'], type: 'number'},
153165
]],

test/parse.test.ts

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,74 @@ it("w-1/2", () => {
150150
"arbitrary": false
151151
}
152152
)
153-
})
153+
})
154+
it("should parse rounded corner classes", () => {
155+
expect(parse("rounded-tl-lg")).toEqual({
156+
arbitrary: false,
157+
important: false,
158+
kind: "functional",
159+
modifier: null,
160+
negative: false,
161+
property: "borderTopLeftRadius",
162+
root: "rounded-tl",
163+
value: "0.5rem",
164+
valueDef: {
165+
class: ["border-top-left-radius"],
166+
kind: "length",
167+
raw: "lg",
168+
value: "0.5rem",
169+
},
170+
variants: [],
171+
});
172+
expect(parse("rounded-tr-lg")).toEqual({
173+
arbitrary: false,
174+
important: false,
175+
kind: "functional",
176+
modifier: null,
177+
negative: false,
178+
property: "borderTopRightRadius",
179+
root: "rounded-tr",
180+
value: "0.5rem",
181+
valueDef: {
182+
class: ["border-top-right-radius"],
183+
kind: "length",
184+
raw: "lg",
185+
value: "0.5rem",
186+
},
187+
variants: [],
188+
});
189+
expect(parse("rounded-bl-lg")).toEqual({
190+
arbitrary: false,
191+
important: false,
192+
kind: "functional",
193+
modifier: null,
194+
negative: false,
195+
property: "borderBottomLeftRadius",
196+
root: "rounded-bl",
197+
value: "0.5rem",
198+
valueDef: {
199+
class: ["border-bottom-left-radius"],
200+
kind: "length",
201+
raw: "lg",
202+
value: "0.5rem",
203+
},
204+
variants: [],
205+
});
206+
expect(parse("rounded-br-lg")).toEqual({
207+
arbitrary: false,
208+
important: false,
209+
kind: "functional",
210+
modifier: null,
211+
negative: false,
212+
property: "borderBottomRightRadius",
213+
root: "rounded-br",
214+
value: "0.5rem",
215+
valueDef: {
216+
class: ["border-bottom-right-radius"],
217+
kind: "length",
218+
raw: "lg",
219+
value: "0.5rem",
220+
},
221+
variants: [],
222+
});
223+
});

0 commit comments

Comments
 (0)