Sha256: bb3095eb3afef4f7023837da43cac516c716ac932a751d3e56ddb1b28faca158

Contents?: true

Size: 1.78 KB

Versions: 53

Compression:

Stored size: 1.78 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'

import {
  buildAriaProps,
  buildCss,
  buildDataProps,
} from '../utilities/props'
import { globalProps } from '../utilities/globalProps.js'

import Avatar from '../pb_avatar/_avatar'
import Icon from '../pb_icon/_icon'

type AvatarActionButtonProps = {
  action?: string,
  aria: Object,
  linkAriaLabel?: string,
  className?: string,
  dark?: boolean,
  data?: Object,
  id?: string,
  imageAlt?: string,
  imageUrl?: string,
  linkUrl?: string,
  name?: string,
  onClick?: string,
  placement?: string,
  size?: string,
}

const AvatarActionButton = (props: AvatarActionButtonProps) => {
  const {
    action = 'add',
    aria = {},
    linkAriaLabel,
    className,
    dark = false,
    data = {},
    id,
    imageAlt = '',
    imageUrl,
    linkUrl,
    name,
    onClick,
    placement = 'bottom left',
    size = 'md',
  } = props

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)

  const classes = classnames(buildCss(
    'pb_avatar_action_button_kit',
    [action],
    [placement],
    [size]),
  globalProps(props),
  className)

  const icons = {
    add: 'plus-circle',
    remove: 'times-circle',
  }

  return (
    <div
        {...ariaProps}
        {...dataProps}
        className={classes}
        id={id}
    >
      <a
          aria-label={linkAriaLabel}
          href={linkUrl}
          onClick={onClick}
      >
        <Avatar
            imageAlt={imageAlt}
            imageUrl={imageUrl}
            name={name}
            size={size}
        />
        <div className={`icon ${dark ? 'dark' : ''}`}>
          <Icon
              dark={dark}
              icon={icons[action]}
          />
        </div>
      </a>
    </div>
  )
}

export default AvatarActionButton

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
playbook_ui-10.14.1.pre.alpha1 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.14.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.13.1 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.13.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.13.0.pre.node.update app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.12.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.11.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.10.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.9.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.8.1.pre.alpha.flexdeps app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.9.0.pre.alpha1 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.8.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.7.1 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.7.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.6.2.pre.alpha.dep app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.6.1.pre.alpha1 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.6.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.5.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.4.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx
playbook_ui-10.3.0 app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx