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

refactor: clean up global stylesheets #7377

Merged
merged 1 commit into from
Jul 25, 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
168 changes: 86 additions & 82 deletions packages/calcite-components/src/assets/styles/_animation.scss
Original file line number Diff line number Diff line change
@@ -1,112 +1,116 @@
@keyframes in {
0% {
opacity: 0;
@mixin animation-helper-classes() {
@keyframes in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
100% {
opacity: 1;

@keyframes in-down {
0% {
opacity: 0;
transform: translate3D(0, -5px, 0);
}
100% {
opacity: 1;
transform: translate3D(0, 0, 0);
}
}
}

@keyframes in-down {
0% {
opacity: 0;
transform: translate3D(0, -5px, 0);
@keyframes in-up {
0% {
opacity: 0;
transform: translate3D(0, 5px, 0);
}
100% {
opacity: 1;
transform: translate3D(0, 0, 0);
}
}
100% {
opacity: 1;
transform: translate3D(0, 0, 0);

@keyframes in-right {
0% {
opacity: 0;
transform: translate3D(-5px, 0, 0);
}
100% {
opacity: 1;
transform: translate3D(0, 0, 0);
}
}
}

@keyframes in-up {
0% {
opacity: 0;
transform: translate3D(0, 5px, 0);
@keyframes in-left {
0% {
opacity: 0;
transform: translate3D(5px, 0, 0);
}
100% {
opacity: 1;
transform: translate3D(0, 0, 0);
}
}
100% {
opacity: 1;
transform: translate3D(0, 0, 0);

@keyframes in-scale {
0% {
opacity: 0;
transform: scale3D(0.95, 0.95, 1);
}
100% {
opacity: 1;
transform: scale3D(1, 1, 1);
}
}
}

@keyframes in-right {
0% {
// allows animation trigger via JS by adding class to element
.calcite-animate {
opacity: 0;
transform: translate3D(-5px, 0, 0);
animation-fill-mode: both;
animation-duration: var(--calcite-animation-timing);
}
100% {
opacity: 1;
transform: translate3D(0, 0, 0);

// specify animation
.calcite-animate__in {
animation-name: in;
}
}

@keyframes in-left {
0% {
opacity: 0;
transform: translate3D(5px, 0, 0);
.calcite-animate__in-down {
animation-name: in-down;
}
100% {
opacity: 1;
transform: translate3D(0, 0, 0);

.calcite-animate__in-up {
animation-name: in-up;
}
}

@keyframes in-scale {
0% {
opacity: 0;
transform: scale3D(0.95, 0.95, 1);
.calcite-animate__in-right {
animation-name: in-right;
}

.calcite-animate__in-left {
animation-name: in-left;
}
100% {
opacity: 1;
transform: scale3D(1, 1, 1);

.calcite-animate__in-scale {
animation-name: in-scale;
}
}

:root {
@mixin animation-base() {
--calcite-animation-timing: calc(150ms * var(--calcite-internal-duration-factor));
--calcite-internal-duration-factor: var(--calcite-duration-factor, 1);
--calcite-internal-animation-timing-fast: calc(100ms * var(--calcite-internal-duration-factor));
--calcite-internal-animation-timing-medium: calc(200ms * var(--calcite-internal-duration-factor));
--calcite-internal-animation-timing-slow: calc(300ms * var(--calcite-internal-duration-factor));
}

// allows animation trigger via JS by adding class to element
.calcite-animate {
opacity: 0;
animation-fill-mode: both;
animation-duration: var(--calcite-animation-timing);
}

// specify animation
.calcite-animate__in {
animation-name: in;
}

.calcite-animate__in-down {
animation-name: in-down;
}

.calcite-animate__in-up {
animation-name: in-up;
}

.calcite-animate__in-right {
animation-name: in-right;
}

.calcite-animate__in-left {
animation-name: in-left;
}

.calcite-animate__in-scale {
animation-name: in-scale;
}

@media (prefers-reduced-motion: reduce) {
:root {
// [workaround] using 0.01 to ensure `openCloseComponent` utils work consistently
// this should be removed once https://github.com/Esri/calcite-design-system/issues/6604 is addressed
--calcite-internal-duration-factor: 0.01;
@mixin animation-reduced-motion() {
@media (prefers-reduced-motion: reduce) {
:root {
// [workaround] using 0.01 to ensure `openCloseComponent` utils work consistently
// this should be removed once https://github.com/Esri/calcite-design-system/issues/6604 is addressed
--calcite-internal-duration-factor: 0.01;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $floating-ui-transform-top: translateY(5px);
$floating-ui-transform-left: translateX(5px);
$floating-ui-transform-right: translateX(-5px);

:root {
@mixin floating-ui-base {
--calcite-floating-ui-transition: var(--calcite-animation-timing);
--calcite-floating-ui-z-index: theme("zIndex.dropdown");
}
Expand Down
6 changes: 6 additions & 0 deletions packages/calcite-components/src/assets/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
@extend %type-vars;
@include calcite-theme-headless();
@include calcite-mode-light-extended();
@include floating-ui-base();
@include animation-base();

text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
Expand Down Expand Up @@ -73,3 +75,7 @@
@include calcite-mode-light-extended();
}
}

@include animation-reduced-motion();

@include animation-helper-classes();