Skip to content
Closed
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ node_modules

# Gatsby
public/
# Allow Storybook's static assets directory
!packages/react/.storybook/public/

# Storybook
storybook-static
Expand Down
3 changes: 3 additions & 0 deletions packages/react/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This file has been automatically migrated to valid ESM format by Storybook.
import {fileURLToPath} from 'node:url'
import {createRequire} from 'node:module'
import path from 'node:path'
import react from '@vitejs/plugin-react'
Expand All @@ -11,6 +12,8 @@ const require = createRequire(import.meta.url)
const {DEPLOY_ENV = 'development'} = process.env

const config: StorybookConfig = {
staticDirs: [path.join(path.dirname(fileURLToPath(import.meta.url)), 'public')],

stories:
DEPLOY_ENV === 'development'
? ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)']
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {Button, Avatar, ActionMenu, IconButton, ActionList, Textarea} from '..'
import {Dialog} from '../deprecated/DialogV1'
import {Divider} from '../deprecated/ActionList/Divider'
import mockData from '../experimental/SelectPanel2/mock-story-data'
import {avatarUrl} from '../utils/story-helpers'
import classes from './ActionBar.examples.stories.module.css'
import type {ActionBarMenuItemProps} from './ActionBar'

Expand Down Expand Up @@ -201,7 +202,7 @@ export const ActionbarToggle = () => {
<div className={classes.ActionBarToggleContainer}>
<div className={classes.ActionBarToggleTop}>
<div>
<Avatar src={`https://github.com/${loginName}.png`} size={30} />
<Avatar src={avatarUrl(loginName)} size={30} />
<Text as="strong" className={classes.ActionBarToggleUser}>
{loginName}
</Text>
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/ActionList/ActionList.dev.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Avatar from '../Avatar'
import {FileDirectoryIcon, HeartFillIcon} from '@primer/octicons-react'
import {Stack} from '../Stack'
import {AnchoredOverlay} from '../AnchoredOverlay'
import {avatarUrl} from '../utils/story-helpers'

export default {
title: 'Components/ActionList/Dev',
Expand Down Expand Up @@ -55,7 +56,7 @@ export const GroupWithSubtleTitleOldAPI = () => {
onSelect={() => toggleAssignee(user)}
>
<ActionList.LeadingVisual>
<Avatar src={`https://github.com/${user.login}.png`} />
<Avatar src={avatarUrl(user.login)} />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot avatarUrl function does so little, just use the url directly in all the files which have this function and remove the helper (same for teamAvatar)

Suggested change
<Avatar src={avatarUrl(user.login)} />
<Avatar src={`/avatars/€{user.login}.png`} />

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0771514. Replaced all avatarUrl()/teamAvatarUrl() calls with inline template literals (e.g. `/avatars/${user.login}.png`) and removed both helper functions from story-helpers.tsx.

</ActionList.LeadingVisual>
{user.login}
<ActionList.Description>{user.name}</ActionList.Description>
Expand Down Expand Up @@ -95,7 +96,7 @@ export const GroupWithFilledTitleOldAPI = () => {
onSelect={() => toggleAssignee(user)}
>
<ActionList.LeadingVisual>
<Avatar src={`https://github.com/${user.login}.png`} />
<Avatar src={avatarUrl(user.login)} />
</ActionList.LeadingVisual>
{user.login}
<ActionList.Description>{user.name}</ActionList.Description>
Expand Down
17 changes: 9 additions & 8 deletions packages/react/src/ActionList/ActionList.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
ProjectIcon,
} from '@primer/octicons-react'
import {KeybindingHint} from '../KeybindingHint'
import {avatarUrl, teamAvatarUrl} from '../utils/story-helpers'
import classes from './ActionList.features.stories.module.css'

export default {
Expand Down Expand Up @@ -194,7 +195,7 @@ export const WithAvatars = () => (
{users.map(user => (
<ActionList.Item key={user.login}>
<ActionList.LeadingVisual>
<Avatar src={`https://github.com/${user.login}.png`} />
<Avatar src={avatarUrl(user.login)} />
</ActionList.LeadingVisual>
{user.login}
</ActionList.Item>
Expand Down Expand Up @@ -225,7 +226,7 @@ export const InlineDescription = () => (
{users.map(user => (
<ActionList.Item key={user.login}>
<ActionList.LeadingVisual>
<Avatar src={`https://github.com/${user.login}.png`} />
<Avatar src={avatarUrl(user.login)} />
</ActionList.LeadingVisual>
{user.login}
<ActionList.Description>{user.name}</ActionList.Description>
Expand All @@ -239,7 +240,7 @@ export const BlockDescription = () => (
{users.map(user => (
<ActionList.Item key={user.login}>
<ActionList.LeadingVisual>
<Avatar src={`https://github.com/${user.login}.png`} />
<Avatar src={avatarUrl(user.login)} />
</ActionList.LeadingVisual>
{user.login}
<ActionList.Description variant="block">{user.name}</ActionList.Description>
Expand Down Expand Up @@ -644,9 +645,9 @@ export const ConditionalChildren = () => {
<ActionList.Item key={index}>
<ActionList.LeadingVisual>
{reviewer.type === 'team' ? (
<Avatar src={`https://avatars.githubusercontent.com/t/${reviewer.id}`} />
<Avatar src={teamAvatarUrl(reviewer.id!)} />
) : (
<Avatar src={`https://avatars.githubusercontent.com/${reviewer.login}`} />
<Avatar src={avatarUrl(reviewer.login!)} />
)}
</ActionList.LeadingVisual>
{reviewer.login || reviewer.slug}
Expand Down Expand Up @@ -687,7 +688,7 @@ export const ChildWithSideEffects = () => {
<ActionList selectionVariant="multiple" role="listbox" aria-label="Assignees">
<ActionList.Item selected={selected} onSelect={() => setSelected(!selected)} role="option">
<ActionList.LeadingVisual>
<Avatar src={`https://avatars.githubusercontent.com/${user.login}`} />
<Avatar src={avatarUrl(user.login)} />
</ActionList.LeadingVisual>
{user.login}
<ActionList.Description>
Expand Down Expand Up @@ -758,7 +759,7 @@ export const GroupWithSubtleTitle = () => {
onSelect={() => toggleAssignee(user)}
>
<ActionList.LeadingVisual>
<Avatar src={`https://github.com/${user.login}.png`} />
<Avatar src={avatarUrl(user.login)} />
</ActionList.LeadingVisual>
{user.login}
<ActionList.Description>{user.name}</ActionList.Description>
Expand Down Expand Up @@ -792,7 +793,7 @@ export const GroupWithFilledTitle = () => {
onSelect={() => toggleAssignee(user)}
>
<ActionList.LeadingVisual>
<Avatar src={`https://github.com/${user.login}.png`} />
<Avatar src={avatarUrl(user.login)} />
</ActionList.LeadingVisual>
{user.login}
<ActionList.Description>{user.name}</ActionList.Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {
const hoverCard = (
<Stack gap="condensed" style={{padding: '16px'}}>
<Stack direction="horizontal" gap="condensed" justify="space-between">
<Avatar src="https://avatars.githubusercontent.com/u/7143434?v=4" size={48} />
<Avatar src="/avatars/mona.png" size={48} />
<Button size="small">Follow</Button>
</Stack>
<Stack direction="horizontal" gap="none">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
const hoverCard = (
<Stack gap="condensed" style={{padding: '16px'}}>
<Stack direction="horizontal" gap="condensed" justify="space-between">
<Avatar src="https://avatars.githubusercontent.com/u/7143434?v=4" size={48} />
<Avatar src="/avatars/mona.png" size={48} />
<Button size="small">Follow</Button>
</Stack>
<Stack direction="horizontal" gap="none">
Expand Down
86 changes: 23 additions & 63 deletions packages/react/src/Avatar/Avatar.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,36 @@ export default {
component: Avatar,
} as Meta<typeof Avatar>

export const Square = () => <Avatar square alt="primer" src="https://avatars.githubusercontent.com/primer" />
export const Square = () => <Avatar square alt="primer" src="/avatars/primer.png" />

export const Size = () => (
<div>
<Avatar size={4} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={8} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={12} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={16} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={20} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={24} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={28} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={32} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={40} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={48} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={56} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={64} alt="mona" src="https://avatars.githubusercontent.com/u/7143434?v=4" />
<Avatar size={4} alt="mona" src="/avatars/mona.png" />
<Avatar size={8} alt="mona" src="/avatars/mona.png" />
<Avatar size={12} alt="mona" src="/avatars/mona.png" />
<Avatar size={16} alt="mona" src="/avatars/mona.png" />
<Avatar size={20} alt="mona" src="/avatars/mona.png" />
<Avatar size={24} alt="mona" src="/avatars/mona.png" />
<Avatar size={28} alt="mona" src="/avatars/mona.png" />
<Avatar size={32} alt="mona" src="/avatars/mona.png" />
<Avatar size={40} alt="mona" src="/avatars/mona.png" />
<Avatar size={48} alt="mona" src="/avatars/mona.png" />
<Avatar size={56} alt="mona" src="/avatars/mona.png" />
<Avatar size={64} alt="mona" src="/avatars/mona.png" />
</div>
)

export const SizeResponsive = () => (
<div>
<Avatar
size={{narrow: 4, regular: 8, wide: 12}}
alt="mona"
src="https://avatars.githubusercontent.com/u/7143434?v=4"
/>
<Avatar
size={{narrow: 8, regular: 12, wide: 16}}
alt="mona"
src="https://avatars.githubusercontent.com/u/7143434?v=4"
/>
<Avatar
size={{narrow: 12, regular: 16, wide: 20}}
alt="mona"
src="https://avatars.githubusercontent.com/u/7143434?v=4"
/>
<Avatar
size={{narrow: 16, regular: 20, wide: 24}}
alt="mona"
src="https://avatars.githubusercontent.com/u/7143434?v=4"
/>
<Avatar
size={{narrow: 20, regular: 24, wide: 28}}
alt="mona"
src="https://avatars.githubusercontent.com/u/7143434?v=4"
/>
<Avatar
size={{narrow: 24, regular: 28, wide: 32}}
alt="mona"
src="https://avatars.githubusercontent.com/u/7143434?v=4"
/>
<Avatar
size={{narrow: 28, regular: 32, wide: 40}}
alt="mona"
src="https://avatars.githubusercontent.com/u/7143434?v=4"
/>
<Avatar
size={{narrow: 32, regular: 40, wide: 48}}
alt="mona"
src="https://avatars.githubusercontent.com/u/7143434?v=4"
/>
<Avatar
size={{narrow: 40, regular: 48, wide: 56}}
alt="mona"
src="https://avatars.githubusercontent.com/u/7143434?v=4"
/>
<Avatar
size={{narrow: 48, regular: 56, wide: 64}}
alt="mona"
src="https://avatars.githubusercontent.com/u/7143434?v=4"
/>
<Avatar size={{narrow: 4, regular: 8, wide: 12}} alt="mona" src="/avatars/mona.png" />
<Avatar size={{narrow: 8, regular: 12, wide: 16}} alt="mona" src="/avatars/mona.png" />
<Avatar size={{narrow: 12, regular: 16, wide: 20}} alt="mona" src="/avatars/mona.png" />
<Avatar size={{narrow: 16, regular: 20, wide: 24}} alt="mona" src="/avatars/mona.png" />
<Avatar size={{narrow: 20, regular: 24, wide: 28}} alt="mona" src="/avatars/mona.png" />
<Avatar size={{narrow: 24, regular: 28, wide: 32}} alt="mona" src="/avatars/mona.png" />
<Avatar size={{narrow: 28, regular: 32, wide: 40}} alt="mona" src="/avatars/mona.png" />
<Avatar size={{narrow: 32, regular: 40, wide: 48}} alt="mona" src="/avatars/mona.png" />
<Avatar size={{narrow: 40, regular: 48, wide: 56}} alt="mona" src="/avatars/mona.png" />
<Avatar size={{narrow: 48, regular: 56, wide: 64}} alt="mona" src="/avatars/mona.png" />
</div>
)
11 changes: 2 additions & 9 deletions packages/react/src/Avatar/Avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,10 @@ type Args = {
sizeAtWide?: number
} & Omit<AvatarProps, 'size'>

export const Default = () => <Avatar src="https://avatars.githubusercontent.com/u/7143434?v=4" />
export const Default = () => <Avatar src="/avatars/mona.png" />

export const Playground: StoryFn<Args> = args => {
return (
<Avatar
size={parseSizeFromArgs(args)}
square={args.square}
src="https://avatars.githubusercontent.com/u/7143434?v=4"
alt="mona"
/>
)
return <Avatar size={parseSizeFromArgs(args)} square={args.square} src="/avatars/mona.png" alt="mona" />
}

Playground.args = {
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/AvatarStack/AvatarStack.dev.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ export default {
export const WithLinkWrappers = () => (
<AvatarStack>
<Link aria-label="Primer is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
<Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
<Avatar alt="Primer logo" src="/avatars/primer.png" />
</Link>
<Link aria-label="GitHub is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
<Avatar alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
<Avatar alt="GitHub logo" src="/avatars/github.png" />
</Link>
<Link aria-label="Atom is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
<Avatar alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
<Avatar alt="Atom logo" src="/avatars/atom.png" />
</Link>
<Link aria-label="GitHub Desktop is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
<Avatar alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
<Avatar alt="GitHub Desktop logo" src="/avatars/desktop.png" />
</Link>
</AvatarStack>
)
Loading
Loading