Skip to content

Commit 1fe9145

Browse files
authored
feat: support widget description content (#90)
1 parent 889bda7 commit 1fe9145

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/Example.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ export default factory(function Example({
8888
const isFullscreen = icache.get('isFullscreen');
8989
const isCodeShowing = icache.getOrSet('isCodeShowing', true);
9090

91+
let description;
92+
if (example.description) {
93+
description =
94+
typeof example.description === 'string' ? example.description : <example.description />;
95+
}
96+
9197
return (
9298
<div>
9399
{isOverview && <div innerHTML={widgetReadme} />}
@@ -157,6 +163,13 @@ export default factory(function Example({
157163
</a>
158164
</div>
159165
)}
166+
{description && (
167+
<virtual>
168+
<HorizontalRule />
169+
<h2 classes="text-2xl mb-4">Description</h2>
170+
{description}
171+
</virtual>
172+
)}
160173
{isOverview && widgetProperty && <InterfaceTable props={widgetProperty} />}
161174
{isOverview && widgetChildren && widgetChildren.length && (
162175
<InterfaceTable props={widgetChildren} tableName="Children" />

src/example/config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import NamedClassButtonExample from './NamedClassButtonExample';
88
import red from './theme/red';
99
import blue from './theme/blue';
1010
import InheritingButtonExample from './InheritingButtonExample';
11+
import { create } from '@dojo/framework/core/vdom';
12+
13+
const ExampleDescription = create()(
14+
() => 'This is an example of an optional description that is a widget.'
15+
);
1116

1217
export default {
1318
name: '@dojo/widgets',
@@ -30,7 +35,8 @@ export default {
3035
overview: {
3136
example: {
3237
filename: 'ButtonExample',
33-
module: ButtonExample
38+
module: ButtonExample,
39+
description: 'This is an example of an optional description that is a string.'
3440
}
3541
},
3642
examples: [
@@ -75,7 +81,8 @@ export default {
7581
overview: {
7682
example: {
7783
filename: 'NamedClassButtonExample',
78-
module: NamedClassButtonExample
84+
module: NamedClassButtonExample,
85+
description: ExampleDescription
7986
}
8087
}
8188
},

0 commit comments

Comments
 (0)