Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 5d22596

Browse files
Anton Bilovusboilund
authored andcommitted
feat(dialog): export internal components
Exports internal components to be able to build custom dialogs.
1 parent c018a4d commit 5d22596

File tree

6 files changed

+31
-16
lines changed

6 files changed

+31
-16
lines changed

packages/core/src/Dialog/Dialog.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ import { useScrollPosition } from 'react-hooks-shareable'
1818

1919
import { Typography } from '../Typography'
2020
import { ModalProps } from '../Modal'
21-
import { Header } from './components/Header'
22-
import { Footer } from './components/Footer'
23-
import { MainSection } from './components/Content'
21+
import {
22+
DialogHeaderContent,
23+
DialogMainSection,
24+
DialogFooterContent,
25+
} from './components'
2426
import {
2527
BaseDialog,
2628
DialogWidth,
@@ -78,16 +80,23 @@ export const Dialog: React.FC<DialogProps> = ({
7880
>
7981
{header !== undefined ? (
8082
<DialogHeader>
81-
<Header shadowHidden={atTop !== false}>{header}</Header>
83+
<DialogHeaderContent shadowHidden={atTop !== false}>
84+
{header}
85+
</DialogHeaderContent>
8286
</DialogHeader>
8387
) : null}
8488
<DialogContent>
85-
<MainSection scrollRef={scrollRef} hasHeader={header !== undefined}>
89+
<DialogMainSection
90+
scrollRef={scrollRef}
91+
hasHeader={header !== undefined}
92+
>
8693
{children}
87-
</MainSection>
94+
</DialogMainSection>
8895
</DialogContent>
8996
<DialogFooter>
90-
<Footer shadowHidden={atBottom !== false}>{controls}</Footer>
97+
<DialogFooterContent shadowHidden={atBottom !== false}>
98+
{controls}
99+
</DialogFooterContent>
91100
</DialogFooter>
92101
</BaseDialog>
93102
)

packages/core/src/Dialog/components/Footer.tsx renamed to packages/core/src/Dialog/components/DialogFooterContent.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* Footer
2+
* DialogFooterContent
33
*
4-
* The Footer component adds a small margin to all its children
4+
* The `DialogFooterContent` component adds a small margin to all its children
55
*
66
* Note: the footer items are rendered from right to left!! This also causes the
77
* focus to land on the most important button first. If focus behaviour needs to
@@ -15,7 +15,9 @@ import styled from 'styled-components'
1515
import { spacing } from '../../designparams'
1616
import { DIALOG_PADDING } from './padding'
1717

18-
export const Footer = styled.div<{ readonly shadowHidden: boolean }>`
18+
export const DialogFooterContent = styled.div<{
19+
readonly shadowHidden: boolean
20+
}>`
1921
display: flex;
2022
flex-direction: row-reverse;
2123
box-sizing: border-box;

packages/core/src/Dialog/components/Header.tsx renamed to packages/core/src/Dialog/components/DialogHeaderContent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import styled from 'styled-components'
2+
23
import { spacing } from '../../designparams'
34
import { DIALOG_PADDING } from './padding'
45

5-
export const Header = styled.div<{
6+
export const DialogHeaderContent = styled.div<{
67
readonly shadowHidden: boolean
78
}>`
89
box-sizing: border-box;

packages/core/src/Dialog/components/Content.tsx renamed to packages/core/src/Dialog/components/DialogMainSection.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { spacing } from '../../designparams'
55
import { DIALOG_PADDING } from './padding'
66

77
/**
8-
* Content
8+
* DialogMainSection
99
*
1010
* Simple div to base other sections on. It comes with a default padding to make
1111
* sure this isn't left out of anything put in the dialog body. Sections can be
@@ -55,7 +55,7 @@ interface ScrollSectionProps {
5555
readonly scrollRef: React.Dispatch<React.SetStateAction<HTMLElement | null>>
5656
}
5757

58-
export const ScrollSection: React.FunctionComponent<ScrollSectionProps> = ({
58+
export const ScrollSection: React.FC<ScrollSectionProps> = ({
5959
className,
6060
maxHeight,
6161
scrollRef,
@@ -66,8 +66,7 @@ export const ScrollSection: React.FunctionComponent<ScrollSectionProps> = ({
6666
</ScrollContainer>
6767
)
6868

69-
/* stylelint-disable selector-type-no-unknown */
70-
export const MainSection = styled(ScrollSection)<{
69+
export const DialogMainSection = styled(ScrollSection)<{
7170
readonly hasHeader: boolean
7271
readonly scrollRef: React.Dispatch<React.SetStateAction<HTMLElement | null>>
7372
}>`
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './DialogFooterContent'
2+
export * from './DialogHeaderContent'
3+
export * from './DialogMainSection'

packages/core/src/Dialog/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ export * from './BaseDialog'
22
export * from './AlertDialog'
33
export * from './ConfirmDialog'
44
export { DialogProps } from './Dialog'
5+
export * from './components'
56

67
import { Dialog as DialogOriginal, HeaderTitle } from './Dialog'
78
import {
89
EdgeToEdgeSection,
910
CenteredSection,
1011
ScrollSection,
11-
} from './components/Content'
12+
} from './components/DialogMainSection'
1213

1314
type DialogOriginalType = typeof DialogOriginal
1415

0 commit comments

Comments
 (0)