Skip to content

Commit

Permalink
Updated theme pwa to latest starter
Browse files Browse the repository at this point in the history
  • Loading branch information
blanklob committed Aug 29, 2023
1 parent b6fbb89 commit 0689ae5
Show file tree
Hide file tree
Showing 32 changed files with 165 additions and 157 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
name: CI
on: [push]
jobs:
lhci:
name: Lighthouse
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lighthouse
uses: shopify/lighthouse-ci-action@v1.1.1
with:
store: ${{ secrets.SHOP_STORE }}
password: ${{ secrets.SHOP_PASSWORD }}
collection_handle: all
access_token: ${{ secrets.SHOP_ACCESS_TOKEN }}
lhci_github_app_token: ${{ secrets.LHCI_GITHUB_TOKEN }}

theme-check:
name: Theme Check
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion assets/styles.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/settings_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"type": "color",
"id": "application_theme_color",
"label": "Application color",
"default": "#000000"
"default": "#1c1c1c"
},
{
"type": "color",
Expand Down
21 changes: 19 additions & 2 deletions layout/theme.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="canonical" href="{{ canonical_url }}">

{% if shop.brand.logo != blank %}
<link rel="icon" type="image/png" href="{{ shop.brand.logo | image_url: width: 32, height: 32 }}">
{% endif %}

{% render 'application' %}

<title>{{ page_title }}</title>
Expand All @@ -16,18 +20,31 @@

{% render 'typography' %}

{{ content_for_header }}
{{ 'styles.css' | asset_url | stylesheet_tag }}

{{ 'styles.css' | asset_url | stylesheet_tag: preload: true }}
{{ content_for_header }}
</head>
<body class="min-h-screen">
<header class="sticky top-0 container mx-auto px-4 flex justify-between items-center py-2 lg:py-4">
<a href="{{ routes.root_url }}" class="font-medium text-lg lg:text-xl no-underline">
{{ shop.name }}
</a>
<a href="https://github.com/odestry/theme-pwa" class="text-gray-500 no-underline" target="_blank">
View on Github
</a>
</header>

<main
id="MainContent"
class="flex flex-col outline-none"
tabindex="-1">
{{ content_for_layout }}
</main>

<footer class="container mx-auto px-4 text-gray-400 py-6 lg:py-8">
{{ powered_by_link }}
</footer>

{% render 'development-screen-indicator' %}

<script>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"scripts": {
"dev": "run-p -sr shopify:dev watch",
"shopify:dev": "shopify theme dev -e development",
"pull": "shopify theme pull -d -o sections/*.json templates/*.json config/*.json",
"watch": "vite build --watch",
"pull": "shopify theme pull -d -o sections/*.json templates/**/*.json config/*.json",
"watch": "vite build -w",
"build": "vite build --minify"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion sections/main-404.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</p>
{% if section.settings.button_label != blank %}
<a
class="inline-flex items-center justify-center px-6 h-11 font-medium rounded-sm text-white bg-black"
class="inline-flex items-center justify-center rounded-sm font-medium transition-colors disabled:pointer-events-none disabled:opacity-50 px-8 h-12 text-white bg-black"
href="{{ routes.root_url }}">
{{ section.settings.button_label }}
</a>
Expand Down
34 changes: 27 additions & 7 deletions sections/main-section.liquid
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<section class="grid items-center py-12 md:py-16 lg:py-20">
<section
class="grid items-center py-[calc(var(--spacing)*0.75)] lg:py-[--spacing]"
style="--spacing: {{ section.settings.spacing }}px">
<div class="container mx-auto px-4 flex flex-col items-start gap-4 md:gap-5">
{% render 'image', class: 'h-[50vh] lg:h-[30rem]', image: section.settings.image %}
{% liquid
assign image = section.settings.image | default: page_image
render 'image' with image, class: 'aspect-square md:aspect-auto lg:h-[30rem]', preload: true
%}
<h1 class="max-w-xl scroll-m-20 text-4xl font-medium tracking-tight lg:text-5xl">
{{ section.settings.heading }}
</h1>
<p class="max-w-prose text-xl text-gray-500">
{{ section.settings.text }}
</p>
{% if section.settings.label != blank %}
{% if section.settings.button_label != blank %}
<button
type="button"
class="inline-flex items-center justify-center px-6 h-11 font-medium rounded-sm text-white bg-black [.no-js_&]:hidden application-button">
{{ section.settings.label }}
</a>
class="inline-flex items-center justify-center rounded-sm font-medium transition-colors disabled:pointer-events-none disabled:opacity-50 px-8 h-12 text-white bg-black application-button">
{{ section.settings.button_label }}
</button>
{% endif %}
</div>
</section>
Expand Down Expand Up @@ -40,9 +45,24 @@
},
{
"type": "text",
"id": "label",
"id": "button_label",
"label": "Button Label",
"default": "Install Application"
},
{
"type": "range",
"id": "spacing",
"min": 0,
"max": 80,
"step": 4,
"unit": "px",
"label": "Vertical Spacing",
"default": 16
}
],
"presets": [
{
"name": "Main Section"
}
]
}
Expand Down
2 changes: 0 additions & 2 deletions snippets/application.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

