Skip to content

Commit 7c437f4

Browse files
feat(gamepad-tester): add gamepad visuals (#413)
1 parent e763173 commit 7c437f4

3 files changed

Lines changed: 433 additions & 4 deletions

File tree

_sass/styles.scss

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,143 @@ table tr:nth-child(2n) {
239239
color: var(--text-col);
240240
}
241241

242+
/* Controller visualization */
243+
.gamepad-visual {
244+
align-items: center;
245+
display: flex;
246+
justify-content: center;
247+
min-height: 16rem;
248+
position: relative;
249+
}
250+
251+
.gamepad-visual > .text-muted {
252+
grid-column: 1 / -1;
253+
}
254+
255+
.gamepad-visual-svg {
256+
display: block;
257+
height: auto;
258+
max-height: 28rem;
259+
max-width: 64rem;
260+
overflow: visible;
261+
width: 100%;
262+
}
263+
264+
.gamepad-visual-control {
265+
fill: var(--bs-primary);
266+
fill-opacity: 0;
267+
pointer-events: none;
268+
transition: fill-opacity 50ms linear;
269+
}
270+
271+
.gamepad-visual-control.active {
272+
filter: drop-shadow(0 0 1.25rem var(--bs-primary));
273+
}
274+
275+
.gamepad-trigger-visual {
276+
--gamepad-trigger-value: 0%;
277+
align-items: center;
278+
background-color: var(--footer-col);
279+
border: 2px solid var(--navbar-border-col);
280+
border-radius: 0.75rem;
281+
display: flex;
282+
flex-direction: column;
283+
isolation: isolate;
284+
min-width: 0;
285+
overflow: hidden;
286+
padding: 0.5rem;
287+
position: absolute;
288+
top: 2.5rem;
289+
transition: border-color 50ms linear, box-shadow 50ms linear;
290+
width: 6rem;
291+
z-index: 1;
292+
}
293+
294+
.gamepad-trigger-visual:first-child {
295+
left: max(calc(50% - 28rem), 0.5rem);
296+
}
297+
298+
.gamepad-trigger-visual:last-child {
299+
right: max(calc(50% - 28rem), 0.5rem);
300+
}
301+
302+
.gamepad-trigger-visual.active {
303+
border-color: var(--bs-primary);
304+
box-shadow: 0 0 1rem rgba(var(--bs-primary-rgb), 0.55);
305+
}
306+
307+
.gamepad-trigger-fill {
308+
background-color: rgba(var(--bs-primary-rgb), 0.45);
309+
bottom: 0;
310+
height: var(--gamepad-trigger-value);
311+
left: 0;
312+
position: absolute;
313+
transition: height 50ms linear;
314+
width: 100%;
315+
z-index: -1;
316+
}
317+
318+
.gamepad-trigger-image {
319+
display: block;
320+
height: auto;
321+
max-height: 3rem;
322+
max-width: 100%;
323+
width: 4rem;
324+
}
325+
326+
.gamepad-trigger-name {
327+
display: none;
328+
font-weight: 700;
329+
line-height: 3rem;
330+
}
331+
332+
.gamepad-trigger-name.visible {
333+
display: block;
334+
}
335+
336+
.gamepad-trigger-value {
337+
font-size: 0.75rem;
338+
font-variant-numeric: tabular-nums;
339+
line-height: 1;
340+
margin-top: 0.35rem;
341+
}
342+
343+
.gamepad-stick-indicator {
344+
fill: var(--bs-primary);
345+
pointer-events: none;
346+
stroke: var(--page-col);
347+
stroke-width: 10;
348+
transition: transform 50ms linear;
349+
}
350+
351+
@media (max-width: 575.98px) {
352+
.gamepad-visual {
353+
display: grid;
354+
gap: 0.35rem;
355+
grid-template-columns: 3rem minmax(0, 1fr) 3rem;
356+
min-height: 10rem;
357+
}
358+
359+
.gamepad-trigger-visual {
360+
align-self: start;
361+
left: auto;
362+
margin-top: 1rem;
363+
padding: 0.25rem;
364+
position: relative;
365+
right: auto;
366+
top: auto;
367+
width: auto;
368+
}
369+
370+
.gamepad-trigger-image {
371+
max-height: 2rem;
372+
}
373+
374+
.gamepad-trigger-value {
375+
font-size: 0.65rem;
376+
}
377+
}
378+
242379
/* Stick visualization */
243380
.stick-circle {
244381
width: 120px;

0 commit comments

Comments
 (0)