Skip to content

Commit 441aba5

Browse files
committed
fix: use custom DialogTitle and DialogDescription
1 parent b3e7db5 commit 441aba5

File tree

6 files changed

+79
-59
lines changed

6 files changed

+79
-59
lines changed

src/components/dialog/DialogContent.vue

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,6 @@ const forwarded = useForwardPropsEmits(props, emits, [
162162
right: var(--dialog-content-padding);
163163
}
164164
165-
.ui-DialogContent > h2[id^="reka-dialog-title"] {
166-
font-size: var(--font-size-5);
167-
font-weight: var(--font-weight-bold);
168-
line-height: var(--line-height-4);
169-
margin-bottom: var(--space-3);
170-
}
171-
172-
.ui-DialogContent > p[id^="reka-dialog-description"] {
173-
font-size: var(--font-size-3);
174-
line-height: var(--line-height-2);
175-
letter-spacing: var(--letter-spacing-2);
176-
}
177-
178165
@media (min-width: 520px) {
179166
.ui-DialogContainer {
180167
justify-content: center;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<script lang="ts">
2+
import type { PrimitiveProps } from 'reka-ui'
3+
import { useForwardExpose } from 'reka-ui'
4+
</script>
5+
6+
<script setup lang="ts">
7+
import { Primitive, injectDialogRootContext } from 'reka-ui'
8+
9+
const props = withDefaults(defineProps<PrimitiveProps>(), { as: 'p' })
10+
11+
useForwardExpose()
12+
const rootContext = injectDialogRootContext()
13+
</script>
14+
15+
<template>
16+
<Primitive
17+
v-bind="props"
18+
:id="rootContext.descriptionId"
19+
class="ui-DialogDescription"
20+
>
21+
<slot></slot>
22+
</Primitive>
23+
</template>
24+
25+
<style>
26+
.ui-DialogDescription {
27+
font-size: var(--font-size-3);
28+
line-height: var(--line-height-2);
29+
color: var(--gray-11);
30+
}
31+
.ui-DialogTitle + .ui-DialogDescription {
32+
margin-top: var(--space-2);
33+
}
34+
</style>

src/components/dialog/DialogHead.vue

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<script lang="ts">
2+
import type { PrimitiveProps } from 'reka-ui'
3+
import { useForwardExpose } from 'reka-ui'
4+
</script>
5+
6+
<script setup lang="ts">
7+
import { Primitive, injectDialogRootContext } from 'reka-ui'
8+
9+
const props = withDefaults(defineProps<PrimitiveProps>(), { as: 'h2' })
10+
const rootContext = injectDialogRootContext()
11+
useForwardExpose()
12+
</script>
13+
14+
<template>
15+
<Primitive
16+
v-bind="props"
17+
:id="rootContext.titleId"
18+
class="ui-DialogTitle"
19+
>
20+
<slot></slot>
21+
</Primitive>
22+
</template>
23+
24+
<style>
25+
.ui-DialogTitle {
26+
font-size: var(--font-size-4);
27+
font-weight: var(--font-weight-semibold);
28+
line-height: var(--line-height-4);
29+
}
30+
</style>

src/components/dialog/index.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
export {
2-
DialogRoot,
3-
DialogTitle,
4-
DialogTrigger,
5-
DialogClose,
6-
DialogDescription,
2+
DialogRoot as DialogRoot,
3+
DialogTrigger as DialogTrigger,
4+
DialogClose as DialogClose,
5+
type DialogRootProps,
6+
type DialogTriggerProps,
7+
type DialogCloseProps,
78
} from 'reka-ui'
89

10+
export {
11+
default as DialogTitle,
12+
} from './DialogTitle.vue'
13+
14+
export {
15+
default as DialogDescription,
16+
} from './DialogDescription.vue'
17+
918
export {
1019
default as DialogContent,
1120
type DialogContentProps,

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export {
22
default as ThemeProvider,
33
type ThemeProviderProps,
4+
injectThemeContext,
45
} from './provider/ThemeProvider.vue'
56

67
export * from './avatar'

0 commit comments

Comments
 (0)