This repository has been archived by the owner on Jul 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Starting work on Toast component. * Toast is working and looking good, but still working on some architecture decisions. * Add useToast hook and update provider. Update docs. * Docs update.
- Loading branch information
1 parent
6a47ca2
commit 67aeeef
Showing
17 changed files
with
589 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
import { createVar, keyframes, style } from '@vanilla-extract/css'; | ||
import { calc } from '@vanilla-extract/css-utils'; | ||
import { recipe, RecipeVariants } from '@vanilla-extract/recipes'; | ||
import { atoms, motionSafe, vars } from '../../css'; | ||
|
||
export const TOAST_VIEWPORT_PADDING = '2rem'; | ||
const translateDistance = calc.add('100%', TOAST_VIEWPORT_PADDING); | ||
|
||
const colorPrimary = createVar(); | ||
const colorSecondary = createVar(); | ||
|
||
const hide = keyframes({ | ||
'0%': { opacity: 1 }, | ||
'100%': { opacity: 0 }, | ||
}); | ||
|
||
const slideIn = keyframes({ | ||
from: { | ||
transform: `translateX(${translateDistance})`, | ||
}, | ||
to: { transform: 'translateX(0)' }, | ||
}); | ||
|
||
const swipeOut = keyframes({ | ||
from: { transform: 'translateX(var(--radix-toast-swipe-end-x))' }, | ||
to: { transform: `translateX(${translateDistance})` }, | ||
}); | ||
|
||
export const toastRecipe = recipe({ | ||
base: [ | ||
atoms({ | ||
alignItems: 'center', | ||
borderRadius: 'medium', | ||
boxShadow: 'medium', | ||
borderStyle: 'solid', | ||
borderWidth: '1', | ||
display: 'flex', | ||
padding: '4', | ||
}), | ||
{ | ||
columnGap: vars.space[2], | ||
|
||
...motionSafe({ | ||
selectors: { | ||
'&[data-state="open"]': { | ||
animationName: slideIn, | ||
animationDuration: vars.transitionDurations[300], | ||
animationTimingFunction: vars.transitionEasingFunctions.out, | ||
}, | ||
'&[data-state="closed"]': { | ||
animationName: hide, | ||
animationDuration: vars.transitionDurations[150], | ||
animationTimingFunction: vars.transitionEasingFunctions.in, | ||
}, | ||
'&[data-swipe="move"]': { | ||
transform: 'translateX(var(--radix-toast-swipe-move-x))', | ||
}, | ||
'&[data-swipe="cancel"]': { | ||
transform: 'translateX(0)', | ||
transitionProperty: 'transform', | ||
transitionDuration: vars.transitionDurations[300], | ||
transitionTimingFunction: vars.transitionEasingFunctions.out, | ||
}, | ||
'&[data-swipe="end"]': { | ||
animationName: swipeOut, | ||
animationDuration: vars.transitionDurations[150], | ||
animationTimingFunction: vars.transitionEasingFunctions.out, | ||
}, | ||
}, | ||
}), | ||
}, | ||
], | ||
defaultVariants: { | ||
color: 'neutral', | ||
}, | ||
variants: { | ||
color: { | ||
accent: [ | ||
atoms({ | ||
backgroundColor: 'accent3', | ||
borderColor: 'accent6', | ||
}), | ||
{ | ||
vars: { | ||
[colorPrimary]: vars.accent.accent12, | ||
[colorSecondary]: vars.accent.accent11, | ||
}, | ||
}, | ||
], | ||
neutral: [ | ||
atoms({ | ||
backgroundColor: 'neutral3', | ||
borderColor: 'neutral6', | ||
}), | ||
{ | ||
vars: { | ||
[colorPrimary]: vars.neutral.neutral12, | ||
[colorSecondary]: vars.neutral.neutral11, | ||
}, | ||
}, | ||
], | ||
error: [ | ||
atoms({ | ||
backgroundColor: 'error3', | ||
borderColor: 'error6', | ||
}), | ||
{ | ||
vars: { | ||
[colorPrimary]: vars.error.error12, | ||
[colorSecondary]: vars.error.error11, | ||
}, | ||
}, | ||
], | ||
warning: [ | ||
atoms({ | ||
backgroundColor: 'warning3', | ||
borderColor: 'warning6', | ||
}), | ||
{ | ||
vars: { | ||
[colorPrimary]: vars.warning.warning12, | ||
[colorSecondary]: vars.warning.warning11, | ||
}, | ||
}, | ||
], | ||
success: [ | ||
atoms({ | ||
backgroundColor: 'success3', | ||
borderColor: 'success6', | ||
}), | ||
{ | ||
vars: { | ||
[colorPrimary]: vars.success.success12, | ||
[colorSecondary]: vars.success.success11, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}); | ||
|
||
export const toastTitleStyle = style([ | ||
atoms({ | ||
fontSize: 'base', | ||
fontWeight: 'medium', | ||
marginBottom: '2', | ||
}), | ||
{ color: colorPrimary }, | ||
]); | ||
|
||
export const toastDescriptionStyle = style([ | ||
atoms({ | ||
fontSize: 'small', | ||
margin: '0', | ||
}), | ||
{ | ||
color: colorSecondary, | ||
}, | ||
]); | ||
|
||
export type ToastRecipe = RecipeVariants<typeof toastRecipe>; |
Oops, something went wrong.
67aeeef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
strum-design – ./
strum-design.vercel.app
strum-design-git-main-colin-hemphill.vercel.app
www.strum.design
strum-design-colin-hemphill.vercel.app
strum.design