Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New templates - fix #1 #8

Merged
merged 6 commits into from
Mar 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
basic templates + default template
  • Loading branch information
hatertron3000 committed Mar 14, 2021
commit c5172d0330394a64df4bea70172a11b825a45df2
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
*.code-workspace
*.code-workspace
.idea
7 changes: 5 additions & 2 deletions src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ module.exports = argv => {
},
{
name: "template",
type: "list",
type: "rawlist",
message: "Choose a template",
choices: templates
choices: templates,
default: templates.find(template => template === 'tab')
? 'tab'
: null
},
{
name: "token",
Expand Down
21 changes: 21 additions & 0 deletions templates/array/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"type": "array",
"label": "Content",
"id": "content",
"defaultCount": 3,
"entryLabel": "item",
"thumbnail": "https://placehold.it/90x90",
"schema": [
{
"type": "tab",
"label": "Item content",
"sections": [
{
"settings": []
}
]
}
]
}
]
9 changes: 9 additions & 0 deletions templates/array/storefront-api-query.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
query WidgetQueries {
site {
settings {
url {
vanityUrl
}
}
}
}
10 changes: 10 additions & 0 deletions templates/array/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- DO NOT DELETE
Access GraphQL query data with {{_.data}}
Access the widget id with {{_.id}}
-->
<ul>
{{#each content}}
<li>Item #{{@index}}</li>
{{/each}}
</ul>
{{{ json _.data }}}
2 changes: 1 addition & 1 deletion templates/featured-products/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"label": "Content",
"sections": [
{
"label": "Text",
"label": "Content",
"settings": [
{
"type": "input",
Expand Down
2 changes: 1 addition & 1 deletion templates/featured-products/storefront-api-query.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
query featuredProducts {
query WidgetQueries {
site {
featuredProducts(first: 4) {
edges {
Expand Down
14 changes: 6 additions & 8 deletions templates/featured-products/template.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<div>
<!--
Access GraphQL query data with {{_.data}}
Access the widget id with {{_.id}}
-->
<h2 class="page-heading">{{ heading }}</h2>
{{{ json _.data }}}
</div>
<!-- DO NOT DELETE
Access GraphQL query data with {{_.data}}
Access the widget id with {{_.id}}
-->
<h2 class="page-heading">{{ heading }}</h2>
{{{ json _.data }}}
19 changes: 19 additions & 0 deletions templates/settings-demo/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"type": "tab",
"label": "Content",
"sections": [
{
"label": "Content",
"settings": [
{
"type": "input",
"label": "Heading text",
"id": "heading",
"default": "Featured Products"
}
]
}
]
}
]
78 changes: 78 additions & 0 deletions templates/settings-demo/storefront-api-query.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
query WidgetQueries {
site {
featuredProducts(first: 4) {
edges {
node {
id
entityId
name
plainTextDescription
defaultImage {
...ImageFields
}
images {
edges {
node {
...ImageFields
}
}
}
reviewSummary {
summationOfRatings
numberOfReviews
}
prices {
price {
...MoneyFields
}
priceRange {
min {
...MoneyFields
}
max {
...MoneyFields
}
}
salePrice {
...MoneyFields
}
retailPrice {
...MoneyFields
}
saved {
...MoneyFields
}
bulkPricing {
minimumQuantity
maximumQuantity
... on BulkPricingFixedPriceDiscount {
price
}
... on BulkPricingPercentageDiscount {
percentOff
}
... on BulkPricingRelativePriceDiscount {
priceAdjustment
}
}
}
brand {
name
}
}
}
}
}
}

fragment ImageFields on Image {
url320wide: url(width: 320)
url640wide: url(width: 640)
url960wide: url(width: 960)
url1280wide: url(width: 1280)
}

fragment MoneyFields on Money {
value
currencyCode
}
6 changes: 6 additions & 0 deletions templates/settings-demo/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- DO NOT DELETE
Access GraphQL query data with {{_.data}}
Access the widget id with {{_.id}}
-->
<pre style="white-space: pre-wrap;">{{json this}}</pre>
{{{ json _.data }}}
Loading