|
1 | 1 | import React from "react"; |
2 | | -import { ComponentStory, ComponentMeta } from "@storybook/react"; |
| 2 | +import { ComponentMeta, ComponentStory, Story } from "@storybook/react"; |
3 | 3 |
|
4 | 4 | import IonPhotoViewer from "./IonPhotoViewer"; |
5 | 5 | import { IonAvatar, IonItem, IonLabel, IonThumbnail } from "@ionic/react"; |
| 6 | +import { IonPhotoViewerProps } from "./IonPhotoViewer.types"; |
6 | 7 |
|
7 | 8 | // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export |
8 | 9 | export default { |
9 | | - title: "Example/IonPhotoViewer", |
| 10 | + title: "Demo/IonPhotoViewer", |
10 | 11 | component: IonPhotoViewer, |
11 | | - // More on argTypes: https://storybook.js.org/docs/react/api/argtypes |
12 | | - // argTypes: { |
13 | | - // backgroundColor: { control: 'color' }, |
14 | | - // }, |
15 | 12 | } as ComponentMeta<typeof IonPhotoViewer>; |
16 | 13 |
|
17 | | -export const IonAvatarItemExample = () => { |
18 | | - return ( |
19 | | - <> |
20 | | - <h2>For development</h2> |
| 14 | +const Template: Story<IonPhotoViewerProps> = (args: IonPhotoViewerProps) => ( |
| 15 | + <IonPhotoViewer {...args}>{args.children}</IonPhotoViewer> |
| 16 | +); |
21 | 17 |
|
22 | | - <h3>Ionic avatar</h3> |
23 | | - <IonItem button lines="none" detail={false}> |
24 | | - <IonAvatar slot="start"> |
25 | | - <IonPhotoViewer |
26 | | - title="Martin arrantzalea" |
27 | | - src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Alcedo_Atthis.jpg/1280px-Alcedo_Atthis.jpg" |
28 | | - > |
29 | | - <img |
30 | | - src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Alcedo_Atthis.jpg/1280px-Alcedo_Atthis.jpg" |
31 | | - alt="Martin arrantzalea" |
32 | | - /> |
33 | | - </IonPhotoViewer> |
34 | | - </IonAvatar> |
35 | | - <IonLabel>Martin arrantzalea</IonLabel> |
36 | | - </IonItem> |
37 | | - <IonItem button lines="none" detail={false}> |
38 | | - <IonAvatar slot="start"> |
39 | | - <img |
40 | | - src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Alcedo_Atthis.jpg/1280px-Alcedo_Atthis.jpg" |
41 | | - alt="Martin arrantzalea" |
42 | | - /> |
43 | | - </IonAvatar> |
44 | | - <IonLabel>Default IonAvatar without photo viewer</IonLabel> |
45 | | - </IonItem> |
46 | | - |
47 | | - <h3>Ionic thumbnail</h3> |
48 | | - <IonItem button lines="none" detail={false}> |
49 | | - <IonThumbnail slot="start"> |
50 | | - <IonPhotoViewer |
51 | | - title="Martin arrantzalea" |
52 | | - src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Alcedo_Atthis.jpg/1280px-Alcedo_Atthis.jpg" |
53 | | - > |
54 | | - <img |
55 | | - src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Alcedo_Atthis.jpg/1280px-Alcedo_Atthis.jpg" |
56 | | - alt="Martin arrantzalea" |
57 | | - /> |
58 | | - </IonPhotoViewer> |
59 | | - </IonThumbnail> |
60 | | - <IonLabel>Martin arrantzalea</IonLabel> |
61 | | - </IonItem> |
62 | | - <IonItem button lines="none" detail={false}> |
63 | | - <IonThumbnail slot="start"> |
64 | | - <img |
65 | | - src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Alcedo_Atthis.jpg/1280px-Alcedo_Atthis.jpg" |
66 | | - alt="Martin arrantzalea" |
67 | | - /> |
68 | | - </IonThumbnail> |
69 | | - <IonLabel>Default IonThumbnail without photo viewer</IonLabel> |
70 | | - </IonItem> |
71 | | - </> |
72 | | - ); |
| 18 | +const imageUrl = |
| 19 | + "https://upload.wikimedia.org/wikipedia/commons/thumb/6/69/June_odd-eyed-cat_cropped.jpg/712px-June_odd-eyed-cat_cropped.jpg"; |
| 20 | +export const Default = Template.bind({}); |
| 21 | +Default.args = { |
| 22 | + title: "Image title", |
| 23 | + src: imageUrl, |
| 24 | + children: <img src={imageUrl} alt="Image alt" />, |
73 | 25 | }; |
| 26 | + |
| 27 | +export const IonAvatarExample: Story = () => ( |
| 28 | + <IonItem button lines="none" detail={false}> |
| 29 | + <IonAvatar slot="start"> |
| 30 | + <IonPhotoViewer title="User name" src={imageUrl}> |
| 31 | + <img src={imageUrl} alt="Image alt" /> |
| 32 | + </IonPhotoViewer> |
| 33 | + </IonAvatar> |
| 34 | + <IonLabel>IonAvatar example</IonLabel> |
| 35 | + </IonItem> |
| 36 | +); |
| 37 | + |
| 38 | +export const IonThumbnailExample: Story = () => ( |
| 39 | + <IonItem button lines="none" detail={false}> |
| 40 | + <IonThumbnail slot="start"> |
| 41 | + <IonPhotoViewer |
| 42 | + title="User name" |
| 43 | + src={imageUrl} |
| 44 | + > |
| 45 | + <img |
| 46 | + src={imageUrl} |
| 47 | + alt="Image alt" |
| 48 | + /> |
| 49 | + </IonPhotoViewer> |
| 50 | + </IonThumbnail> |
| 51 | + <IonLabel>IonThumbnail example</IonLabel> |
| 52 | + </IonItem> |
| 53 | +); |
| 54 | + |
0 commit comments