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

cleanup: more demo page enhacements #3106

Merged
merged 2 commits into from
Jan 10, 2025
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
14 changes: 10 additions & 4 deletions server/src/public/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,20 @@
<script type="module">
import {renderToDiv} from '{{ search_component_url | safe }}/dist/vanilla/index.js';
const root = document.querySelector("#root");
const params = {{params | tojson}};

const params = {{ params | tojson }};
if (params.inline) {
const inlineParams = {{ params | tojson }};
const inlineRoot = document.querySelector("#inline-root");
params.groupTrackingId = params.singleProductOptions.groupTrackingId;
params.cleanGroupName = params.singleProductOptions.productName;
inlineParams.groupTrackingId = params.singleProductOptions.groupTrackingId;
inlineParams.cleanGroupName = params.singleProductOptions.productName;

if (inlineParams.singleProductOptions && inlineParams.singleProductOptions.productQuestions) {
inlineParams.defaultAiQuestions = inlineParams.singleProductOptions.productQuestions;
}

renderToDiv(inlineRoot, {
...params,
...inlineParams,
})
}

Expand Down
14 changes: 7 additions & 7 deletions server/src/public/product.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h4 class="text-sm text-gray-500 mt-2 w-fit">
class="recs mt-6 flex flex-nowrap overflow-x-auto gap-x-4 sm:gap-x-6 xl:gap-x-8 py-2"
>
{% for i in range(5) %}
<div class="w-64 flex-shrink-0" x-key="{{ i }}">
<div class="mt-auto w-64 flex-shrink-0" x-key="{{ i }}">
<div class="h-72 w-full overflow-hidden rounded-lg">
<div class="h-full w-full bg-gray-200 animate-pulse"></div>
</div>
Expand Down Expand Up @@ -117,7 +117,7 @@ <h4 class="text-sm text-gray-500 mt-2 w-fit">
recProducts.forEach((recProduct, i) => {
if (!idsToKeep.includes(recProduct.getAttribute("x-group-tracking-id"))) {
const newDiv = document.createElement("div");
newDiv.classList.add("w-64", "flex-shrink-0");
newDiv.classList.add("w-64", "flex-shrink-0", "mt-auto");
newDiv.setAttribute("x-key", i);
newDiv.innerHTML = `
<div class="h-72 w-full overflow-hidden rounded-lg">
Expand Down Expand Up @@ -283,16 +283,16 @@ <h4 class="text-sm text-gray-500 mt-2 w-fit">
const price = priceNum ? `$${priceNum.toFixed(2)}` : null;

const chunkElement = document.createElement("div");
chunkElement.classList.add(...["rec", "w-64", "flex-shrink-0"]);
chunkElement.classList.add(...["rec", "w-64", "flex-shrink-0", "mt-auto"]);
chunkElement.setAttribute("x-group-tracking-id", groupTrackingId);
chunkElement.innerHTML = `
<div
class="h-72 w-full overflow-hidden rounded-lg"
class="w-full overflow-hidden rounded-lg"
>
<img
src="${imageUrl}"
alt="${title}"
class="rec-image size-full object-cover"
class="rec-image w-full object-cover"
/>
</div>
<div class="mt-4">
Expand All @@ -302,12 +302,12 @@ <h6 class="rec-price mt-1 text-sm text-gray-700">${price}</h6>
</div>
<div class="mt-6 flex gap-2">
<button
class="similar-button rec-button bg-brand-color w-1/2 flex items-center justify-center rounded-md border border-transparent px-8 py-2 text-sm font-medium text-white"
class="similar-button rec-button bg-brand-color w-1/2 flex items-center justify-center rounded-md border border-transparent px-1 py-2 text-sm font-medium text-white"
>
More Like This
</button>
<button
class="different-button rec-button bg-brand-color w-1/2 flex items-center justify-center rounded-md border border-transparent px-8 py-2 text-sm font-medium text-white"
class="different-button rec-button bg-brand-color w-1/2 flex items-center justify-center rounded-md border border-transparent px-1 py-2 text-sm font-medium text-white"
>
Less Like This
</button>
Expand Down
14 changes: 9 additions & 5 deletions server/static/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,10 @@ video {
margin-top: 2rem;
}

.mt-auto {
margin-top: auto;
}

.line-clamp-1 {
overflow: hidden;
display: -webkit-box;
Expand All @@ -639,11 +643,6 @@ video {
display: none;
}

.size-full {
width: 100%;
height: 100%;
}

.h-10 {
height: 2.5rem;
}
Expand Down Expand Up @@ -832,6 +831,11 @@ video {
object-fit: cover;
}

.px-1 {
padding-left: 0.25rem;
padding-right: 0.25rem;
}

.px-3 {
padding-left: 0.75rem;
padding-right: 0.75rem;
Expand Down