Skip to content

Commit

Permalink
Merge branch 'main' into feat/235-v5-new-tooltip-component
Browse files Browse the repository at this point in the history
  • Loading branch information
ksolanki7 authored Jan 13, 2025
2 parents 8ebdc21 + 5e0a20e commit cc19708
Show file tree
Hide file tree
Showing 79 changed files with 1,939 additions and 1,385 deletions.
4 changes: 2 additions & 2 deletions src/components/avatar-button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export const ElAvatarButton = styled.button`
${ElAvatar} {
box-shadow:
0px 0px 0px 1px #fff,
0px 0px 0px 4px var(--Colours-Purple-purple-300, #7e9bfa);
0px 0px 0px 4px var(--purple-300);
}
}
&:hover ${ElAvatar} {
background: var(--fill-colour-fill-action-light, #d6e1ff);
background: var(--fill-action-light);
}
`
22 changes: 8 additions & 14 deletions src/components/avatar-rectangle/avatar-rectangle.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta, Canvas, Controls } from '@storybook/blocks'
import { Meta, Canvas, Controls, Description } from '@storybook/blocks'
import { RenderHtmlMarkup } from '../../storybook/render-html-markup'
import * as AvatarRectangleStories from './avatar-rectangle.stories'

Expand All @@ -10,30 +10,24 @@ A versatile component designed to render property image.

<Controls />

## Default Usage

The default usage use the residential variant and medium size, each can be set using the `data-` attribute.
## Default

<Description of={AvatarRectangleStories.DefaultUsage} />
<Canvas of={AvatarRectangleStories.DefaultUsage} />
<RenderHtmlMarkup of={AvatarRectangleStories.DefaultUsage} />

## Avatar Rectangle Variant

<Canvas of={AvatarRectangleStories.AvatarRectangleVariant} />
<RenderHtmlMarkup of={AvatarRectangleStories.AvatarRectangleVariant} />

## Using Residential Placeholder

<Canvas of={AvatarRectangleStories.UsingResidentialPlaceholder} />
<RenderHtmlMarkup of={AvatarRectangleStories.UsingResidentialPlaceholder} />

## Using Commercial Variant

<Canvas of={AvatarRectangleStories.UsingCommercialVariant} />
<RenderHtmlMarkup of={AvatarRectangleStories.UsingCommercialPlaceholder} />

## Using Commercial Placeholder

<Canvas of={AvatarRectangleStories.UsingCommercialPlaceholder} />
<RenderHtmlMarkup of={AvatarRectangleStories.UsingCommercialPlaceholder} />

## React Usage

<Canvas of={AvatarRectangleStories.ReactUsage} />

<RenderHtmlMarkup of={AvatarRectangleStories.ReactUsage} />
45 changes: 14 additions & 31 deletions src/components/avatar-rectangle/avatar-rectangle.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import type { Meta, StoryObj } from '@storybook/react'
import { AvatarRectangle } from '.'
import {
ElAvatarRectangle,
ElAvatarRectResidentialPlaceholder,
ElAvatarRectBottomImage,
ElAvatarRectCommercialPlaceholder,
} from './styles'
import { ElAvatarRectResidentialPlaceholder, ElAvatarRectCommercialPlaceholder } from './styles'

