|
1 | | -import { |
2 | | - html |
3 | | -} from "lit-html"; |
| 1 | +import { html } from "lit-html"; |
4 | 2 |
|
5 | | -import { |
6 | | - Canvas, |
7 | | - Meta, |
8 | | - Story |
9 | | -} from '@storybook/addon-docs/blocks'; |
| 3 | +import { Canvas, Meta, Story } from "@storybook/addon-docs/blocks"; |
10 | 4 |
|
11 | 5 | <Meta |
12 | 6 | title="pos-image" |
13 | 7 | args={{ |
| 8 | + width: "300px", |
| 9 | + height: "300px", |
| 10 | + borderRadius: "0", |
14 | 11 | url: "https://solidproject.solidcommunity.net/SPS/assets/img/solid-emblem.svg", |
15 | | - notFoundUrl: "https://solidproject.solidcommunity.net/public/non-existing-image.png", |
16 | | - unauthenticatedUrl: "https://solidproject.solidcommunity.net/private/restricted-access.png" |
| 12 | + notFoundUrl: |
| 13 | + "https://solidproject.solidcommunity.net/public/non-existing-image.png", |
| 14 | + unauthenticatedUrl: |
| 15 | + "https://solidproject.solidcommunity.net/private/restricted-access.png", |
17 | 16 | }} |
18 | 17 | /> |
19 | 18 |
|
20 | | - |
21 | 19 | ## pos-image |
22 | 20 |
|
23 | 21 | Fetches and shows an image. It supports images that are behind access control. |
24 | 22 |
|
25 | | -While loading it will show an animated skeleton and afterwords the successfully loaded image: |
| 23 | +While loading it will show an animated skeleton and afterwords the successfully |
| 24 | +loaded image: |
26 | 25 |
|
27 | | -<Canvas |
28 | | - withSource="open"> |
29 | | - <Story |
30 | | - name="Display an image" |
31 | | - > |
32 | | - {({url}) => html` |
33 | | - <pos-image |
34 | | - src=${url}/> |
| 26 | +<Canvas withSource="open"> |
| 27 | + <Story name="Display an image"> |
| 28 | + {({ url, width, height, borderRadius }) => html` |
| 29 | + <pos-image style="--width: ${width}; --height: ${height}; --border-radius: ${borderRadius};" src=${url} /> |
35 | 30 | `} |
36 | 31 | </Story> |
37 | 32 | </Canvas> |
38 | 33 |
|
39 | 34 | If the file is not found it will display a box with an error message: |
40 | 35 |
|
41 | | -<Canvas |
42 | | - withSource="open"> |
43 | | - <Story |
44 | | - name="Not Found" |
45 | | - > |
46 | | - {({notFoundUrl}) => html` |
47 | | - <pos-image |
48 | | - src=${notFoundUrl}/> |
49 | | - `} |
| 36 | +<Canvas withSource="open"> |
| 37 | + <Story name="Not Found"> |
| 38 | + {({ notFoundUrl, width, height, borderRadius }) => html` <pos-image style="--width: ${width}; --height: ${height}; --border-radius: ${borderRadius};" src=${notFoundUrl} /> `} |
50 | 39 | </Story> |
51 | 40 | </Canvas> |
52 | 41 |
|
53 | | -If the file is behind access control, but the user is not authenticated it will show that: |
| 42 | +If the file is behind access control, but the user is not authenticated it will |
| 43 | +show that: |
54 | 44 |
|
55 | | -<Canvas |
56 | | - withSource="open"> |
57 | | - <Story |
58 | | - name="Unauthenticated" |
59 | | - > |
60 | | - {({unauthenticatedUrl}) => html` |
61 | | - <pos-image |
62 | | - src=${unauthenticatedUrl}/> |
| 45 | +<Canvas withSource="open"> |
| 46 | + <Story name="Unauthenticated"> |
| 47 | + {({ unauthenticatedUrl, width, height, borderRadius }) => html` |
| 48 | + <pos-image style="--width: ${width}; --height: ${height}; --border-radius: ${borderRadius};" src=${unauthenticatedUrl} /> |
63 | 49 | `} |
64 | 50 | </Story> |
65 | 51 | </Canvas> |
66 | 52 |
|
67 | | -After authentication the image will load normally, if the user has the required access rights. |
| 53 | +After authentication the image will load normally, if the user has the required |
| 54 | +access rights. |
0 commit comments