Created
May 24, 2023 20:13
-
-
Save 55Cancri/f725550f2afc39bde3a076d63f464c14 to your computer and use it in GitHub Desktop.
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
// atoms/grid/index.ts | |
import React from "react"; | |
import { motion, MotionConfig, Transition } from "framer-motion"; | |
import * as theme from "modules/theme"; | |
const Stitch = theme.styled(motion.div, { | |
// base styles | |
display: "grid", | |
/* Works on Firefox */ | |
scrollbarWidth: "thin", | |
scrollbarColor: `gray gray`, | |
/* Works on Chrome, Edge, and Safari */ | |
"&::-webkit-scrollbar": { | |
height: 6, | |
width: 6, | |
}, | |
"&::-webkit-scrollbar-track": { | |
background: "transparent", | |
}, | |
"&::-webkit-scrollbar-thumb": { | |
backgroundColor: "gray", | |
borderRadius: 20, | |
}, | |
"&::-webkit-scrollbar-corner": { | |
backgroundColor: "transparent", | |
}, | |
variants: { | |
variant: { | |
primary: { | |
// primary styles | |
}, | |
secondary: { | |
// secondary styles | |
}, | |
}, | |
}, | |
}); | |
type CustomProps = { | |
children?: any; | |
config?: Transition; | |
as?: | |
| "html" | |
| "body" | |
| "li" | |
| "ul" | |
| "div" | |
| "nav" | |
| "form" | |
| "main" | |
| "section" | |
| "article" | |
| "aside" | |
| "header" | |
| "footer"; | |
}; | |
type Props = theme.GetProps<typeof Stitch, CustomProps>; | |
export type GridProps = Props; | |
const Grid = React.forwardRef<HTMLDivElement, Props>((props, ref) => { | |
const { children, as, config, ...rest } = props; | |
const [styles, args] = theme.extractStyles(rest); | |
return ( | |
<MotionConfig transition={config}> | |
<Stitch {...args} as={as} ref={ref} css={styles}> | |
{children} | |
</Stitch> | |
</MotionConfig> | |
); | |
}); | |
Grid.displayName = "Grid"; | |
export default Grid as (props: Props) => JSX.Element; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment