|
1 | 1 | import React, {useCallback} from 'react' |
2 | 2 | import {createRoot} from 'react-dom/client' |
3 | | -import styled from 'styled-components' |
4 | | -import Box from '../Box' |
5 | 3 | import type {ThemeProviderProps} from '../ThemeProvider' |
6 | 4 | import {ThemeProvider, useTheme} from '../ThemeProvider' |
7 | 5 | import {FocusKeys} from '@primer/behaviors' |
8 | | -import {get} from '../constants' |
9 | 6 | import type {DialogProps, DialogHeaderProps, DialogButtonProps} from '../Dialog/Dialog' |
10 | 7 | import {Dialog} from '../Dialog/Dialog' |
11 | 8 | import {useFocusZone} from '../hooks/useFocusZone' |
12 | 9 | import BaseStyles from '../BaseStyles' |
13 | | -import {toggleStyledComponent} from '../internal/utils/toggleStyledComponent' |
14 | | -import {useFeatureFlag} from '../FeatureFlags' |
15 | 10 | import classes from './ConfirmationDialog.module.css' |
16 | 11 |
|
17 | 12 | /** |
@@ -46,87 +41,34 @@ export interface ConfirmationDialogProps { |
46 | 41 | confirmButtonType?: 'normal' | 'primary' | 'danger' |
47 | 42 | } |
48 | 43 |
|
49 | | -const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_ga' |
50 | | - |
51 | | -const StyledConfirmationHeader = toggleStyledComponent( |
52 | | - CSS_MODULES_FEATURE_FLAG, |
53 | | - 'div', |
54 | | - styled.div` |
55 | | - padding: ${get('space.2')}; |
56 | | - display: flex; |
57 | | - flex-direction: row; |
58 | | - `, |
59 | | -) |
60 | | - |
61 | | -const StyledTitle = toggleStyledComponent( |
62 | | - CSS_MODULES_FEATURE_FLAG, |
63 | | - 'h1', |
64 | | - styled(Box).attrs({as: 'h1'})` |
65 | | - font-size: ${get('fontSizes.3')}; |
66 | | - font-weight: ${get('fontWeights.bold')}; |
67 | | - padding: 6px ${get('space.2')}; |
68 | | - flex-grow: 1; |
69 | | - margin: 0; /* override default margin */ |
70 | | - `, |
71 | | -) |
72 | | - |
73 | 44 | const ConfirmationHeader: React.FC<React.PropsWithChildren<DialogHeaderProps>> = ({title, onClose, dialogLabelId}) => { |
74 | 45 | const onCloseClick = useCallback(() => { |
75 | 46 | onClose('close-button') |
76 | 47 | }, [onClose]) |
77 | 48 |
|
78 | | - const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG) |
79 | 49 | return ( |
80 | | - <StyledConfirmationHeader className={enabled && classes.ConfirmationHeader}> |
81 | | - <StyledTitle id={dialogLabelId}>{title}</StyledTitle> |
| 50 | + <div className={classes.ConfirmationHeader}> |
| 51 | + <h1 id={dialogLabelId}>{title}</h1> |
82 | 52 | <Dialog.CloseButton onClose={onCloseClick} /> |
83 | | - </StyledConfirmationHeader> |
| 53 | + </div> |
84 | 54 | ) |
85 | 55 | } |
86 | | -const StyledConfirmationBody = toggleStyledComponent( |
87 | | - CSS_MODULES_FEATURE_FLAG, |
88 | | - 'div', |
89 | | - styled(Box)` |
90 | | - font-size: ${get('fontSizes.1')}; |
91 | | - padding: 0 ${get('space.3')} ${get('space.3')} ${get('space.3')}; |
92 | | - flex-grow: 1; |
93 | | - `, |
94 | | -) |
95 | 56 |
|
96 | 57 | const ConfirmationBody: React.FC<React.PropsWithChildren<DialogProps>> = ({children}) => { |
97 | | - const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG) |
98 | | - return <StyledConfirmationBody className={enabled && classes.ConfirmationBody}>{children}</StyledConfirmationBody> |
| 58 | + return <div className={classes.ConfirmationBody}>{children}</div> |
99 | 59 | } |
100 | | -const StyledConfirmationFooter = toggleStyledComponent( |
101 | | - CSS_MODULES_FEATURE_FLAG, |
102 | | - 'div', |
103 | | - styled(Box)` |
104 | | - display: grid; |
105 | | - grid-auto-flow: column; |
106 | | - grid-auto-columns: max-content; |
107 | | - grid-gap: ${get('space.2')}; |
108 | | - align-items: end; |
109 | | - justify-content: end; |
110 | | - padding: ${get('space.1')} ${get('space.3')} ${get('space.3')}; |
111 | | - `, |
112 | | -) |
113 | 60 |
|
114 | 61 | const ConfirmationFooter: React.FC<React.PropsWithChildren<DialogProps>> = ({footerButtons}) => { |
115 | 62 | const {containerRef: footerRef} = useFocusZone({ |
116 | 63 | bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.Tab, |
117 | 64 | focusInStrategy: 'closest', |
118 | 65 | }) |
119 | 66 |
|
120 | | - const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG) |
121 | | - |
122 | 67 | // Must have exactly 2 buttons! |
123 | 68 | return ( |
124 | | - <StyledConfirmationFooter |
125 | | - ref={footerRef as React.RefObject<HTMLDivElement>} |
126 | | - className={enabled && classes.ConfirmationFooter} |
127 | | - > |
| 69 | + <div ref={footerRef as React.RefObject<HTMLDivElement>} className={classes.ConfirmationFooter}> |
128 | 70 | <Dialog.Buttons buttons={footerButtons ?? []} /> |
129 | | - </StyledConfirmationFooter> |
| 71 | + </div> |
130 | 72 | ) |
131 | 73 | } |
132 | 74 |
|
|
0 commit comments