Halte die gewaehlte Inhaltsliste beim Oeffnen und mache Typ sowie das Logo auf dunkler Flaeche aus der Lieferung erkennbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
dc8a9c2db6
commit
97bffc6175
71 files changed
+572
-142
No files matched your search
@@ -0,0 +1,96 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import "./jinkendo-mark.css";
|
||||
|
||||
const LABELS = { mitai: "Mitai", shinkan: "Shinkan", kairo: "Kairo", kansho: "Kanshō", tsumugu: "Tsumugu" };
|
||||
|
||||
/**
|
||||
* Existing raster brush and product motif on separate layers.
|
||||
* motion: intro = one turn on mount; busy = only during a real pending operation;
|
||||
* none = static. No business state or navigation depends on the animation.
|
||||
*/
|
||||
export function JinkendoMark({
|
||||
product = "tsumugu",
|
||||
size = 48,
|
||||
motion = "intro",
|
||||
assetBase = "/brand/enso-motion-v1",
|
||||
label,
|
||||
onIntroComplete,
|
||||
className = "",
|
||||
}) {
|
||||
if (!Object.hasOwn(LABELS, product)) throw new Error(`Unknown Jinkendo product: ${product}`);
|
||||
const [ringSource, setRingSource] = useState(null);
|
||||
const [symbolSource, setSymbolSource] = useState(null);
|
||||
const [failedSource, setFailedSource] = useState(null);
|
||||
const [introDone, setIntroDone] = useState(false);
|
||||
const [visible, setVisible] = useState(() => typeof document === "undefined" || !document.hidden);
|
||||
const [reduced, setReduced] = useState(() => typeof window === "undefined" || window.matchMedia("(prefers-reduced-motion: reduce)").matches);
|
||||
const source = `${assetBase.replace(/\/$/, "")}/${product}`;
|
||||
|
||||
useEffect(() => {
|
||||
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
|
||||
const updateMotion = () => {
|
||||
setReduced(query.matches);
|
||||
if (query.matches) setIntroDone(true);
|
||||
};
|
||||
const updateVisibility = () => setVisible(!document.hidden);
|
||||
updateMotion();
|
||||
updateVisibility();
|
||||
query.addEventListener("change", updateMotion);
|
||||
document.addEventListener("visibilitychange", updateVisibility);
|
||||
return () => {
|
||||
query.removeEventListener("change", updateMotion);
|
||||
document.removeEventListener("visibilitychange", updateVisibility);
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setIntroDone(false);
|
||||
}, [source]);
|
||||
|
||||
useEffect(() => {
|
||||
if (motion !== "intro" || reduced) setIntroDone(true);
|
||||
}, [motion, reduced]);
|
||||
|
||||
const ready = ringSource === source && symbolSource === source && failedSource !== source;
|
||||
const active = !ready || reduced ? "none" : motion === "busy" ? "busy" : motion === "intro" && !introDone ? "intro" : "none";
|
||||
|
||||
return (
|
||||
<span
|
||||
role="img"
|
||||
aria-label={label || LABELS[product]}
|
||||
className={`jk-mark jk-mark--${active} ${className}`.trim()}
|
||||
data-ready={ready ? "true" : "false"}
|
||||
style={{ "--jk-mark-size": `${size}px`, "--jk-ring-play-state": visible ? "running" : "paused" }}
|
||||
>
|
||||
<img className="jk-mark__poster" src={`${source}/logo-rest.png`} alt="" aria-hidden="true" width="320" height="320" />
|
||||
<img
|
||||
key={`${source}/ring-layer.png`}
|
||||
className="jk-mark__ring"
|
||||
src={`${source}/ring-layer.png`}
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
width="320"
|
||||
height="320"
|
||||
onLoad={() => setRingSource(source)}
|
||||
onError={() => setFailedSource(source)}
|
||||
onAnimationEnd={(event) => {
|
||||
if (event.animationName === "jk-enso-intro") {
|
||||
setIntroDone(true);
|
||||
onIntroComplete?.();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<img
|
||||
key={`${source}/symbol-layer.png`}
|
||||
className="jk-mark__symbol"
|
||||
src={`${source}/symbol-layer.png`}
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
width="320"
|
||||
height="320"
|
||||
onLoad={() => setSymbolSource(source)}
|
||||
onError={() => setFailedSource(source)}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
.jk-mark {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
width: var(--jk-mark-size, 48px);
|
||||
height: var(--jk-mark-size, 48px);
|
||||
overflow: hidden;
|
||||
border-radius: 18.125%;
|
||||
background: #085041;
|
||||
vertical-align: middle;
|
||||
isolation: isolate;
|
||||
}
|
||||
|
||||
.jk-mark > img {
|
||||
display: block;
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: none;
|
||||
margin: 0;
|
||||
object-fit: contain;
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.jk-mark__poster { z-index: 0; }
|
||||
.jk-mark__ring { z-index: 1; transform-origin: 50% 50%; }
|
||||
.jk-mark__symbol { z-index: 2; }
|
||||
.jk-mark[data-ready="false"] .jk-mark__ring,
|
||||
.jk-mark[data-ready="false"] .jk-mark__symbol { visibility: hidden; }
|
||||
.jk-mark[data-ready="true"] .jk-mark__poster { visibility: hidden; }
|
||||
|
||||
.jk-mark--intro .jk-mark__ring {
|
||||
animation: jk-enso-intro 2400ms ease-in-out 1 both;
|
||||
animation-play-state: var(--jk-ring-play-state, running);
|
||||
}
|
||||
|
||||
.jk-mark--busy .jk-mark__ring {
|
||||
animation: jk-enso-busy 3200ms linear infinite;
|
||||
animation-play-state: var(--jk-ring-play-state, running);
|
||||
}
|
||||
|
||||
@keyframes jk-enso-intro { from { transform: rotate(-360deg); } to { transform: rotate(0deg); } }
|
||||
@keyframes jk-enso-busy { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.jk-mark--intro .jk-mark__ring,
|
||||
.jk-mark--busy .jk-mark__ring { animation: none; transform: none; }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/* For animated marks only. Static logo-on-dark PNGs already contain this frame. */
|
||||
.jk-logo-frame {
|
||||
--jk-frame-size: 48px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 0 0 auto;
|
||||
box-sizing: border-box;
|
||||
width: var(--jk-frame-size);
|
||||
height: var(--jk-frame-size);
|
||||
padding: calc(var(--jk-frame-size) / 16);
|
||||
border: calc(var(--jk-frame-size) / 48) solid #5dcaa5;
|
||||
border-radius: calc(var(--jk-frame-size) * 5 / 24);
|
||||
background: #146b57;
|
||||
overflow: hidden;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.jk-logo-frame > .jk-mark {
|
||||
--jk-mark-size: calc(var(--jk-frame-size) * 5 / 6);
|
||||
width: calc(var(--jk-frame-size) * 5 / 6);
|
||||
height: calc(var(--jk-frame-size) * 5 / 6);
|
||||
}
|
||||
Reference in new issue
Block a user