<link rel="manifest" href="{{ 'manifest.json' | asset_url }}" type="application/json">

{% comment %} {% assign service_worker_url = shop.domain | append: '/cdn/shop/t/70/assets/' | append: 'service-worker.js' | prepend: 'https://' %} {% endcomment %}

{% unless request.design_mode %}
<script>
if ('serviceWorker' in navigator) {
Expand Down
32 changes: 17 additions & 15 deletions snippets/image.liquid
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% comment %}theme-check-disable ImgLazyLoading, RemoteAsset{% endcomment %}
{% comment %}
Renders a specific image.
Renders an image tag with all necessary attributes.
Accepts:
- image: {object} Image object (required)
- image: {object} Image object (optional)
- class: {string} Extra classes (optional)
- lazyload: {boolean} Lazyload the image (optional) (default: false)
- alt: {string} Custom image ALT (optional) (default: image.alt)
Expand All @@ -14,45 +14,47 @@
{% endcomment %}

{% liquid
assign image_class = 'aspect-auto h-auto w-full rounded-sm object-cover ' | append: class
assign class = 'aspect-auto h-auto w-full object-cover rounded-sm ' | append: class
assign alt = alt | default: image.alt | escape

assign lazyload = lazyload | default: false

assign priority = 'auto'
assign decoding = 'auto'

if lazyload == false or lazyload == null
assign loading = 'eager'
assign priority = 'high'
elsif lazyload == true
if lazyload
assign loading = 'lazy'
assign decoding = 'async'
else
assign loading = 'eager'
assign priority = 'high'
endif
%}

<picture class="{{ image_class }}">
<picture class="{{ class }}">
{% if image and image != blank %}
{{
image
| image_url: width: image.width
| image_tag:
alt: image_alt,
class: image_class,
widths: '200,300,400,500,600,700,800,1000,1200,1400,1600,1800,2000,2200',
alt: alt,
class: class,
widths: '100,200,300,400,500,600,700,800,1000,1200,1400,1600,1800,2000',
loading: loading,
fetchpriority: priority,
decoding: decoding
}}
{% else %}
{% liquid
assign placeholder_name = placeholder | default: 'hero-apparel-1'
assign placeholder_image = placeholder_name | placeholder_svg_tag | base64_encode | prepend: 'data:image/svg+xml;base64,'
assign placeholder = placeholder | default: 'hero-apparel-1'
assign placeholder_image = placeholder | placeholder_svg_tag | base64_encode | prepend: 'data:image/svg+xml;base64,'
%}

<img
role="presentation"
class="{{ image_class }}"
class="{{ class }}"
src="{{ placeholder_image }}"
alt="{{ placeholder_name }}"
alt="{{ placeholder }}"
width="800"
height="800"
loading="{{ loading }}"
Expand Down
66 changes: 31 additions & 35 deletions snippets/typography.liquid
Original file line number Diff line number Diff line change
@@ -1,52 +1,48 @@
{% comment %}theme-check-disable AssetPreload{% endcomment %}
{% comment %}
Renders typography variables and tokens.
Renders typography styles and preloads fonts.
Usage:
{% render 'typography' %}
{% endcomment %}

{% comment %} We check if its a system font, or a web-safe font {% endcomment %}
{% unless settings.enable_custom_font %}
{% unless settings.font_heading.system? %}
<link rel="preload" href="{{ settings.font_heading | font_url }}" type="font/woff2" as="font" fetchpriority="high" crossorigin>
{% endunless %}
{% unless settings.font_heading.system? %}
<link rel="preload" href="{{ settings.font_heading | font_url }}" type="font/woff2" as="font" fetchpriority="high" crossorigin>
{% endunless %}

