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

Limit the number of stylesheets on the page #3509

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
98 changes: 98 additions & 0 deletions assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -3462,3 +3462,101 @@ details-disclosure > details {
--border-offset: 0px; /* Prevent the border from growing on buttons when this effect is on. */
}
}

/* Loading spinner */
.loading__spinner {
position: absolute;
z-index: 1;
width: 1.8rem;
}

.loading__spinner {
width: 1.8rem;
display: inline-block;
}

.spinner {
animation: rotator 1.4s linear infinite;
}

@keyframes rotator {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(270deg);
}
}

.path {
stroke-dasharray: 280;
stroke-dashoffset: 0;
transform-origin: center;
stroke: rgb(var(--color-foreground));
animation: dash 1.4s ease-in-out infinite;
}

@media screen and (forced-colors: active) {
.path {
stroke: CanvasText;
}
}

@keyframes dash {
0% {
stroke-dashoffset: 280;
}
50% {
stroke-dashoffset: 75;
transform: rotate(135deg);
}
100% {
stroke-dashoffset: 280;
transform: rotate(450deg);
}
}

.loading__spinner:not(.hidden) + .cart-item__price-wrapper,
.loading__spinner:not(.hidden) ~ cart-remove-button {
opacity: 50%;
}

.loading__spinner:not(.hidden) ~ cart-remove-button {
pointer-events: none;
cursor: default;
}

/* Progress bar */
.progress-bar-container {
width: 100%;
margin: auto;
}

.progress-bar {
height: 0.13rem;
width: 100%;
}

.progress-bar-value {
width: 100%;
height: 100%;
background-color: rgb(var(--color-foreground));
animation: indeterminateAnimation var(--duration-extra-longer) infinite ease-in-out;
transform-origin: 0;
}

.progress-bar .progress-bar-value {
display: block;
}

@keyframes indeterminateAnimation {
0% {
transform: translateX(-20%) scaleX(0);
}
40% {
transform: translateX(30%) scaleX(0.7);
}
100% {
transform: translateX(100%) scaleX(0);
}
}
61 changes: 0 additions & 61 deletions assets/component-loading-spinner.css

This file was deleted.

5 changes: 4 additions & 1 deletion sections/collage.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
</h2>
{%- endif -%}
<div class="collage{% if section.settings.mobile_layout == 'collage' %} collage--mobile{% endif %}">
{% assign skip_card_product_styles = false %}
{%- for block in section.blocks -%}
<div
class="collage__item collage__item--{{ block.type }} collage__item--{{ section.settings.desktop_layout }}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
Expand Down Expand Up @@ -91,14 +92,16 @@
</div>
</div>
{%- when 'product' -%}
{%- assign placeholder_image = 'product-apparel-' | append: placeholder_image_index -%}

Check warning on line 95 in sections/collage.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/collage.liquid#L95

[LiquidTag] Use {% liquid ... %} to write multiple tags
{% render 'card-product',
card_product: block.settings.product,
media_aspect_ratio: 'adapt',
show_secondary_image: block.settings.second_image,
extend_height: true,
placeholder_image: placeholder_image
placeholder_image: placeholder_image,
skip_styles: skip_card_product_styles
%}
{% assign skip_card_product_styles = true %}
{%- when 'collection' -%}
{%- assign placeholder_image = 'collection-apparel-' | append: placeholder_image_index -%}
{% render 'card-collection',
Expand Down Expand Up @@ -208,7 +211,7 @@
</div>
</div>

{% schema %}

Check notice on line 214 in sections/collage.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/collage.liquid#L214

[SchemaJsonFormat] JSON formatting could be improved
{
"name": "t:sections.collage.name",
"tag": "section",
Expand Down
3 changes: 3 additions & 0 deletions sections/featured-collection.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
role="list"
aria-label="{{ 'general.slider.name' | t }}"
>
{% assign skip_card_product_styles = false %}
{%- for product in section.settings.collection.products limit: section.settings.products_to_show -%}
<li
id="Slide-{{ section.id }}-{{ forloop.index }}"
Expand All @@ -110,10 +111,12 @@
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating,
skip_styles: skip_card_product_styles,
section_id: section.id,
quick_add: section.settings.quick_add
%}
</li>
{%- assign skip_card_product_styles = true -%}
{%- else -%}
{%- for i in (1..section.settings.columns_desktop) -%}
<li
Expand Down Expand Up @@ -190,7 +193,7 @@
</div>
</div>

{% schema %}

Check notice on line 196 in sections/featured-collection.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/featured-collection.liquid#L196

[SchemaJsonFormat] JSON formatting could be improved
{
"name": "t:sections.featured-collection.name",
"tag": "section",
Expand Down
3 changes: 3 additions & 0 deletions sections/main-collection-product-grid.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
{% if section.settings.quick_add == 'bulk' %} collection-quick-add-bulk{% endif %}
"
>
{% assign skip_card_product_styles = false %}

Check warning on line 153 in sections/main-collection-product-grid.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-collection-product-grid.liquid#L153

[LiquidTag] Use {% liquid ... %} to write multiple tags
{%- for product in collection.products -%}
{% assign lazy_load = false %}
{%- if forloop.index > 2 -%}
Expand All @@ -170,10 +171,12 @@
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating,
lazy_load: lazy_load,
skip_styles: skip_card_product_styles,
quick_add: section.settings.quick_add,
section_id: section.id
%}
</li>
{%- assign skip_card_product_styles = true -%}
{%- endfor -%}
</ul>

Expand Down
3 changes: 3 additions & 0 deletions sections/main-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
%}

