2023-08-10 19:58:22 -07:00
|
|
|
import React from "react";
|
|
|
|
import ReactDOM from "react-dom";
|
|
|
|
|
|
|
|
import { AppProvider, ItemPageOutfitPreview } from "./wardrobe-2020";
|
|
|
|
|
|
|
|
const rootNode = document.querySelector("#outfit-preview-root");
|
|
|
|
const itemId = rootNode.getAttribute("data-item-id");
|
2023-11-02 18:03:15 -07:00
|
|
|
// TODO: Use the new React 18 APIs instead!
|
|
|
|
// eslint-disable-next-line react/no-deprecated
|
2023-08-10 19:58:22 -07:00
|
|
|
ReactDOM.render(
|
|
|
|
<AppProvider>
|
|
|
|
<ItemPageOutfitPreview itemId={itemId} />
|
|
|
|
</AppProvider>,
|
2023-10-24 16:45:49 -07:00
|
|
|
rootNode,
|
2023-08-10 19:58:22 -07:00
|
|
|
);
|
2024-01-19 04:29:43 -08:00
|
|
|
|
|
|
|
try {
|
|
|
|
const tradeHangers = document.querySelector("#trade-hangers");
|
|
|
|
const tradeSections = document.querySelectorAll("#trade-hangers p");
|
|
|
|
for (const section of tradeSections) {
|
|
|
|
const oneLine = parseFloat(getComputedStyle(section)['line-height']);
|
2024-01-19 04:35:44 -08:00
|
|
|
const maxHeight = Math.ceil(oneLine * 2);
|
2024-01-19 04:29:43 -08:00
|
|
|
|
2024-01-19 04:35:44 -08:00
|
|
|
if (section.clientHeight > maxHeight) {
|
2024-01-19 04:29:43 -08:00
|
|
|
section.style.maxHeight = `${maxHeight}px`;
|
|
|
|
section.setAttribute("data-overflows", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
section.querySelector(".more")?.addEventListener("click", (event) => {
|
|
|
|
section.setAttribute("data-showing-more", "");
|
|
|
|
section.style.maxHeight = "none";
|
|
|
|
});
|
|
|
|
|
|
|
|
section.querySelector(".less")?.addEventListener("click", (event) => {
|
|
|
|
section.removeAttribute("data-showing-more");
|
|
|
|
section.style.maxHeight = `${maxHeight}px`;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error("Error applying trade list more/less toggle", error);
|
|
|
|
}
|