Sha256: f0cf255f0ec90fdd758f6b39ab658f17a825dd5c2a502f798c6a7cf4106c9e1a

Contents?: true

Size: 1.6 KB

Versions: 7

Compression:

Stored size: 1.6 KB

Contents

/* @flow */

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

type MessageProps = {
  aria: object,
  avatarName?: String,
  avatarStatus?: String,
  avatarUrl?: String,
  className?: String,
  data?: object,
  id?: String,
  label?: String,
  message: String,
  timestamp?: String,
}

const Message = (props: MessageProps) => {
  const {
    aria = {},
    avatarName,
    avatarStatus = null,
    avatarUrl,
    className,
    data = {},
    id,
    label,
    message,
    timestamp,
  } = props
  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const shouldDisplayAvatar = avatarUrl || avatarName
  const baseClassName = shouldDisplayAvatar
    ? 'pb_message_kit_avatar'
    : 'pb_message_kit'

  const classes = classnames(buildCss(baseClassName), className, globalProps(props))

  return (
    <div
        {...ariaProps}
        {...dataProps}
        className={classes}
        id={id}
    >
      <If condition={shouldDisplayAvatar}>
        <Avatar
            imageUrl={avatarUrl}
            name={avatarName}
            size="sm"
            status={avatarStatus}
        />
      </If>
      <div className="content_wrapper">
        <If condition={label}>
          <Caption>{label}</Caption>
        </If>
        <Body>{message}</Body>
        <If condition={timestamp}>
          <Caption size="xs">{timestamp}</Caption>
        </If>
      </div>
    </div>
  )
}

export default Message

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
playbook_ui-6.1.0.pre.alpha5 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.1.0.pre.alpha4 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.1.0.pre.alpha3 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.1.0.pre.alpha2 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.1.0.pre.alpha1 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.1.0 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.0.1.pre.alpha6 app/pb_kits/playbook/pb_message/_message.jsx