Skip to content

feature/logical-revamp-v8 : feedback #773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,7 @@
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,7 @@
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
5 changes: 1 addition & 4 deletions plugin-packs/postcss-preset-env/test/basic.ch38.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,7 @@
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,7 @@ h6.test-custom-selectors {
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,7 @@ h6.test-custom-selectors {
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,7 @@ h6.test-custom-selectors {
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
2 changes: 1 addition & 1 deletion plugin-packs/postcss-preset-env/test/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
right: round(nearest, 2.5px, 1px);
bottom: round(up, 2.5px, 1px);
left: round(down, 2.5px, 1px);
inset: round(to-zero, 2.5px, 1px);
padding-left: round(to-zero, 2.5px, 1px);
}

.trigonometric {
Expand Down
5 changes: 1 addition & 4 deletions plugin-packs/postcss-preset-env/test/basic.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,7 @@
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
5 changes: 1 addition & 4 deletions plugin-packs/postcss-preset-env/test/basic.ff49.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,7 @@
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
2 changes: 1 addition & 1 deletion plugin-packs/postcss-preset-env/test/basic.ff66.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@
right: 3px;
bottom: 3px;
left: 2px;
inset: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
5 changes: 1 addition & 4 deletions plugin-packs/postcss-preset-env/test/basic.ie10.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,7 @@
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,7 @@ h6.test-custom-selectors {
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
right: round(nearest, 2.5px, 1px);
bottom: round(up, 2.5px, 1px);
left: round(down, 2.5px, 1px);
inset: round(to-zero, 2.5px, 1px);
padding-left: round(to-zero, 2.5px, 1px);
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,7 @@ h6.test-custom-selectors {
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -975,20 +975,8 @@ h6.test-custom-selectors {
bottom: round(up, 2.5px, 1px);
left: 2px;
left: round(down, 2.5px, 1px);
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
inset: 2px;
top: 2px;
top: round(to-zero, 2.5px, 1px);
right: 2px;
right: round(to-zero, 2.5px, 1px);
bottom: 2px;
bottom: round(to-zero, 2.5px, 1px);
left: 2px;
left: round(to-zero, 2.5px, 1px);
inset: round(to-zero, 2.5px, 1px);
padding-left: 2px;
padding-left: round(to-zero, 2.5px, 1px);
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@
right: 3px;
bottom: 3px;
left: 2px;
inset: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,7 @@ h6.test-custom-selectors {
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ h6.test-custom-selectors {
right: 3px;
bottom: 3px;
left: 2px;
inset: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
5 changes: 1 addition & 4 deletions plugin-packs/postcss-preset-env/test/basic.stage0.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,7 @@ h6.test-custom-selectors {
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,7 @@
right: 3px;
bottom: 3px;
left: 2px;
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
padding-left: 2px;
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,7 @@
right: round(nearest, 2.5px, 1px);
bottom: round(up, 2.5px, 1px);
left: round(down, 2.5px, 1px);
top: round(to-zero, 2.5px, 1px);
right: round(to-zero, 2.5px, 1px);
bottom: round(to-zero, 2.5px, 1px);
left: round(to-zero, 2.5px, 1px);
padding-left: round(to-zero, 2.5px, 1px);
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,7 @@
right: round(nearest, 2.5px, 1px);
bottom: round(up, 2.5px, 1px);
left: round(down, 2.5px, 1px);
top: round(to-zero, 2.5px, 1px);
right: round(to-zero, 2.5px, 1px);
bottom: round(to-zero, 2.5px, 1px);
left: round(to-zero, 2.5px, 1px);
padding-left: round(to-zero, 2.5px, 1px);
}

.trigonometric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,5 +813,4 @@ h6.test-custom-selectors:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):n
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,6 @@ h6.test-custom-selectors:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):n
top: 2px;
right: 2px;
bottom: 2px;
left: 2px;
inset: 2px;
top: 2px;
top: round(to-zero, 2.5px, 1px);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
.js-has-pseudo [csstools-has-2p-1m-2w-2p-37-14-1a-2q-15]:not(does-not-exist) {
margin-left: 2px;
margin-left: 2px;
margin-inline-start: 2px;
}
.js-has-pseudo [csstools-has-2p-1m-2w-2p-37-14-1a-2q-15]:not(does-not-exist) {
margin-left: 2px;
margin-left: 2px;
margin-inline-start: 2px;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
.js-has-pseudo [csstools-has-2p-1m-2w-2p-37-14-1a-2q-15]:not(does-not-exist) {
margin-left: 2px;
margin-left: 2px;
margin-inline-start: 2px;
}
.js-has-pseudo [csstools-has-2p-1m-2w-2p-37-14-1a-2q-15]:not(does-not-exist) {
margin-left: 2px;
margin-left: 2px;
margin-inline-start: 2px;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/postcss-logical/dist/index.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/postcss-logical/dist/index.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/postcss-logical/dist/lib/clone-declaration.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import type { Declaration } from 'postcss';
export declare function cloneDeclaration(declaration: Declaration, value: string, prop: string): Declaration;
export declare function cloneDeclaration(declaration: Declaration, value: string, prop: string): void;
15 changes: 7 additions & 8 deletions plugins/postcss-logical/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,22 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
if (!transform) {
return;
}
const parent = decl.parent;

let transformed = false;

try {
transformed = transform(decl);
} catch (error) {
decl.warn(result, error.message);
return;
}

if (transformed) {
if (!options.preserve) {
decl.remove();
}
if (!transformed) {
return;
}

if (!parent.nodes.length) {
parent.remove();
}
if (!options.preserve) {
decl.remove();
}
};
};
Expand Down
10 changes: 8 additions & 2 deletions plugins/postcss-logical/src/lib/clone-declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ export function cloneDeclaration(
declaration: Declaration,
value: string,
prop: string,
) : Declaration {
return declaration.cloneBefore({ value, prop });
): void {
if (declaration.parent && declaration.parent.some((x) => {
return x.type == 'decl' && x.prop === prop && x.value === value;
})) {
return;
}

declaration.cloneBefore({ value, prop });
}
4 changes: 2 additions & 2 deletions plugins/postcss-logical/src/lib/transform-borders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function transformBorder(

export function transformBorderProperty(
borderSetting: string,
side: [string,string],
side: [string, string],
): (declaration: Declaration) => boolean {
return (declaration: Declaration) => {
const [sideA, sideB] = side;
Expand All @@ -42,7 +42,7 @@ export function transformBorderProperty(
}

export function transformBorderShorthand(
side: [string] | [string,string],
side: [string] | [string, string],
): (declaration: Declaration) => boolean {
return (declaration: Declaration) => {
side.forEach((sidePart) => cloneDeclaration(
Expand Down
Loading