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

Commit ee3e8eb

Browse files
authored
Replacing rem utility with fontSizeUtility and pxToRem (#44)
Added fontSizeUtility. Removed rem util. Added .vscode support for testing.
1 parent 426d932 commit ee3e8eb

File tree

25 files changed

+201
-127
lines changed

25 files changed

+201
-127
lines changed

.vscode/launch.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug Jest Tests",
6+
"type": "node",
7+
"request": "launch",
8+
"protocol": "inspector",
9+
"port": 9230,
10+
"runtimeArgs": [
11+
"--inspect-brk=9230",
12+
"${workspaceRoot}/node_modules/jest/bin/jest.js",
13+
"--runInBand"
14+
],
15+
"console": "integratedTerminal",
16+
"internalConsoleOptions": "neverOpen"
17+
}
18+
]
19+
}

docs/src/components/ComponentDoc/ComponentExample/ComponentExample.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { renderToStaticMarkup } from 'react-dom/server'
66
import { html } from 'js-beautify'
77
import copyToClipboard from 'copy-to-clipboard'
88
import { Divider, Form, Grid, Menu, Segment, Visibility } from 'semantic-ui-react'
9-
import { rem } from 'src/lib'
9+
import { pxToRem } from 'src/lib'
1010
import evalTypeScript from 'docs/src/utils/evalTypeScript'
1111
import { Provider } from 'stardust'
1212

@@ -25,18 +25,18 @@ import ComponentExampleTitle from './ComponentExampleTitle'
2525

2626
const childrenStyle = {
2727
paddingTop: 0,
28-
maxWidth: rem(50),
28+
maxWidth: pxToRem(500),
2929
}
3030

3131
const errorStyle = {
3232
padding: '1em',
33-
fontSize: rem(0.9),
33+
fontSize: pxToRem(9),
3434
color: '#a33',
3535
background: '#fff2f2',
3636
}
3737

3838
const controlsWrapperStyle = {
39-
minHeight: rem(3),
39+
minHeight: pxToRem(30),
4040
}
4141

4242
/**

docs/src/components/Knobs/Knobs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createComponent } from 'react-fela'
2-
import { rem } from 'src/lib'
2+
import { pxToRem } from 'src/lib'
33

44
import KnobsField from './KnobsField'
55
import KnobsControl from './KnobsControl'
@@ -11,7 +11,7 @@ import KnobsScalar from './KnobsScalar'
1111

1212
const Knobs: any = createComponent(
1313
() => ({
14-
padding: rem(1),
14+
padding: pxToRem(10),
1515
background: '#eee',
1616
}),
1717
'div',

docs/src/components/Knobs/KnobsControl.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { createComponent } from 'react-fela'
2-
import { rem } from 'src/lib'
2+
import { pxToRem } from 'src/lib'
33

44
const KnobsControl = createComponent(
55
() => ({
6-
padding: `0 ${rem(1)}`,
6+
padding: `0 ${pxToRem(10)}`,
77
}),
88
'span',
99
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { createComponent } from 'react-fela'
2-
import { rem } from 'src/lib'
2+
import { pxToRem } from 'src/lib'
33

44
const KnobsField = createComponent(() => ({
5-
padding: `${rem(0.5)} 0`,
6-
width: rem(30),
5+
padding: `${pxToRem(5)} 0`,
6+
width: pxToRem(300),
77
}))
88

99
export default KnobsField

docs/src/components/Knobs/KnobsValue.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react'
22
import { createComponent } from 'react-fela'
3-
import { rem } from 'src/lib'
3+
import { pxToRem } from 'src/lib'
44

55
const KnobsValue = createComponent(
66
() => ({
7-
padding: `0 ${rem(0.5)}`,
7+
padding: `0 ${pxToRem(5)}`,
88
}),
99
props => (
1010
<span className={props.className}>

docs/src/examples/components/Layout/Variations/LayoutExampleGap.knobs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types'
22
import React from 'react'
3-
import { rem } from 'src/lib'
3+
import { pxToRem } from 'src/lib'
44

55
import Knobs from 'docs/src/components/Knobs/Knobs'
66

@@ -22,7 +22,7 @@ LayoutExampleGapKnobs.propTypes = {
2222
}
2323

2424
LayoutExampleGapKnobs.defaultProps = {
25-
gap: rem(5),
25+
gap: pxToRem(50),
2626
vertical: false,
2727
}
2828

src/components/Button/buttonVariables.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { rem } from '../../lib'
1+
import { pxToRem } from '../../lib'
22

33
export interface IButtonVariables {
44
backgroundColor: string
@@ -19,7 +19,7 @@ export default (siteVars: any): IButtonVariables => {
1919
return {
2020
backgroundColor: siteVars.gray08,
2121
backgroundColorHover: siteVars.gray06,
22-
circularRadius: rem(99),
22+
circularRadius: pxToRem(999),
2323
circularWidth: '32px',
2424
typePrimaryColor: siteVars.white,
2525
typePrimaryBackgroundColor: siteVars.brand,

src/components/Divider/dividerRules.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
import { rem, childrenExist } from '../../lib'
1+
import { childrenExist, pxToRem } from '../../lib'
22

33
const dividerBorderRule = size => ({
4-
height: rem(0.1 + size * 0.1),
4+
height: pxToRem(1 + size),
55
background: 'lightgray',
66
})
77

88
const beforeAndAfter = (size, radius) => ({
99
content: '""',
1010
flex: 1,
11-
borderRadius: rem(radius),
11+
borderRadius: pxToRem(radius),
1212
...dividerBorderRule(size),
1313
})
1414

1515
export default ({ children, size, variables }) => ({
1616
root: {
17-
marginTop: rem(0.1 + size * 0.75),
18-
marginBottom: rem(0.1 + size * 0.75),
17+
marginTop: pxToRem(10 + size * 7.5),
18+
marginBottom: pxToRem(10 + size * 7.5),
1919
...(childrenExist(children)
2020
? {
2121
display: 'flex',
2222
alignItems: 'center',
2323
textAlign: 'center',
2424
lineHeight: 0,
25-
fontSize: rem(1.4 + size * 0.1),
25+
fontSize: pxToRem(14 + size),
2626
':before': {
2727
...beforeAndAfter(size, variables.borderRadius),
28-
marginRight: rem(1 + size * 0.2),
28+
marginRight: pxToRem(10 + size * 2),
2929
},
3030
':after': {
3131
...beforeAndAfter(size, variables.borderRadius),
32-
marginLeft: rem(1 + size * 0.2),
32+
marginLeft: pxToRem(10 + size * 2),
3333
},
3434
}
3535
: {
36-
borderRadius: rem(variables.borderRadius),
36+
borderRadius: pxToRem(variables.borderRadius),
3737
...dividerBorderRule(size),
3838
}),
3939
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default () => {
22
const vars: any = {}
33

4-
vars.borderRadius = 1
4+
vars.borderRadius = 10
55

66
return vars
77
}

0 commit comments

Comments
 (0)