Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/__tests__/vendor/tailwind.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ test("transition", () => {
"color",
"backgroundColor",
"borderColor",
"outlineColor",
"textDecorationColor",
"fill",
"stroke",
Expand Down
85 changes: 65 additions & 20 deletions src/__tests__/vendor/tailwind/borders.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,34 +391,79 @@ describe.skip("Borders - Divide Style", () => {
// TODO
});

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

describe.skip("Borders - Outline Color", () => {
// TODO
test("outline-5", async () => {
expect(await renderCurrentTest()).toStrictEqual({
props: { style: { outlineWidth: 5, outlineStyle: "solid" } },
});
});
});

describe.skip("Borders - Outline Style", () => {
// TODO
});
describe("Borders - Outline Color", () => {
test("outline-black", async () => {
expect(await renderCurrentTest()).toStrictEqual({
props: { style: { outlineColor: "#000" } },
});
});

describe.skip("Borders - Outline Offset", () => {
// TODO
test("outline-white", async () => {
expect(await renderCurrentTest()).toStrictEqual({
props: { style: { outlineColor: "#fff" } },
});
});
});

describe.skip("Borders - Ring Width", () => {
// TODO
});
describe("Borders - Outline Style", () => {
test("outline-solid", async () => {
expect(await renderCurrentTest()).toStrictEqual({
props: { style: { outlineStyle: "solid" } },
});
});

describe.skip("Borders - Ring Color", () => {
// TODO
});
test("outline-dashed", async () => {
expect(await renderCurrentTest()).toStrictEqual({
props: { style: { outlineStyle: "dashed" } },
});
});

describe.skip("Borders - Ring Offset Width", () => {
// TODO
test("outline-dotted", async () => {
expect(await renderCurrentTest()).toStrictEqual({
props: { style: { outlineStyle: "dotted" } },
});
});

test("outline-double", async () => {
expect(await renderCurrentTest()).toStrictEqual({
props: {},
warnings: { values: { "outline-style": "double" } },
});
});
});

describe.skip("Borders - Ring Offset Color", () => {
// TODO
describe("Borders - Outline Offset", () => {
test("outline-offset-1", async () => {
expect(await renderCurrentTest()).toStrictEqual({
props: {
style: {
outlineOffset: 1,
},
},
});
});

test("-outline-offset-1", async () => {
expect(await renderCurrentTest()).toStrictEqual({
props: {
style: {
outlineOffset: -1,
},
},
});
});
});
40 changes: 30 additions & 10 deletions src/compiler/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ const parsers: {
"min-inline-size": parseSizeDeclaration,
"min-width": parseSizeDeclaration,
"opacity": ({ value }) => value,
"outline-color": parseColorDeclaration,
// "outline-offset": parseColorDeclaration,
"outline-style": parseOutlineStyle,
"outline-width": parseBorderSideWidthDeclaration,
"overflow": parseOverflow,
"padding": parsePadding,
"padding-block": parsePaddingBlock,
Expand Down Expand Up @@ -982,6 +986,12 @@ export function parseCustomDeclaration(
} else if (property === "object-position") {
// https://github.com/parcel-bundler/lightningcss/issues/1047
parseObjectPosition(declaration.value, builder);
} else if (property === "outline-offset") {
// https://github.com/parcel-bundler/lightningcss/issues/1048
builder.addDescriptor(
property,
parseUnparsed(declaration.value.value, builder, property),
);
} else if (
validProperties.has(property) ||
property.startsWith("--") ||
Expand Down Expand Up @@ -2097,16 +2107,7 @@ function parseBorderBlockStyle(
}

export function parseBorderSideWidthDeclaration(
declaration: DeclarationType<
| "border-block-end-width"
| "border-block-start-width"
| "border-bottom-width"
| "border-inline-end-width"
| "border-inline-start-width"
| "border-left-width"
| "border-right-width"
| "border-top-width"
>,
declaration: Extract<Declaration, { value: BorderSideWidth }>,
builder: StylesheetBuilder,
) {
builder.addDescriptor(
Expand Down Expand Up @@ -3044,6 +3045,25 @@ function parseVisibility(
}
}

function parseOutlineStyle(
declaration: DeclarationType<"outline-style">,
builder: StylesheetBuilder,
) {
const allowed = ["solid", "dotted", "dashed"];

if (
declaration.value.type !== "auto" &&
allowed.includes(declaration.value.value)
) {
builder.addDescriptor("outlineStyle", declaration.value.value);
} else {
builder.addWarning(
"value",
declaration.value.type === "auto" ? "auto" : declaration.value.value,
);
}
}

function parseFilter(
declaration: DeclarationType<"filter">,
builder: StylesheetBuilder,
Expand Down