Skip to content

Commit a67faa2

Browse files
committed
refactor: dialog vanilla extract (#5705)
1 parent 4157c13 commit a67faa2

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

.changeset/nice-showers-bet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ultraviolet/ui": minor
3+
---
4+
5+
Refactor component `Dialog` to use vanilla extract instead of Emotion

packages/ui/src/components/Dialog/index.tsx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use client'
22

3-
import styled from '@emotion/styled'
43
import { AlertCircleIcon, CheckIcon } from '@ultraviolet/icons'
54
import type { ComponentProps } from 'react'
65
import { useMemo } from 'react'
@@ -15,20 +14,10 @@ import { DialogCancelButton } from './components/CancelButton'
1514
import { DialogStack } from './components/Stack'
1615
import { DialogText } from './components/Text'
1716
import type { DialogSentiment } from './constants'
17+
import { dialogTitle, dialogXsmall } from './styles.css'
1818

1919
const DIALOG_SIZE = 'xsmall'
2020

21-
const StyledTextTitle = styled(Text)`
22-
margin-top: ${({ theme }) => theme.space['2']};
23-
margin-bottom: ${({ theme }) => theme.space['1']};
24-
`
25-
26-
const StyledModal = styled(Modal)`
27-
&[data-size="${DIALOG_SIZE}"] {
28-
width: 32.5rem; // size is on purpose different than a modal
29-
}
30-
`
31-
3221
type DialogProps = Pick<
3322
ComponentProps<typeof Modal>,
3423
| 'ariaLabel'
@@ -75,13 +64,14 @@ export const BaseDialog = ({
7564
<CheckIcon />
7665
)}
7766
</Bullet>
78-
<StyledTextTitle
67+
<Text
7968
as="h2"
69+
className={dialogTitle}
8070
sentiment="neutral"
8171
variant="headingSmallStronger"
8272
>
8373
{title}
84-
</StyledTextTitle>
74+
</Text>
8575
</>
8676
)
8777

@@ -93,9 +83,9 @@ export const BaseDialog = ({
9383
)
9484

9585
return (
96-
<StyledModal
86+
<Modal
9787
ariaLabel={ariaLabel}
98-
className={className}
88+
className={`${className ? `${className} ` : ''}${dialogXsmall}`}
9989
data-testid={dataTestId}
10090
disclosure={disclosure}
10191
hideOnClickOutside={hideOnClickOutside}
@@ -121,7 +111,7 @@ export const BaseDialog = ({
121111
</DialogContext.Provider>
122112
)
123113
}
124-
</StyledModal>
114+
</Modal>
125115
)
126116
}
127117

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { theme } from '@ultraviolet/themes'
2+
import { style } from '@vanilla-extract/css'
3+
4+
export const dialogTitle = style({
5+
marginTop: theme.space[2],
6+
marginBottom: theme.space[1],
7+
})
8+
9+
export const dialogXsmall = style({ width: '32.5rem' })

0 commit comments

Comments
 (0)