Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/storybook/person/avtar/data source #2432

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fluffy-ads-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@equinor/fusion-react-components-stories': patch
---

Updating PersonAvatar story with dataSource
31 changes: 31 additions & 0 deletions storybook/src/stories/person/avatar/avatar.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Meta, Markdown, ArgTypes, Canvas } from '@storybook/blocks';
import * as avatarStories from './avatar.stories';


<Meta title="Person/Avatar" />

## Avatar
<ArgTypes of={ avatarStories.basic } />

### Basic
<Canvas of={ avatarStories.basic } meta={avatarStories} story={{height: '350px'}}/>

### Sizes
<Canvas of={ avatarStories.sizes } meta={avatarStories} story={{height: '350px'}}/>

### withDataSource

The avatar will not resolve any data about the user when using property `dataSource`, so the persons avatar will be the users initial as provided in `dataSource`.

When using `dataSource` be sure to add the property `trigger="none"` to prevent the personCard from opening when hovering/clicking on the avatar since it will not resolve a user.

<Canvas of={ avatarStories.withDataSource } meta={avatarStories} story={{height: '350px'}}/>

### Clickable
<Canvas of={ avatarStories.clickable } meta={avatarStories} story={{height: '350px'}}/>

### Trigger none
<Canvas of={ avatarStories.disableCard } meta={avatarStories}/>

### disabled
<Canvas of={ avatarStories.disabled } meta={avatarStories} />
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import { Meta, StoryObj } from '@storybook/react';

import { PersonAvatar } from '@equinor/fusion-react-person/src/PersonAvatar';
import { AvatarSize, PersonDetails } from '@equinor/fusion-react-person/src/index';
import { AvatarSize, AvatarData } from '@equinor/fusion-react-person/src/index';
import { PersonProvider } from '@equinor/fusion-react-person/src/PersonProvider';
import { Theme } from '../../components/Theme';
import { Theme } from '../../../components/Theme';

import { resolver } from './person-provider';
import { resolver } from '../person-provider';

import { faker } from '@faker-js/faker';
import { Story } from '@storybook/blocks';
faker.seed(123);

const meta: Meta<typeof PersonAvatar> = {
Expand Down Expand Up @@ -46,10 +47,23 @@ export const sizes: Story = {
),
};

const person: AvatarData = resolver.getInfo
? (resolver.getInfo({ azureId: faker.string.uuid() }) as AvatarData)
: {
name: faker.person.fullName(),
accountType: 'Employee',
accountClassification: 'Internal',
};

export const withDataSource: Story = {
...basic,
args: {
dataSource: resolver.getInfo ? (resolver.getInfo({ azureId: faker.string.uuid() }) as PersonDetails) : undefined,
dataSource: {
name: person.name,
accountType: person.accountType,
accountClassification: person.accountClassification,
},
trigger: 'none',
},
};

Expand Down
9 changes: 7 additions & 2 deletions storybook/src/stories/person/person.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import changelogReact from '#packages/person/CHANGELOG.md?raw';

import { ChangeLog, PackageInfo } from '../../components';

import * as avatarStories from './avatar.stories';
import * as avatarStories from './avatar/avatar.stories';
import * as cardStories from './card.stories';
import * as selectStories from './select.stories';
import * as cellStories from './cell.stories';


<Meta title="Person/Docs" />
<Meta title="Person" />

<PackageInfo pkg={pkg} />

Expand All @@ -29,6 +29,11 @@ import * as cellStories from './cell.stories';
<Canvas of={ avatarStories.sizes } meta={avatarStories} story={{height: '350px'}}/>

### withDataSource

The avatar will not resolve any data about the user when using property `dataSource`, so the persons avatar will be the users initial as provided in `dataSource`.

When using `dataSource` be sure to add the property `trigger="none"` to prevent the personCard from opening when hovering/clicking on the avatar since it will not resolve a user.

<Canvas of={ avatarStories.withDataSource } meta={avatarStories} story={{height: '350px'}}/>

### Clickable
Expand Down
Loading