refactor(Card + FloatingCard)!: changing FloatCard to internal use and refactoring Card#3042
refactor(Card + FloatingCard)!: changing FloatCard to internal use and refactoring Card#3042codecademydev merged 69 commits intomainfrom
Conversation
|
View your CI Pipeline Execution ↗ for commit 6e79a7f. ☁️ Nx Cloud last updated this comment at |
dreamwasp
left a comment
There was a problem hiding this comment.
this is looking awesome - a couple of nits but nothing blocking or necessary. i still need to test mono + monolith but i think this is shipshape already!
| export const ShadowPatternLeft: Story = { | ||
| render: () => ( | ||
| <FlexBox column> | ||
| <FlexBox p={24} border={1}> | ||
| <Box flexGrow={1}> | ||
| <Card shadow="patternLeft">Default with patternLeft</Card> | ||
| </Box> | ||
| </FlexBox> | ||
| <FlexBox row gap={16} p={24} border={1}> | ||
| <Box flexGrow={1}> | ||
| <Card variant="white" shadow="patternLeft"> | ||
| White with patternLeft | ||
| </Card> | ||
| </Box> | ||
| <Box flexGrow={1}> | ||
| <Card variant="yellow" shadow="patternLeft"> | ||
| Yellow with patternLeft | ||
| </Card> | ||
| </Box> | ||
| <Box flexGrow={1}> | ||
| <Card variant="beige" shadow="patternLeft"> | ||
| Beige with patternLeft | ||
| </Card> | ||
| </Box> | ||
| </FlexBox> | ||
| <Background bg="navy"> | ||
| <FlexBox row gap={16} p={24} border={1}> | ||
| <Box flexGrow={1}> | ||
| <Card variant="navy" shadow="patternLeft"> | ||
| Navy with patternLeft | ||
| </Card> | ||
| </Box> | ||
| <Box flexGrow={1}> | ||
| <Card variant="hyper" shadow="patternLeft"> | ||
| Hyper with patternLeft | ||
| </Card> | ||
| </Box> | ||
| </FlexBox> | ||
| </Background> | ||
| </FlexBox> | ||
| ), | ||
| }; |
There was a problem hiding this comment.
I wonder if these could be DRYed up with a utility React.FC (pass the config and it will generate based on config)
There was a problem hiding this comment.
My thought process here was that if I do that, then the "Show Code" button will only show the util comp, e.g.:
<BadgeWithPatternExamples />
And then it wouldn't be as helpful :\
There was a problem hiding this comment.
Would you prefer I change it tho?
I do agree it's not as DRY as it could be.
packages/styleguide/src/lib/Atoms/InternalFloatingCard/InternalFloatingCard.stories.tsx
Show resolved
Hide resolved
| import styled from '@emotion/styled'; | ||
| import { motion } from 'framer-motion'; | ||
|
|
||
| import { Box } from '../Box'; | ||
| import { cardVariants, shadowVariants } from './styles'; | ||
| import { CardWrapperProps } from './types'; | ||
|
|
||
| export const MotionBox = motion.create(Box); | ||
|
|
||
| export const CardWrapper = styled(MotionBox)<CardWrapperProps>( | ||
| cardVariants, | ||
| shadowVariants | ||
| ); |
There was a problem hiding this comment.
why remove the Background card wrapper? everything looks good i'm just curious
There was a problem hiding this comment.
Thanks Cass... I remember why I kept Background now...
The outline variant in particular got messed up 🫠

