From 9090739a53b6e60f3474271b57b46ae2720e0a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 11 Nov 2020 14:42:08 +0100 Subject: [PATCH] storybook: fix broken stories that lack a router parent (#3273) --- .../ProgressBars/GaugeCard.stories.tsx | 23 ++++-- .../src/layout/InfoCard/InfoCard.stories.tsx | 17 +++-- .../core/src/layout/Page/Page.stories.tsx | 53 +++++++------- .../layout/TabbedCard/TabbedCard.stories.tsx | 71 +++++++++++-------- 4 files changed, 94 insertions(+), 70 deletions(-) diff --git a/packages/core/src/components/ProgressBars/GaugeCard.stories.tsx b/packages/core/src/components/ProgressBars/GaugeCard.stories.tsx index 45de49cd2d..982999f8d6 100644 --- a/packages/core/src/components/ProgressBars/GaugeCard.stories.tsx +++ b/packages/core/src/components/ProgressBars/GaugeCard.stories.tsx @@ -14,19 +14,28 @@ * limitations under the License. */ -import React from 'react'; +import React, { PropsWithChildren } from 'react'; import { GaugeCard } from './GaugeCard'; import { Grid } from '@material-ui/core'; +import { MemoryRouter } from 'react-router'; const linkInfo = { title: 'Go to XYZ Location', link: '#' }; +const Wrapper = ({ children }: PropsWithChildren<{}>) => ( + + + {children} + + +); + export default { title: 'Data Display/Progress Card', component: GaugeCard, }; export const Default = () => ( - + @@ -36,11 +45,11 @@ export const Default = () => ( - + ); export const Subhead = () => ( - + @@ -58,11 +67,11 @@ export const Subhead = () => ( progress={0.89} /> - + ); export const LinkInFooter = () => ( - + @@ -72,5 +81,5 @@ export const LinkInFooter = () => ( - + ); diff --git a/packages/core/src/layout/InfoCard/InfoCard.stories.tsx b/packages/core/src/layout/InfoCard/InfoCard.stories.tsx index 4886a38b0f..0c3c523ba0 100644 --- a/packages/core/src/layout/InfoCard/InfoCard.stories.tsx +++ b/packages/core/src/layout/InfoCard/InfoCard.stories.tsx @@ -13,9 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React, { FC } from 'react'; -import { InfoCard } from '.'; import { Grid, Typography } from '@material-ui/core'; +import React, { PropsWithChildren } from 'react'; +import { MemoryRouter } from 'react-router'; +import { InfoCard } from '.'; const linkInfo = { title: 'Go to XYZ Location', link: '#' }; @@ -35,12 +36,14 @@ const text = ( ); -const Wrapper: FC<{}> = ({ children }) => ( - - - {children} +const Wrapper = ({ children }: PropsWithChildren<{}>) => ( + + + + {children} + - + ); export const Default = () => ( diff --git a/packages/core/src/layout/Page/Page.stories.tsx b/packages/core/src/layout/Page/Page.stories.tsx index 1d3aaea412..1fdaf8eced 100644 --- a/packages/core/src/layout/Page/Page.stories.tsx +++ b/packages/core/src/layout/Page/Page.stories.tsx @@ -14,25 +14,26 @@ * limitations under the License. */ +import { Box, Chip, Grid, Link, Typography } from '@material-ui/core'; import React, { useState } from 'react'; +import { MemoryRouter } from 'react-router'; import { - Header, - Page, - HeaderLabel, - ContentHeader, Content, - InfoCard, + ContentHeader, + Header, + HeaderLabel, HeaderTabs, + InfoCard, + Page, } from '../'; import { + GaugeCard, + StatusOK, SupportButton, Table, - StatusOK, TableColumn, - GaugeCard, TrendLine, } from '../../components'; -import { Box, Typography, Link, Chip, Grid } from '@material-ui/core'; export default { title: 'Plugins/Examples', @@ -194,23 +195,25 @@ const ExampleContentHeader = ({ selectedTab }: { selectedTab?: number }) => ( export const PluginWithData = () => { const [selectedTab, setSelectedTab] = useState(2); return ( -
- - - setSelectedTab(index)} - tabs={tabs.map(({ label }, index) => ({ - id: index.toString(), - label, - }))} - /> - - - - - -
+ +
+ + + setSelectedTab(index)} + tabs={tabs.map(({ label }, index) => ({ + id: index.toString(), + label, + }))} + /> + + + + + +
+
); }; diff --git a/packages/core/src/layout/TabbedCard/TabbedCard.stories.tsx b/packages/core/src/layout/TabbedCard/TabbedCard.stories.tsx index f4af6dcf9f..65c73b190a 100644 --- a/packages/core/src/layout/TabbedCard/TabbedCard.stories.tsx +++ b/packages/core/src/layout/TabbedCard/TabbedCard.stories.tsx @@ -13,12 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React, { useState } from 'react'; +import React, { useState, PropsWithChildren } from 'react'; import { TabbedCard, CardTab } from '.'; import { Grid } from '@material-ui/core'; +import { MemoryRouter } from 'react-router'; const cardContentStyle = { height: 200, width: 500 }; +const Wrapper = ({ children }: PropsWithChildren<{}>) => ( + {children} +); + export default { title: 'Layout/Tabbed Card', component: TabbedCard, @@ -33,20 +38,22 @@ export default { export const Default = () => { return ( - - -
Some content
-
- -
Some content 2
-
- -
Some content 3
-
- -
Some content 4
-
-
+ + + +
Some content
+
+ +
Some content 2
+
+ +
Some content 3
+
+ +
Some content 4
+
+
+
); }; @@ -54,20 +61,22 @@ const linkInfo = { title: 'Go to XYZ Location', link: '#' }; export const WithFooterLink = () => { return ( - - -
Some content
-
- -
Some content 2
-
- -
Some content 3
-
- -
Some content 4
-
-
+ + + +
Some content
+
+ +
Some content 2
+
+ +
Some content 3
+
+ +
Some content 4
+
+
+
); }; @@ -78,7 +87,7 @@ export const WithControlledTabValue = () => { setSelectedTab(newSelectedTab); return ( - <> + Selected tab is {selectedTab} {
Some content 4
- +
); };