-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Admin API docs, aditional APIs and align with checkout docs
Co-authored-by: Tiffany Tse <tiffanytse@users.noreply.github.com>
- Loading branch information
Showing
91 changed files
with
1,881 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@shopify/ui-extensions': minor | ||
--- | ||
|
||
Exposes Action and Block extension targets in the admin surface. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,3 @@ packages/ui-extensions/docs/**/generated | |
.idea | ||
|
||
tsconfig.tsbuildinfo | ||
|
||
# Generated doc files | ||
docs/*/generated/* |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
...extensions-react/src/surfaces/admin/components/AdminAction/examples/AppAction.example.tsx
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
...i-extensions-react/src/surfaces/admin/components/Button/examples/basic-button.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {render, Button} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return ( | ||
<Button | ||
onPress={() => { | ||
console.log('onPress event'); | ||
}} | ||
> | ||
Click here | ||
</Button> | ||
); | ||
} |
18 changes: 18 additions & 0 deletions
18
...extensions-react/src/surfaces/admin/components/Divider/examples/basic-Divider.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { | ||
render, | ||
Divider, | ||
VerticalStack, | ||
} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return ( | ||
<VerticalStack gap="3"> | ||
<>First text</> | ||
<Divider /> | ||
<>Second Text</> | ||
</VerticalStack> | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
...ions-react/src/surfaces/admin/components/EmailField/examples/basic-emailfield.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {render, EmailField} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return <EmailField label="Enter your email address" />; | ||
} |
51 changes: 51 additions & 0 deletions
51
...es/ui-extensions-react/src/surfaces/admin/components/Form/examples/basic-form.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React, { useCallback, useState } from 'react'; | ||
import { | ||
reactExtension, | ||
Form, | ||
TextField, | ||
} from '@shopify/ui-extensions-react/admin'; | ||
|
||
export default reactExtension("admin.product-details.block.render", () => <App />); | ||
|
||
function App() { | ||
const [value, setValue] = useState(""); | ||
const [error, setError] = useState(); | ||
|
||
const onSubmit = useCallback( | ||
async () => { | ||
// API call to save the values | ||
const res = await fetch('/save', {method:'POST', body: JSON.stringify({name: value})}); | ||
if (!res.ok) { | ||
// The Host can catch these errors and do something with them. | ||
throw Error(`There were errors: ${res.errors.join(',')}`); | ||
} | ||
setError(); | ||
}, | ||
[value] | ||
); | ||
|
||
const onReset = useCallback(async () => { | ||
// Reset to initial value | ||
setValue("") | ||
// Clear errors | ||
setError() | ||
}, []); | ||
|
||
const onInput = useCallback((nameValue) => { | ||
if (!nameValue) { | ||
setError("Please enter a name."); | ||
} | ||
}, []) | ||
|
||
// Field values can only be updated on change when using Remote UI. | ||
const onChange = useCallback((nameValue) => { | ||
setValue(nameValue); | ||
}, []) | ||
|
||
|
||
return ( | ||
<Form id="form" onSubmit={onSubmit} onReset={onReset}> | ||
<TextField label="name" value={value} onInput={onInput} onChange={onChange} error={error} /> | ||
</Form> | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
...extensions-react/src/surfaces/admin/components/Heading/examples/basic-heading.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {render, Heading} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return <Heading>Store name</Heading>; | ||
} |
23 changes: 23 additions & 0 deletions
23
...-react/src/surfaces/admin/components/HeadingGroup/examples/basic-headinggroup.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { | ||
render, | ||
HeadingGroup, | ||
Heading, | ||
} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return ( | ||
<> | ||
<Heading>Heading <h1></Heading> | ||
|
||
<HeadingGroup> | ||
<Heading>Heading <h2></Heading> | ||
|
||
<HeadingGroup> | ||
<Heading>Heading <h3></Heading> | ||
</HeadingGroup> | ||
</HeadingGroup> | ||
</> | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
...es/ui-extensions-react/src/surfaces/admin/components/Icon/examples/basic-icon.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {render, Icon} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return <Icon source="AppsMajor" />; | ||
} |
9 changes: 9 additions & 0 deletions
9
.../ui-extensions-react/src/surfaces/admin/components/Image/examples/basic-image.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {render, Image} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return ( | ||
<Image source="https://shopify.dev/assets/api/ui-extensions/admin/components/image-example-code.png" /> | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
...ns-react/src/surfaces/admin/components/NumberField/examples/basic-numberfield.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {render, NumberField} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return <NumberField label="Enter a discount amount" />; | ||
} |
17 changes: 17 additions & 0 deletions
17
...eact/src/surfaces/admin/components/PasswordField/examples/basic-passwordfield.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { | ||
render, | ||
BlockStack, | ||
TextField, | ||
PasswordField | ||
} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return ( | ||
<BlockStack> | ||
<TextField label="Enter some text" /> | ||
<PasswordField label="Enter some text" /> | ||
</BlockStack> | ||
) | ||
} |
16 changes: 16 additions & 0 deletions
16
...es/ui-extensions-react/src/surfaces/admin/components/Text/examples/basic-text.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {render, Text, BlockStack} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return ( | ||
<BlockStack inlineAlignment="center"> | ||
<Text size="extraSmall">Extra Small</Text> | ||
<Text size="small">Small</Text> | ||
<Text size="base">Base</Text> | ||
<Text size="medium">Medium</Text> | ||
<Text size="large">Large</Text> | ||
<Text size="extraLarge">Extra Large</Text> | ||
</BlockStack> | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
...nsions-react/src/surfaces/admin/components/TextField/examples/basic-textfield.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {render, TextField} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return <TextField label="Enter some text" />; | ||
} |
7 changes: 7 additions & 0 deletions
7
...tensions-react/src/surfaces/admin/components/URLField/examples/basic-urlfield.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {render, URLField} from '@shopify/ui-extensions-react/admin'; | ||
|
||
render('Playground', () => <App />); | ||
|
||
function App() { | ||
return <URLField label="Enter store url" />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
DOCS_PATH=docs/surfaces/admin | ||
SRC_PATH=src/surfaces/admin | ||
|
||
|
||
# COMPILE_COMPONENT_DOCS="yarn tsc --project ./docs/surfaces/${surface}/tsconfig.docs.json --types react --moduleResolution node --target esNext --module CommonJS && generate-docs --input ./src/surfaces/${surface}/components/* ./src/surfaces/${surface}/api/* --typesInput ./src --output ./docs/surfaces/${surface}/generated && rm -rf ../../src/surfaces/${surface}/**/**/*.doc.js" | ||
# COMPILE_API_DOCS="yarn tsc --project ./docs/${surface}/tsconfig.docs.json --types react --moduleResolution node --target esNext --module CommonJS && generate-docs --input ./src/surfaces/${surface}/components/* --typesInput ./src --output ./docs/surfaces/${surface}/generated && rm -rf ./src/surfaces/${surface}/components/**/*.doc.js" | ||
# COMPILE_STATIC_PAGES="yarn tsc ./docs/surfaces/${surface}/staticPages/*.doc.ts --types react --moduleResolution node --target esNext --module CommonJS && generate-docs --isLandingPage --input ./docs/surfaces/${surface}/staticPages --output ./docs/surfaces/${surface}/generated && rm -rf ./docs/surfaces/${surface}/staticPages/*.doc.js" | ||
|
||
|
||
COMPILE_DOCS="yarn tsc --project $DOCS_PATH/tsconfig.docs.json --types react --moduleResolution node --target esNext --module CommonJS && yarn generate-docs --overridePath ./$DOCS_PATH/typeOverride.json --input ./$DOCS_PATH/reference ./$SRC_PATH --typesInput ./$SRC_PATH ../ui-extensions-react/$SRC_PATH --output ./$DOCS_PATH/generated" | ||
COMPILE_STATIC_PAGES="yarn tsc $DOCS_PATH/staticPages/*.doc.ts --types react --moduleResolution node --target esNext --module CommonJS && yarn generate-docs --isLandingPage --input ./$DOCS_PATH/staticPages --output ./$DOCS_PATH/generated" | ||
|
||
|
||
eval $COMPILE_DOCS && eval $COMPILE_STATIC_PAGES | ||
build_exit=$? | ||
|
||
|
||
# Remove .doc.js files | ||
find ./ -name '*.doc*.js' -exec rm -r {} \; | ||
|
||
if [ $build_exit -ne 0 ]; then | ||
fail_and_exit $build_exit | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.