{% unless settings.font_body.system? %}
<link rel="preload" href="{{ settings.font_body | font_url }}" type="font/woff2" as="font" fetchpriority="high" crossorigin>
{% endunless %}
{% unless settings.font_body.system? %}
<link rel="preload" href="{{ settings.font_body | font_url }}" type="font/woff2" as="font" fetchpriority="high" crossorigin>
{% endunless %}

{% style %}
{% unless settings.enable_custom_font %}
{% unless settings.font_heading.system? %}
{% liquid
assign font_heading_medium = settings.font_heading | font_modify: 'weight', '500'
assign font_heading_semi_bold = settings.font_heading | font_modify: 'weight', '600'
assign font_heading_bold = settings.font_heading | font_modify: 'weight', 'bold'
assign font_heading_bold_italic = font_heading_bold | font_modify: 'style', 'italic'
%}
{% unless settings.font_heading.system? %}
{% liquid
assign font_heading_medium = settings.font_heading | font_modify: 'weight', '500'
assign font_heading_semi_bold = settings.font_heading | font_modify: 'weight', '600'
assign font_heading_bold = settings.font_heading | font_modify: 'weight', 'bold'
assign font_heading_bold_italic = font_heading_bold | font_modify: 'style', 'italic'
%}

{{ settings.font_heading | font_face: font_display: 'swap' }}
{{ font_heading_medium | font_face: font_display: 'swap' }}
{{ font_heading_semi_bold | font_face: font_display: 'swap' }}
{{ font_heading_bold | font_face: font_display: 'swap' }}
{{ font_heading_bold_italic | font_face: font_display: 'swap' }}
{% endunless %}
{{ settings.font_heading | font_face: font_display: 'swap' }}
{{ font_heading_medium | font_face: font_display: 'swap' }}
{{ font_heading_semi_bold | font_face: font_display: 'swap' }}
{{ font_heading_bold | font_face: font_display: 'swap' }}
{{ font_heading_bold_italic | font_face: font_display: 'swap' }}
{% endunless %}

{% unless settings.font_body.system? %}
{% liquid
assign font_body_semi_bold = settings.font_body | font_modify: 'weight', '500'
assign font_body_bold = settings.font_body | font_modify: 'weight', 'bold'
assign font_body_italic = font_body | font_modify: 'style', 'italic'
assign font_body_bold_italic = font_body_bold | font_modify: 'style', 'italic'
%}
{% unless settings.font_body.system? %}
{% liquid
assign font_body_semi_bold = settings.font_body | font_modify: 'weight', '500'
assign font_body_bold = settings.font_body | font_modify: 'weight', 'bold'
assign font_body_italic = settings.font_body | font_modify: 'style', 'italic'
assign font_body_bold_italic = font_body_bold | font_modify: 'style', 'italic'
%}

{{ settings.font_body | font_face: font_display: 'swap' }}
{{ font_body_semi_bold | font_face: font_display: 'swap' }}
{{ font_body_bold | font_face: font_display: 'swap' }}
{{ font_body_italic | font_face: font_display: 'swap' }}
{{ font_body_bold_italic | font_face: font_display: 'swap' }}
{% endunless %}
{{ settings.font_body | font_face: font_display: 'swap' }}
{{ font_body_semi_bold | font_face: font_display: 'swap' }}
{{ font_body_bold | font_face: font_display: 'swap' }}
{{ font_body_italic | font_face: font_display: 'swap' }}
{{ font_body_bold_italic | font_face: font_display: 'swap' }}
{% endunless %}
{% endstyle %}
19 changes: 19 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
html {
text-size-adjust: 100%;
text-rendering: optimizeLegibility;
font-variant-ligatures: none;
}

details > summary {
@apply list-none;
}

details summary::-webkit-details-marker {
@apply hidden;
}
}
2 changes: 1 addition & 1 deletion tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Config } from 'tailwindcss'

export default {
content: ['./**/*.{liquid,json,js}'],
content: ['./*/*.{liquid,json,js}'],
theme: {},
plugins: []
} satisfies Config
6 changes: 2 additions & 4 deletions templates/404.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"sections": {
"main": {
"type": "main-404",
"settings": {
}
"type": "main-404"
}
},
"order": [
"main"
]
}
}
6 changes: 2 additions & 4 deletions templates/article.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"sections": {
"main": {
"type": "main-404",
"settings": {
}
"type": "main-404"
}
},
"order": [
"main"
]
}
}
6 changes: 2 additions & 4 deletions templates/blog.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"sections": {
"main": {
"type": "main-404",
"settings": {
}
"type": "main-404"
}
},
"order": [
"main"
]
}
}
Loading

0 comments on commit 0689ae5

Please sign in to comment.