-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Match dialog button layout to OS #6044
base: main
Are you sure you want to change the base?
Changes from 8 commits
8811afc
9d97d45
344b32d
8065add
bcf06c8
b455d3c
307eba9
d79808e
e8925f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import React from 'react'; | |
// Other dependencies. | ||
import { localize } from '../../../../../nls.js'; | ||
import { Button } from '../../../../../base/browser/ui/positronComponents/button/button.js'; | ||
import * as platform from '../../../../../base/common/platform.js'; | ||
|
||
/** | ||
* OKCancelBackNextActionBarProps interface. | ||
|
@@ -38,31 +39,33 @@ interface ActionBarButtonConfig { | |
* @returns The rendered component. | ||
*/ | ||
export const OKCancelBackNextActionBar = ({ okButtonConfig, cancelButtonConfig, backButtonConfig, nextButtonConfig }: OKCancelBackNextActionBarProps) => { | ||
const cancelButton = (cancelButtonConfig ? | ||
<Button className='action-bar-button' onPressed={cancelButtonConfig.onClick} disabled={cancelButtonConfig.disable ?? false}> | ||
{cancelButtonConfig.title ?? localize('positronCancel', "Cancel")} | ||
</Button> : null); | ||
const okButton = (okButtonConfig ? | ||
<Button className='action-bar-button default' onPressed={okButtonConfig.onClick} disabled={okButtonConfig.disable ?? false}> | ||
{okButtonConfig.title ?? localize('positronOK', "OK")} | ||
</Button> : null); | ||
const nextButton = (nextButtonConfig ? | ||
<Button className='action-bar-button default' onPressed={nextButtonConfig.onClick} disabled={nextButtonConfig.disable ?? false}> | ||
{nextButtonConfig.title ?? localize('positronNext', "Next")} | ||
</Button> : null); | ||
|
||
// Render. | ||
return ( | ||
<div className='ok-cancel-action-bar top-separator'> | ||
<div className='ok-cancel-back-action-bar top-separator'> | ||
<div className='left-actions'> | ||
{backButtonConfig ? | ||
<Button className='button action-bar-button' onPressed={backButtonConfig.onClick} disabled={backButtonConfig.disable ?? false}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that we had this Let me know if this is wrong and we do need it! |
||
<Button className='action-bar-button' onPressed={backButtonConfig.onClick} disabled={backButtonConfig.disable ?? false}> | ||
{backButtonConfig.title ?? localize('positronBack', "Back")} | ||
</Button> : null | ||
} | ||
</div> | ||
<div className='right-actions'> | ||
{cancelButtonConfig ? | ||
<Button className='button action-bar-button' onPressed={cancelButtonConfig.onClick} disabled={cancelButtonConfig.disable ?? false}> | ||
{cancelButtonConfig.title ?? localize('positronCancel', "Cancel")} | ||
</Button> : null | ||
} | ||
{okButtonConfig ? | ||
<Button className='button action-bar-button default' onPressed={okButtonConfig.onClick} disabled={okButtonConfig.disable ?? false}> | ||
{okButtonConfig.title ?? localize('positronOK', "OK")} | ||
</Button> : null | ||
} | ||
{nextButtonConfig ? | ||
<Button className='button action-bar-button default' onPressed={nextButtonConfig.onClick} disabled={nextButtonConfig.disable ?? false}> | ||
{nextButtonConfig.title ?? localize('positronNext', "Next")} | ||
</Button> : null | ||
{platform.isWindows | ||
? <>{nextButton}{okButton}{cancelButton}</> | ||
: <>{cancelButton}{nextButton}{okButton}</> | ||
} | ||
</div> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
|
||
// React. | ||
import React from 'react'; | ||
|
||
// Other dependencies. | ||
import * as platform from '../../../../../base/common/platform.js'; | ||
|
||
/** | ||
* PlatformNativeDialogActionBarProps interface. | ||
*/ | ||
interface PlatformNativeDialogActionBarProps { | ||
secondaryButton?: React.ReactNode, | ||
primaryButton?: React.ReactNode | ||
} | ||
|
||
/** | ||
* PlatformNativeDialogActionBar component. | ||
* @param props A PlatformNativeDialogActionBarProps that contains the component properties. | ||
* @returns The rendered component. | ||
*/ | ||
export const PlatformNativeDialogActionBar = ({ secondaryButton, primaryButton }: PlatformNativeDialogActionBarProps) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a super basic component that renders the primary and secondary button in the order most common for a given OS. Windows always positions the cancel/secondary button after the primary button and the inverse is true for Mac. |
||
// Render. | ||
return ( | ||
<> | ||
{ | ||
platform.isWindows | ||
? <>{primaryButton}{secondaryButton}</> | ||
: <>{secondaryButton}{primaryButton}</> | ||
} | ||
</> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,36 +5,35 @@ | |
|
||
// CSS. | ||
import './positronModalDialog.css'; | ||
import './confirmationModalDialog.css'; | ||
import './confirmDeleteModalDialog.css'; | ||
|
||
// React. | ||
import React, { PropsWithChildren } from 'react'; | ||
|
||
// Other dependencies. | ||
import { positronClassNames } from '../../../../base/common/positronUtilities.js'; | ||
import { localize } from '../../../../nls.js'; | ||
import { Button } from '../../../../base/browser/ui/positronComponents/button/button.js'; | ||
import { ContentArea } from './components/contentArea.js'; | ||
import { PositronModalDialog, PositronModalDialogProps } from './positronModalDialog.js'; | ||
|
||
/** | ||
* ConfirmationModalDialogProps interface. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This component was renamed to If I misunderstood what we were trying to do with this dialog or think there's issues with this change, let me know and I'll undo it! |
||
* ConfirmDeleteModalDialogProps interface. | ||
*/ | ||
export interface ConfirmationModalDialogProps extends PositronModalDialogProps { | ||
export interface ConfirmDeleteModalDialogProps extends PositronModalDialogProps { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This modal has been simplified in its usage so its shown when we want a user to see a confirmation modal for a delete action. We always provide the delete action now and optionally can provide a different label for the delete action. The |
||
title: string; | ||
secondaryActionTitle?: string; | ||
secondaryActionDestructive?: boolean; | ||
primaryActionTitle: string; | ||
onSecondaryAction: () => (void | Promise<void>); | ||
onPrimaryAction: () => (void | Promise<void>); | ||
cancelButtonTitle?: string; | ||
deleteActionTitle?: string | ||
onCancel: () => (void | Promise<void>); | ||
onDeleteAction: () => (void | Promise<void>); | ||
} | ||
|
||
/** | ||
* ConfirmationModalDialog component. | ||
* @param props A PropsWithChildren<ConfirmationModalDialogProps> that contains the component | ||
* ConfirmDeleteModalDialog component. | ||
* @param props A PropsWithChildren<ConfirmDeleteModalDialogProps> that contains the component | ||
* properties. | ||
* @returns The rendered component. | ||
*/ | ||
export const ConfirmationModalDialog = (props: PropsWithChildren<ConfirmationModalDialogProps>) => { | ||
export const ConfirmDeleteModalDialog = (props: PropsWithChildren<ConfirmDeleteModalDialogProps>) => { | ||
// Render. | ||
return ( | ||
<PositronModalDialog {...props}> | ||
|
@@ -45,22 +44,17 @@ export const ConfirmationModalDialog = (props: PropsWithChildren<ConfirmationMod | |
<div className='left-actions'> | ||
</div> | ||
<div className='right-actions'> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like we explicitly want the button order here to be delete/cancel. This button order may seem odd to non-windows users now that we are trying to match native OS button ordering but I have left it as is for now because it looked like the button order was intentionally made so delete was the secondary action. I think we should change it to be native to the OS but would love to get thoughts on this from others. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @juliasilge |
||
{props.secondaryActionTitle && | ||
<Button | ||
className={positronClassNames( | ||
'action-bar-button', | ||
{ 'destructive': props.secondaryActionDestructive } | ||
)} | ||
onPressed={async () => await props.onSecondaryAction()} | ||
> | ||
{props.secondaryActionTitle} | ||
</Button> | ||
} | ||
<Button | ||
className='action-bar-button destructive' | ||
onPressed={async () => await props.onDeleteAction()} | ||
> | ||
{props.deleteActionTitle ?? localize('positron.delete', "Delete")} | ||
</Button> | ||
<Button | ||
className='action-bar-button default' | ||
onPressed={async () => await props.onPrimaryAction()} | ||
onPressed={async () => await props.onCancel()} | ||
> | ||
{props.primaryActionTitle} | ||
{props.cancelButtonTitle ?? localize('positron.cancel', "Cancel")} | ||
</Button> | ||
</div> | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed the
ok-cancel-action-bar
class took-cancel-back-action-bar
to avoid name collisions. The layout is different for this action bar and theOkCancelActionBar
:justify-content: space-between
vsjustify-content: end
.This change prevents the
OKCancelModalDialog
using theOkCancelActionBar
from having the buttons positioned incorrectly. I noticed during my testing that the styles from this sheet were overriding the styles inOkCancelActionBar
which we don't want anymore.Here's a screenshot of what was happening: