Skip to content
This repository was archived by the owner on Feb 28, 2019. It is now read-only.

Commit 637cf77

Browse files
committedFeb 22, 2019
Merge branch 'master' into AdvancedSelect
2 parents c247dcf + 6b90a6a commit 637cf77

18 files changed

+98
-9
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/build
1313

1414
# misc
15+
.idea*
1516
.DS_Store
1617
.env.local
1718
.env.development.local

‎.storybook/config.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import React from 'react'
22
import { configure } from '@storybook/react'
33
import { addDecorator } from '@storybook/react'
44
import { withThemesProvider } from 'storybook-addon-styled-component-theme'
5+
import WebfontLoader from '@dr-kobros/react-webfont-loader'
6+
57
import theme from '../src/theme'
8+
import { fontConfig } from '../src/fontConfig'
69

710
const styles = {
811
display: 'flex',
@@ -12,14 +15,24 @@ const styles = {
1215
alignItems: 'center',
1316
flexDirection: 'column'
1417
}
18+
1519
const CenterDecorator = (storyFn) => (
1620
<div style={styles}>
1721
{ storyFn() }
1822
</div>
19-
);
23+
)
24+
25+
const FontLoader = (storyFn) => (
26+
<WebfontLoader config={fontConfig} onStatus={(fontStatus) => console.log('font status:', fontStatus)}>
27+
{ storyFn() }
28+
</WebfontLoader>
29+
)
30+
2031
const themes = [theme]
2132
addDecorator(withThemesProvider(themes))
33+
addDecorator(FontLoader)
2234
addDecorator(CenterDecorator)
35+
2336
function loadStories() {
2437
require('../src/stories')
2538
}

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@dr-kobros/react-webfont-loader": "^8.0.0",
67
"@storybook/cli": "^5.0.0-rc.3",
78
"react": "^16.8.2",
89
"react-dom": "^16.8.2",
31.6 KB
Binary file not shown.
18.6 KB
Binary file not shown.
Binary file not shown.
112 KB
Binary file not shown.
60.5 KB
Binary file not shown.
49.5 KB
Binary file not shown.
99.8 KB
Binary file not shown.
55.2 KB
Binary file not shown.
46.1 KB
Binary file not shown.

‎src/assets/styles/fonts.css

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@font-face {
2+
font-family: 'Fira Mono Latin Regular';
3+
font-style: normal;
4+
font-weight: normal;
5+
src: url('../fonts/fira-mono-v5-latin-regular.ttf');
6+
}
7+
8+
@font-face {
9+
font-family: 'Pt Sans Latin Bold';
10+
font-style: normal;
11+
font-weight: 700;
12+
src: url('../fonts/pt-sans-v8-latin-700.ttf');
13+
}
14+
15+
@font-face {
16+
font-family: 'Pt Sans Latin Regular';
17+
font-style: normal;
18+
font-weight: normal;
19+
src: url('../fonts/pt-sans-v8-latin-regular.ttf');
20+
}
21+
22+
body {
23+
font-family: 'Fira Mono Latin Regular';
24+
}

‎src/components/atoms/Input/TextInput/index.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react'
2-
import styled from 'styled-components';
2+
import styled from 'styled-components'
33

