Skip to content
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

Rework transforms to require less CSS #32

Merged
merged 6 commits into from
Jul 29, 2023
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
2 changes: 1 addition & 1 deletion build/style.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '8a8920dcfe863de47e17');
<?php return array('dependencies' => array(), 'version' => 'ca9dfa13a90bf7f4013a');
2 changes: 1 addition & 1 deletion build/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 11 additions & 90 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
* Editor and frontend styles for the Icon Block.
*/

/* Register our variables. */
$r90: rotate(90deg);
$r180: rotate(180deg);
$r270: rotate(270deg);
$flipH: scaleX(-1);
$flipV: scaleY(-1);
$flipHV: scale(-1, -1);

/* Icon Block styles. */
.wp-block-outermost-icon-block {
display: flex;
Expand Down Expand Up @@ -50,109 +42,38 @@ $flipHV: scale(-1, -1);
transform: scale(1.1);
}

/* There is likely a more efficient way to handle the rotation/flipping */
svg {
transform: rotate(var(--outermost--icon-block--transform-rotate, 0deg)) scaleX(var(--outermost--icon-block--transform-scale-x, 1)) scaleY(var(--outermost--icon-block--transform-scale-y, 1));
}

&.rotate-90,
.rotate-90 {
svg {
transform: $r90;
}
--outermost--icon-block--transform-rotate: 90deg;
}

&.rotate-180,
.rotate-180 {
svg {
transform: $r180;
}
--outermost--icon-block--transform-rotate: 180deg;
}

&.rotate-270,
.rotate-270 {
svg {
transform: $r270;
}
--outermost--icon-block--transform-rotate: 270deg;
}

&.flip-horizontal,
.flip-horizontal {
svg {
transform: $flipH;
}
--outermost--icon-block--transform-scale-x: -1;
}

&.flip-vertical,
.flip-vertical {
svg {
transform: $flipV;
}
--outermost--icon-block--transform-scale-y: -1;
}

&.flip-vertical.flip-horizontal,
.flip-vertical.flip-horizontal {
svg {
transform: $flipHV;
}
}

&.rotate-90.flip-horizontal,
.rotate-90.flip-horizontal {
svg {
transform: $r90 $flipH;
}
}

&.rotate-90.flip-vertical,
.rotate-90.flip-vertical {
svg {
transform: $r90 $flipV;
}
}

&.rotate-90.flip-horizontal.flip-vertical,
.rotate-90.flip-horizontal.flip-vertical {
svg {
transform: $r90 $flipHV;
}
}

&.rotate-180.flip-horizontal,
.rotate-180.flip-horizontal {
svg {
transform: $r180 $flipH;
}
}

&.rotate-180.flip-vertical,
.rotate-180.flip-vertical {
svg {
transform: $r180 $flipV;
}
}

&.rotate-180.flip-horizontal.flip-vertical,
.rotate-180.flip-horizontal.flip-vertical {
svg {
transform: $r180 $flipHV;
}
}

&.rotate-270.flip-horizontal,
.rotate-270.flip-horizontal {
svg {
transform: $r270 $flipH;
}
}

&.rotate-270.flip-vertical,
.rotate-270.flip-vertical {
svg {
transform: $r270 $flipV;
}
}

&.rotate-270.flip-horizontal.flip-vertical,
.rotate-270.flip-horizontal.flip-vertical {
svg {
transform: $r270 $flipHV;
}
--outermost--icon-block--transform-scale-x: -1;
--outermost--icon-block--transform-scale-y: -1;
}
}