Skip to content

Commit

Permalink
Merge pull request #570 from catho/QTM-723
Browse files Browse the repository at this point in the history
feat(QTM-723): Typography converted from styled components to css mod…
  • Loading branch information
MichelAraujo authored Jun 27, 2024
2 parents c964b50 + 00a8573 commit fe300ab
Show file tree
Hide file tree
Showing 34 changed files with 189 additions and 223 deletions.
5 changes: 3 additions & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import GlobalStyle from '../components/GlobalStyle';
import Typography from '../components/Typography';
import '../components/theme.css';
import '../components/_utilities.css';
import '../components/global.css';

const CSSDecorator = (Story, context) => (
<>
<Story {...context} />
<GlobalStyle />
<Typography />
</>
);

Expand Down
5 changes: 3 additions & 2 deletions .storybook/regression-test/preview.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'loki/configure-react';
import GlobalStyle from '../../components/GlobalStyle';
import Typography from '../../components/Typography';
import '../../components/theme.css';
import '../../components/_utilities.css';
import '../../components/global.css';

const CSSDecorator = (Story, context) => (
<div id="regression-test">
<Story {...context} />
<GlobalStyle />
<Typography />
</div>
);

Expand Down
5 changes: 0 additions & 5 deletions components/GlobalStyle/GlobalStyle.jsx

This file was deleted.

21 changes: 0 additions & 21 deletions components/GlobalStyle/GlobalStyle.unit.test.jsx

This file was deleted.

7 changes: 0 additions & 7 deletions components/GlobalStyle/index.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions components/GlobalStyle/index.js

This file was deleted.

10 changes: 0 additions & 10 deletions components/GlobalStyle/sub-components/Blockquote.jsx

This file was deleted.

9 changes: 0 additions & 9 deletions components/GlobalStyle/sub-components/Subtitle.jsx

This file was deleted.

5 changes: 0 additions & 5 deletions components/GlobalStyle/sub-components/Title.jsx

This file was deleted.

112 changes: 0 additions & 112 deletions components/GlobalStyle/sub-components/Typography.jsx

This file was deleted.

This file was deleted.

21 changes: 21 additions & 0 deletions components/Typography/Typography.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Typography = () => (
<>
<link
rel="preconnect"
href="https://fonts.gstatic.com"
crossOrigin="anonymous"
/>
<link
rel="preload"
href="https://fonts.googleapis.com/css?family=Nunito+Sans:400,600,700,400i,600i,700i&display=swap"
as="font"
crossOrigin="anonymous"
/>
<link
href="https://fonts.googleapis.com/css?family=Nunito+Sans:400,600,700,400i,600i,700i&display=swap"
rel="stylesheet"
/>
</>
);

export default Typography;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render } from '@testing-library/react';

import Typography from './Typography';

import { expectCSSMatches } from '../../../test-utils/helpers/shared/test.utils';
import { expectCSSMatches } from '../../test-utils/helpers/shared/test.utils';

describe.skip('Typography component', () => {
it('Should match snapshot', () => {
Expand Down
2 changes: 2 additions & 0 deletions components/Typography/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "./sub-components/Blockquote.module.css";
@import "./sub-components/Subtitle.module.css";
5 changes: 5 additions & 0 deletions components/Typography/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { FC } from 'react';

declare const Typography: FC;

export default Typography;
7 changes: 7 additions & 0 deletions components/Typography/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Typography from './Typography';
import Title from './sub-components/Title';
import Subtitle from './sub-components/Subtitle';
import Blockquote from './sub-components/Blockquote';

export { Title, Subtitle, Blockquote };
export default Typography;
13 changes: 13 additions & 0 deletions components/Typography/sub-components/Blockquote.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import classNames from 'classnames';
import styles from './Blockquote.module.css';

const Blockquote = ({ className = '', children, ...props }) => {
const classContent = classNames(styles.blockquote, className);
return (
<blockquote className={classContent} {...props}>
{children}
</blockquote>
);
};

export default Blockquote;
6 changes: 6 additions & 0 deletions components/Typography/sub-components/Blockquote.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.blockquote {
font-size: 12px;
line-height: 18px;
letter-spacing: 0.2px;
margin: 0;
}
13 changes: 13 additions & 0 deletions components/Typography/sub-components/Subtitle.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import classNames from 'classnames';
import styles from './Subtitle.module.css';

const Subtitle = ({ className = '', children, ...props }) => {
const classContent = classNames(styles.span, className);
return (
<span className={classContent} {...props}>
{children}
</span>
);
};

export default Subtitle;
5 changes: 5 additions & 0 deletions components/Typography/sub-components/Subtitle.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.span {
font-size: 14px;
line-height: 21px;
letter-spacing: 0.3px;
}
12 changes: 12 additions & 0 deletions components/Typography/sub-components/Title.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import classNames from 'classnames';

const Title = ({ className = '', children, ...props }) => {
const classContent = classNames(className);
return (
<h1 className={classContent} {...props}>
{children}
</h1>
);
};

export default Title;
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

exports[`<Blockquote /> Should match the snapshot 1`] = `
<DocumentFragment>
.c0 {
.Blockquote-module__blockquote___Xqdgz {
font-size: 12px;
letter-spacing: .2px;
line-height: 18px;
-webkit-letter-spacing: 0.2px;
-moz-letter-spacing: 0.2px;
-ms-letter-spacing: 0.2px;
letter-spacing: 0.2px;
margin: 0;
}
<blockquote
class="c0"
class="Blockquote-module__blockquote___Xqdgz"
/>
</DocumentFragment>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

exports[`<Subtitle /> Should match the snapshot 1`] = `
<DocumentFragment>
.c0 {
.Subtitle-module__span___BW9AV {
font-size: 14px;
letter-spacing: .3px;
line-height: 21px;
-webkit-letter-spacing: 0.3px;
-moz-letter-spacing: 0.3px;
-ms-letter-spacing: 0.3px;
letter-spacing: 0.3px;
}
<span
class="c0"
class="Subtitle-module__span___BW9AV"
/>
</DocumentFragment>
`;
Loading

0 comments on commit fe300ab

Please sign in to comment.