Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Typography Component - Introduced ForwardRef #179

Merged
merged 9 commits into from
Oct 12, 2019
4 changes: 2 additions & 2 deletions src/components/Author/Author.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DetailContext } from '../../pages/Version';
import { isEmail } from '../../utils/url';
import Avatar from '../../muiComponents/Avatar';

import { Heading, AuthorListItem, AuthorListItemText } from './styles';
import { StyledText, AuthorListItem, AuthorListItemText } from './styles';

const Author: FC = () => {
const { packageMeta } = useContext(DetailContext);
Expand All @@ -25,7 +25,7 @@ const Author: FC = () => {
const avatarComponent = <Avatar alt={author.name} src={author.avatar} />;

return (
<List subheader={<Heading variant={'subtitle1'}>{'Author'}</Heading>}>
<List subheader={<StyledText variant={'subtitle1'}>{'Author'}</StyledText>}>
<AuthorListItem button={true}>
{!email || !isEmail(email) ? (
avatarComponent
Expand Down
4 changes: 2 additions & 2 deletions src/components/Author/__snapshots__/Author.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Author /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-hyrz44 e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-xugzlj e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><a href=\\"mailto:[email protected][email protected]\\" target=\\"_top\\"><div class=\\"MuiAvatar-root\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div></a><div class=\\"MuiListItemText-root css-1vhg3jx e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<Author /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-xugzlj e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><a href=\\"mailto:[email protected][email protected]\\" target=\\"_top\\"><div class=\\"MuiAvatar-root\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div></a><div class=\\"MuiListItemText-root css-1vhg3jx e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;

exports[`<Author /> component should render the component when there is no author email 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-hyrz44 e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-xugzlj e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div><div class=\\"MuiListItemText-root css-1vhg3jx e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<Author /> component should render the component when there is no author email 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-xugzlj e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div><div class=\\"MuiListItemText-root css-1vhg3jx e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
11 changes: 5 additions & 6 deletions src/components/Author/styles.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import styled from 'react-emotion';
import Typography from '@material-ui/core/Typography';
import ListItemText from '@material-ui/core/ListItemText';

import { fontWeight } from '../../utils/styles/sizes';
import ListItem from '../../muiComponents/ListItem';
import Text from '../../muiComponents/Text';

export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
textTransform: 'capitalize',
},
export const StyledText = styled(Text)({
fontWeight: fontWeight.bold,
textTransform: 'capitalize',
});

export const AuthorListItem = styled(ListItem)({
'&&': {
padding: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Dependencies/Dependencies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PackageDependencies } from '../../../types/packageMeta';
import { DetailContext } from '../../pages/Version';
import NoItems from '../NoItems';

import { CardWrap, Heading, Tags, Tag } from './styles';
import { CardWrap, StyledText, Tags, Tag } from './styles';

interface DependencyBlockProps {
title: string;
Expand All @@ -28,7 +28,7 @@ const DependencyBlock: React.FC<DependencyBlockProps> = ({ title, dependencies }
return (
<CardWrap>
<CardContent>
<Heading variant="subtitle1">{`${title} (${deps.length})`}</Heading>
<StyledText variant="subtitle1">{`${title} (${deps.length})`}</StyledText>
<Tags>
{deps.map(([name, version]) => (
// eslint-disable-next-line
Expand Down
10 changes: 4 additions & 6 deletions src/components/Dependencies/styles.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import styled from 'react-emotion';
import Card from '@material-ui/core/Card';
import Typography from '@material-ui/core/Typography';
import Chip from '@material-ui/core/Chip';

import { fontWeight } from '../../utils/styles/sizes';
import Text from '../../muiComponents/Text';

export const CardWrap = styled(Card)({
'&&': {
margin: '0 0 16px',
},
});

export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
textTransform: 'capitalize',
},
export const StyledText = styled(Text)({
fontWeight: fontWeight.bold,
textTransform: 'capitalize',
});

export const Tags = styled('div')({
Expand Down
4 changes: 2 additions & 2 deletions src/components/Developers/Developers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Add from '@material-ui/icons/Add';
import { DetailContext } from '../../pages/Version';
import { AvatarTooltip } from '../AvatarTooltip';

import { Details, Heading, Content, Fab } from './styles';
import { Details, StyledText, Content, Fab } from './styles';

export type DevelopersType = 'contributors' | 'maintainers';

Expand Down Expand Up @@ -34,7 +34,7 @@ const Developers: FC<Props> = ({ type, visibleMax }) => {

return (
<Fragment>
<Heading variant={'subtitle1'}>{type}</Heading>
<StyledText variant={'subtitle1'}>{type}</StyledText>
<Content>
{listVisibleDevelopers.map(developer => (
<Details key={developer.email}>{renderDeveloperDetails(developer, packageMeta)}</Details>
Expand Down
206 changes: 108 additions & 98 deletions src/components/Developers/__snapshots__/Developers.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,73 @@ exports[`test Developers should render the component for contributors with items
<Developers
type="contributors"
>
<Styled(WithStyles(ForwardRef(Typography)))
<Styled(Component)
variant="subtitle1"
>
<WithStyles(ForwardRef(Typography))
className="css-18tsvng emotion-0"
<ForwardRef(Text)
className="css-48zeoi emotion-0"
variant="subtitle1"
>
<ForwardRef(Typography)
className="css-18tsvng emotion-0"
classes={
Object {
"alignCenter": "MuiTypography-alignCenter",
"alignJustify": "MuiTypography-alignJustify",
"alignLeft": "MuiTypography-alignLeft",
"alignRight": "MuiTypography-alignRight",
"body1": "MuiTypography-body1",
"body2": "MuiTypography-body2",
"button": "MuiTypography-button",
"caption": "MuiTypography-caption",
"colorError": "MuiTypography-colorError",
"colorInherit": "MuiTypography-colorInherit",
"colorPrimary": "MuiTypography-colorPrimary",
"colorSecondary": "MuiTypography-colorSecondary",
"colorTextPrimary": "MuiTypography-colorTextPrimary",
"colorTextSecondary": "MuiTypography-colorTextSecondary",
"displayBlock": "MuiTypography-displayBlock",
"displayInline": "MuiTypography-displayInline",
"gutterBottom": "MuiTypography-gutterBottom",
"h1": "MuiTypography-h1",
"h2": "MuiTypography-h2",
"h3": "MuiTypography-h3",
"h4": "MuiTypography-h4",
"h5": "MuiTypography-h5",
"h6": "MuiTypography-h6",
"noWrap": "MuiTypography-noWrap",
"overline": "MuiTypography-overline",
"paragraph": "MuiTypography-paragraph",
"root": "MuiTypography-root",
"srOnly": "MuiTypography-srOnly",
"subtitle1": "MuiTypography-subtitle1",
"subtitle2": "MuiTypography-subtitle2",
}
}
<WithStyles(ForwardRef(Typography))
className="css-48zeoi emotion-0"
variant="subtitle1"
>
<h6
className="MuiTypography-root css-18tsvng emotion-0 MuiTypography-subtitle1"
<ForwardRef(Typography)
className="css-48zeoi emotion-0"
classes={
Object {
"alignCenter": "MuiTypography-alignCenter",
"alignJustify": "MuiTypography-alignJustify",
"alignLeft": "MuiTypography-alignLeft",
"alignRight": "MuiTypography-alignRight",
"body1": "MuiTypography-body1",
"body2": "MuiTypography-body2",
"button": "MuiTypography-button",
"caption": "MuiTypography-caption",
"colorError": "MuiTypography-colorError",
"colorInherit": "MuiTypography-colorInherit",
"colorPrimary": "MuiTypography-colorPrimary",
"colorSecondary": "MuiTypography-colorSecondary",
"colorTextPrimary": "MuiTypography-colorTextPrimary",
"colorTextSecondary": "MuiTypography-colorTextSecondary",
"displayBlock": "MuiTypography-displayBlock",
"displayInline": "MuiTypography-displayInline",
"gutterBottom": "MuiTypography-gutterBottom",
"h1": "MuiTypography-h1",
"h2": "MuiTypography-h2",
"h3": "MuiTypography-h3",
"h4": "MuiTypography-h4",
"h5": "MuiTypography-h5",
"h6": "MuiTypography-h6",
"noWrap": "MuiTypography-noWrap",
"overline": "MuiTypography-overline",
"paragraph": "MuiTypography-paragraph",
"root": "MuiTypography-root",
"srOnly": "MuiTypography-srOnly",
"subtitle1": "MuiTypography-subtitle1",
"subtitle2": "MuiTypography-subtitle2",
}
}
variant="subtitle1"
>
contributors
</h6>
</ForwardRef(Typography)>
</WithStyles(ForwardRef(Typography))>
</Styled(WithStyles(ForwardRef(Typography)))>
<h6
className="MuiTypography-root css-48zeoi emotion-0 MuiTypography-subtitle1"
>
contributors
</h6>
</ForwardRef(Typography)>
</WithStyles(ForwardRef(Typography))>
</ForwardRef(Text)>
</Styled(Component)>
<Styled(div)>
<div
className="css-mkcn9c emotion-5"
className="css-mkcn9c emotion-6"
>
<Styled(span)
key="[email protected]"
>
<span
className="css-dvxtzn emotion-3"
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="[email protected]"
Expand Down Expand Up @@ -161,7 +166,7 @@ exports[`test Developers should render the component for contributors with items
key="[email protected]"
>
<span
className="css-dvxtzn emotion-3"
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="[email protected]"
Expand Down Expand Up @@ -262,68 +267,73 @@ exports[`test Developers should render the component for maintainers with items
<Developers
type="maintainers"
>
<Styled(WithStyles(ForwardRef(Typography)))
<Styled(Component)
variant="subtitle1"
>
<WithStyles(ForwardRef(Typography))
className="css-18tsvng emotion-0"
<ForwardRef(Text)
className="css-48zeoi emotion-0"
variant="subtitle1"
>
<ForwardRef(Typography)
className="css-18tsvng emotion-0"
classes={
Object {
"alignCenter": "MuiTypography-alignCenter",
"alignJustify": "MuiTypography-alignJustify",
"alignLeft": "MuiTypography-alignLeft",
"alignRight": "MuiTypography-alignRight",
"body1": "MuiTypography-body1",
"body2": "MuiTypography-body2",
"button": "MuiTypography-button",
"caption": "MuiTypography-caption",
"colorError": "MuiTypography-colorError",
"colorInherit": "MuiTypography-colorInherit",
"colorPrimary": "MuiTypography-colorPrimary",
"colorSecondary": "MuiTypography-colorSecondary",
"colorTextPrimary": "MuiTypography-colorTextPrimary",
"colorTextSecondary": "MuiTypography-colorTextSecondary",
"displayBlock": "MuiTypography-displayBlock",
"displayInline": "MuiTypography-displayInline",
"gutterBottom": "MuiTypography-gutterBottom",
"h1": "MuiTypography-h1",
"h2": "MuiTypography-h2",
"h3": "MuiTypography-h3",
"h4": "MuiTypography-h4",
"h5": "MuiTypography-h5",
"h6": "MuiTypography-h6",
"noWrap": "MuiTypography-noWrap",
"overline": "MuiTypography-overline",
"paragraph": "MuiTypography-paragraph",
"root": "MuiTypography-root",
"srOnly": "MuiTypography-srOnly",
"subtitle1": "MuiTypography-subtitle1",
"subtitle2": "MuiTypography-subtitle2",
}
}
<WithStyles(ForwardRef(Typography))
className="css-48zeoi emotion-0"
variant="subtitle1"
>
<h6
className="MuiTypography-root css-18tsvng emotion-0 MuiTypography-subtitle1"
<ForwardRef(Typography)
className="css-48zeoi emotion-0"
classes={
Object {
"alignCenter": "MuiTypography-alignCenter",
"alignJustify": "MuiTypography-alignJustify",
"alignLeft": "MuiTypography-alignLeft",
"alignRight": "MuiTypography-alignRight",
"body1": "MuiTypography-body1",
"body2": "MuiTypography-body2",
"button": "MuiTypography-button",
"caption": "MuiTypography-caption",
"colorError": "MuiTypography-colorError",
"colorInherit": "MuiTypography-colorInherit",
"colorPrimary": "MuiTypography-colorPrimary",
"colorSecondary": "MuiTypography-colorSecondary",
"colorTextPrimary": "MuiTypography-colorTextPrimary",
"colorTextSecondary": "MuiTypography-colorTextSecondary",
"displayBlock": "MuiTypography-displayBlock",
"displayInline": "MuiTypography-displayInline",
"gutterBottom": "MuiTypography-gutterBottom",
"h1": "MuiTypography-h1",
"h2": "MuiTypography-h2",
"h3": "MuiTypography-h3",
"h4": "MuiTypography-h4",
"h5": "MuiTypography-h5",
"h6": "MuiTypography-h6",
"noWrap": "MuiTypography-noWrap",
"overline": "MuiTypography-overline",
"paragraph": "MuiTypography-paragraph",
"root": "MuiTypography-root",
"srOnly": "MuiTypography-srOnly",
"subtitle1": "MuiTypography-subtitle1",
"subtitle2": "MuiTypography-subtitle2",
}
}
variant="subtitle1"
>
maintainers
</h6>
</ForwardRef(Typography)>
</WithStyles(ForwardRef(Typography))>
</Styled(WithStyles(ForwardRef(Typography)))>
<h6
className="MuiTypography-root css-48zeoi emotion-0 MuiTypography-subtitle1"
>
maintainers
</h6>
</ForwardRef(Typography)>
</WithStyles(ForwardRef(Typography))>
</ForwardRef(Text)>
</Styled(Component)>
<Styled(div)>
<div
className="css-mkcn9c emotion-5"
className="css-mkcn9c emotion-6"
>
<Styled(span)
key="[email protected]"
>
<span
className="css-dvxtzn emotion-3"
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="[email protected]"
Expand Down Expand Up @@ -419,7 +429,7 @@ exports[`test Developers should render the component for maintainers with items
key="[email protected]"
>
<span
className="css-dvxtzn emotion-3"
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="[email protected]"
Expand Down
12 changes: 5 additions & 7 deletions src/components/Developers/styles.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import styled from 'react-emotion';
import Typography from '@material-ui/core/Typography';
import { default as MuiFab } from '@material-ui/core/Fab';

import colors from '../../utils/styles/colors';
import { fontWeight } from '../../utils/styles/sizes';
import Text from '../../muiComponents/Text';

export const Details = styled('span')({
display: 'flex',
Expand All @@ -20,12 +20,10 @@ export const Content = styled('div')({
},
});

export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
marginBottom: '10px',
textTransform: 'capitalize',
},
export const StyledText = styled(Text)({
fontWeight: fontWeight.bold,
marginBottom: '10px',
textTransform: 'capitalize',
});

export const Fab = styled(MuiFab)({
Expand Down
Loading