Skip to content

Commit

Permalink
refactor: code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Dec 22, 2023
1 parent d4b9768 commit c4e27e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions www/src/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
3 changes: 2 additions & 1 deletion www/src/pages/foundations/elevation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import SEO from '../../components/SEO';
import Layout from '../../components/PageLayout';
import { SettingsContext } from '../../context/SettingsContext';
import { sendUserAnalyticsEvent, SHADOW_GENERATOR_LAYER_EVENTS } from '../../../segment-events';
import upperFirstLetter from '../../utils/helpers';

const boxShadowSides = ['down', 'up', 'right', 'left', 'centered'];
const boxShadowLevels = [1, 2, 3, 4, 5];
Expand Down Expand Up @@ -280,7 +281,7 @@ export default function ElevationPage({ pageContext }) {

const sideTitle = boxShadowSides.map(side => (
<p key={side} className="pgn-doc__box-shadow-side-title h3">
{side.charAt(0).toUpperCase() + side.substring(1)}
{upperFirstLetter(side)}
</p>
));

Expand Down
7 changes: 3 additions & 4 deletions www/src/templates/component-page-template.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}`, '');

Expand Down

0 comments on commit c4e27e4

Please sign in to comment.