Skip to content

Commit 4ed2269

Browse files
Make the Author story code example better/update component (#1300)
1 parent 188a4eb commit 4ed2269

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

.changeset/serious-clocks-visit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': patch
3+
---
4+
5+
Remove function calls for properties in Author component

src/components/author/author.stories.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import gerardoImage from './demo/gerardo.png';
44
import tylerImage from './demo/tyler.png';
55
import meganImage from './demo/megan.png';
66
const gerardo = {
7-
name: () => 'Gerardo Rodriguez',
8-
avatar: () => gerardoImage,
9-
link: () => 'https://cloudfour.com/is/gerardo',
7+
name: 'Gerardo Rodriguez',
8+
avatar: gerardoImage,
9+
link: 'https://cloudfour.com/is/gerardo',
1010
};
1111
const tyler = {
12-
name: () => 'Tyler Sticka',
13-
avatar: () => tylerImage,
14-
link: () => 'https://cloudfour.com/is/tyler',
12+
name: 'Tyler Sticka',
13+
avatar: tylerImage,
14+
link: 'https://cloudfour.com/is/tyler',
1515
};
1616
const megan = {
17-
name: () => 'Megan Notarte',
18-
avatar: () => meganImage,
19-
link: () => 'https://cloudfour.com/is/megnotarte',
17+
name: 'Megan Notarte',
18+
avatar: meganImage,
19+
link: 'https://cloudfour.com/is/megnotarte',
2020
};
2121

2222
<Meta
@@ -41,7 +41,7 @@ const megan = {
4141
Displays an author, or set of authors, for article bylines.
4242

4343
<Canvas>
44-
<Story name="Default" args={{}}>
44+
<Story name="Default">
4545
{(args) =>
4646
template({
4747
authors: [gerardo, tyler, megan].slice(0, args.count),
@@ -58,9 +58,9 @@ Displays an author, or set of authors, for article bylines.
5858

5959
```ts
6060
{
61-
name: () => string;
62-
avatar: () => string;
63-
link: () => string;
61+
name: string | () => string;
62+
avatar: string | () => string;
63+
link: string | () => string;
6464
}
6565
```
6666

src/components/author/author.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{% embed '@cloudfour/objects/bunch/bunch.twig' with { class: 'o-media__object' } %}
33
{% block content %}
44
{% for author in authors %}
5-
{% include '@cloudfour/components/avatar/avatar.twig' with { src: author.avatar() } only %}
5+
{% include '@cloudfour/components/avatar/avatar.twig' with { src: author.avatar } only %}
66
{% endfor %}
77
{% endblock %}
88
{% endembed %}
@@ -11,7 +11,7 @@
1111
<span class="u-hidden-visually">Authored by</span>
1212
{% for author in authors %}
1313
{% if loop.last and loop.length > 1 %}and {% endif %}
14-
<a href="{{ author.link() }}">{{ author.name() }}</a>
14+
<a href="{{ author.link }}">{{ author.name }}</a>
1515
{%- if not loop.last and loop.length > 2 %},{% endif %}
1616
{% endfor %}
1717
</div>

0 commit comments

Comments
 (0)