-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Move share button into a snippet #2123
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
Changes from 2 commits
7878877
84e40b7
cb1f8cb
bfd9b93
094e479
4ee87b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,47 +246,14 @@ | |
| {{- block.settings.text -}} | ||
| </a> | ||
| {%- when 'share' -%} | ||
| <share-button | ||
| id="Share-{{ section.id }}" | ||
| class="share-button quick-add-hidden" | ||
| {{ block.shopify_attributes }} | ||
| > | ||
| <button class="share-button__button hidden"> | ||
| {% render 'icon-share' %} | ||
| {{ block.settings.share_label | escape }} | ||
| </button> | ||
| <details id="Details-{{ block.id }}-{{ section.id }}"> | ||
| <summary class="share-button__button"> | ||
| {% render 'icon-share' %} | ||
| {{ block.settings.share_label | escape }} | ||
| </summary> | ||
| <div id="Product-share-{{ section.id }}" class="share-button__fallback motion-reduce"> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've remove this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also don't see where this would be used so removing it is fine with me. Otherwise I'd suggest just remove the section specific prefix of "Product-" or "Article-" |
||
| <div class="field"> | ||
| <span id="ShareMessage-{{ section.id }}" class="share-button__message hidden" role="status"> | ||
| </span> | ||
| <input | ||
| type="text" | ||
| class="field__input" | ||
| id="url" | ||
| value="{{ product.selected_variant.url | default: product.url | prepend: request.origin }}" | ||
| placeholder="{{ 'general.share.share_url' | t }}" | ||
| onclick="this.select();" | ||
| readonly | ||
| > | ||
| <label class="field__label" for="url">{{ 'general.share.share_url' | t }}</label> | ||
| </div> | ||
| <button class="share-button__close hidden no-js-hidden"> | ||
| {% render 'icon-close' %} | ||
| <span class="visually-hidden">{{ 'general.share.close' | t }}</span> | ||
| </button> | ||
| <button class="share-button__copy no-js-hidden"> | ||
| {% render 'icon-clipboard' %} | ||
| <span class="visually-hidden">{{ 'general.share.copy_to_clipboard' | t }}</span> | ||
| </button> | ||
| </div> | ||
| </details> | ||
| </share-button> | ||
| <script src="{{ 'share.js' | asset_url }}" defer="defer"></script> | ||
| {% assign share_url = product.selected_variant.url | default: product.url | prepend: request.origin %} | ||
| {% render 'share-button-block', | ||
| context: block, | ||
| origin: 'Main-Product', | ||
| share_value: share_url | ||
| %} | ||
|
|
||
| {%- when 'variant_picker' -%} | ||
| {%- unless product.has_only_default_variant -%} | ||
| {%- if block.settings.picker_type == 'button' -%} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| {% comment %} | ||
| Renders share button. | ||
| Accepts: | ||
| - context: {Object} either passing the block/section. | ||
ludoboludo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - origin: {String} file it's coming from to assign IDs. | ||
| - share_value: {String} url to share. | ||
ludoboludo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Usage: | ||
| {% render 'share-button-block', | ||
| context: block, | ||
| origin: 'Template/Section name', | ||
| share_value: share_url | ||
| %} | ||
| {% endcomment %} | ||
| <share-button {% if origin contains 'Product' %}id="Share-{{ section.id }}" {% endif %}class="share-button{% if origin contains 'Main-Product' %} quick-add-hidden{% endif %}" {{ context.shopify_attributes }}> | ||
ludoboludo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <button class="share-button__button hidden"> | ||
| {% render 'icon-share' %} | ||
| {{ context.settings.share_label | escape }} | ||
| </button> | ||
| <details id="Details-{{ context.id }}-{{ section.id }}"> | ||
| <summary class="share-button__button"> | ||
| {% render 'icon-share' %} | ||
| {{ context.settings.share_label | escape }} | ||
| </summary> | ||
| <div id="{{ origin }}-share-{{ section.id }}" class="share-button__fallback motion-reduce"> | ||
| <div class="field"> | ||
| <span id="ShareMessage-{{ section.id }}" class="share-button__message hidden" role="status"> | ||
| </span> | ||
| <input | ||
| type="text" | ||
| class="field__input" | ||
| id="url" | ||
|
||
| value="{{ share_value }}" | ||
| placeholder="{{ 'general.share.share_url' | t }}" | ||
| onclick="this.select();" | ||
| readonly | ||
| > | ||
| <label class="field__label" for="url">{{ 'general.share.share_url' | t }}</label> | ||
| </div> | ||
| <button class="share-button__close hidden no-js-hidden"> | ||
| {% render 'icon-close' %} | ||
| <span class="visually-hidden">{{ 'general.share.close' | t }}</span> | ||
| </button> | ||
| <button class="share-button__copy no-js-hidden"> | ||
| {% render 'icon-clipboard' %} | ||
| <span class="visually-hidden">{{ 'general.share.copy_to_clipboard' | t }}</span> | ||
| </button> | ||
| </div> | ||
| </details> | ||
| </share-button> | ||
Uh oh!
There was an error while loading. Please reload this page.