From f1eaba36dfe4f98d82ee53c2b6489bfe6f40bc70 Mon Sep 17 00:00:00 2001 From: Charlotte Dann Date: Tue, 23 Jul 2024 17:05:00 +0100 Subject: [PATCH] Update AnchorNav playground story Adds controls for actions, removes controls from default story. --- .../react/src/AnchorNav/AnchorNav.stories.tsx | 146 ++++++++++-------- 1 file changed, 85 insertions(+), 61 deletions(-) diff --git a/packages/react/src/AnchorNav/AnchorNav.stories.tsx b/packages/react/src/AnchorNav/AnchorNav.stories.tsx index 6733149ba0..6c26b9184e 100644 --- a/packages/react/src/AnchorNav/AnchorNav.stories.tsx +++ b/packages/react/src/AnchorNav/AnchorNav.stories.tsx @@ -14,66 +14,20 @@ export default { parameters: { layout: 'fullscreen', }, - args: { - enableDefaultBgColor: true, - data: { - ['GitHub vs Jenkins']: 'githubvsjenkins', - ['GitHub vs GitLab']: 'githubvsgitlab', - ['GitHub vs CircleCI']: 'githubvscircleci', - ['GitHub vs BitBucket']: 'githubvsvsbitbucket', - ['GitHub vs TravisCI']: 'githubvsvstravis', - }, - sectionHeight: 1000, - offset: 100, - }, - argTypes: { - data: { - name: 'Data', - description: 'Test data', - control: { - type: 'object', - }, - table: { - category: 'Story customization', - }, - }, - sectionHeight: { - name: 'Section height', - description: 'Section height', - control: { - type: 'number', - }, - table: { - category: 'Story customization', - }, - }, - offset: { - name: 'Offset', - description: 'Offset from the top of the page', - control: { - type: 'number', - }, - table: { - category: 'Story customization', - }, - }, - }, } as Meta -export const Default = ({data, ...args}: {data: MockData}) => { - return ( - - Section one - Section two - Section three - Section four - Section five - Sign up - - ) -} +export const Default = () => ( + + Section one + Section two + Section three + Section four + Section five + Sign up + +) -export const Playground = ({data, ...args}: {data: MockData; offset: number; sectionHeight: number}) => { +export const Playground = ({data, sectionHeight, actionText, secondaryAction, secondaryActionText, ...args}) => { return (
@@ -87,12 +41,13 @@ export const Playground = ({data, ...args}: {data: MockData; offset: number; sec - {Object.entries(data).map(([key, value]) => ( + {Object.entries(data as MockData).map(([key, value]) => ( {key} ))} - Sign up + {actionText} + {secondaryAction && {secondaryActionText}} {/** * The following markup is provided for demonstration purposes only. @@ -105,7 +60,7 @@ export const Playground = ({data, ...args}: {data: MockData; offset: number; sec style={{marginBottom: '100px'}} padding="none" > - {Object.entries(data).map(([key, value]) => ( + {Object.entries(data as MockData).map(([key, value]) => ( {key} @@ -128,3 +83,72 @@ export const Playground = ({data, ...args}: {data: MockData; offset: number; sec
) } +Playground.argTypes = { + actionText: { + name: 'text', + control: {type: 'text'}, + table: { + category: 'AnchorNav.Action', + }, + }, + secondaryAction: { + name: 'visible', + control: {type: 'boolean'}, + table: { + category: 'AnchorNav.SecondaryAction', + }, + }, + secondaryActionText: { + name: 'text', + control: {type: 'text'}, + table: { + category: 'AnchorNav.SecondaryAction', + }, + }, + data: { + name: 'Data', + description: 'Test data', + control: { + type: 'object', + }, + table: { + category: 'Story customization', + }, + }, + sectionHeight: { + name: 'Section height', + description: 'Section height', + control: { + type: 'number', + }, + table: { + category: 'Story customization', + }, + }, + offset: { + name: 'Offset', + description: 'Offset from the top of the page', + control: { + type: 'number', + }, + table: { + category: 'Story customization', + }, + }, +} +Playground.args = { + hideUntilSticky: false, + enableDefaultBgColor: false, + actionText: 'Sign up', + secondaryAction: false, + secondaryActionText: 'Learn more', + data: { + ['GitHub vs Jenkins']: 'githubvsjenkins', + ['GitHub vs GitLab']: 'githubvsgitlab', + ['GitHub vs CircleCI']: 'githubvscircleci', + ['GitHub vs BitBucket']: 'githubvsvsbitbucket', + ['GitHub vs TravisCI']: 'githubvsvstravis', + }, + sectionHeight: 1000, + offset: 100, +}