From 31cdb368bfb099a162cd2f0cd0039a13d2e26c65 Mon Sep 17 00:00:00 2001 From: Sonatai Date: Fri, 5 Jan 2024 10:47:51 +0100 Subject: [PATCH] #144 separate shared component types --- src/components/Feature/Feature.tsx | 25 +++++-------------- src/components/Feature/types.d.ts | 6 +++++ src/components/shared/Layout/Layout.tsx | 7 +----- src/components/shared/Layout/OnPageNav.tsx | 9 +++---- src/components/shared/Layout/types.d.ts | 12 +++++++++ .../shared/LoadingSpinner/LoadingSpinner.tsx | 5 +--- .../shared/LoadingSpinner/types.d.ts | 5 ++++ .../MarkdownRenderer.tsx | 7 ++---- .../shared/MarkdownRenderer/index.ts | 1 + .../shared/MarkdownRenderer/types.d.ts | 5 ++++ src/components/shared/Message/Message.tsx | 18 +++++-------- src/components/shared/Message/types.d.ts | 11 ++++++++ src/components/shared/NavLink/NavAnchor.tsx | 10 ++------ src/components/shared/NavLink/NavLink.tsx | 7 +----- src/components/shared/NavLink/types.d.ts | 8 ++++++ .../shared/PageTemplate/MarkdownPage.tsx | 5 +--- src/components/shared/PageTemplate/types.d.ts | 5 ++++ .../SyntaxHighlighter.tsx | 6 +---- .../shared/SyntaxHighlighter/index.ts | 1 + .../shared/SyntaxHighlighter/types.d.ts | 6 +++++ src/components/shared/Tab/CustomTab.tsx | 11 +------- src/components/shared/Tab/types.d.ts | 12 +++++++++ .../Table/ResponsiveTable/ResponsiveTable.tsx | 11 +------- .../shared/Table/ResponsiveTable/types.d.ts | 12 +++++++++ src/types.d.ts | 8 +++++- 25 files changed, 117 insertions(+), 96 deletions(-) create mode 100644 src/components/Feature/types.d.ts create mode 100644 src/components/shared/Layout/types.d.ts create mode 100644 src/components/shared/LoadingSpinner/types.d.ts rename src/components/shared/{ => MarkdownRenderer}/MarkdownRenderer.tsx (95%) create mode 100644 src/components/shared/MarkdownRenderer/index.ts create mode 100644 src/components/shared/MarkdownRenderer/types.d.ts create mode 100644 src/components/shared/Message/types.d.ts create mode 100644 src/components/shared/NavLink/types.d.ts create mode 100644 src/components/shared/PageTemplate/types.d.ts rename src/components/shared/{ => SyntaxHighlighter}/SyntaxHighlighter.tsx (85%) create mode 100644 src/components/shared/SyntaxHighlighter/index.ts create mode 100644 src/components/shared/SyntaxHighlighter/types.d.ts create mode 100644 src/components/shared/Tab/types.d.ts create mode 100644 src/components/shared/Table/ResponsiveTable/types.d.ts diff --git a/src/components/Feature/Feature.tsx b/src/components/Feature/Feature.tsx index 8cb0164..a286505 100644 --- a/src/components/Feature/Feature.tsx +++ b/src/components/Feature/Feature.tsx @@ -5,7 +5,10 @@ import { Fragment } from 'react'; import { faHashtag } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { IRow, ResponsiveTable, SyntaxHighlighter } from '../shared'; +import { ResponsiveTable, SyntaxHighlighter } from '../shared'; +import { IMinimalFeature } from 'spock-react-types'; +import { IWhereTable } from 'spock-react/components/feature-types'; +import { IRow } from 'spock-react/shared/responsive-table-types'; /* className === unique key for spec @@ -14,23 +17,6 @@ feature.id === unique key for test kind: GIVEN | WHEN | THEN | AND | CLEANUP | WHERE | EXPECT */ -export interface IBlock { - kind: string; - text: string; - /* eslint-disable @typescript-eslint/consistent-indexed-object-style */ - code: string[] | { [key: string]: string[] }; -} - -export interface IFeature { - id: string; - blocks: IBlock[]; -} - -interface IWhereTable { - /* eslint-disable @typescript-eslint/consistent-indexed-object-style */ - data: { [key: string]: string[] }; -} - // It gives you a responsive table with the where-table from the specs const WhereTable = (props: IWhereTable): JSX.Element => { const { data } = props; @@ -56,7 +42,7 @@ const WhereTable = (props: IWhereTable): JSX.Element => { return ; }; -export const Feature = (props: IFeature): JSX.Element => { +export const Feature = (props: IMinimalFeature): JSX.Element => { const { id, blocks } = props; return ( @@ -96,6 +82,7 @@ export const Feature = (props: IFeature): JSX.Element => { Object.keys(block.code).length !== 0 && ( ): JSX.Element => { const { hasOnPageNav, children, features } = props; diff --git a/src/components/shared/Layout/OnPageNav.tsx b/src/components/shared/Layout/OnPageNav.tsx index 3aa2e27..de6950c 100644 --- a/src/components/shared/Layout/OnPageNav.tsx +++ b/src/components/shared/Layout/OnPageNav.tsx @@ -1,11 +1,8 @@ import { nanoid } from 'nanoid'; import { NavAnchor } from '..'; -import { IFeature } from '../../Feature'; - -interface IOnPageNave { - features: IFeature[]; -} +import { IOnPageNave } from 'spock-react/shared/layout-types'; +import { IMinimalFeature } from 'spock-react-types'; export const OnPageNav = (props: IOnPageNave): JSX.Element => { const { features } = props; @@ -15,7 +12,7 @@ export const OnPageNav = (props: IOnPageNave): JSX.Element => {

On the Page