Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

update level #61

@staydecent

Description

@staydecent
import check from 'check-arg-types'

const toType = check.prototype.toType

const classMap = {
  noPadding: 'no-padding',
  halfPadding: 'half-padding',
  notSpaced: 'not-spaced',
  withUnderline: 'with-underline'
}

const cls = (obj) =>
  'level ' +
  Object
    .keys(obj)
    .filter((k) => obj[k] === true)
    .map((k) => classMap[k])
    .join(' ')

const Level = ({
  // Components as props
  left,
  right,
  // CSS modifiers
  noPadding,
  halfPadding,
  notSpaced,
  withUnderline,
  // ...rest
  children,
  ...props
}) =>
  <div>
    {children.length > 0 &&
      <div class={cls({noPadding, halfPadding, notSpaced, withUnderline})}>
        {children}
      </div>}

    {!children.length &&
      <div class={cls({noPadding, halfPadding})}>
        <div class='level-left'>
          {toType(left) === 'function' ? left(props) : left}
        </div>
        <div class='level-right'>
          {toType(right) === 'function' ? right(props) : right}
        </div>
      </div>}
  </div>

export default Level

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions