-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Customize labels on AvailabilityTemplate component
- Loading branch information
Showing
12 changed files
with
4,182 additions
and
5,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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
// .storybook/main.ts | ||
const config = { | ||
stories: ['../stories/**/*.stories.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx)'], | ||
addons: ['@storybook/addon-links', '@storybook/addon-essentials'], | ||
core: { | ||
builder: '@storybook/builder-vite', | ||
import type { StorybookConfig } from "@storybook/react-vite"; | ||
const config: StorybookConfig = { | ||
stories: ["../stories/**/*.mdx", "../stories/**/*.stories.@(js|jsx|ts|tsx)"], | ||
addons: [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-interactions", | ||
], | ||
framework: { | ||
name: "@storybook/react-vite", | ||
options: {}, | ||
}, | ||
async viteFinal(config) { | ||
// Add your configuration here | ||
return config; | ||
docs: { | ||
autodocs: "tag", | ||
}, | ||
}; | ||
|
||
module.exports = config; | ||
export default config; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,70 @@ | ||
import { ComponentMeta, type ComponentStory } from '@storybook/react' | ||
|
||
import type { Meta, StoryObj } from '@storybook/react' | ||
import CommerceLayer from '@commercelayer/react-components/auth/CommerceLayer' | ||
import Price from '@commercelayer/react-components/prices/Price' | ||
import PricesContainer from '@commercelayer/react-components/prices/PricesContainer' | ||
import { Price as PriceComponent } from '@commercelayer/react-components/prices/Price' | ||
import useGetToken from '../hooks/useGetToken' | ||
import { skus } from '../assets/config' | ||
import React from 'react' | ||
|
||
interface MetaProps { | ||
/** | ||
* The skuCode of the price to be fetched | ||
*/ | ||
skuCode: string | ||
accessToken?: string | ||
endpoint?: string | ||
} | ||
|
||
const Story: ComponentMeta<typeof PriceComponent> = { | ||
title: 'Components/Prices/Price', | ||
component: PriceComponent, | ||
const meta: Meta<MetaProps> = { | ||
/* 👇 The title prop is optional. | ||
* Seehttps://storybook.js.org/docs/react/configure/overview#configure-story-loading | ||
* to learn how to generate automatic titles | ||
*/ | ||
title: 'Components/Price', | ||
args: { | ||
skuCode: 'BABYONBU000000E63E7412MX', | ||
accessToken: undefined, | ||
endpoint: undefined | ||
}, | ||
argTypes: { | ||
skuCode: { | ||
description: 'SKU is a unique identifier, meaning Stock Keeping Unit.', | ||
description: 'The skuCode of the price to be fetched', | ||
type: { name: 'string', required: true }, | ||
defaultValue: 'BABYONBU000000E63E7412MX' | ||
}, | ||
accessToken: { | ||
description: 'The access token to be used for the API calls', | ||
type: { name: 'string', required: false }, | ||
table: { | ||
category: 'attributes' | ||
} | ||
defaultValue: undefined | ||
}, | ||
showCompare: { | ||
description: 'SKU is a unique identifier, meaning Stock Keeping Unit.', | ||
type: { name: 'boolean', required: false }, | ||
table: { | ||
category: 'attributes' | ||
} | ||
endpoint: { | ||
description: 'The endpoint to be used for the API calls', | ||
type: { name: 'string', required: false }, | ||
defaultValue: undefined | ||
} | ||
} | ||
} | ||
|
||
export default Story | ||
export default meta | ||
type Story = StoryObj<MetaProps> | ||
|
||
const Template: ComponentStory<typeof PriceComponent> = (arg) => { | ||
const config = useGetToken() | ||
return ( | ||
<CommerceLayer {...config}> | ||
<PricesContainer> | ||
<PriceComponent {...arg} /> | ||
</PricesContainer> | ||
</CommerceLayer> | ||
) | ||
// 👇 The PriceTemplate construct will be spread to the existing stories. | ||
const PriceTemplate: Story = { | ||
render: ({ skuCode, accessToken, endpoint }) => { | ||
const { accessToken: defaultToken, endpoint: defaultEndpoint } = | ||
useGetToken() | ||
return ( | ||
<CommerceLayer | ||
accessToken={accessToken ?? defaultToken} | ||
endpoint={endpoint ?? defaultEndpoint} | ||
> | ||
<PricesContainer> | ||
<Price skuCode={skuCode} /> | ||
</PricesContainer> | ||
</CommerceLayer> | ||
) | ||
} | ||
} | ||
|
||
export const Price = Template.bind({}) | ||
Price.args = { skuCode: skus.withAvailabilities, showCompare: false } | ||
export const GetSinglePrice = { | ||
...PriceTemplate | ||
} |
This file was deleted.
Oops, something went wrong.
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,5 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react", | ||
"jsx": "react", | ||
"jsx": "react", | ||
"target": "es5", | ||
"lib": [ | ||
"dom", | ||
|
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 |
---|---|---|
|
@@ -225,4 +225,4 @@ | |
"peerDependencies": { | ||
"react": "^18.0.0" | ||
} | ||
} | ||
} |
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.