From 5f0d045e6f6e1f3304b9ad553605f5681b445ca3 Mon Sep 17 00:00:00 2001 From: PKulkoRaccoonGang Date: Sun, 10 Dec 2023 20:03:06 +0200 Subject: [PATCH] refactor: code refactoring --- www/src/components/header/Header.tsx | 5 +++-- www/src/pages/foundations/elevation.jsx | 3 ++- www/src/templates/component-page-template.tsx | 7 +++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/www/src/components/header/Header.tsx b/www/src/components/header/Header.tsx index 142ba913e2..8e955a1a7b 100644 --- a/www/src/components/header/Header.tsx +++ b/www/src/components/header/Header.tsx @@ -14,7 +14,7 @@ import Menu from '../Menu'; export interface IHeaderProps { siteTitle: string, showMinimizedTitle?: boolean, - tabName: string, + tabName?: string, } function Header({ siteTitle, showMinimizedTitle, tabName }: IHeaderProps) { @@ -74,12 +74,13 @@ function Header({ siteTitle, showMinimizedTitle, tabName }: IHeaderProps) { Header.propTypes = { siteTitle: PropTypes.string, showMinimizedTitle: PropTypes.bool, - tabName: PropTypes.string.isRequired, + tabName: PropTypes.string, }; Header.defaultProps = { siteTitle: '', showMinimizedTitle: false, + tabName: undefined, }; export default Header; diff --git a/www/src/pages/foundations/elevation.jsx b/www/src/pages/foundations/elevation.jsx index 68d1421c56..8d46e2c5f2 100644 --- a/www/src/pages/foundations/elevation.jsx +++ b/www/src/pages/foundations/elevation.jsx @@ -13,6 +13,7 @@ import { Close, WbSunny, DoDisturb } from '~paragon-icons'; import SEO from '../../components/SEO'; import Layout from '../../components/PageLayout'; import { SettingsContext } from '../../context/SettingsContext'; +import upperFirstLetter from '../../utils/helpers'; const boxShadowSides = ['down', 'up', 'right', 'left', 'centered']; const boxShadowLevels = [1, 2, 3, 4, 5]; @@ -279,7 +280,7 @@ export default function ElevationPage({ pageContext }) { const sideTitle = boxShadowSides.map(side => (

- {side.charAt(0).toUpperCase() + side.substring(1)} + {upperFirstLetter(side)}

)); diff --git a/www/src/templates/component-page-template.tsx b/www/src/templates/component-page-template.tsx index 9e3c80d5b1..0319d2986a 100644 --- a/www/src/templates/component-page-template.tsx +++ b/www/src/templates/component-page-template.tsx @@ -1,7 +1,5 @@ /* eslint-disable react/no-unstable-nested-components */ -import React, { - useContext, useEffect, useState, -} from 'react'; +import React, { useContext, useEffect, useState } from 'react'; import PropTypes from 'prop-types'; import { graphql, Link, navigate } from 'gatsby'; import { MDXProvider } from '@mdx-js/react'; @@ -141,7 +139,8 @@ export default function PageTemplate({ const isCurrentTab = selectedTab === mdx.frontmatter.tabName; const hasSelectedTab = componentTabsData .some((availableTabs) => ( - Array.isArray(availableTabs) ? availableTabs.includes(selectedTab) : availableTabs === selectedTab)); + Array.isArray(availableTabs) + ? availableTabs.includes(selectedTab) : availableTabs === selectedTab)); const componentBaseUrl = componentUrl.replace(`/${tabName}`, '');