diff --git a/IdoSellAddOn/script.js b/IdoSellAddOn/script.js index 8629540..5e2442b 100644 --- a/IdoSellAddOn/script.js +++ b/IdoSellAddOn/script.js @@ -144,6 +144,7 @@ function idmGetSingleProdGraphQLPM({ name link type + icon ${labels ? "zones" : ""} ${ opinions @@ -406,25 +407,32 @@ async function idmPictureModuleProductsPM(containerEL) { // OPINIE let opinionsHTML = ""; - if (isOpinions) { + if ( + isOpinions && + typeof prodData.opinion?.rating === "number" && + typeof prodData.opinion?.count === "number" + ) { opinionsHTML = `
- - - - - + + + + +
${prodData.opinion.rating} / 5.00 ${prodData.opinion.count} `; } prodEl.innerHTML = ` - ${isLabels ? `${labelsHTML}` : ""} - ${isOpinions ? `
${opinionsHTML}
` : ""} - ${prodData.name} - ${idmMarkupPricePM({ prodData, addToBasket: isAddToBasket })} - ${isAddToBasket ? idmMarkupAddToBasketPM(prodData) : ""} + ${prodData.name} +
+ ${isLabels ? `${labelsHTML}` : ""} + ${isOpinions ? `
${opinionsHTML}
` : ""} + ${prodData.name} + ${idmMarkupPricePM({ prodData, addToBasket: isAddToBasket })} + ${isAddToBasket ? idmMarkupAddToBasketPM(prodData) : ""} +
`; idmInitEventsPM({ @@ -444,21 +452,31 @@ async function idmPictureModuleProductsPM(containerEL) { document.body.addEventListener("click", (e) => { if (app_shop.vars.view === 3 || app_shop.vars.view === 4) return; - const prodContainerEl = e.target.closest(".idm_picture__product"); + const moduleCotnainer = e.target.closest(".idm_picture__module"); + const prodContainerEl = e.target + .closest(".idm_picture__product") + ?.querySelector(".product_info"); + if (!prodContainerEl || !moduleCotnainer) return; // ClearShow - if (!prodContainerEl) - return document - .querySelector(".idm_picture__product.--show") - ?.classList?.remove("--show"); - if (prodContainerEl.classList.contains("--show")) - return prodContainerEl.classList.remove("--show"); + // if(!prodContainerEl) return document.querySelector(".idm_picture__product.--show")?.classList?.remove("--show"); + // if(prodContainerEl.classList.contains("--show")) return prodContainerEl.classList.remove("--show"); - const moduleContainer = prodContainerEl.closest(".idm_picture__module"); - if (!moduleContainer) return; + // const moduleContainer = prodContainerEl.closest(".idm_picture__module"); + // if(!moduleContainer) return; - moduleContainer - .querySelectorAll(".idm_picture__product.--show") - .forEach((prodConEl) => prodConEl.classList.remove("--show")); - prodContainerEl.classList.add("--show"); + // moduleContainer.querySelectorAll(".idm_picture__product.--show").forEach(prodConEl=>prodConEl.classList.remove("--show")); + // prodContainerEl.classList.add("--show"); + const computedStyles = window.getComputedStyle(moduleCotnainer); + const backgroundColor = computedStyles.getPropertyValue("--photo-mod-col-bg"); + const textColor = computedStyles.getPropertyValue("--photo-mod-col-text"); + + new Modal({ + element: prodContainerEl, + classList: "--mobile --photo-prod-mobile", + afterShow: (modal) => { + modal.style.setProperty("--photo-prod-box-bg", backgroundColor || "#fff"); + modal.style.setProperty("--photo-prod-box-text", textColor || "#111"); + }, + }); }); diff --git a/IdoSellAddOn/style.html b/IdoSellAddOn/style.html index a147c3b..ea03f75 100644 --- a/IdoSellAddOn/style.html +++ b/IdoSellAddOn/style.html @@ -1,7 +1,8 @@ diff --git a/package-lock.json b/package-lock.json index 7e137a2..528ebef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@mui/icons-material": "^7.3.6", "@mui/material": "^7.3.6", "react": "^19.2.0", + "react-color": "^2.19.3", "react-dom": "^19.2.0", "react-hot-toast": "^2.6.0", "react-router-dom": "^7.11.0", @@ -1076,6 +1077,15 @@ "url": "https://github.com/sponsors/nzakas" } }, + "node_modules/@icons/material": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@icons/material/-/material-0.2.4.tgz", + "integrity": "sha512-QPcGmICAPbGLGb6F/yNf/KzKqvFx8z5qx3D1yFqVAjoFmXK35EgyW+cJ57Te3CNsmzblwtzakLGFqHPqrfb4Tw==", + "license": "MIT", + "peerDependencies": { + "react": "*" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", @@ -2999,6 +3009,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.23", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz", + "integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==", + "license": "MIT" + }, + "node_modules/lodash-es": { + "version": "4.17.23", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.23.tgz", + "integrity": "sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==", + "license": "MIT" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -3028,6 +3050,12 @@ "yallist": "^3.0.2" } }, + "node_modules/material-colors": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/material-colors/-/material-colors-1.2.6.tgz", + "integrity": "sha512-6qE4B9deFBIa9YSpOc9O0Sgc43zTeVYbgDT5veRKSlB2+ZuHNoVVxA1L/ckMUayV9Ay9y7Z/SZCLcGteW9i7bg==", + "license": "ISC" + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -3268,6 +3296,7 @@ "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", "license": "MIT", + "peer": true, "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -3300,6 +3329,24 @@ "node": ">=0.10.0" } }, + "node_modules/react-color": { + "version": "2.19.3", + "resolved": "https://registry.npmjs.org/react-color/-/react-color-2.19.3.tgz", + "integrity": "sha512-LEeGE/ZzNLIsFWa1TMe8y5VYqr7bibneWmvJwm1pCn/eNmrabWDh659JSPn9BuaMpEfU83WTOJfnCcjDZwNQTA==", + "license": "MIT", + "dependencies": { + "@icons/material": "^0.2.4", + "lodash": "^4.17.15", + "lodash-es": "^4.17.15", + "material-colors": "^1.2.1", + "prop-types": "^15.5.10", + "reactcss": "^1.2.0", + "tinycolor2": "^1.4.1" + }, + "peerDependencies": { + "react": "*" + } + }, "node_modules/react-dom": { "version": "19.2.3", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz", @@ -3404,6 +3451,15 @@ "react-dom": ">=16.6.0" } }, + "node_modules/reactcss": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/reactcss/-/reactcss-1.2.3.tgz", + "integrity": "sha512-KiwVUcFu1RErkI97ywr8nvx8dNOpT03rbnma0SSalTYjkrPYaEajR4a/MRt6DZ46K6arDRbWMNHF+xH7G7n/8A==", + "license": "MIT", + "dependencies": { + "lodash": "^4.0.1" + } + }, "node_modules/resolve": { "version": "1.22.11", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz", @@ -3583,6 +3639,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tinycolor2": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz", + "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==", + "license": "MIT" + }, "node_modules/tinyglobby": { "version": "0.2.15", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", diff --git a/package.json b/package.json index c5ec98b..07c3a69 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@mui/icons-material": "^7.3.6", "@mui/material": "^7.3.6", "react": "^19.2.0", + "react-color": "^2.19.3", "react-dom": "^19.2.0", "react-hot-toast": "^2.6.0", "react-router-dom": "^7.11.0", diff --git a/src/App.jsx b/src/App.jsx index 9ce5c2e..6121fed 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,7 +3,6 @@ import Home from "./pages/Home"; import AppLayout from "./ui/AppLayout"; import Instruction from "./pages/Instruction"; import { Toaster } from "react-hot-toast"; -import { Alert } from "@mui/material"; function App() { return ( diff --git a/src/constants/photo.js b/src/constants/photo.js index 233127d..ea91669 100644 --- a/src/constants/photo.js +++ b/src/constants/photo.js @@ -22,3 +22,17 @@ export const DEFAULT_POINT = { id: 0, direction: Object.keys(DIRECTIONS)[0], }; // Default point structure + +export const DEFAULT_COLOR_PALLETE = [ + "#D9E3F0", + "#F47373", + "#697689", + "#37D67A", + "#2CCCE4", + "#555555", + "#dce775", + "#ff8a65", + "#ba68c8", + "#111111", + "#f2f2f2", +]; diff --git a/src/features/htmlBuilder/components/CodeBox.jsx b/src/features/htmlBuilder/components/CodeBox.jsx index b879671..1b90ab9 100644 --- a/src/features/htmlBuilder/components/CodeBox.jsx +++ b/src/features/htmlBuilder/components/CodeBox.jsx @@ -17,6 +17,13 @@ export default function CodeBox() { } }, [state.urls, state.points, state.photoAlt, state.previewMode]); // reactive slices + if ( + import.meta.env.MODE === "production" && + window.location.href.includes("https://zooart6.yourtechnicaldomain.com/") && + !window.location.search.includes("dev=test") + ) + return null; + const copyCode = () => { navigator.clipboard.writeText(code); toast.success("Skopiowano tekst!"); diff --git a/src/features/htmlBuilder/generated/GeneratePreview.jsx b/src/features/htmlBuilder/generated/GeneratePreview.jsx index ad12fc8..ad0c30a 100644 --- a/src/features/htmlBuilder/generated/GeneratePreview.jsx +++ b/src/features/htmlBuilder/generated/GeneratePreview.jsx @@ -11,6 +11,9 @@ function GeneratePreview({ preview = true }) { const opinions = useSharedState((state) => state.opinions); const addToBasket = useSharedState((state) => state.addToBasket); + const bgColor = useSharedState((state) => state.bgColor); + const textColor = useSharedState((state) => state.textColor); + if (preview && urls[previewMode] === "") return null; return ( @@ -20,6 +23,10 @@ function GeneratePreview({ preview = true }) { data-labels={labels && true} data-opinions={opinions && true} data-add-to-basket={addToBasket && true} + style={{ + "--photo-mod-col-bg": bgColor, + "--photo-mod-col-text": textColor, + }} > {} {} diff --git a/src/features/htmlBuilder/generated/GeneratePreviewImage.jsx b/src/features/htmlBuilder/generated/GeneratePreviewImage.jsx index 0aa687d..afce514 100644 --- a/src/features/htmlBuilder/generated/GeneratePreviewImage.jsx +++ b/src/features/htmlBuilder/generated/GeneratePreviewImage.jsx @@ -1,13 +1,15 @@ import { useSharedState } from "../../../store/useSharedState"; function GeneratePreviewImage({ preview, urls }) { - const imagePrefix = - import.meta.env.MODE === "development" - ? `${import.meta.env.VITE_PUBLIC_URL}/` - : ""; const previewMode = useSharedState((state) => state.previewMode); const photoAlt = useSharedState((state) => state.photoAlt); + const imagePrefix = + import.meta.env.MODE === "development" && + !urls[previewMode]?.includes("https://") + ? `${import.meta.env.VITE_PUBLIC_URL}/` + : ""; + if (preview) return ( {preview && ( - <> +
{labels && ( Nowość @@ -130,7 +130,7 @@ function GeneratePreviewSinglePoint({ Do koszyka )} - +
)} diff --git a/src/features/htmlBuilder/generated/GenerateStyle.jsx b/src/features/htmlBuilder/generated/GenerateStyle.jsx index f2dc998..7168d16 100644 --- a/src/features/htmlBuilder/generated/GenerateStyle.jsx +++ b/src/features/htmlBuilder/generated/GenerateStyle.jsx @@ -3,397 +3,443 @@ function GenerateStyle() { <> diff --git a/src/features/photoModule/PhotoGenericOptions.jsx b/src/features/photoModule/PhotoGenericOptions.jsx index 719fff1..8ef3a2f 100644 --- a/src/features/photoModule/PhotoGenericOptions.jsx +++ b/src/features/photoModule/PhotoGenericOptions.jsx @@ -6,6 +6,8 @@ import { FormGroup, Switch, } from "@mui/material"; +import ColorPickerInput from "../../ui/ColorPickerInput"; +import { DEFAULT_COLOR_PALLETE } from "../../constants/photo"; function PhotoGenericOptions() { const setField = useSharedState((state) => state.setField); @@ -15,6 +17,8 @@ function PhotoGenericOptions() { const labels = useSharedState((state) => state.labels); const opinions = useSharedState((state) => state.opinions); const addToBasket = useSharedState((state) => state.addToBasket); + const bgColor = useSharedState((state) => state.bgColor); + const textColor = useSharedState((state) => state.textColor); const handleUrlRadioChange = (e) => { toggleField("isRWD"); @@ -67,6 +71,25 @@ function PhotoGenericOptions() { +
+ setField("bgColor", newColor)} + label="Kolor Tła" + palette={DEFAULT_COLOR_PALLETE} + /> + setField("textColor", newColor)} + label="Kolor Tekstu" + palette={DEFAULT_COLOR_PALLETE} + /> +
+ + + Uwaga!
diff --git a/src/main.jsx b/src/main.jsx index e8f56c2..5257df6 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -1,28 +1,26 @@ -import React from 'react' -import ReactDOM from 'react-dom/client' -import App from './App' -import { ThemeProvider, CssBaseline } from '@mui/material'; -import { BrowserRouter } from 'react-router-dom'; -import theme from './styles/theme'; +import React from "react"; +import ReactDOM from "react-dom/client"; +import App from "./App"; +import { ThemeProvider, CssBaseline } from "@mui/material"; +import { BrowserRouter } from "react-router-dom"; +import theme from "./styles/theme"; // import ThemeCssVars from './styles/ThemeCssVars'; - const BASENAME = import.meta.env.VITE_PUBLIC_URL || "/"; const path = window.location.pathname; -if (path.endsWith('index.html')) { - window.location.replace(BASENAME); +if (path.endsWith("index.html")) { + window.location.replace(BASENAME); } - -ReactDOM.createRoot(document.getElementById('root')).render( - - - - - {/* */} - - - - -) \ No newline at end of file +ReactDOM.createRoot(document.getElementById("root")).render( + + + + + {/* */} + + + + , +); diff --git a/src/store/useSharedState.js b/src/store/useSharedState.js index 7df4e6e..b8f4cb1 100644 --- a/src/store/useSharedState.js +++ b/src/store/useSharedState.js @@ -13,6 +13,10 @@ const defaultState = { labels: false, opinions: false, addToBasket: false, + + //colros + bgColor: "#fff", + textColor: "#060606", }; export const useSharedState = create( @@ -110,6 +114,9 @@ export const useSharedState = create( addToBasket: state.addToBasket, previewMode: state.previewMode, isRWD: state.isRWD, + + bgColor: state.bgColor, + textColor: state.textColor, }), }, ), diff --git a/src/ui/ColorPickerInput.jsx b/src/ui/ColorPickerInput.jsx new file mode 100644 index 0000000..06d5158 --- /dev/null +++ b/src/ui/ColorPickerInput.jsx @@ -0,0 +1,71 @@ +import { useEffect, useRef, useState } from "react"; +import { BlockPicker } from "react-color"; +import { Box, ButtonBase, Typography } from "@mui/material"; + +function ColorPickerButton({ color, onChange, label = "Color", palette = [] }) { + const [open, setOpen] = useState(false); + const wrapperRef = useRef(null); + + useEffect(() => { + function handleClickOutside(e) { + if (!wrapperRef.current?.contains(e.target)) { + setOpen(false); + } + } + + if (open) { + document.addEventListener("mousedown", handleClickOutside); + } + + return () => { + document.removeEventListener("mousedown", handleClickOutside); + }; + }, [open]); + + return ( + + {label && ( + + {label} + + )} + + setOpen((v) => !v)} + sx={{ + width: "100%", + height: 32, + borderRadius: 1, + border: "1px solid", + borderColor: "divider", + backgroundColor: color, + }} + /> + + {open && ( + + onChange(c.hex)} + /> + + )} + + ); +} + +export default ColorPickerButton;