Skip to content

Commit

Permalink
feat(presets): reorg presets
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Feb 8, 2021
1 parent 2c948e9 commit fdec8b1
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 61 deletions.
5 changes: 0 additions & 5 deletions presets/default.js

This file was deleted.

55 changes: 54 additions & 1 deletion utils/shorthands.js → presets/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
const tokens = {
space: [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64],
fontSize: ['3rem', '3rem', '2.2rem', '1.8rem', '1.4rem', '1rem', '0.875rem'],
fontWeight: [
'0',
'100',
'200',
'300',
'400',
'500',
'600',
'700',
'800',
'900',
'1000'
],
lineHeight: [1.1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6]
}

function px (v) {
return typeof v === 'number' ? v + 'px' : v
}
Expand Down Expand Up @@ -193,4 +212,38 @@ shorthands.fontWeight = shorthands.fe
shorthands.textAlign = shorthands.ta
shorthands.lineHeight = shorthands.lh

module.exports = shorthands
const macros = {
db: { d: 'block' },
dib: { d: 'inline-block' },
di: { d: 'inline' },
f: { d: 'flex' },
fw: { fw: 'wrap' },
ais: { ai: 'flex-start' },
aic: { ai: 'center' },
aie: { ai: 'flex-end' },
jcs: { jc: 'flex-start' },
jcc: { jc: 'center' },
jce: { jc: 'flex-end' },
jca: { jc: 'space-around' },
jcb: { jc: 'space-between' },
rel: { position: 'relative' },
abs: { position: 'absolute' },
fix: { position: 'fixed' },
top: { top: 0 },
bottom: { bottom: 0 },
left: { left: 0 },
right: { right: 0 },
cover: {
top: 0,
bottom: 0,
left: 0,
right: 0
},
w: { w: 1 },
h: { h: 1 },
tac: { ta: 'center' },
tar: { ta: 'right' },
taj: { ta: 'justify' }
}

module.exports = { tokens, shorthands, macros }
6 changes: 2 additions & 4 deletions test/hypostyle.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { hypostyle } from '../index'
import shorthands from '../utils/shorthands'
import macros from '../utils/macros'
import tokens from '../utils/tokens'
import * as defaults from '../presets/default'
import * as defaults from '../presets'

const { tokens, shorthands, macros } = defaults
const { css, style, flush } = hypostyle(defaults)

export default (test, assert) => {
Expand Down
33 changes: 0 additions & 33 deletions utils/macros.js

This file was deleted.

18 changes: 0 additions & 18 deletions utils/tokens.js

This file was deleted.

0 comments on commit fdec8b1

Please sign in to comment.