UNPKG

@workday/canvas-kit-preview-react

Version:

Canvas Kit Preview is made up of components that have the full design and a11y review, are part of the DS ecosystem and are approved for use in product. The API's could be subject to change, but not without strong communication and migration strategies.

14 lines (13 loc) 774 B
import React from 'react'; import { createSubcomponent } from '@workday/canvas-kit-react/common'; import { Avatar } from '@workday/canvas-kit-react/avatar'; import { usePillModel } from './usePillModel'; import { px2rem } from '@workday/canvas-kit-styling'; // When the component is created, it needs to be a button element to match AvatarProps. // Once Avatar becomes a `createComponent` we can default the element type to a `div` // and the types should be properly extracted export const PillAvatar = createSubcomponent('div')({ modelHook: usePillModel, })(({ ...elemProps }, Element, model) => { return (React.createElement(Avatar, { style: { opacity: model.state.disabled ? '.7' : '1' }, size: px2rem(18), as: Element, altText: undefined, ...elemProps })); });