Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nice-showers-bet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ultraviolet/ui": minor
---

Refactor component `Dialog` to use vanilla extract instead of Emotion
24 changes: 7 additions & 17 deletions packages/ui/src/components/Dialog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client'

import styled from '@emotion/styled'
import { AlertCircleIcon, CheckIcon } from '@ultraviolet/icons'
import type { ComponentProps } from 'react'
import { useMemo } from 'react'
Expand All @@ -15,20 +14,10 @@ import { DialogCancelButton } from './components/CancelButton'
import { DialogStack } from './components/Stack'
import { DialogText } from './components/Text'
import type { DialogSentiment } from './constants'
import { dialogTitle, dialogXsmall } from './styles.css'

const DIALOG_SIZE = 'xsmall'

const StyledTextTitle = styled(Text)`
margin-top: ${({ theme }) => theme.space['2']};
margin-bottom: ${({ theme }) => theme.space['1']};
`

const StyledModal = styled(Modal)`
&[data-size="${DIALOG_SIZE}"] {
width: 32.5rem; // size is on purpose different than a modal
}
`

type DialogProps = Pick<
ComponentProps<typeof Modal>,
| 'ariaLabel'
Expand Down Expand Up @@ -75,13 +64,14 @@ export const BaseDialog = ({
<CheckIcon />
)}
</Bullet>
<StyledTextTitle
<Text
as="h2"
className={dialogTitle}
sentiment="neutral"
variant="headingSmallStronger"
>
{title}
</StyledTextTitle>
</Text>
</>
)

Expand All @@ -93,9 +83,9 @@ export const BaseDialog = ({
)

return (
<StyledModal
<Modal
ariaLabel={ariaLabel}
className={className}
className={`${className ? `${className} ` : ''}${dialogXsmall}`}
data-testid={dataTestId}
disclosure={disclosure}
hideOnClickOutside={hideOnClickOutside}
Expand All @@ -121,7 +111,7 @@ export const BaseDialog = ({
</DialogContext.Provider>
)
}
</StyledModal>
</Modal>
)
}

Expand Down
9 changes: 9 additions & 0 deletions packages/ui/src/components/Dialog/styles.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { theme } from '@ultraviolet/themes'
import { style } from '@vanilla-extract/css'

export const dialogTitle = style({
marginTop: theme.space[2],
marginBottom: theme.space[1],
})

export const dialogXsmall = style({ width: '32.5rem' })
Loading