Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

docs(Address): add story #3

Merged
merged 5 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
window.global = window;
tatimblin marked this conversation as resolved.
Show resolved Hide resolved
</script>
6 changes: 4 additions & 2 deletions src/components/Address/Address.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Address } from "@yext/types";
import { Address as AddressType } from "@yext/types";
import { AddressLine } from "./AddressLine";
import { localeAddressFormat } from "./i18n";

/**
* The shape of the data passed to {@link Address}
tatimblin marked this conversation as resolved.
Show resolved Hide resolved
*
* @public
tatimblin marked this conversation as resolved.
Show resolved Hide resolved
*/
export interface AddressProps {
/** The address field from Knowledge Graph. */
address: Address;
address: AddressType;
}

/**
Expand Down
19 changes: 19 additions & 0 deletions tests/components/Address.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ComponentMeta } from "@storybook/react";
import { Optional } from "../types";
import { Address, AddressProps } from "../../src/components/Address/Address";
import { US_ADDRESS, BR_ADDRESS } from "../__fixtures__/km/address";

const meta: ComponentMeta<typeof Address> = {
tatimblin marked this conversation as resolved.
Show resolved Hide resolved
title: "components/Address",
tatimblin marked this conversation as resolved.
Show resolved Hide resolved
component: Address,
};

export default meta;

export const Primary = (args: Optional<AddressProps>) => {
return <Address address={US_ADDRESS} {...args} />;
};

export const Brazil = (args: Optional<AddressProps>) => {
return <Address address={BR_ADDRESS} {...args} />;
};
1 change: 1 addition & 0 deletions tests/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Optional<Type> = { [Key in keyof Type]?: Type[Key] };
tatimblin marked this conversation as resolved.
Show resolved Hide resolved