-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2519 from Shopify/my/posExtensibilityDocMigration
POS Extensibility Tutorial Conversion to MDX
- Loading branch information
Showing
21 changed files
with
111 additions
and
608 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
45 changes: 45 additions & 0 deletions
45
packages/ui-extensions/docs/surfaces/point-of-sale/mdxExamples/discount-example/modal.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,45 @@ | ||
import React from 'react'; | ||
|
||
import {CartDiscountType} from '@shopify/ui-extensions/point-of-sale'; | ||
import { | ||
ScrollView, | ||
Button, | ||
Navigator, | ||
Screen, | ||
useApi, | ||
reactExtension, | ||
} from '@shopify/ui-extensions-react/point-of-sale'; | ||
|
||
const SmartGridModal = () => { | ||
const api = useApi<'pos.home.modal.render'>(); | ||
// [START modal.define-onpress] | ||
const onButtonPress = ( | ||
type: CartDiscountType, | ||
title: string, | ||
amount: string, | ||
) => { | ||
api.cart.applyCartDiscount(type, title, amount); | ||
api.toast.show('Discount applied'); | ||
}; | ||
// [END modal.define-onpress] | ||
return ( | ||
<Navigator> | ||
<Screen name="Discounts" title="Available Discounts"> | ||
<ScrollView> | ||
<Button | ||
title="25%" | ||
onPress={() => onButtonPress('Percentage', '25% off', '25')} | ||
/> | ||
<Button | ||
title="$10" | ||
onPress={() => onButtonPress('FixedAmount', '$10 off', '10')} | ||
/> | ||
</ScrollView> | ||
</Screen> | ||
</Navigator> | ||
); | ||
}; | ||
|
||
export default reactExtension('pos.home.modal.render', () => { | ||
return <SmartGridModal />; | ||
}); |
File renamed without changes.
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
40 changes: 40 additions & 0 deletions
40
packages/ui-extensions/docs/surfaces/point-of-sale/mdxExamples/discount-example/tile.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,40 @@ | ||
import React, {useState} from 'react'; | ||
|
||
import { | ||
Tile, | ||
useApi, | ||
reactExtension, | ||
} from '@shopify/ui-extensions-react/point-of-sale'; | ||
|
||
const SmartGridTile = () => { | ||
const api = useApi<'pos.home.tile.render'>(); | ||
|
||
const shouldEnable = (subtotal: string): boolean => { | ||
return Number(subtotal) > 100; | ||
}; | ||
|
||
// [START tile.enable] | ||
const [enabled, setEnabled] = useState( | ||
shouldEnable(api.cart.subscribable.initial.subtotal), | ||
); | ||
// [END tile.enable] | ||
|
||
// [START tile.subscribe] | ||
api.cart.subscribable.subscribe((cart) => { | ||
setEnabled(shouldEnable(cart.subtotal)); | ||
}); | ||
// [END tile.subscribe] | ||
|
||
return ( | ||
<Tile | ||
title="Discount Example App" | ||
subtitle="React" | ||
onPress={api.action.presentModal} | ||
enabled={enabled} | ||
/> | ||
); | ||
}; | ||
|
||
export default reactExtension('pos.home.tile.render', () => { | ||
return <SmartGridTile />; | ||
}); |
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
File renamed without changes.
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
File renamed without changes.
6 changes: 0 additions & 6 deletions
6
...ns/docs/surfaces/point-of-sale/staticPages/examples/discount-example/1-enable-the-tile.ts
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...s/docs/surfaces/point-of-sale/staticPages/examples/discount-example/1-enable-the-tile.tsx
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
.../docs/surfaces/point-of-sale/staticPages/examples/discount-example/2-subscribe-to-cart.ts
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...docs/surfaces/point-of-sale/staticPages/examples/discount-example/2-subscribe-to-cart.tsx
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
...nsions/docs/surfaces/point-of-sale/staticPages/examples/discount-example/3-add-buttons.ts
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...sions/docs/surfaces/point-of-sale/staticPages/examples/discount-example/3-add-buttons.tsx
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...ons/docs/surfaces/point-of-sale/staticPages/examples/discount-example/4-define-onpress.ts
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...ns/docs/surfaces/point-of-sale/staticPages/examples/discount-example/4-define-onpress.tsx
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
...ui-extensions/docs/surfaces/point-of-sale/staticPages/examples/discount-example/modal.tsx
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
.../ui-extensions/docs/surfaces/point-of-sale/staticPages/examples/discount-example/tile.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.