{%- when 'variant_picker' -%}
{% render 'product-variant-picker', product: product, block: block, product_form_id: product_form_id %}

Check warning on line 462 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L462

[NestedSnippet] Too many nested snippets

Check warning on line 462 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L462

[NestedSnippet] Too many nested snippets

Check warning on line 462 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L462

[NestedSnippet] Too many nested snippets
{%- when 'buy_buttons' -%}
{%- render 'buy-buttons',
block: block,
Expand Down Expand Up @@ -552,6 +552,7 @@
aria-label="{{ 'general.slider.name' | t }}"
{% endif %}
>
{% assign skip_card_product_styles = false %}
{%- for i in (1..number_of_slides) -%}
<div
id="Slide-{{ block.id }}-{{ forloop.index }}"
Expand Down Expand Up @@ -579,12 +580,14 @@
media_aspect_ratio: block.settings.image_ratio,
show_secondary_image: false,
lazy_load: false,
skip_styles: skip_card_product_styles,
quick_add: quick_add,
section_id: section.id,
horizontal_class: true,
horizontal_quick_add: true
%}
</li>
{%- assign skip_card_product_styles = true -%}
{%- endfor -%}
</ul>
</div>
Expand Down Expand Up @@ -704,7 +707,7 @@
if product.selected_or_first_available_variant.featured_media
assign seo_media = product.selected_or_first_available_variant.featured_media
else
assign seo_media = product.featured_media

Check warning on line 710 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L710

[UnusedAssign] `seo_media` is never used
endif
-%}

Expand Down
5 changes: 4 additions & 1 deletion sections/main-search.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
class="grid product-grid grid--{{ section.settings.columns_mobile }}-col-tablet-down grid--{{ section.settings.columns_desktop }}-col-desktop"
role="list"
>
{%- assign skip_card_product_styles = false -%}

Check warning on line 257 in sections/main-search.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-search.liquid#L257

[LiquidTag] Use {% liquid ... %} to write multiple tags
{%- for item in search.results -%}
{% assign lazy_load = false %}
{%- if forloop.index > 2 -%}
Expand All @@ -276,8 +277,10 @@
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating,
lazy_load: lazy_load
lazy_load: lazy_load,
skip_styles: skip_card_product_styles
%}
{%- assign skip_card_product_styles = true -%}
{%- when 'article' -%}
{% render 'article-card',
article: item,
Expand Down
5 changes: 4 additions & 1 deletion sections/related-products.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
class="grid product-grid grid--{{ section.settings.columns_desktop }}-col-desktop grid--{{ section.settings.columns_mobile }}-col-tablet-down"
role="list"
>
{% assign skip_card_product_styles = false %}
{% for recommendation in recommendations.products %}
<li class="grid__item">
{% render 'card-product',
Expand All @@ -43,9 +44,11 @@
image_shape: section.settings.image_shape,
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating
show_rating: section.settings.show_rating,
skip_styles: skip_card_product_styles
%}
</li>
{%- assign skip_card_product_styles = true -%}
{% endfor %}
</ul>
{% endif %}
Expand Down
15 changes: 8 additions & 7 deletions snippets/card-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- show_rating: {Boolean} Show the product rating. Default: false
- extend_height: {Boolean} Card height extends to available container space. Default: true (optional)
- lazy_load: {Boolean} Image should be lazy loaded. Default: true (optional)
- skip_styles: {Boolean} Don't include component styles. Useful when rendering multiple product cards in a loop. Default: false (optional)
- quick_add: {Boolean} Show the quick add button.
- section_id: {String} The ID of the section that contains this card.
- horizontal_class: {Boolean} Add a card--horizontal class if set to true. Default: false (optional)
Expand All @@ -19,14 +20,14 @@
Usage:
{% render 'card-product', show_vendor: section.settings.show_vendor %}
{% endcomment %}
{%- unless skip_styles -%}
{{ 'component-rating.css' | asset_url | stylesheet_tag }}
{{ 'component-volume-pricing.css' | asset_url | stylesheet_tag }}

{{ 'component-rating.css' | asset_url | stylesheet_tag }}
{{ 'component-volume-pricing.css' | asset_url | stylesheet_tag }}

{{ 'component-price.css' | asset_url | stylesheet_tag }}
{{ 'quick-order-list.css' | asset_url | stylesheet_tag }}
{{ 'quantity-popover.css' | asset_url | stylesheet_tag }}

{{ 'component-price.css' | asset_url | stylesheet_tag }}
{{ 'quick-order-list.css' | asset_url | stylesheet_tag }}
{{ 'quantity-popover.css' | asset_url | stylesheet_tag }}
{%- endunless -%}
{%- if card_product and card_product != empty -%}
{%- liquid
assign ratio = 1
Expand Down
2 changes: 0 additions & 2 deletions snippets/loading-spinner.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
{% render 'loading-spinner' %}
{% endcomment %}

{{ 'component-loading-spinner.css' | asset_url | stylesheet_tag }}

<div class="{% if class %}{{ class }}{% else %}loading__spinner hidden{% endif %}">
<svg
aria-hidden="true"
Expand Down
2 changes: 0 additions & 2 deletions snippets/progress-bar.liquid
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{{ 'component-progress-bar.css' | asset_url | stylesheet_tag }}

<div class="progress-bar-container hidden">
<div class="progress-bar">
<div class="progress-bar-value"></div>
Expand Down
Loading