aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/atoms/flip/flip.module.scss
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-10-07 18:44:14 +0200
committerArmand Philippot <git@armandphilippot.com>2023-11-11 18:14:41 +0100
commitd75b9a1e150ab211c1052fb49bede9bd16320aca (patch)
treee5bb221d2b8dc83151697fe646e9194f921b5807 /src/components/atoms/flip/flip.module.scss
parent12a03a9a72f7895d571dbaeeb245d92aa277a610 (diff)
feat(components): add a generic Flip component
The flipping animation is used at several places so it makes sense to use a single component to handle the animation. It will avoid styles duplication.
Diffstat (limited to 'src/components/atoms/flip/flip.module.scss')
-rw-r--r--src/components/atoms/flip/flip.module.scss49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/components/atoms/flip/flip.module.scss b/src/components/atoms/flip/flip.module.scss
new file mode 100644
index 0000000..20b1715
--- /dev/null
+++ b/src/components/atoms/flip/flip.module.scss
@@ -0,0 +1,49 @@
+@use "../../../styles/abstracts/functions" as fun;
+
+.front,
+.back {
+ grid-area: 1 / 1 / 2 / 2;
+ backface-visibility: hidden;
+ transition: all var(--flipper-speed, 0.6s) linear 0s;
+}
+
+.back {
+ transform: var(--rotation);
+}
+
+.wrapper {
+ display: grid;
+ transform-style: preserve-3d;
+
+ &--dynamic {
+ &:hover,
+ &:focus,
+ &:focus-within {
+ .back {
+ transform: rotate(0);
+ }
+
+ .front {
+ transform: var(--rotation);
+ }
+ }
+ }
+
+ &--manual#{&}--is-back {
+ .back {
+ transform: rotate(0);
+ }
+
+ .front {
+ transform: var(--rotation);
+ }
+ }
+
+ &--horizontal {
+ --rotation: rotateY(180deg);
+ }
+
+ &--vertical {
+ --rotation: rotateX(180deg);
+ }
+}