Sha256: a56085df7bad3be94dfe584d753a78a7536ab629777f58f3553c155c6df745f8

Contents?: true

Size: 1.97 KB

Versions: 56

Compression:

Stored size: 1.97 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { Body, Caption, Flex, IconCircle, Title } from '../'
import { globalProps } from '../utilities/globalProps.js'

type IconStatValueProps = {
  aria?: object,
  className?: string,
  data?: object,
  icon: string,
  id?: string,
  orientation?: "vertical" | "horizontal",
  size?: "sm" | "md" | "lg",
  text?: string,
  unit?: string,
  value: number,
  variant?: "default"
    | "royal"
    | "blue"
    | "purple"
    | "teal"
    | "red"
    | "yellow"
    | "green",
}

const IconStatValue = (props: IconStatValueProps) => {
  const {
    aria = {},
    className,
    data = {},
    icon,
    id,
    orientation = 'horizontal',
    size = 'sm',
    text = '',
    unit = '',
    value = 0,
    variant = 'default',
  } = props
  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(
    buildCss('pb_icon_stat_value_kit', orientation, size, variant), globalProps(props),
    className
  )
  const titleSize = function(size) {
    if (size == 'lg') {
      return (
        <Title
            size={1}
            text={`${value}`}
        />
      )
    } else if (size == 'md') {
      return (
        <Title
            size={2}
            text={`${value}`}
        />
      )
    } else {
      return (
        <Title
            size={3}
            text={`${value}`}
        />
      )
    }
  }

  return (
    <div
        {...ariaProps}
        {...dataProps}
        className={classes}
        id={id}
    >
      <IconCircle
          icon={icon}
          size={size}
          variant={variant}
      />

      <div>
        <Flex
            vertical="bottom"
        >
          {titleSize(size)}
          &nbsp;
          <Body
              text={unit}
          />
        </Flex>
        <Caption text={text} />
      </div>

    </div>
  )
}

export default IconStatValue

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
playbook_ui-9.1.0 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-9.0.0 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.3.0.alpha.select.pre.margin app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.3.0 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.2.1.pre.alpha5 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.2.1.pre.alpha4 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.2.1.alpha.iconacc app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.2.1.pre.alpha3 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.2.1.pre.alpha2 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.3.0.deps2 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.3.0.pre.alpha1 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.2.1.pre.alpha1 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.2.1 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.1.3 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.4.0.alpha.dependencies.2 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.4.0.alpha.dependencies.1 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.2.0.pre.alpha4 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.2.0.pre.alpha3 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.2.0 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx
playbook_ui-8.1.2 app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx