Skip to content

Commit cb6863b

Browse files
matthprostlisalupi
authored andcommitted
refactor(ContentCardGroup): use vanilla extract (#5663)
1 parent 19cb986 commit cb6863b

File tree

6 files changed

+135
-509
lines changed

6 files changed

+135
-509
lines changed

.changeset/sour-candles-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ultraviolet/plus": minor
3+
---
4+
5+
Refactor `<ContentCardGroup />` to use vanilla extract
Lines changed: 15 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
'use client'
22

3-
import styled from '@emotion/styled'
43
import { OpenInNewIcon } from '@ultraviolet/icons'
54
import { Stack, Text } from '@ultraviolet/ui'
65
import type { AnchorHTMLAttributes, ElementType, ReactNode } from 'react'
76
import { forwardRef } from 'react'
7+
import {
8+
customStack,
9+
fullHeightStack,
10+
iconWrapper,
11+
styledWrapper,
12+
} from './styles.css'
813

914
type CardProps = {
1015
title?: string
@@ -17,53 +22,6 @@ type CardProps = {
1722
target?: AnchorHTMLAttributes<HTMLAnchorElement>['target']
1823
}
1924

20-
const StyledStack = styled(Stack)`
21-
min-width: 0;
22-
`
23-
24-
const IconWrapper = styled.div`
25-
display: inline-flex;
26-
background: ${({ theme }) => theme.colors.neutral.backgroundWeak};
27-
padding: ${({ theme }) => theme.space['1']};
28-
border-radius: ${({ theme }) => theme.radii.default};
29-
`
30-
31-
const StyledWrapper = styled.a`
32-
padding: ${({ theme }) => theme.space['3']};
33-
text-decoration: none;
34-
height: 100%;
35-
36-
&:not(:first-child) {
37-
border-top: 1px solid ${({ theme }) => theme.colors.neutral.border};
38-
}
39-
40-
&:first-child {
41-
border-radius: ${({ theme }) => theme.radii.default}
42-
${({ theme }) => theme.radii.default} 0 0;
43-
}
44-
45-
&:last-child {
46-
border-radius: 0 0 ${({ theme }) => theme.radii.default}
47-
${({ theme }) => theme.radii.default};
48-
}
49-
50-
& ${IconWrapper} {
51-
background: ${({ theme }) => theme.colors.neutral.backgroundWeak};
52-
}
53-
54-
&:hover {
55-
background: ${({ theme }) => theme.colors.neutral.backgroundHover};
56-
57-
& ${IconWrapper} {
58-
background: none;
59-
}
60-
}
61-
`
62-
63-
const FullHeightStack = styled(Stack)`
64-
height: 100%;
65-
`
66-
6725
export const Card = forwardRef<HTMLAnchorElement, CardProps>(
6826
(
6927
{
@@ -78,14 +36,15 @@ export const Card = forwardRef<HTMLAnchorElement, CardProps>(
7836
},
7937
ref,
8038
) => (
81-
<StyledWrapper href={href} ref={ref} target={target}>
82-
<FullHeightStack
39+
<a className={styledWrapper} href={href} ref={ref} target={target}>
40+
<Stack
8341
alignItems="center"
42+
className={fullHeightStack}
8443
direction="row"
8544
gap={2}
8645
justifyContent="space-between"
8746
>
88-
<StyledStack gap="0.5">
47+
<Stack className={customStack} gap="0.5">
8948
<div>
9049
{subtitle ? (
9150
<Text
@@ -113,11 +72,11 @@ export const Card = forwardRef<HTMLAnchorElement, CardProps>(
11372
</Text>
11473
) : null}
11574
{children}
116-
</StyledStack>
117-
<IconWrapper>
75+
</Stack>
76+
<div className={iconWrapper}>
11877
<OpenInNewIcon sentiment="neutral" />
119-
</IconWrapper>
120-
</FullHeightStack>
121-
</StyledWrapper>
78+
</div>
79+
</Stack>
80+
</a>
12281
),
12382
)
Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,17 @@
11
'use client'
22

3-
import styled from '@emotion/styled'
43
import { Skeleton, Stack } from '@ultraviolet/ui'
5-
6-
const StyledWrapper = styled.div`
7-
padding: ${({ theme }) => theme.space['3']};
8-
9-
&:not(:first-child) {
10-
border-top: 1px solid ${({ theme }) => theme.colors.neutral.border};
11-
}
12-
`
13-
14-
const StyledSquareSkeleton = styled(Skeleton)`
15-
height: 32px;
16-
width: 32px;
17-
border-radius: ${({ theme }) => theme.radii.default};
18-
`
4+
import { skeletonWrapper, squareSkeleton } from './styles.css'
195

206
export const SkeletonCard = () => (
21-
<StyledWrapper>
7+
<div className={skeletonWrapper}>
228
<Stack alignItems="center" direction="row" justifyContent="space-between">
239
<Stack gap={2}>
2410
<Skeleton variant="line" />
2511
<Skeleton variant="line" />
2612
<Skeleton variant="line" />
2713
</Stack>
28-
<StyledSquareSkeleton variant="square" />
14+
<Skeleton className={squareSkeleton} variant="square" />
2915
</Stack>
30-
</StyledWrapper>
16+
</div>
3117
)

0 commit comments

Comments
 (0)