diff --git a/docs/scripts/generate-props-tables-data.ts b/docs/scripts/generate-props-tables-data.ts index dc8bfead649..0ec049c84be 100644 --- a/docs/scripts/generate-props-tables-data.ts +++ b/docs/scripts/generate-props-tables-data.ts @@ -6,7 +6,7 @@ import type { Category, ComponentName, Properties, - PropsTableSubComponentData, + ComponentPropsData, SortedPropertiesByCategory, } from './types/catalog'; import { TypeFileName } from './types/allTypesData'; @@ -23,9 +23,9 @@ createAllPropsTablesData().then((allPropsTablesData) => { }); async function createAllPropsTablesData(): Promise< - Map + Map > { - const data: Map = new Map(); + const data: Map = new Map(); for await (const componentFilepath of globbyStream( path.join( __dirname, @@ -48,7 +48,7 @@ async function createAllPropsTablesData(): Promise< ); data.set(componentName, { [componentName]: propsSortedByCategory, - } as PropsTableSubComponentData); + } as ComponentPropsData); if (componentName in componentsWithChildren) { const subComponentProps = {}; diff --git a/docs/scripts/types/catalog.d.ts b/docs/scripts/types/catalog.d.ts index f52aaacb00b..750f91e5c13 100644 --- a/docs/scripts/types/catalog.d.ts +++ b/docs/scripts/types/catalog.d.ts @@ -142,8 +142,6 @@ export type Properties = Record; export type Catalog = Record; export type SortedPropertiesByCategory = { [key: string]: Properties }[]; -export type PropsTableSubComponentData = { +export type ComponentPropsData = { [key in ComponentName]: SortedPropertiesByCategory; }; - -export type PropsTableData = { [key in ComponentName]: PropsTableSubComponentData } diff --git a/docs/src/components/Layout/PageTabLayout.tsx b/docs/src/components/Layout/PageTabLayout.tsx index 444535e0d6d..ed6ea4fbbc7 100644 --- a/docs/src/components/Layout/PageTabLayout.tsx +++ b/docs/src/components/Layout/PageTabLayout.tsx @@ -6,47 +6,22 @@ import { Tabs, View } from '@aws-amplify/ui-react'; export const PageTabLayout = ({ tabComponents, }: { - tabComponents: [{ title: string; children: React.ReactNode }]; + tabComponents: { title: string; children: React.ReactNode }[]; }) => { - const { - query: { tab = '', platform }, - pathname, - push, - } = useRouter(); - const tabComponentsMap = tabComponents.map(({ title }) => - title.toLocaleLowerCase() - ); + const { query, pathname, push } = useRouter(); - const getValue = React.useCallback( - (tab: string) => (tab === '' ? tabComponentsMap[0] : tab), - [tabComponentsMap] - ); - const defaultValue = getValue(tab as string); + const defaultValue = tabComponents[0]['title'].toLocaleLowerCase(); - const [currentTab, setCurrentTab] = React.useState(defaultValue); - const changeURL = (tab) => { - push( - { - pathname, - query: { - platform, - ...(tab !== tabComponentsMap[0] ? { tab: tab.toLowerCase() } : null), - }, - }, - undefined, - { shallow: true } - ); - setCurrentTab(tab); + const handleValueChange = (value: string) => { + const { platform } = query; + const tab = value !== defaultValue ? value.toLocaleLowerCase() : undefined; + push({ pathname, query: { platform, tab } }, undefined, { shallow: true }); }; - React.useEffect(() => { - setCurrentTab(getValue(tab as string)); - }, [tab, getValue]); - return ( diff --git a/docs/src/components/propsTable/PropsTableTab.tsx b/docs/src/components/propsTable/PropsTableTab.tsx index 7c3d7d7aed4..6fdfb09daa0 100644 --- a/docs/src/components/propsTable/PropsTableTab.tsx +++ b/docs/src/components/propsTable/PropsTableTab.tsx @@ -1,17 +1,15 @@ import { Heading, Link, Text } from '@aws-amplify/ui-react'; -import { - PropsTableData, - PropsTableSubComponentData, -} from '../../../scripts/types/catalog'; +import { ComponentPropsData } from '../../../scripts/types/catalog'; import { PropsTable } from './PropsTable'; import { PropsTableExpander } from './PropsTableExpander'; +import PROPS_TABLE from '@/data/props-table.json'; function PropsTableSet({ componentName, componentPropsData, }: { componentName: string; - componentPropsData: PropsTableSubComponentData; + componentPropsData: ComponentPropsData; }) { return ( <> @@ -32,17 +30,14 @@ function PropsTableSet({ export function PropsTableTab({ componentName, - PropsData, htmlElement, mdnUrl, }: { componentName: string; - PropsData: PropsTableData; htmlElement: string; mdnUrl: string; }) { - const componentPropsData: PropsTableSubComponentData = - PropsData[componentName]; + const componentPropsData: ComponentPropsData = PROPS_TABLE[componentName]; return ( <> - Hello world + Hello world ```css /* styles.css */ diff --git a/docs/src/pages/_document.page.tsx b/docs/src/pages/_document.page.tsx index 9ff9db0a186..2d899465924 100644 --- a/docs/src/pages/_document.page.tsx +++ b/docs/src/pages/_document.page.tsx @@ -66,10 +66,8 @@ class MyDocument extends Document { httpEquiv="Content-Security-Policy" content={getCSPContent(this.props)} /> - - -