Skip to content

Commit 40cee1c

Browse files
committed
feat: outline-width, outline-color, outline-style, outline-offset
1 parent d086a5e commit 40cee1c

File tree

3 files changed

+96
-30
lines changed

3 files changed

+96
-30
lines changed

src/__tests__/vendor/tailwind.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ test("transition", () => {
3636
"color",
3737
"backgroundColor",
3838
"borderColor",
39+
"outlineColor",
3940
"textDecorationColor",
4041
"fill",
4142
"stroke",

src/__tests__/vendor/tailwind/borders.test.tsx

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -391,34 +391,79 @@ describe.skip("Borders - Divide Style", () => {
391391
// TODO
392392
});
393393

394-
describe.skip("Borders - Outline Width", () => {
395-
// TODO
396-
});
394+
describe("Borders - Outline Width", () => {
395+
test("outline-1", async () => {
396+
expect(await renderCurrentTest()).toStrictEqual({
397+
props: { style: { outlineWidth: 1, outlineStyle: "solid" } },
398+
});
399+
});
397400

398-
describe.skip("Borders - Outline Color", () => {
399-
// TODO
401+
test("outline-5", async () => {
402+
expect(await renderCurrentTest()).toStrictEqual({
403+
props: { style: { outlineWidth: 5, outlineStyle: "solid" } },
404+
});
405+
});
400406
});
401407

402-
describe.skip("Borders - Outline Style", () => {
403-
// TODO
404-
});
408+
describe("Borders - Outline Color", () => {
409+
test("outline-black", async () => {
410+
expect(await renderCurrentTest()).toStrictEqual({
411+
props: { style: { outlineColor: "#000" } },
412+
});
413+
});
405414

406-
describe.skip("Borders - Outline Offset", () => {
407-
// TODO
415+
test("outline-white", async () => {
416+
expect(await renderCurrentTest()).toStrictEqual({
417+
props: { style: { outlineColor: "#fff" } },
418+
});
419+
});
408420
});
409421

410-
describe.skip("Borders - Ring Width", () => {
411-
// TODO
412-
});
422+
describe("Borders - Outline Style", () => {
423+
test("outline-solid", async () => {
424+
expect(await renderCurrentTest()).toStrictEqual({
425+
props: { style: { outlineStyle: "solid" } },
426+
});
427+
});
413428

414-
describe.skip("Borders - Ring Color", () => {
415-
// TODO
416-
});
429+
test("outline-dashed", async () => {
430+
expect(await renderCurrentTest()).toStrictEqual({
431+
props: { style: { outlineStyle: "dashed" } },
432+
});
433+
});
417434

418-
describe.skip("Borders - Ring Offset Width", () => {
419-
// TODO
435+
test("outline-dotted", async () => {
436+
expect(await renderCurrentTest()).toStrictEqual({
437+
props: { style: { outlineStyle: "dotted" } },
438+
});
439+
});
440+
441+
test("outline-double", async () => {
442+
expect(await renderCurrentTest()).toStrictEqual({
443+
props: {},
444+
warnings: { values: { "outline-style": "double" } },
445+
});
446+
});
420447
});
421448

422-
describe.skip("Borders - Ring Offset Color", () => {
423-
// TODO
449+
describe("Borders - Outline Offset", () => {
450+
test("outline-offset-1", async () => {
451+
expect(await renderCurrentTest()).toStrictEqual({
452+
props: {
453+
style: {
454+
outlineOffset: 1,
455+
},
456+
},
457+
});
458+
});
459+
460+
test("-outline-offset-1", async () => {
461+
expect(await renderCurrentTest()).toStrictEqual({
462+
props: {
463+
style: {
464+
outlineOffset: -1,
465+
},
466+
},
467+
});
468+
});
424469
});

src/compiler/declarations.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ const parsers: {
204204
"min-inline-size": parseSizeDeclaration,
205205
"min-width": parseSizeDeclaration,
206206
"opacity": ({ value }) => value,
207+
"outline-color": parseColorDeclaration,
208+
// "outline-offset": parseColorDeclaration,
209+
"outline-style": parseOutlineStyle,
210+
"outline-width": parseBorderSideWidthDeclaration,
207211
"overflow": parseOverflow,
208212
"padding": parsePadding,
209213
"padding-block": parsePaddingBlock,
@@ -982,6 +986,12 @@ export function parseCustomDeclaration(
982986
} else if (property === "object-position") {
983987
// https://github.com/parcel-bundler/lightningcss/issues/1047
984988
parseObjectPosition(declaration.value, builder);
989+
} else if (property === "outline-offset") {
990+
// https://github.com/parcel-bundler/lightningcss/issues/1048
991+
builder.addDescriptor(
992+
property,
993+
parseUnparsed(declaration.value.value, builder, property),
994+
);
985995
} else if (
986996
validProperties.has(property) ||
987997
property.startsWith("--") ||
@@ -2097,16 +2107,7 @@ function parseBorderBlockStyle(
20972107
}
20982108

20992109
export function parseBorderSideWidthDeclaration(
2100-
declaration: DeclarationType<
2101-
| "border-block-end-width"
2102-
| "border-block-start-width"
2103-
| "border-bottom-width"
2104-
| "border-inline-end-width"
2105-
| "border-inline-start-width"
2106-
| "border-left-width"
2107-
| "border-right-width"
2108-
| "border-top-width"
2109-
>,
2110+
declaration: Extract<Declaration, { value: BorderSideWidth }>,
21102111
builder: StylesheetBuilder,
21112112
) {
21122113
builder.addDescriptor(
@@ -3044,6 +3045,25 @@ function parseVisibility(
30443045
}
30453046
}
30463047

3048+
function parseOutlineStyle(
3049+
declaration: DeclarationType<"outline-style">,
3050+
builder: StylesheetBuilder,
3051+
) {
3052+
const allowed = ["solid", "dotted", "dashed"];
3053+
3054+
if (
3055+
declaration.value.type !== "auto" &&
3056+
allowed.includes(declaration.value.value)
3057+
) {
3058+
builder.addDescriptor("outlineStyle", declaration.value.value);
3059+
} else {
3060+
builder.addWarning(
3061+
"value",
3062+
declaration.value.type === "auto" ? "auto" : declaration.value.value,
3063+
);
3064+
}
3065+
}
3066+
30473067
function parseFilter(
30483068
declaration: DeclarationType<"filter">,
30493069
builder: StylesheetBuilder,

0 commit comments

Comments
 (0)