-
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 a story for
QuantityFormatSettingsPage
component (#1206)
* Fix import attributes error. * Add story for QuantityFormatSettingsPage
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { QuantityType } from "@itwin/core-frontend"; | ||
import { AppUiDecorator, InitializerDecorator } from "../Decorators"; | ||
import { enumArgType } from "../Utils"; | ||
import { QuantityFormatStory } from "./QuantityFormat"; | ||
|
||
const meta = { | ||
title: "Components/QuantityFormat", | ||
component: QuantityFormatStory, | ||
tags: ["autodocs"], | ||
decorators: [AppUiDecorator, InitializerDecorator], | ||
args: { | ||
initialQuantityType: QuantityType.Length, | ||
availableUnitSystems: ["metric", "imperial", "usCustomary", "usSurvey"], | ||
}, | ||
argTypes: { | ||
initialQuantityType: enumArgType(QuantityType), | ||
}, | ||
} satisfies Meta<typeof QuantityFormatStory>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof QuantityFormatStory>; | ||
|
||
export const Default: Story = {}; |
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,26 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { QuantityFormatSettingsPage } from "@itwin/appui-react"; | ||
import { UnitSystemKey } from "@itwin/core-quantity"; | ||
|
||
type QuantityFormatSettingsPageProps = React.ComponentProps< | ||
typeof QuantityFormatSettingsPage | ||
>; | ||
interface QuantityFormatStoryProps | ||
extends Omit<QuantityFormatSettingsPageProps, "availableUnitSystems"> { | ||
availableUnitSystems: UnitSystemKey[]; | ||
} | ||
|
||
export function QuantityFormatStory(props: QuantityFormatStoryProps) { | ||
const { availableUnitSystems, ...rest } = props; | ||
|
||
return ( | ||
<QuantityFormatSettingsPage | ||
key={rest.initialQuantityType} | ||
availableUnitSystems={new Set(availableUnitSystems)} | ||
{...rest} | ||
/> | ||
); | ||
} |
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