Sha256: a2b66fded7c4e68245cb5cdd25e0fa16bd8814bb04c90e7a25af0aae3c05dd61

Contents?: true

Size: 1.6 KB

Versions: 37

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

37 entries across 37 versions & 1 rubygems

Version Path
playbook_ui-7.3.0.pre.alpha2 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.7.0.pre.alpha1 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.7.0 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.6.1 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.0.pre.alpha10 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.6.0 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.5.2 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.1.pre.alpha12 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.1.pre.alpha11 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.1.pre.alpha10 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.1.pre.alpha9 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.5.1 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-6.5.0 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.1.pre.alpha8 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.1.pre.alpha7 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.1.pre.alpha6 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.1.pre.alpha5 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.1.pre.alpha4 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.1.pre.alpha3 app/pb_kits/playbook/pb_message/_message.jsx
playbook_ui-7.0.1.pre.alpha2 app/pb_kits/playbook/pb_message/_message.jsx