Skip to content

Commit 78b3108

Browse files
committed
story for imagesOf
1 parent efb4228 commit 78b3108

3 files changed

Lines changed: 29 additions & 6 deletions

File tree

src/stories/RdfUtils.stories.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as UI from '../../lib'
22

33
import { Canvas, Meta, Story } from '@storybook/addon-docs/blocks'
4+
import { rawJsonDecorator } from './decorators'
45

56
<Meta title="RDF utilities" />
67

@@ -11,9 +12,7 @@ Retrieve all RDF class URIs from solid-ui's RDF store
1112
[API Documentation](https://solid.github.io/solid-ui/Documentation/api/modules/_widgets_buttons_.html#allclassuris)
1213

1314
<Canvas withSource="open">
14-
<Story name="allClassUris" decorators={[ (Story) => {
15-
return `<pre>${JSON.stringify(Story(), null, 2)}</pre>`
16-
}]}>
15+
<Story name="allClassUris" decorators={[rawJsonDecorator]}>
1716
{ () => {
1817
UI.store.add(
1918
UI.rdf.namedNode('http://example.com/#some-thing'),
@@ -38,9 +37,7 @@ Make a URI in the Tabulator.org annotation store out of the URI of the thing to
3837
[API Documentation](https://solid.github.io/solid-ui/Documentation/api/modules/_widgets_buttons_.html#defaultannotationstore)
3938

4039
<Canvas withSource="open">
41-
<Story name="defaultAnnotationStore" decorators={[ (Story) => {
42-
return `<pre>${JSON.stringify(Story(), null, 2)}</pre>`
43-
}]}>
40+
<Story name="defaultAnnotationStore" decorators={[rawJsonDecorator]}>
4441
{ () => {
4542
const url = 'http://example.com/a/b.html'
4643
return UI.widgets.defaultAnnotationStore(UI.rdf.namedNode(url))

src/stories/decorators.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const rawJsonDecorator = (Story) => {
2+
return `<pre>${JSON.stringify(Story(), null, 2)}</pre>`
3+
}

src/stories/findImage.stories.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as UI from '../../lib'
22

33
import { Canvas, Meta, Story } from '@storybook/addon-docs/blocks'
4+
import { rawJsonDecorator } from './decorators'
45

56
export const imageDecorator = (Story) => {
67
const result = Story()
@@ -110,4 +111,26 @@ Find an image for this thing as a class
110111
UI.widgets.findImageFromURI(UI.rdf.namedNode('mailto:user@mail.example'))
111112
}
112113
</Story>
114+
</Canvas>
115+
116+
## imagesOf
117+
118+
Set of suitable images
119+
120+
[API Documentation](https://solid.github.io/solid-ui/Documentation/api/modules/_widgets_buttons_.html#imagesof)
121+
122+
<Canvas withSource="open">
123+
<Story name="imagesOf" decorators={[rawJsonDecorator]}>
124+
{
125+
() => {
126+
const store = UI.rdf.graph()
127+
const thing = UI.rdf.namedNode('http://thing.example/resource#it')
128+
const avatar = UI.rdf.namedNode('https://pod.example/image1.png')
129+
const image = UI.rdf.namedNode('https://pod.example/image2.jpg')
130+
store.add(thing, UI.ns.sioc('avatar'), avatar)
131+
store.add(thing, UI.ns.foaf('img'), image)
132+
return UI.widgets.imagesOf(thing, store)
133+
}
134+
}
135+
</Story>
113136
</Canvas>

0 commit comments

Comments
 (0)