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

Adding motion tokens #5247

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
38 changes: 12 additions & 26 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions packages/react/.storybook/primitives-v8.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* size/typography */
@import '@primer/primitives/dist/css/base/motion/motion.css';
@import '@primer/primitives/dist/css/base/size/size.css';
@import '@primer/primitives/dist/css/base/typography/typography.css';
@import '@primer/primitives/dist/css/functional/motion/motion.css';
@import '@primer/primitives/dist/css/functional/size/border.css';
@import '@primer/primitives/dist/css/functional/size/breakpoints.css';
@import '@primer/primitives/dist/css/functional/size/size-coarse.css';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@primer/behaviors": "^1.7.2",
"@primer/live-region-element": "^0.7.1",
"@primer/octicons-react": "^19.9.0",
"@primer/primitives": "9.x || 10.x",
"@primer/primitives": "0.0.0-20241107121105",
"@styled-system/css": "^5.1.5",
"@styled-system/props": "^5.1.5",
"@styled-system/theme-get": "^5.1.2",
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/Button/ButtonBase.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
border: var(--borderWidth-thin) solid;
border-color: var(--button-default-borderColor-rest);
border-radius: var(--borderRadius-medium);
transition: 80ms cubic-bezier(0.65, 0, 0.35, 1);
transition-timing-function: var(--easing-exit);
transition-duration: var(--base-duration-instant);
transition-property: color, fill, background-color, border-color;
appearance: none;
align-items: center;
justify-content: space-between;
gap: var(--base-size-8);

&:hover {
transition-duration: 80ms;
transition-timing-function: var(--easing-entrance);
}

