Skip to content

Commit 50aaf4f

Browse files
committed
feat: Add ContentDialog support empty button
1 parent 27319ec commit 50aaf4f

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

docs/src/routes/Components/ContentDialog/SimpleExample.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export default class SimpleExample extends React.Component<{}, SimpleExampleStat
7676
{...statusBarProps}
7777
defaultShow={showStatusBarDialog}
7878
primaryButtonAction={this.toggleShowStatusBarDialog}
79-
secondaryButtonAction={this.toggleShowStatusBarDialog}
8079
closeButtonAction={this.toggleShowStatusBarDialog}
8180
onCloseDialog={() => {
8281
this.setState({ showStatusBarDialog: false });
@@ -96,6 +95,8 @@ export default class SimpleExample extends React.Component<{}, SimpleExampleStat
9695
primaryButtonAction={this.toggleShowDialog}
9796
secondaryButtonAction={this.toggleShowDialog}
9897
closeButtonAction={this.toggleShowDialog}
98+
primaryButtonText="Sure"
99+
secondaryButtonText={null}
99100
onCloseDialog={() => {
100101
this.setState({ showDialog: false });
101102
}}

src/ContentDialog/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,20 +206,20 @@ export class ContentDialog extends React.Component<ContentDialogProps, ContentDi
206206
</div>
207207
{contentNode}
208208
<div {...styles.content}>
209-
<div {...styles.buttonGroup}>
210-
<Button
209+
{(primaryButtonText || secondaryButtonText) && <div {...styles.buttonGroup}>
210+
{primaryButtonText && <Button
211211
onClick={e => { primaryButtonAction(e), this.closeDialog(); }}
212212
style={inlineStyles.button}
213213
>
214214
{primaryButtonText}
215-
</Button>
216-
<Button
215+
</Button>}
216+
{secondaryButtonText && <Button
217217
onClick={e => { secondaryButtonAction(e), this.closeDialog(); }}
218218
style={inlineStyles.button}
219219
>
220220
{secondaryButtonText}
221-
</Button>
222-
</div>
221+
</Button>}
222+
</div>}
223223
</div>
224224
</div>
225225
</div>
@@ -243,7 +243,9 @@ function getStyles(contentDialog: ContentDialog): {
243243
const { context, props: {
244244
style,
245245
background,
246-
padding
246+
padding,
247+
primaryButtonText,
248+
secondaryButtonText
247249
}, state: { showDialog } } = contentDialog;
248250
const { theme } = context;
249251
const { prefixStyle } = theme;
@@ -333,7 +335,7 @@ function getStyles(contentDialog: ContentDialog): {
333335
justifyContent: "space-between"
334336
}),
335337
button: {
336-
width: "calc(50% - 2px)"
338+
width: (primaryButtonText && secondaryButtonText) ? "calc(50% - 2px)" : "100%"
337339
}
338340
};
339341
}

0 commit comments

Comments
 (0)