Skip to content

Commit 96b220e

Browse files
Merge pull request #2791 from Shopify/customer-account-doc----add-preact-examples-for-components
customer account doc - add preact examples for components
2 parents 1709f5b + 957d5d9 commit 96b220e

File tree

6 files changed

+82
-0
lines changed

6 files changed

+82
-0
lines changed

packages/ui-extensions/src/surfaces/customer-account/components/CustomerAccountAction/CustomerAccountAction.doc.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ const data: ReferenceEntityTemplateSchema = {
3535
codeblock: {
3636
title: 'Basic CustomerAccountAction',
3737
tabs: [
38+
{
39+
title: 'Preact',
40+
code: './examples/basic-CustomerAccountAction-preact.example.tsx',
41+
language: 'tsx',
42+
},
3843
{
3944
title: 'JS',
4045
code: './examples/basic-CustomerAccountAction-js.example.ts',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {render} from 'preact';
2+
3+
export default function extension() {
4+
render(<App />, document.body);
5+
}
6+
7+
function App() {
8+
return (
9+
<s-customer-account-action heading="Extension title">
10+
Extension content
11+
<s-button slot="primaryAction" onClick={() => shopify.close()}>
12+
Click to close
13+
</s-button>
14+
</s-customer-account-action>
15+
);
16+
}

packages/ui-extensions/src/surfaces/customer-account/components/ImageGroup/ImageGroup.doc.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ const data: ReferenceEntityTemplateSchema = {
2323
codeblock: {
2424
title: 'Basic ImageGroup',
2525
tabs: [
26+
{
27+
title: 'Preact',
28+
code: './examples/basic-ImageGroup-preact.example.tsx',
29+
language: 'tsx',
30+
},
2631
{
2732
title: 'JS',
2833
code: './examples/basic-ImageGroup-js.example.ts',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {render} from 'preact';
2+
3+
export default function extension() {
4+
render(<App />, document.body);
5+
}
6+
7+
function App() {
8+
return (
9+
<s-image-group>
10+
<s-image src="../assets/flower.jpg" />
11+
<s-image src="../assets/flower.jpg" />
12+
<s-image src="../assets/flower.jpg" />
13+
</s-image-group>
14+
);
15+
}

packages/ui-extensions/src/surfaces/customer-account/components/Page/Page.doc.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ const data: ReferenceEntityTemplateSchema = {
4141
codeblock: {
4242
title: 'Basic Page',
4343
tabs: [
44+
{
45+
title: 'Preact',
46+
code: './examples/basic-Page-preact.example.tsx',
47+
language: 'tsx',
48+
},
4449
{
4550
title: 'JS',
4651
code: './examples/basic-Page-js.example.ts',
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {render} from 'preact';
2+
3+
export default function extension() {
4+
render(<App />, document.body);
5+
}
6+
7+
function App() {
8+
return (
9+
<s-page heading="Order #1411" subheading="Confirmed Oct 5">
10+
<s-button
11+
slot="primaryAction"
12+
onClick={() => console.log('Primary action')}
13+
>
14+
Primary action
15+
</s-button>
16+
<s-button
17+
slot="secondaryActions"
18+
onClick={() => console.log('Secondary action 1')}
19+
>
20+
Secondary action 1
21+
</s-button>
22+
<s-button
23+
slot="secondaryActions"
24+
onClick={() => console.log('Secondary action 2')}
25+
>
26+
Secondary action 2
27+
</s-button>
28+
<s-button
29+
slot="breadcrumbActions"
30+
accessibilitylabel="Button"
31+
href="shopify://customer-account/orders"
32+
/>
33+
Content
34+
</s-page>
35+
);
36+
}

0 commit comments

Comments
 (0)