Skip to content

Commit

Permalink
new homepage teaser
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis committed May 6, 2024
1 parent 4324857 commit 0a78611
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 16 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "src/server.js",
"scripts": {
"dev": "npm run build && node --watch --es-module-specifier-resolution=node --no-warnings src/server.node.js",
"dev:local-images": "USE_LOCAL_IMAGES=true npm run dev",
"watch": "node esbuild.js --watch",
"build": "node esbuild.js",
"lint": "eslint .",
Expand All @@ -31,4 +32,4 @@
"prettier": "^3.2.5",
"wrangler": "^3.34.0"
}
}
}
Binary file added public/cdn/img/scene/1000/autonomous.webp
Binary file not shown.
Binary file added public/cdn/img/scene/1000/classics.webp
Binary file not shown.
Binary file added public/cdn/img/scene/500/autonomous.webp
Binary file not shown.
Binary file added public/cdn/img/scene/500/classics.webp
Binary file not shown.
Binary file removed public/cdn/img/scene/autonomous.jpg
Binary file not shown.
Binary file removed public/cdn/img/scene/classics.jpg
Binary file not shown.
28 changes: 28 additions & 0 deletions public/cdn/img/scene/convert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Directory containing the original PNG images
input_directory="./full"
# Array of target widths
declare -a sizes=(500 1000)

# Iterate through each file in the input directory
for file in "$input_directory"/*.jpg; do
# Extract filename without extension
filename=$(basename -- "$file")
filename="${filename%.*}"

# Iterate through each size
for size in "${sizes[@]}"; do
# Create output directory if it doesn't exist
output_directory="./$size"
mkdir -p "$output_directory"

# Define output filename
output_file="$output_directory/${filename}.webp"

# Convert and resize the image
convert "$file" -resize "${size}x${size}" - | cwebp -m 6 -q 80 -o "$output_file" -- -
done
done

echo "Conversion completed."
Binary file added public/cdn/img/scene/full/autonomous.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/cdn/img/scene/full/classics.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 28 additions & 15 deletions src/explore/pages/HomePage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Header from "../components/Header.js";
import Footer from "../components/Footer.js";
import Recommendations from "../components/Recommendations.js";
import { html, IMAGE_SERVER } from "../utils.js";
import { html, src, srcset } from "../utils.js";
import Meta from "../components/Meta.js";

/**
Expand All @@ -11,6 +11,19 @@ import Meta from "../components/Meta.js";
* @returns {string} The HomePage component markup.
*/
export default ({ c }) => {
const teaser = [
{
title: "Classic Tractors",
image: "/cdn/img/scene/[size]/classics.webp",
url: "/products/classic",
},
{
title: "Autonomous Tractors",
image: "/cdn/img/scene/[size]/autonomous.webp",
url: "/products/autonomous",
},
];

return html`<!doctype html>
<html>
<head>
Expand All @@ -23,20 +36,20 @@ export default ({ c }) => {
<body data-boundary="explore-page">
${Header({ c })}
<main class="e_HomePage">
<a class="e_HomePage__categoryLink" href="/products/classic"
><img
src="${IMAGE_SERVER}/cdn/img/scene/classics.jpg"
alt="Classic Tractor"
/>
Classic Tractors
</a>
<a class="e_HomePage__categoryLink" href="/products/autonomous"
><img
src="${IMAGE_SERVER}/cdn/img/scene/autonomous.jpg"
alt="Autonomous Tractor"
/>
Autonomous Tractors</a
>
${teaser
.map(
({ title, image, url }) =>
html`<a class="e_HomePage__categoryLink" href="${url}">
<img
src="${src(image, 500)}"
srcet="${srcset(image, [500, 1000])}"
sizes="100vw, (min-width: 500px) 50vw"
alt="${title}"
/>
${title}
</a>`,
)
.join("")}
<div class="e_HomePage__recommendations">
${Recommendations({
skus: ["CL-01-GY", "AU-07-MT"],
Expand Down

0 comments on commit 0a78611

Please sign in to comment.