Skip to content

Instantly share code, notes, and snippets.

@queckezz
Last active September 15, 2015 15:32
Show Gist options
  • Save queckezz/fad6b982b734d5a6bed6 to your computer and use it in GitHub Desktop.
Save queckezz/fad6b982b734d5a6bed6 to your computer and use it in GitHub Desktop.

Spacings

Paddings

  • all
  • x, y

Margins

  • all
  • top, right, bottom, left
  • x, y
  • auto
paddings.all[0] // 0 til 4
/**
* given a model and a direction it returns a function which given
* a `size` returns an object like `{ paddingLeft: 0 }`
*/
const gen =
(model, direction) =>
(size) => ({ [model + upper(direction)]: size })
//generateDirections('margin', ['top', 'bottom'])
const left = gen('padding', 'left')
const right = gen('padding', 'right')
const top = gen('padding', 'top')
const bottom = gen('padding', 'bottom')
const all = size => ({ padding: size })
const x = size => ({ ...left(size), ...right(size) })
// or: const x = size => mergeAll([ left(size), right(size) ])
const y = size => ({ ...top(size), ...bottom(size) })
const left = gen('margin', 'left')
const right = gen('margin', 'right')
const top = gen('margin', 'top')
const bottom = gen('margin', 'bottom')
const all = size => ({ margin: size })
const x = size => ({ ...left(size), ..right(size) })
const y = size => ({ ...top(size), ..bottom(size) })
const auto = () => x('auto')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment