-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ModalFrontstageButton
component (#1156)
* Ability to override backButton of a modal frontstage. * Add ModalFrontstageButton * Remove unused BackButton * rush change * NextVersion.md * Extract API * Update snaps (cherry picked from commit b8a94f9) # Conflicts: # docs/changehistory/NextVersion.md # ui/appui-react/src/appui-react/layout/widget/tools/button/Back.tsx
- Loading branch information
1 parent
282c149
commit df80eb2
Showing
20 changed files
with
159 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
common/changes/@itwin/appui-react/modal-frontstage-back_2024-12-13-14-49.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@itwin/appui-react", | ||
"comment": "Add ModalFrontstageButton component.", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@itwin/appui-react" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-986 Bytes
(97%)
...eui/configurable-ui.test.ts-snapshots/configurable-ui-test-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-41.3 KB
(24%)
...ntent/content-layout.test.ts-snapshots/content-layout-test-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.71 KB
(93%)
...s/content/split-pane.test.ts-snapshots/content-layout-test-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4.43 KB
(92%)
...e/modal-frontstage.test.ts-snapshots/modal-frontstage-test-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.96 KB
(87%)
.../picker/view-selector.test.ts-snapshots/view-selector-test-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
ui/appui-react/src/appui-react/frontstage/ModalFrontstageButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
/** @packageDocumentation | ||
* @module Frontstage | ||
*/ | ||
|
||
import "./ModalFrontstageButton.scss"; | ||
import * as React from "react"; | ||
import { SvgProgressBackwardCircular } from "@itwin/itwinui-icons-react"; | ||
import { UiFramework } from "../UiFramework.js"; | ||
import { useTranslation } from "../hooks/useTranslation.js"; | ||
import { IconButton } from "@itwin/itwinui-react"; | ||
|
||
type IconButtonProps = React.ComponentProps<typeof IconButton>; | ||
|
||
interface ModalFrontstageButtonProps extends Pick<IconButtonProps, "onClick"> { | ||
children?: never; | ||
/** If specified overrides the default icon. */ | ||
icon?: React.ReactNode; | ||
/** If specified overrides the default label. */ | ||
label?: string; | ||
/** If specified overrides the default behavior of closing the modal frontstage. */ | ||
onClick?: IconButtonProps["onClick"]; | ||
} | ||
|
||
/** Button usually shown in the top-left corner of the modal frontstage. By default closes the modal frontstage. | ||
* @public | ||
*/ | ||
export function ModalFrontstageButton(props: ModalFrontstageButtonProps) { | ||
const { translate } = useTranslation(); | ||
const { label, icon, onClick } = props; | ||
const defaultLabel = translate("modalFrontstage.backButtonTitle"); | ||
const defaultIcon = <SvgProgressBackwardCircular />; | ||
|
||
const defaultOnClick = React.useCallback(() => { | ||
UiFramework.frontstages.closeModalFrontstage(); | ||
}, []); | ||
|
||
return ( | ||
<IconButton | ||
className="uifw-frontstage-modalFrontstageButton" | ||
onClick={onClick ?? defaultOnClick} | ||
label={label ?? defaultLabel} | ||
iconProps={{ | ||
className: "uifw-frontstage-modalFrontstageButton_icon", | ||
}} | ||
> | ||
{icon ?? defaultIcon} | ||
</IconButton> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.