From a04e4767308dddee4e331b1756e0e6a0e37d535b Mon Sep 17 00:00:00 2001 From: "krissy.conant" Date: Mon, 24 Jun 2024 17:57:57 -0400 Subject: [PATCH 01/31] Starting refactor of Avatar component using storybook - WIP as breaking build --- modules/react/avatar/lib/Avatar.tsx | 293 ++++++++++++---------- modules/react/avatar/spec/Avatar.spec.tsx | 45 +++- 2 files changed, 202 insertions(+), 136 deletions(-) diff --git a/modules/react/avatar/lib/Avatar.tsx b/modules/react/avatar/lib/Avatar.tsx index 010886d5ea..0c643f9f18 100644 --- a/modules/react/avatar/lib/Avatar.tsx +++ b/modules/react/avatar/lib/Avatar.tsx @@ -1,49 +1,17 @@ import React, {useState} from 'react'; import {Property} from 'csstype'; -import {styled, focusRing, hideMouseFocus} from '@workday/canvas-kit-react/common'; -import isPropValid from '@emotion/is-prop-valid'; -import {borderRadius, colors} from '@workday/canvas-kit-react/tokens'; -import {SystemIconCircle, SystemIconCircleSize} from '@workday/canvas-kit-react/icon'; +import { + createComponent, + focusRing, + hideMouseFocus, + pickForegroundColor, +} from '@workday/canvas-kit-react/common'; +import {cssVar, createStencil, px2rem, calc} from '@workday/canvas-kit-styling'; +import {mergeStyles} from '@workday/canvas-kit-react/layout'; +import {borderRadius} from '@workday/canvas-kit-react/tokens'; +import {SystemIconCircleSize, SystemIcon, systemIconStencil} from '@workday/canvas-kit-react/icon'; import {userIcon} from '@workday/canvas-system-icons-web'; - -export enum AvatarVariant { - Light, - Dark, -} - -export interface AvatarProps extends React.ButtonHTMLAttributes { - /** - * The variant of the Avatar default state. Accepts `Light` or `Dark`. - * @default AvatarVariant.Light - */ - variant?: AvatarVariant; - /** - * The size of the Avatar. - * @default SystemIconCircleSize.m - */ - size?: SystemIconCircleSize | number; - /** - * The alt text of the Avatar image. This prop is also used for the aria-label - * @default Avatar - */ - altText?: string; - /** - * The url of the Avatar image. - */ - url?: string; - /** - * The alternative container type for the button. Uses Emotion's special `as` prop. - * Will render an `div` tag instead of a `button` when defined. - */ - as?: 'div'; - /** - * The object-fit CSS property sets how the content of a replaced element, - * such as an `` or `