Skip to content

Commit 4e39c37

Browse files
authored
Merge pull request #58 from 3daddict/include-to-render-update
changed include to render on simple compnents, updated readme with SS…
2 parents f77445c + 6382abb commit 4e39c37

File tree

8 files changed

+43
-44
lines changed

8 files changed

+43
-44
lines changed

config.yml.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ development:
99
store:
1010
storefront_api_key:
1111
directory: dist/
12+
# Note: when first deploying to a new theme you may have to comment out the ignore files.
13+
# Then after first upload uncomment them.
1214
ignore_files:
1315
- config/settings_data.json
1416
- "*.js"

readme.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ This project uses [TailwindCSS](https://tailwindcss.com/) `v2` a utility-first C
7777
In the event that you find the HMR assets are not loading and the requests to localhost:9000 are 404 you will need to approve or pass a valid certificate.
7878
To solve this issue you can open a new browser window and approve the SSL Certificate or pass a valid certificate as mentioned here [devServer.https](https://webpack.js.org/configuration/dev-server/#devserverhttps).
7979

80+
**Note:** a quick fix with Chrome `chrome://flags/#allow-insecure-localhost` change to enable
81+
8082
## HMR (Hot Module Reloading)
8183
When in development mode `yarn start` hot module reloading is enabled. It watches for changes to `JavaScript`, `CSS` and `Liquid` files. When JS or CSS is changes the browser will change without the need to refresh. When changes are made to liquid files a manual browser reload may be required.
8284

@@ -95,29 +97,22 @@ If you don’t want any of your tags to print whitespace, as a general rule you
9597

9698
## Variable Scope & Components
9799
This is not unique to this project but it's worth mentioning and creating a component example. See the `src/components/snippets/dynamic-modal/dynamic-modal.liquid` component. This is a simple modal that uses variable scope for data, styles and functions.
98-
In this file we assign some default variables.
99-
```html
100-
{%- assign id = "defaultModal" -%}
101-
{%- assign openModalBtn = "defaultOpenButton" -%}
102-
{%- assign title = "Modal Title" -%}
103-
{%- assign body = "Modal Body" -%}
104-
```
105-
Use this `dynamic-modal.liquid` component by creating a trigger element like a button with an id.
100+
Use this `dynamic-modal.liquid` component by creating a trigger element or function like a button with an id.
106101
```html
107102
<button id="testButton">Trigger Modal</button>
108103
```
109104
Next we include the modal in a section with declared variables. These will be scoped to the snippet and we now have a dynamic reusable modal component we can use throughout our theme.
110105
```html
111-
{%- include "dynamic-modal",
112-
id: "homePageTestModal",
113-
openModalBtn: "testButton",
114-
title: "Testing Title Variable",
115-
body: "Testing the Dynamic Body Of the Modal...",
116-
buttonOne: "Alert",
117-
buttonOneFunction: "alert('Q: Do you struggle with impostor syndrome? Me: no I’m great at it')"
118-
buttonTwo: "Close",
119-
buttonTwoStyle: "text-white bg-red-500 hover:bg-red-700"
120-
buttonTwoFunction: "modal.style.display = 'none';"
106+
{%- render 'dynamic-modal',
107+
id: "testModal",
108+
openModalBtn: "modalBtn",
109+
title: "Modal Title",
110+
body: "Modal Body",
111+
buttonOne: "Alert",
112+
buttonOneFunction: "alert('Q: Do you struggle with impostor syndrome? Me: no I’m great at it')"
113+
buttonTwo: "Close",
114+
buttonTwoStyle: "text-white bg-red-500 hover:bg-red-700"
115+
buttonTwoFunction: "modal.style.display = 'none';"
121116
-%}
122117
```
123-
Read more on this [Shopify Variable Scopes](https://ellodave.dev/blog/2019/5/24/shopify-variable-scopes/). If you find some good use cases for these please post them in the [discussion ideas category](https://github.com/3daddict/themekit-webpack/discussions/categories/ideas)
118+
I came across this idea using `include` from [David Warrington's](https://github.com/davidwarrington) article [Shopify Variable Scopes](https://ellodave.dev/blog/2019/5/24/shopify-variable-scopes/) and re-factored to use `render` tags. If you find some good use cases for these please post them in the [discussion ideas category](https://github.com/3daddict/themekit-webpack/discussions/categories/ideas)

src/components/layout/theme.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
{%- comment -%}Varibles{%- endcomment -%}
3232
{{ content_for_header }}
33-
{% include 'global-css' %}
33+
{% render 'global-css' %}
3434

3535
{{ 'tailwind.min.css' | asset_url | stylesheet_tag }}
3636
{{ 'bundle.global-css.css' | asset_url | stylesheet_tag }}

src/components/sections/header/header.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
{%- for link in linklists[section.settings.menu].links -%}
3030
{%- if link.links != blank -%}
3131
<li class="inline-block mt-0 mr-4">
32-
<a href="{{ link.url }}">{{ link.title }}{%- include 'icon-arrow-down' -%}</a>
32+
<a href="{{ link.url }}">{{ link.title }}</a>
3333
<ul class="text-sm flex-grow">
3434
{%- for childlink in link.links -%}
3535
<li class="inline-block mt-0 mr-4"><a href="{{ childlink.url }}">{{ childlink.title }}</a>

src/components/sections/product/product.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</div>
5353
</div>
5454
<div class="mt-3 pb-5 border-b-2 border-gray-200 mb-5">
55-
{% include 'input-counter' %}
55+
{% render 'input-counter' %}
5656
</div>
5757
<div class="flex">
5858
<span

src/components/snippets/dynamic-modal/dynamic-modal.liquid

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
{%- comment -%}
22
This snippet uses Variable Scope and can be re-used throughout the theme.
3-
To use this snippet in sections, add {%- include, key: value -%} with some assigned variables.
3+
To use this snippet in sections, add {%- render, key: value -%} with assigned variables.
44
For Example:
5+
This is the target button id that will open the modal.
6+
<button id="modalBtn">TEST MODAL</button>
57
=========================================================================
6-
{%- include "dynamic-modal",
7-
id: "homePageTestModal",
8-
openModalBtn: "testButton",
9-
title: "Testing Title Variable",
10-
body: "Testing the Dynamic Body Of the Modal..."
8+
Here is a render tag example to use in the section with some example variables declared.
9+
Note the openModalBtn matches the button element above which triggers the modal in this example.
10+
=========================================================================
11+
{%- render 'dynamic-modal',
12+
id: "testModal",
13+
openModalBtn: "modalBtn",
14+
title: "Modal Title",
15+
body: "Modal Body",
16+
buttonOne: "Button One",
17+
buttonOneStyle: "text-white bg-blue-500 hover:bg-blue-700",
18+
buttonOneFunction: "javascript:void(0);",
19+
buttonTwo: "Button Two",
20+
buttonTwoStyle: "text-white bg-transparent hover:bg-blue-700 text-blue-500 hover:text-white border border-blue-500 hover:border-transparent",
21+
buttonTwoFunction: "javascript:void(0);"
1122
-%}
1223
=========================================================================
13-
These 👆 will change the default assignments below 👇
24+
id, openModalBtn, title and body are required. If you don't want buttons make the value = null.
25+
=========================================================================
1426
{%- endcomment -%}
15-
{%- assign id = "defaultModal" -%}
16-
{%- assign openModalBtn = "defaultOpenButton" -%}
17-
{%- assign title = "Modal Title" -%}
18-
{%- assign body = "Modal Body" -%}
19-
{%- assign buttonOne = null -%}
20-
{%- assign buttonOneStyle = "text-white bg-blue-500 hover:bg-blue-700" -%}
21-
{%- assign buttonOneFunction = "javascript:void(0);" -%}
22-
{%- assign buttonTwo = null -%}
23-
{%- assign buttonTwoStyle = "text-white bg-transparent hover:bg-blue-700 text-blue-500 hover:text-white border border-blue-500 hover:border-transparent" -%}
24-
{%- assign buttonTwoFunction = "javascript:void(0);" -%}
2527

2628
<section class="hidden" id="{{ id }}">
27-
<div class="flex items-center justify-center fixed left-0 bottom-0 w-full h-full bg-black bg-opacity-75" id="modalContainer">
29+
<div class="flex items-center justify-center fixed left-0 bottom-0 w-full h-full bg-black bg-opacity-75 z-50" id="modalContainer">
2830
<div class="bg-white rounded-lg w-1/2">
2931
<div class="flex flex-col items-start p-4">
3032
<div class="flex items-center w-full">

src/components/templates/collection.liquid

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
{%- if settings.pagination and paginate.pages > 1 -%}
2727
{%- comment -%}Pagination Control in Theme Settings{%- endcomment -%}
2828
{%- if settings.pagination_type == 'accessable_pagination' -%}
29-
{% include 'accessible-pagination' %}
29+
{%- render 'accessible-pagination' with { paginate: paginate} -%}
3030
{%- elsif settings.pagination_type == 'default_pagination' -%}
31-
{% include 'default-pagination' %}
31+
{%- render 'default-pagination' with { paginate: paginate} -%}
3232
{%- endif -%}
3333
{%- endif -%}
3434
{% endpaginate %}

src/components/templates/list-collections.liquid

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
{%- if settings.pagination and paginate.pages > 1 -%}
2727
{%- comment -%}Pagination Control in Theme Settings{%- endcomment -%}
2828
{%- if settings.pagination_type == 'accessable_pagination' -%}
29-
{% include 'accessible-pagination' %}
29+
{%- render 'accessible-pagination' with { paginate: paginate} -%}
3030
{%- endif -%}
3131
{%- if settings.pagination_type == 'default_pagination' -%}
32-
{% include 'default-pagination' %}
32+
{%- render 'default-pagination' with { paginate: paginate} -%}
3333
{%- endif -%}
3434
{%- endif -%}
3535
{%- endpaginate -%}

0 commit comments

Comments
 (0)