Skip to content

Commit

Permalink
feat: Add ContentDialog support empty button
Browse files Browse the repository at this point in the history
  • Loading branch information
myxvisual committed Jan 23, 2019
1 parent 27319ec commit 50aaf4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion docs/src/routes/Components/ContentDialog/SimpleExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export default class SimpleExample extends React.Component<{}, SimpleExampleStat
{...statusBarProps}
defaultShow={showStatusBarDialog}
primaryButtonAction={this.toggleShowStatusBarDialog}
secondaryButtonAction={this.toggleShowStatusBarDialog}
closeButtonAction={this.toggleShowStatusBarDialog}
onCloseDialog={() => {
this.setState({ showStatusBarDialog: false });
Expand All @@ -96,6 +95,8 @@ export default class SimpleExample extends React.Component<{}, SimpleExampleStat
primaryButtonAction={this.toggleShowDialog}
secondaryButtonAction={this.toggleShowDialog}
closeButtonAction={this.toggleShowDialog}
primaryButtonText="Sure"
secondaryButtonText={null}
onCloseDialog={() => {
this.setState({ showDialog: false });
}}
Expand Down
18 changes: 10 additions & 8 deletions src/ContentDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,20 @@ export class ContentDialog extends React.Component<ContentDialogProps, ContentDi
</div>
{contentNode}
<div {...styles.content}>
<div {...styles.buttonGroup}>
<Button
{(primaryButtonText || secondaryButtonText) && <div {...styles.buttonGroup}>
{primaryButtonText && <Button
onClick={e => { primaryButtonAction(e), this.closeDialog(); }}
style={inlineStyles.button}
>
{primaryButtonText}
</Button>
<Button
</Button>}
{secondaryButtonText && <Button
onClick={e => { secondaryButtonAction(e), this.closeDialog(); }}
style={inlineStyles.button}
>
{secondaryButtonText}
</Button>
</div>
</Button>}
</div>}
</div>
</div>
</div>
Expand All @@ -243,7 +243,9 @@ function getStyles(contentDialog: ContentDialog): {
const { context, props: {
style,
background,
padding
padding,
primaryButtonText,
secondaryButtonText
}, state: { showDialog } } = contentDialog;
const { theme } = context;
const { prefixStyle } = theme;
Expand Down Expand Up @@ -333,7 +335,7 @@ function getStyles(contentDialog: ContentDialog): {
justifyContent: "space-between"
}),
button: {
width: "calc(50% - 2px)"
width: (primaryButtonText && secondaryButtonText) ? "calc(50% - 2px)" : "100%"
}
};
}
Expand Down

0 comments on commit 50aaf4f

Please sign in to comment.