Skip to content

Commit

Permalink
Add a story for QuantityFormatSettingsPage component (#1206)
Browse files Browse the repository at this point in the history
* Fix import attributes error.

* Add story for QuantityFormatSettingsPage
  • Loading branch information
GerardasB authored Feb 3, 2025
1 parent 1734411 commit f09ed6b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
28 changes: 28 additions & 0 deletions docs/storybook/src/components/QuantityFormat.stories.tsx
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 = {};
26 changes: 26 additions & 0 deletions docs/storybook/src/components/QuantityFormat.tsx
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}
/>
);
}
8 changes: 7 additions & 1 deletion docs/storybook/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ export default defineConfig({
},
},
plugins: [
react(),
react({
babel: {
generatorOpts: {
importAttributesKeyword: "with",
},
},
}),
fixedViteCommonjs({
include: ["@itwin/core-frontend"],
}),
Expand Down

0 comments on commit f09ed6b

Please sign in to comment.