chore: update prettier tab width for consistency (#175)

This commit is contained in:
41666 2021-03-13 22:54:34 -05:00 committed by GitHub
parent a931f8c69c
commit f24d2fcc99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
247 changed files with 7224 additions and 7375 deletions

View file

@ -2,52 +2,52 @@ import * as React from 'react';
import { TabContent, TabTitle, TabTitleRow, TabViewStyled } from './TabView.styled';
export type TabViewProps = {
children: React.ReactNode[];
initialTab?: number;
children: React.ReactNode[];
initialTab?: number;
};
type TabProps = {
title: string;
children: () => React.ReactNode;
title: string;
children: () => React.ReactNode;
};
export const TabView = (props: TabViewProps) => {
const tabNames = React.Children.map(props.children, (child) => {
if (!React.isValidElement(child)) {
return '(Oops)';
}
return child.props.title;
}) as string[];
if (tabNames.length === 0) {
return null;
const tabNames = React.Children.map(props.children, (child) => {
if (!React.isValidElement(child)) {
return '(Oops)';
}
const [currentTab, setCurrentTab] = React.useState<number>(props.initialTab ?? 0);
return child.props.title;
}) as string[];
return (
<TabViewStyled>
<TabTitleRow>
{tabNames.map((tabName, idx) => (
<TabTitle
selected={currentTab === idx}
onClick={() => setCurrentTab(idx)}
key={`tab${tabName}${idx}`}
>
{tabName}
</TabTitle>
))}
</TabTitleRow>
<TabContent>
{props.children[currentTab] || (
<i onLoad={() => setCurrentTab(0)}>
Tabs were misconfigured, resetting to zero.
</i>
)}
</TabContent>
</TabViewStyled>
);
if (tabNames.length === 0) {
return null;
}
const [currentTab, setCurrentTab] = React.useState<number>(props.initialTab ?? 0);
return (
<TabViewStyled>
<TabTitleRow>
{tabNames.map((tabName, idx) => (
<TabTitle
selected={currentTab === idx}
onClick={() => setCurrentTab(idx)}
key={`tab${tabName}${idx}`}
>
{tabName}
</TabTitle>
))}
</TabTitleRow>
<TabContent>
{props.children[currentTab] || (
<i onLoad={() => setCurrentTab(0)}>
Tabs were misconfigured, resetting to zero.
</i>
)}
</TabContent>
</TabViewStyled>
);
};
export const Tab = (props: TabProps) => <div>{props.children()}</div>;