44
interface IProps {
55
value?: string
@@ -20,9 +20,8 @@ TextInput.defaultProps = {
2020
value: ''
2121
}
2222

23-
2423
export default styled(TextInput)`
25-
font-family: inherit;
24+
font-family: ${props => props.theme.primaryFont};
2625
color: #444444;
2726
height: 30px;
2827
width: 300px;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react'
2+
import { ThemeProvider } from 'styled-components'
3+
// @ts-ignore
4+
import WebfontLoader from '@dr-kobros/react-webfont-loader'
5+
6+
import { fontConfig } from '../../../fontConfig'
7+
import mainTheme, { Theme } from '../../../theme'
8+
9+
interface ThemeAndFontProviderProps {
10+
fontsConfig?: object
11+
theme?: Theme
12+
onFontStatus?: (status: string) => void
13+
children: any
14+
}
15+
16+
export const ThemeAndFontProvider: React.FC<ThemeAndFontProviderProps> = ({
17+
fontsConfig = fontConfig,
18+
theme = mainTheme,
19+
onFontStatus,
20+
children
21+
}) => (
22+
<ThemeProvider theme={theme}>
23+
<WebfontLoader config={fontsConfig} onStatus={onFontStatus && onFontStatus}>
24+
{ children }
25+
</WebfontLoader>
26+
</ThemeProvider>
27+
)
28+
29+
export default ThemeAndFontProvider

‎src/fontConfig.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import './assets/styles/fonts.css'
2+
3+
export const fontConfig = {
4+
custom: {
5+
families: ['Fira Mono Latin Regular', 'Pt Sans Latin Bold', 'Pt Sans Latin Regular'],
6+
urls: ['./assets/styles/fonts.css']
7+
}
8+
}

‎src/theme.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
const theme = {
2-
global: {
3-
margin: '20px !default'
4-
}
2+
primaryFont: 'Fira Mono Latin Regular',
3+
global: {
4+
margin: '20px !default'
5+
}
56
}
67

7-
type Required<T> = { [P in keyof T]-?: T[P] };
8+
type Required<T> = { readonly [P in keyof T]-?: T[P] };
89
export type Theme = Required<typeof theme>
910

1011
export default theme as Theme

‎yarn.lock

+14-1
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,14 @@
842842
resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7"
843843
integrity sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw==
844844

845+
"@dr-kobros/react-webfont-loader@^8.0.0":
846+
version "8.0.0"
847+
resolved "https://registry.yarnpkg.com/@dr-kobros/react-webfont-loader/-/react-webfont-loader-8.0.0.tgz#1e000be944d846cc9101e656cdcf2521e859e066"
848+
integrity sha512-7cC+Amhh3gbj/FenRym6N+a8JAm3SGUFSwK4jxOQJcy49qzBMt1Q3VbI8I1ZHuKSIThNzz8FlauDlOLsuFPE+g==
849+
dependencies:
850+
prop-types "^15.5.8"
851+
webfontloader "^1.6.27"
852+
845853
"@emotion/cache@^10.0.7":
846854
version "10.0.7"
847855
resolved "https://registry.yarnpkg.com/@emotion/cache/-/cache-10.0.7.tgz#6221de2e939f62022c04b4df2c165ce577809f23"
@@ -10291,7 +10299,7 @@ prompts@^0.1.9:
1029110299
kleur "^2.0.1"
1029210300
sisteransi "^0.1.1"
1029310301

10294-
prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.6.0, prop-types@^15.6.1:
10302+
prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1:
1029510303
version "15.7.2"
1029610304
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
1029710305
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
@@ -12892,6 +12900,11 @@ web-namespaces@^1.1.2:
1289212900
resolved "https://registry.yarnpkg.com/web-namespaces/-/web-namespaces-1.1.2.tgz#c8dc267ab639505276bae19e129dbd6ae72b22b4"
1289312901
integrity sha512-II+n2ms4mPxK+RnIxRPOw3zwF2jRscdJIUE9BfkKHm4FYEg9+biIoTMnaZF5MpemE3T+VhMLrhbyD4ilkPCSbg==
1289412902

12903+
webfontloader@^1.6.27:
12904+
version "1.6.28"
12905+
resolved "https://registry.yarnpkg.com/webfontloader/-/webfontloader-1.6.28.tgz#db786129253cb6e8eae54c2fb05f870af6675bae"
12906+
integrity sha1-23hhKSU8tujq5UwvsF+HCvZnW64=
12907+
1289512908
webidl-conversions@^4.0.2:
1289612909
version "4.0.2"
1289712910
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"

0 commit comments

Comments
 (0)