export default {
title: 'Components/Avatar Rectangle',
component: AvatarRectangle,
args: {
variant: 'residential',
size: 'medium',
src: 'https://picsum.photos/id/206/100/100',
},
argTypes: {
variant: {
Expand All @@ -26,36 +22,23 @@ export default {
},
} as Meta<typeof AvatarRectangle>

const exampleImageUrl = 'https://picsum.photos/id/206/100/100'
type Story = StoryObj<typeof AvatarRectangle>

export const DefaultUsage = {
render: ({}) => (
<ElAvatarRectangle>
<img src={exampleImageUrl} alt="example" />
</ElAvatarRectangle>
),
}
/**
* The default usage use the residential variant and medium size, each can be set using the `data-` attribute.
*/
export const DefaultUsage: Story = {}

export const UsingResidentialPlaceholder = {
render: ({}) => <ElAvatarRectResidentialPlaceholder aria-label="Image placeholder" />,
export const AvatarRectangleVariant: Story = {
args: {
variant: 'commercial',
},
}

export const UsingCommercialVariant = {
render: ({}) => (
<ElAvatarRectangle data-variant="commercial">
<img src={exampleImageUrl} alt="example" />
<ElAvatarRectBottomImage aria-hidden="true" />
</ElAvatarRectangle>
),
export const UsingResidentialPlaceholder = {
render: () => <ElAvatarRectResidentialPlaceholder aria-label="Image placeholder" />,
}

export const UsingCommercialPlaceholder = {
render: ({}) => <ElAvatarRectCommercialPlaceholder aria-label="Image placeholder" />,
}

export const ReactUsage: StoryObj<typeof AvatarRectangle> = {
args: {
src: exampleImageUrl,
},
render: (props) => <AvatarRectangle {...props}></AvatarRectangle>,
render: () => <ElAvatarRectCommercialPlaceholder aria-label="Image placeholder" />,
}
10 changes: 5 additions & 5 deletions src/components/avatar-rectangle/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import CommercialBottomImage from './icons/bottom-commercial-image.svg?react'
import CommercialSmallBottomImage from './icons/bottom-commercial-image-small.svg?react'

const baseAvatarRectMediumSize = `
width: var(--size-size-12, 72px);
width: var(--size-18);
height: 54px;
`

const baseAvatarRectSmallSize = `
width: var(--size-size-11, 64px);
height: var(--size-size-9, 48px);
width: var(--size-16);
height: var(--size-12);
`

// The commercial consists of two sections: the commercial image and the bottom placeholder.
const baseCommercialMediumImagesSize = `
width: 54px;
height: var(--size-size-8, 40px);
height: var(--size-10);
`

const baseCommercialBottomSmallPlaceholderSize = `
width: var(--size-size-9, 48px);
width: var(--size-12);
height: 36px;
`

Expand Down
42 changes: 19 additions & 23 deletions src/components/avatar/avatar.mdx
Original file line number Diff line number Diff line change
@@ -1,47 +1,43 @@
import { Meta, Story, Canvas, Controls } from '@storybook/blocks'
import { Meta, Story, Canvas, Controls, Description
} from '@storybook/blocks'
import { RenderHtmlMarkup } from '../../storybook/render-html-markup'
import * as AvatarStories from './avatar.stories'

<Meta of={AvatarStories} />

# Avatar

An avatar component to be used typically with a `Card` or `Nav` component. The default variant renders a circle with children.
<Description of={AvatarStories.Default} />

There are multiple variants that can be used by utilizing the data props, such as size, colour, and shape (see the HTML version of React usage). In addition to text, it also accepts an Icon as a child.

## Style Only Usage

<Canvas of={AvatarStories.StyleOnlyUsage} />
<Controls />

<RenderHtmlMarkup of={AvatarStories.StyleOnlyUsage} />
## Default

<Canvas of={AvatarStories.WithIconUsage} />
<Canvas of={AvatarStories.Default} />

<RenderHtmlMarkup of={AvatarStories.WithIconUsage} />
<RenderHtmlMarkup of={AvatarStories.Default} />

## With Colour
## Avatar with Icon

<Canvas of={AvatarStories.WithColour} />
<Canvas of={AvatarStories.AvatarWithIcon} />

<RenderHtmlMarkup of={AvatarStories.WithColour} />
<RenderHtmlMarkup of={AvatarStories.AvatarWithIcon} />

## With Square Shape

<Canvas of={AvatarStories.WithSquareShape} />
## Avatar Colour

<RenderHtmlMarkup of={AvatarStories.WithSquareShape} />
<Canvas of={AvatarStories.AvatarColour} />

## With Small Size
<RenderHtmlMarkup of={AvatarStories.AvatarColour} />

<Canvas of={AvatarStories.WithSmallSize} />
## Avatar Shape

<RenderHtmlMarkup of={AvatarStories.WithSmallSize} />
<Canvas of={AvatarStories.AvatarShape} />

## React Usage
<RenderHtmlMarkup of={AvatarStories.AvatarShape} />

<Controls />
## Avatar Size

<Canvas of={AvatarStories.ReactUsage} />
<Canvas of={AvatarStories.AvatarSize} />

<RenderHtmlMarkup of={AvatarStories.ReactUsage} />WithColourWithColour
<RenderHtmlMarkup of={AvatarStories.AvatarSize} />
62 changes: 31 additions & 31 deletions src/components/avatar/avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
import type { StoryObj } from '@storybook/react'
import { Avatar, ElAvatar } from '.'
import type { Meta, StoryObj } from '@storybook/react'
import { Avatar } from '.'
import { Icon } from '../icon'

export default {
title: 'Components/Avatar',
component: Avatar,
}
args: {
children: 'AD',
},
} as Meta<typeof Avatar>

export const StyleOnlyUsage = {
render: ({}) => <ElAvatar>AD</ElAvatar>,
}
type Story = StoryObj<typeof Avatar>

/**
* An avatar component to be used typically with a `Card` or `Nav` component.
* The default variant renders a circle with children.
*
* There are multiple variants that can be used by utilizing the `data-` props
* such as `size`, `colour`, and `shape` (see the HTML version of each version).
* In addition to text, it also accepts an Icon as a child.
*/
export const Default: Story = {}

export const WithIconUsage = {
render: ({}) => (
<ElAvatar>
export const AvatarWithIcon: Story = {
render: (props) => (
<Avatar {...props}>
<Icon icon="contact" />
</ElAvatar>
</Avatar>
),
}

export const WithColour = {
render: ({}) => <ElAvatar data-colour="purple">AD</ElAvatar>,
name: 'Colour: Purple',
}

export const WithSquareShape = {
render: ({}) => <ElAvatar data-shape="square">AD</ElAvatar>,
name: 'Shape: Square',
export const AvatarColour: Story = {
args: {
colour: 'purple',
},
}

export const WithSmallSize = {
render: ({}) => (
<ElAvatar data-size="small">
<Icon icon="contact" />
</ElAvatar>
),
name: 'Size: Small',
export const AvatarShape: Story = {
args: {
shape: 'square',
},
}

export const ReactUsage: StoryObj<typeof Avatar> = {
export const AvatarSize: Story = {
args: {
shape: 'circle',
size: 'medium',
colour: 'default',
children: 'AD',
size: 'small',
},
render: (props) => <Avatar {...props}>{props.children}</Avatar>,
}
38 changes: 19 additions & 19 deletions src/components/avatar/styles.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { styled } from '@linaria/react'

const baseCircleStyle = `
border-radius: var(--corner-3xl, 24px);
border-radius: var(--corner-3xl);
`

const baseMediumSizeStyle = `
width: var(--size-8, 40px);
height: var(--size-8, 40px);
font-size: var(--font-size-base, 15px);
line-height: var(--line-height-base, 24px);
letter-spacing: var(--letter-spacing-base, -0.15px);
width: var(--size-10);
height: var(--size-10);
font-size: var(--font-size-base);
line-height: var(--line-height-base);
letter-spacing: var(--letter-spacing-base);
`

const baseColourDefaultStyle = `
background: var(--fill-default-medium, #9faebc);
color: var(--text-white, #fff);
background: var(--fill-default-medium);
color: var(--text-white);
/* override Icon element colour */
svg {
color: var(--text-white, #fff);
color: var(--text-white);
}
`

Expand All @@ -28,7 +28,7 @@ export const ElAvatar = styled.span`
justify-content: center;
align-items: center;
text-align: center;
font-family: var(--font-family, Inter);
font-family: var(--font-family);
font-style: normal;
font-weight: 600;
Expand All @@ -37,23 +37,23 @@ export const ElAvatar = styled.span`
${baseMediumSizeStyle}
&[data-shape='square'] {
border-radius: var(--corner-lg, 8px);
border-radius: var(--corner-lg);
}
&[data-colour='purple'] {
background: var(--fill-action-lightest, #ecf3ff);
color: var(--text-action, #4e56ea);
background: var(--fill-action-lightest);
color: var(--text-action);
/* override Icon element colour */
svg {
color: var(--text-action, #4e56ea);
color: var(--text-action);
}
}
&[data-size='small'] {
width: var(--size-7, 32px);
height: var(--size-7, 32px);
font-size: var(--font-size-2xs, 12px);
line-height: var(--line-height-2xs, 16px);
letter-spacing: var(--letter-spacing-2xs, -0.12px);
width: var(--size-8);
height: var(--size-8);
font-size: var(--font-size-2xs);
line-height: var(--line-height-2xs);
letter-spacing: var(--letter-spacing-2xs);
}
`
Loading

0 comments on commit cc19708

Please sign in to comment.