&:focus-visible {
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/Button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ export const getBaseStyles = (theme?: Theme) => ({
padding: '0 12px',
gap: '8px',
minWidth: 'max-content',
transition: '80ms cubic-bezier(0.65, 0, 0.35, 1)',
transitionTimingFunction: 'var(--easing-exit)',
transitionDuration: 'var(--base-duration-instant)',
transitionProperty: 'color, fill, background-color, border-color',
'&[href]': {
display: 'inline-flex',
Expand All @@ -264,7 +265,7 @@ export const getBaseStyles = (theme?: Theme) => ({
},
},
'&:hover': {
transitionDuration: '80ms',
transitionTimingFunction: 'var(--easing-entrance)',
},
'&:active': {
transition: 'none',
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/Checkbox/Checkbox.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* checked -> unchecked - add 120ms delay to fully see animation-out */
transition:
background-color,
border-color 80ms cubic-bezier(0.33, 1, 0.68, 1);
border-color var(--base-duration-instant) var(--easing-entrance);

&::before {
width: var(--base-size-16);
Expand All @@ -19,7 +19,7 @@
mask-size: 75%;
mask-repeat: no-repeat;
mask-position: center;
animation: checkmarkOut 80ms cubic-bezier(0.65, 0, 0.35, 1) forwards;
animation: checkmarkOut var(--base-duration-instant) var(--easing-move) forwards;
}

&:checked,
Expand All @@ -31,7 +31,7 @@
border-color: var(--control-checked-bgColor-rest);

&::before {
animation: checkmarkIn 80ms cubic-bezier(0.65, 0, 0.35, 1) forwards 80ms;
animation: checkmarkIn var(--base-duration-instant) var(--easing-move) forwards var(--base-delay-instant);
}
}

Expand All @@ -42,7 +42,7 @@
&:checked {
transition:
background-color,
border-color 80ms cubic-bezier(0.32, 0, 0.67, 0) 0ms;
border-color var(--base-duration-instant) var(--easing-exit) var(--base-delay-none);

&::before {
visibility: visible;
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const StyledCheckbox = styled.input`
mask-repeat: no-repeat;
mask-position: center;

animation: checkmarkOut 80ms cubic-bezier(0.65, 0, 0.35, 1) forwards;
animation: checkmarkOut var(--base-duration-instant) var(--easing-move) forwards;
}

&:checked,
Expand All @@ -75,7 +75,7 @@ const StyledCheckbox = styled.input`
); /* using bgColor here to avoid a border change in dark high contrast */

&::before {
animation: checkmarkIn 80ms cubic-bezier(0.65, 0, 0.35, 1) forwards 80ms;
animation: checkmarkIn var(--base-duration-instant) var(--easing-move) forwards var(--base-delay-instant);
}
}

Expand All @@ -86,11 +86,11 @@ const StyledCheckbox = styled.input`
&:checked {
transition:
background-color,
border-color 80ms cubic-bezier(0.32, 0, 0.67, 0) 0ms;
border-color var(--base-duration-instant) var(--easing-exit) var(--base-delay-none);

&::before {
visibility: visible;
transition: visibility 0s linear 0s;
transition: visibility 0s var(--easing-static) 0s;
}

&:disabled {
Expand Down
20 changes: 13 additions & 7 deletions packages/react/src/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const Backdrop = styled('div')`
align-items: center;
justify-content: center;
background-color: ${get('colors.primer.canvas.backdrop')};
animation: dialog-backdrop-appear 200ms ${get('animation.easeOutCubic')};
animation: dialog-backdrop-appear var(--base-duration-fast) var(--easing-entrance);

&[data-position-regular='center'] {
align-items: center;
Expand Down Expand Up @@ -254,14 +254,16 @@ const StyledDialog = styled.div<StyledDialogProps>`
opacity: 1;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-scaleFade var(--base-duration-fast) var(--easing-entrance) var(--base-delay-none) 1
normal none running;
}

&[data-position-regular='center'] {
border-radius: var(--borderRadius-large, 0.75rem);

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-scaleFade var(--base-duration-fast) cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none
running;
}
}

Expand All @@ -273,7 +275,8 @@ const StyledDialog = styled.div<StyledDialogProps>`
border-bottom-left-radius: 0;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-slideInRight 0.25s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-slideInRight var(--base-duration-default) cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal
none running;
}
}

Expand All @@ -285,7 +288,8 @@ const StyledDialog = styled.div<StyledDialogProps>`
border-bottom-right-radius: 0;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-slideInLeft 0.25s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-slideInLeft var(--base-duration-default) cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal
none running;
}
}

Expand All @@ -306,7 +310,8 @@ const StyledDialog = styled.div<StyledDialogProps>`
border-bottom-left-radius: 0;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-slideUp 0.25s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-slideUp var(--base-duration-default) cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none
running;
}
}

Expand All @@ -319,7 +324,8 @@ const StyledDialog = styled.div<StyledDialogProps>`
flex-grow: 1;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-scaleFade var(--base-duration-fast) cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none
running;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/Overlay/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const StyledOverlay = styled.div<StyledOverlayProps>`
width: ${props => widthMap[props.width || 'auto']};
border-radius: 12px;
overflow: ${props => (props.overflow ? props.overflow : 'hidden')};
animation: overlay-appear ${animationDuration}ms ${get('animation.easeOutCubic')};
animation: overlay-appear var(--base-duration-fast) var(--easing-entrance);

@keyframes overlay-appear {
0% {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const loadingKeyframes = keyframes`
`

export const LoadingCounter = styled.span`
animation: ${loadingKeyframes} 1.2s ease-in-out infinite alternate;
animation: ${loadingKeyframes} 1.2s var(--easing-move) infinite alternate;
background-color: var(--bgColor-neutral-muted, ${get('colors.neutral.subtle')});
border-color: var(--borderColor-default, ${get('colors.border.default')});
width: 1.5rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const fadeIn = keyframes`
`
// using easeOutQuint easing fn https://easings.net/#easeOutQuint
const AnimatedElement = styled.div<Props>`
animation: ${props => props.show && css`170ms ${fadeIn} cubic-bezier(0.44, 0.74, 0.36, 1);`};
animation: ${props => props.show && css`var(--base-duration-fast) ${fadeIn} var(--easing-entrance);`};
@media (prefers-reduced-motion) {
animation: none;
}
Expand Down
Loading