-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(@lapidist/title): init * feat(@lapidist/title): initial implementation
- Loading branch information
1 parent
1d37195
commit f998365
Showing
8 changed files
with
323 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.ts | ||
!*.d.ts | ||
*.spec.js | ||
*.spec.d.ts | ||
*.tsx | ||
*.mdx | ||
tsconfig.json | ||
__snapshots__ | ||
jest.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../../jest.config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "@lapidist/title", | ||
"version": "0.0.0", | ||
"description": "Title component", | ||
"author": "Brett Dorrans <[email protected]>", | ||
"license": "MIT", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"build": "tsc -p tsconfig.json", | ||
"test": "jest" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"release": { | ||
"analyzeCommits": { | ||
"preset": "angular", | ||
"releaseRules": [ | ||
{ | ||
"type": "build", | ||
"release": "minor" | ||
} | ||
] | ||
} | ||
}, | ||
"dependencies": { | ||
"@lapidist/design-tokens": "^1.7.0", | ||
"@lapidist/theme-provider": "^1.13.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import 'jest-styled-components'; | ||
|
||
import Title from './index'; | ||
|
||
test('it works as h1', () => { | ||
const tree = renderer.create(<Title size={1}>H1</Title>).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
test('it works as h2', () => { | ||
const tree = renderer.create(<Title size={2}>H2</Title>).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
test('it works as h3', () => { | ||
const tree = renderer.create(<Title size={3}>H3</Title>).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
test('it works as h4', () => { | ||
const tree = renderer.create(<Title size={4}>H4</Title>).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
test('it works as h5', () => { | ||
const tree = renderer.create(<Title size={5}>H5</Title>).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
test('it works as h6', () => { | ||
const tree = renderer.create(<Title size={6}>H6</Title>).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`it works as h1 1`] = ` | ||
.c0 { | ||
font-size: 36px; | ||
} | ||
.c1 { | ||
font-family: 'Montserrat',sans-serif; | ||
display: block; | ||
width: 100%; | ||
margin: 0 0 4px; | ||
color: #292b3e; | ||
line-height: 1.6; | ||
-webkit-letter-spacing: 0.8px; | ||
-moz-letter-spacing: 0.8px; | ||
-ms-letter-spacing: 0.8px; | ||
letter-spacing: 0.8px; | ||
} | ||
<h1 | ||
className="c0 c1" | ||
> | ||
H1 | ||
</h1> | ||
`; | ||
|
||
exports[`it works as h2 1`] = ` | ||
.c0 { | ||
font-size: 24px; | ||
} | ||
.c1 { | ||
font-family: 'Montserrat',sans-serif; | ||
display: block; | ||
width: 100%; | ||
margin: 0 0 4px; | ||
color: #292b3e; | ||
line-height: 1.6; | ||
-webkit-letter-spacing: 0.8px; | ||
-moz-letter-spacing: 0.8px; | ||
-ms-letter-spacing: 0.8px; | ||
letter-spacing: 0.8px; | ||
} | ||
<h2 | ||
className="c0 c1" | ||
> | ||
H2 | ||
</h2> | ||
`; | ||
|
||
exports[`it works as h3 1`] = ` | ||
.c0 { | ||
font-size: 16px; | ||
} | ||
.c1 { | ||
font-family: 'Montserrat',sans-serif; | ||
display: block; | ||
width: 100%; | ||
margin: 0 0 4px; | ||
color: #292b3e; | ||
line-height: 1.6; | ||
-webkit-letter-spacing: 0.8px; | ||
-moz-letter-spacing: 0.8px; | ||
-ms-letter-spacing: 0.8px; | ||
letter-spacing: 0.8px; | ||
} | ||
<h3 | ||
className="c0 c1" | ||
> | ||
H3 | ||
</h3> | ||
`; | ||
|
||
exports[`it works as h4 1`] = ` | ||
.c0 { | ||
font-size: 14px; | ||
} | ||
.c1 { | ||
font-family: 'Montserrat',sans-serif; | ||
display: block; | ||
width: 100%; | ||
margin: 0 0 4px; | ||
color: #292b3e; | ||
line-height: 1.6; | ||
-webkit-letter-spacing: 0.8px; | ||
-moz-letter-spacing: 0.8px; | ||
-ms-letter-spacing: 0.8px; | ||
letter-spacing: 0.8px; | ||
} | ||
<h4 | ||
className="c0 c1" | ||
> | ||
H4 | ||
</h4> | ||
`; | ||
|
||
exports[`it works as h5 1`] = ` | ||
.c0 { | ||
font-size: 14px; | ||
} | ||
.c1 { | ||
font-family: 'Montserrat',sans-serif; | ||
display: block; | ||
width: 100%; | ||
margin: 0 0 4px; | ||
color: #292b3e; | ||
line-height: 1.6; | ||
-webkit-letter-spacing: 0.8px; | ||
-moz-letter-spacing: 0.8px; | ||
-ms-letter-spacing: 0.8px; | ||
letter-spacing: 0.8px; | ||
} | ||
<h5 | ||
className="c0 c1" | ||
> | ||
H5 | ||
</h5> | ||
`; | ||
|
||
exports[`it works as h6 1`] = ` | ||
.c0 { | ||
font-size: 14px; | ||
} | ||
.c1 { | ||
font-family: 'Montserrat',sans-serif; | ||
display: block; | ||
width: 100%; | ||
margin: 0 0 4px; | ||
color: #292b3e; | ||
line-height: 1.6; | ||
-webkit-letter-spacing: 0.8px; | ||
-moz-letter-spacing: 0.8px; | ||
-ms-letter-spacing: 0.8px; | ||
letter-spacing: 0.8px; | ||
} | ||
<h6 | ||
className="c0 c1" | ||
> | ||
H6 | ||
</h6> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { | ||
fontFamilyBold, | ||
fontSizeExtraLarge, | ||
fontSizeLarge, | ||
fontSizeMedium, | ||
fontSizeSmall | ||
} from '@lapidist/design-tokens'; | ||
import { defaultTheme } from '@lapidist/theme-provider'; | ||
|
||
export type TitleSize = 1 | 2 | 3 | 4 | 5 | 6; | ||
|
||
export interface TitleProps { | ||
/** The Title's id. */ | ||
readonly id?: string; | ||
/** The Title's classname. */ | ||
readonly className?: string; | ||
/** The Title's size. */ | ||
readonly size?: TitleSize; | ||
} | ||
|
||
const H1Title: React.FC<TitleProps> = styled.h1` | ||
${fontSizeExtraLarge()}; | ||
`; | ||
const H2Title: React.FC<TitleProps> = styled.h2` | ||
${fontSizeLarge()}; | ||
`; | ||
const H3Title: React.FC<TitleProps> = styled.h3` | ||
${fontSizeMedium()}; | ||
`; | ||
const H4Title: React.FC<TitleProps> = styled.h4` | ||
${fontSizeSmall()}; | ||
`; | ||
const H5Title: React.FC<TitleProps> = styled.h5` | ||
${fontSizeSmall()}; | ||
`; | ||
const H6Title: React.FC<TitleProps> = styled.h6` | ||
${fontSizeSmall()}; | ||
`; | ||
|
||
const TitleBySize: React.FC<TitleProps> = ({ id, className, children, size }) => | ||
size === 2 ? ( | ||
<H2Title id={id} className={className}> | ||
{children} | ||
</H2Title> | ||
) : size === 3 ? ( | ||
<H3Title id={id} className={className}> | ||
{children} | ||
</H3Title> | ||
) : size === 4 ? ( | ||
<H4Title id={id} className={className}> | ||
{children} | ||
</H4Title> | ||
) : size === 5 ? ( | ||
<H5Title id={id} className={className}> | ||
{children} | ||
</H5Title> | ||
) : size === 6 ? ( | ||
<H6Title id={id} className={className}> | ||
{children} | ||
</H6Title> | ||
) : ( | ||
<H1Title id={id} className={className}> | ||
{children} | ||
</H1Title> | ||
); | ||
|
||
const Title: React.FC<TitleProps> = styled(TitleBySize)<TitleProps>` | ||
${fontFamilyBold()}; | ||
display: block; | ||
width: 100%; | ||
margin: 0 0 ${defaultTheme.sizing.xxs}; | ||
color: ${defaultTheme.colors.greys.dark}; | ||
line-height: 1.6; | ||
letter-spacing: 0.8px; | ||
`; | ||
|
||
export default Title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/tsconfig", | ||
"extends": "../../tsconfig.base.json", | ||
"include": ["src/**/*.ts", "src/**/*.tsx"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters