Skip to content

Commit

Permalink
docs(Image): add alt
Browse files Browse the repository at this point in the history
- closed #4987
  • Loading branch information
SevereCloud committed Mar 15, 2024
1 parent 99afe21 commit 758c686
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
7 changes: 6 additions & 1 deletion packages/vkui/src/components/Avatar/Avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export default story;
type Story = StoryObj<AvatarStoryProps>;

export const Playground: Story = {
args: {
alt: 'Фотография Татьяны Плуталовой',
},
render: ({ badge, overlay, children, size = 48, ...args }) => (
<Avatar src={args.initials ? undefined : getAvatarUrl('user_id34')} {...args} size={size}>
{size >= 24 && badge}
Expand All @@ -87,6 +90,7 @@ export const Playground: Story = {
export const WithBadge: Story = {
...Playground,
args: {
...Playground.args,
children: (
<Avatar.Badge>
<IconExampleForBadgeBasedOnImageBaseSize />
Expand All @@ -98,8 +102,9 @@ export const WithBadge: Story = {
export const WithOverlay: Story = {
...Playground,
args: {
...Playground.args,
children: (
<Avatar.Overlay>
<Avatar.Overlay aria-label="Кнопка для изображения">
<IconExampleForOverlayBasedOnImageBaseSize />
</Avatar.Overlay>
),
Expand Down
2 changes: 1 addition & 1 deletion packages/vkui/src/components/Avatar/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const OthersFeatures = () => {
)
)}
{overlay && (
<Avatar.Overlay {...overlay}>
<Avatar.Overlay aria-label="Кнопка для изображения" {...overlay}>
<IconExampleForOverlayBasedOnImageBaseSize />
</Avatar.Overlay>
)}
Expand Down
1 change: 1 addition & 0 deletions packages/vkui/src/components/Image/Image.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ type Story = StoryObj<ImageProps>;
export const Playground: Story = {
args: {
src: getAvatarUrl('app_shorm_online'),
alt: 'Приложение шторм онлайн',
},
};
8 changes: 6 additions & 2 deletions packages/vkui/src/components/Image/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
const Default = () => {
return (
<Group header={<Header mode="secondary">По умолчанию</Header>}>
<SimpleCell before={<Image src={getAvatarUrl('app_shorm_online')} />} description="Ролевая">
<SimpleCell
before={<Image src={getAvatarUrl('app_shorm_online')} alt="Приложение шторм онлайн" />}
description="Ролевая"
>
Шторм онлайн
</SimpleCell>
</Group>
Expand Down Expand Up @@ -39,6 +42,7 @@ const OthersFeatures = () => {
key={size}
size={size}
src={getAvatarUrl('app_shorm_online')}
alt="Приложение шторм онлайн"
borderRadius={borderRadius}
>
{size >= 24 && badge && (
Expand All @@ -47,7 +51,7 @@ const OthersFeatures = () => {
</Image.Badge>
)}
{overlay && (
<Image.Overlay {...overlay}>
<Image.Overlay aria-label="Кнопка для изображения" {...overlay}>
<IconExampleForOverlayBasedOnImageBaseSize />
</Image.Overlay>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as React from 'react';
import { Meta, StoryObj } from '@storybook/react';
import { CanvasFullLayout, DisableCartesianParam } from '../../../storybook/constants';
import { getAvatarUrl } from '../../../testing/mock';
import { ImageBase } from '../ImageBase';
import { ImageBaseOverlay, ImageBaseOverlayProps } from './ImageBaseOverlay';

const story: Meta<ImageBaseOverlayProps> = {
Expand All @@ -14,12 +16,14 @@ export default story;
type Story = StoryObj<ImageBaseOverlayProps>;

export const Playground: Story = {
render: ({ children, ...args }) => <ImageBaseOverlay {...args}>{children}</ImageBaseOverlay>,
args: {
'aria-label': 'Кнопка для изображения',
},
decorators: [
(Component, context) => (
<div style={{ width: 50, height: 50, border: '1px dashed red', position: 'relative' }}>
<Component args={{ ...context.args }} />
</div>
(Component) => (
<ImageBase size={48} src={getAvatarUrl('app_shorm_online')} alt="Приложение шторм онлайн">
<Component />
</ImageBase>
),
],
};

0 comments on commit 758c686

Please sign in to comment.