-
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.
* Update docs * Add story * Group status bar fields * Use ConfigurableUiContent * Add indefinite cursorPromptTimeout * Fix an issue with CursorPopup where a fading popup is not re-opened. * Refactor cursor prompt. * Close the prompt if toggled off (after toggle on tool still needs to be activated). * Add promptAtContent prop. * Add promptAtContent story * rush change * Extract API * NextVersion * Mark componentDidUpdate as internal to fix docs CI issue
- Loading branch information
Showing
14 changed files
with
419 additions
and
238 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
10 changes: 10 additions & 0 deletions
10
common/changes/@itwin/appui-react/issue-1201_2025-02-10-11-01.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 `promptAtContent` prop to `ToolAssistanceField` 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
# NextVersion <!-- omit from toc --> | ||
|
||
- [@itwin/appui-react](#itwinappui-react) | ||
- [Additions](#additions) | ||
- [Changes](#changes) | ||
|
||
## @itwin/appui-react | ||
|
||
### Additions | ||
|
||
- Added `useSavedState` property to `Widget` interface. By default widgets with `defaultState=Hidden` are always hidden when the layout is restored (i.e. page is reloaded). When `useSavedState` is set to `true` it will override the default behavior and force the widget to use its saved layout state instead. This is useful for widgets that are hidden by default but should be shown when the layout is restored. [#1210](https://github.com/iTwin/appui/pull/1210) | ||
- Added `promptAtContent` prop to `ToolAssistanceField` component. When set to `true` the prompt will be displayed only when the content area (i.e. viewport) is hovered. [#1211](https://github.com/iTwin/appui/pull/1211) | ||
|
||
### Changes | ||
|
||
- Updated `cursorPromptTimeout` prop of `ToolAssistanceField` component to handle `Number.POSITIVE_INFINITY`, which when enabled will display the cursor prompt indefinitely. [#1211](https://github.com/iTwin/appui/pull/1211) |
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
128 changes: 128 additions & 0 deletions
128
docs/storybook/src/components/ToolAssistanceField.stories.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,128 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import * as React from "react"; | ||
import type { Decorator, Meta, StoryObj } from "@storybook/react"; | ||
import { | ||
MessageManager, | ||
StatusBarItemUtilities, | ||
ToolAssistanceField, | ||
UiFramework, | ||
} from "@itwin/appui-react"; | ||
import { | ||
Tool, | ||
ToolAssistance, | ||
ToolAssistanceImage, | ||
} from "@itwin/core-frontend"; | ||
import { AppUiStory } from "src/AppUiStory"; | ||
import { createFrontstage } from "src/Utils"; | ||
|
||
const StoryDecorator: Decorator = (Story) => { | ||
return ( | ||
<AppUiStory | ||
frontstages={[ | ||
createFrontstage({ | ||
hideStatusBar: false, | ||
}), | ||
]} | ||
itemProviders={[ | ||
{ | ||
id: "provider-1", | ||
getStatusBarItems: () => [ | ||
StatusBarItemUtilities.createCustomItem({ | ||
id: "tool-assistance", | ||
content: ( | ||
<> | ||
<Story /> | ||
<Setup /> | ||
</> | ||
), | ||
}), | ||
], | ||
}, | ||
]} | ||
/> | ||
); | ||
}; | ||
|
||
function Setup() { | ||
React.useEffect(() => { | ||
const mainInstruction = ToolAssistance.createInstruction( | ||
ToolAssistanceImage.CursorClick, | ||
"Main instruction of a tool" | ||
); | ||
|
||
const cursorSection = ToolAssistance.createSection( | ||
[ | ||
ToolAssistance.createInstruction( | ||
ToolAssistanceImage.LeftClick, | ||
"Left click to select a point" | ||
), | ||
ToolAssistance.createInstruction( | ||
ToolAssistanceImage.RightClick, | ||
"Right click to cancel" | ||
), | ||
], | ||
ToolAssistance.inputsLabel | ||
); | ||
|
||
const touchSection = ToolAssistance.createSection( | ||
[ | ||
ToolAssistance.createInstruction( | ||
ToolAssistanceImage.OneTouchTap, | ||
"Touch to select a point" | ||
), | ||
], | ||
ToolAssistance.inputsLabel | ||
); | ||
|
||
const instructions = ToolAssistance.createInstructions(mainInstruction, [ | ||
cursorSection, | ||
touchSection, | ||
]); | ||
// Tool assistance information | ||
MessageManager.setToolAssistance(instructions); | ||
|
||
// Icon for the tool assistance | ||
UiFramework.frontstages.setActiveTool( | ||
new (class extends Tool { | ||
get iconSpec(): string { | ||
return "icon-placeholder"; | ||
} | ||
})() | ||
); | ||
}, []); | ||
return null; | ||
} | ||
|
||
const meta = { | ||
title: "Components/Status fields/ToolAssistanceField", | ||
component: ToolAssistanceField, | ||
tags: ["autodocs"], | ||
decorators: [StoryDecorator], | ||
args: { | ||
includePromptAtCursor: true, | ||
cursorPromptTimeout: 5000, | ||
fadeOutCursorPrompt: true, | ||
defaultPromptAtCursor: true, | ||
}, | ||
} satisfies Meta<typeof ToolAssistanceField>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; | ||
|
||
export const AlwaysVisible: Story = { | ||
args: { | ||
cursorPromptTimeout: Number.POSITIVE_INFINITY, | ||
}, | ||
}; | ||
|
||
export const PromptAtContent: Story = { | ||
args: { | ||
cursorPromptTimeout: Number.POSITIVE_INFINITY, | ||
promptAtContent: true, | ||
}, | ||
}; |
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
Oops, something went wrong.