UNPKG

zextra

Version:

zikojs extra components

110 lines (98 loc) 2.93 kB
:root { } /* Rigid container dimensions + center alignment */ .zextra{ &.joystick-container { --joystick-size: 140px; --handle-size: 20px; --base-bg: #1e293b; --base-border: #334155; --handle-bg: #3b82f6; --handle-shadow: rgba(0, 0, 0, 0.4); --label-color: #94a3b8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; width: var(--joystick-size); flex-shrink: 0; user-select: none; -webkit-user-select: none; touch-action: none; text-align: center; } &.joystick-label { font-size: 0.75rem; font-weight: 700; color: var(--label-color); text-transform: uppercase; letter-spacing: 0.08em; pointer-events: none; } /* Outer Joystick Base Ring/Square */ &.joystick-base { position: relative; width: var(--joystick-size); height: var(--joystick-size); background: var(--base-bg); border: 2px solid var(--base-border); box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5); touch-action: none; outline: none; cursor: pointer; overflow: visible; transform: translate3d(0, 0, 0); margin: 0 auto; } /* Shape variations */ &.joystick-base.shape-circle { border-radius: 50%; } &.joystick-base.shape-square { border-radius: 16px; } &.joystick-base:focus-visible { box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(59, 130, 246, 0.5); } /* Crosshair Guides */ &.joystick-axis-x, .joystick-axis-y { position: absolute; background: rgba(255, 255, 255, 0.05); pointer-events: none; } &.joystick-axis-x { top: 50%; left: 10%; right: 10%; height: 1px; transform: translateY(-50%); } &.joystick-axis-y { left: 50%; top: 10%; bottom: 10%; width: 1px; transform: translateX(-50%); } /* Movable Handle */ &.joystick-handle { position: absolute; top: 50%; left: 50%; width: var(--handle-size); height: var(--handle-size); margin-top: calc(var(--handle-size) / -2); margin-left: calc(var(--handle-size) / -2); background: radial-gradient(circle at 35% 35%, #60a5fa, var(--handle-bg)); border-radius: 50%; box-shadow: 0 4px 10px var(--handle-shadow), inset 0 2px 2px rgba(255, 255, 255, 0.3); cursor: grab; will-change: transform; pointer-events: none; touch-action: none; } &.joystick-base:active .joystick-handle { cursor: grabbing; } }