Skip to content

Commit a678fc2

Browse files
committed
parameterize pos-image story to manipulate style
1 parent 4e1a22f commit a678fc2

File tree

1 file changed

+26
-39
lines changed

1 file changed

+26
-39
lines changed
Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,54 @@
1-
import {
2-
html
3-
} from "lit-html";
1+
import { html } from "lit-html";
42

5-
import {
6-
Canvas,
7-
Meta,
8-
Story
9-
} from '@storybook/addon-docs/blocks';
3+
import { Canvas, Meta, Story } from "@storybook/addon-docs/blocks";
104

115
<Meta
126
title="pos-image"
137
args={{
8+
width: "300px",
9+
height: "300px",
10+
borderRadius: "0",
1411
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",
1716
}}
1817
/>
1918

20-
2119
## pos-image
2220

2321
Fetches and shows an image. It supports images that are behind access control.
2422

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:
2625

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} />
3530
`}
3631
</Story>
3732
</Canvas>
3833

3934
If the file is not found it will display a box with an error message:
4035

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} /> `}
5039
</Story>
5140
</Canvas>
5241

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:
5444

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} />
6349
`}
6450
</Story>
6551
</Canvas>
6652

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

Comments
 (0)