the outline color should match the color of the card, but now it's all white.
and I bet the yellow pattern is a result of the pattern getting confused by the background color.
—
To answer your question tho, I removed it because I forgot all of this and I wanted to get rid of the bg prop that was extra confusing
There was a problem hiding this comment.
I updated the bg prop to
bg={variant !== 'default' ? (variant as Colors) : '' as Colors}
I couldn't cast undefined as Colors :\
is there a better way?
| export const ShadowPatternLeft: Story = { | ||
| render: () => ( | ||
| <FlexBox column> | ||
| <FlexBox p={24} border={1}> | ||
| <Box flexGrow={1}> | ||
| <Card shadow="patternLeft">Default with patternLeft</Card> | ||
| </Box> | ||
| </FlexBox> | ||
| <FlexBox row gap={16} p={24} border={1}> | ||
| <Box flexGrow={1}> | ||
| <Card variant="white" shadow="patternLeft"> | ||
| White with patternLeft | ||
| </Card> | ||
| </Box> | ||
| <Box flexGrow={1}> | ||
| <Card variant="yellow" shadow="patternLeft"> | ||
| Yellow with patternLeft | ||
| </Card> | ||
| </Box> | ||
| <Box flexGrow={1}> | ||
| <Card variant="beige" shadow="patternLeft"> | ||
| Beige with patternLeft | ||
| </Card> | ||
| </Box> | ||
| </FlexBox> | ||
| <Background bg="navy"> | ||
| <FlexBox row gap={16} p={24} border={1}> | ||
| <Box flexGrow={1}> | ||
| <Card variant="navy" shadow="patternLeft"> | ||
| Navy with patternLeft | ||
| </Card> | ||
| </Box> | ||
| <Box flexGrow={1}> | ||
| <Card variant="hyper" shadow="patternLeft"> | ||
| Hyper with patternLeft | ||
| </Card> | ||
| </Box> | ||
| </FlexBox> | ||
| </Background> | ||
| </FlexBox> | ||
| ), | ||
| }; |
| export const IsInteractive: Story = { | ||
| render: () => ( | ||
| <FlexBox column> | ||
| <FlexBox p={24} border={1}> | ||
| <Box flexGrow={1}> | ||
| <Anchor dimensions={1} href="" variant="interface"> | ||
| <Card shadow="patternRight" isInteractive> | ||
| Default, patternRight, and isInteractive | ||
| </Card> | ||
| </Anchor> | ||
| </Box> | ||
| </FlexBox> | ||
| <FlexBox row gap={16} p={24} border={1}> | ||
| <Box flexGrow={1}> | ||
| <Anchor dimensions={1} href="" variant="interface"> | ||
| <Card variant="white" shadow="none" isInteractive> | ||
| White, no shadow, and isInteractive | ||
| </Card> | ||
| </Anchor> | ||
| </Box> | ||
| <Box flexGrow={1}> | ||
| <Anchor dimensions={1} href="" variant="interface"> | ||
| <Card variant="yellow" shadow="patternLeft" isInteractive> | ||
| Yellow, patternLeft, and isInteractive | ||
| </Card> | ||
| </Anchor> | ||
| </Box> | ||
| <Box flexGrow={1}> | ||
| <Anchor dimensions={1} href="" variant="interface"> | ||
| <Card variant="beige" shadow="outline" isInteractive> | ||
| Beige, outline, and isInteractive | ||
| </Card> | ||
| </Anchor> | ||
| </Box> | ||
| </FlexBox> | ||
| <Background bg="navy"> | ||
| <FlexBox row gap={16} p={24} border={1}> | ||
| <Box flexGrow={1}> | ||
| <Anchor dimensions={1} href="" variant="interface"> | ||
| <Card variant="navy" shadow="patternLeft" isInteractive> | ||
| Navy, patternLeft, and isInteractive | ||
| </Card> | ||
| </Anchor> | ||
| </Box> | ||
| <Box flexGrow={1}> | ||
| <Anchor dimensions={1} href="" variant="interface"> | ||
| <Card variant="hyper" shadow="patternRight" isInteractive> | ||
| Hyper, patternRight, and isInteractive | ||
| </Card> | ||
| </Anchor> | ||
| </Box> | ||
| </FlexBox> | ||
| </Background> | ||
| </FlexBox> |
There was a problem hiding this comment.
the colors on dark mode here are a little wonky - maybe we still want a dark border on white and yellow even in dark mode? the pattern on dark mode also turns yellow before disappearing, is that intended?
Screen.Recording.2025-03-28.at.9.26.25.AM.mov
There was a problem hiding this comment.
Forgot to post a follow-up
onHover, the Card was taking its color from Anchor, which was yellow/hyper
So for the light mode Cards, it probably just wasn't as visible.
setting color="text" on the MotionBox wrapping the Pattern seemed to do the trick :)
aresnik11
left a comment
There was a problem hiding this comment.
Looks so good!! Just a couple small notes
packages/gamut/src/Card/styles.tsx
Outdated
| animate: { | ||
| opacity: 0, | ||
| transition: { | ||
| duration: timingValues.slow / 1000, |
There was a problem hiding this comment.
personally i think this transition is a little slow and prefer it at timingValues.medium but ill defer to stacey
There was a problem hiding this comment.
yaaa, I wanted to keep it slower so that not everything just happened at the same time lol
and Stacey was cool with it: https://skillsoftartisan.slack.com/archives/C07BTPZR85A/p1741107708596829?thread_ts=1741096822.725829&cid=C07BTPZR85A
but ya, feels like a good thing to just check with the team on for these kinda updates, esp if we're gonna do more animations in the future
There was a problem hiding this comment.
not a sticking point tho just a personal pref
There was a problem hiding this comment.
gotcha, I'll change then :) thanks
| transition: { | ||
| duration: timingValues.fast / 1000, | ||
| ease: 'easeOut', | ||
| }, | ||
| }, | ||
| animate: { | ||
| transform: 'translate(4px, -4px)', | ||
| boxShadow: `-8px 8px 0 ${theme.colors['shadow-primary']}`, | ||
| transition: { | ||
| duration: timingValues.fast / 1000, | ||
| ease: 'easeIn', |
There was a problem hiding this comment.
these transitions on the non pattern outlines are a little trippy but it also matches what we currently have (checked prod storybook) so i guess its fine, just noting
📬Published Alpha Packages:@codecademy/gamut@59.3.2-alpha.6e79a7.0 |
|
🚀 Styleguide deploy preview ready! |


Overview
Making
FloatingCardan internal component, for Gamut use only.The styling that
FloatingCardprovided is now in theCardcomponent, such as:Other changes:
FloatingCardis renamed toInternalFloatingCardand marked as deprecatedCardnow has variants that uses thevariantutil functionCardelements are based off framer motion and provide small animations for the hover effectCardtakes on a medium border radius and a shadow hover whenisInteractiveprop istrue(i.e. in a link, or button, or has a clickable area inside the body of theCard)Cardthat is not interactive will have anoneborder radius by defaultPR Checklist
Testing Instructions
InternalFloatingCard, like Modal, Toast and see that they still work and are ok.PR Links and Envs