Skip to content

Commit f64ba9f

Browse files
authored
Merge pull request #3478 from Shopify/thumbnail-callbacks
Add onLoad callback example for Thumbnail component
2 parents ff14255 + 57233ec commit f64ba9f

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
<s-thumbnail
2-
src="https://cdn.shopify.com/static/sample-product/House-Plant1.png"
3-
alt="Product"
4-
size="base"
5-
></s-thumbnail>
1+
<s-stack direction="inline" gap="base">
2+
<s-thumbnail
3+
src="https://cdn.shopify.com/static/sample-product/House-Plant1.png"
4+
alt="Product"
5+
size="small-200"
6+
onLoad="setLoading(false)"
7+
/>
8+
<s-paragraph>Image loaded</s-paragraph>
9+
</s-stack>
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
<s-thumbnail
2-
src="https://cdn.shopify.com/static/sample-product/House-Plant1.png"
3-
alt="Product"
4-
size="base"
5-
/>
1+
const [loading, setLoading] = useState(true)
2+
3+
return (
4+
<s-stack direction="inline" gap="base" alignItems="center">
5+
<s-thumbnail
6+
src="https://cdn.shopify.com/static/sample-product/House-Plant1.png"
7+
alt="Product"
8+
size="small-200"
9+
onLoad={() => setLoading(false)}
10+
/>
11+
<s-paragraph>{loading ? 'Loading...' : 'Image loaded'}</s-paragraph>
12+
</s-stack>
13+
)

0 commit comments

Comments
 (0)