Ron Au commited on
Commit
38e3cc4
1 Parent(s): 99431c9

feat(a11y): Adjust for prefers-reduced-motion

Browse files
Files changed (2) hide show
  1. static/js/index.js +3 -1
  2. static/style.css +56 -8
static/js/index.js CHANGED
@@ -60,7 +60,9 @@ const generate = async () => {
60
 
61
  mousemoveHandlerForPreviousCard = initialiseCardRotation(scene);
62
 
63
- await new Promise((resolve) => setTimeout(resolve, 1_000));
 
 
64
 
65
  setOutput('card', 'completed');
66
  } catch (err) {
 
60
 
61
  mousemoveHandlerForPreviousCard = initialiseCardRotation(scene);
62
 
63
+ await new Promise((resolve) =>
64
+ setTimeout(resolve, window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 1_500 : 1_000)
65
+ );
66
 
67
  setOutput('card', 'completed');
68
  } catch (err) {
static/style.css CHANGED
@@ -57,16 +57,10 @@ main {
57
  main {
58
  padding: 3rem 0;
59
  }
60
-
61
- .output .actions {
62
- display: flex;
63
- width: 90vw;
64
- flex-wrap: wrap;
65
- }
66
  }
67
 
68
  @media (max-width: 1280px) {
69
- .info h1 {
70
  font-size: 3rem;
71
  }
72
 
@@ -128,6 +122,12 @@ section {
128
  transition: font-size 0.5s ease;
129
  }
130
 
 
 
 
 
 
 
131
  .info label {
132
  width: 100%;
133
  text-align: center;
@@ -184,6 +184,7 @@ input:focus {
184
  .output .actions {
185
  display: flex;
186
  flex-direction: row;
 
187
  justify-content: center;
188
  align-items: center;
189
  gap: 1rem;
@@ -578,7 +579,7 @@ img.hf-logo {
578
  }
579
  }
580
 
581
- [data-mode='booster']:is([data-state='ready'], [data-state='generating'], [data-state='completed'], [data-state='failed']) .booster {
582
  display: block;
583
  }
584
 
@@ -603,6 +604,10 @@ img.hf-logo {
603
  transform: scale(0);
604
  }
605
 
 
 
 
 
606
  [data-mode='card'][data-state='completed'] .booster {
607
  --booster-scale: 0;
608
  }
@@ -611,6 +616,47 @@ img.hf-logo {
611
  transform: scale(1);
612
  }
613
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
614
 
615
  /* Pokémon Card */
616
 
@@ -743,6 +789,7 @@ img.hf-logo {
743
  --card-scale: 1;
744
  display: flex;
745
  flex-direction: column;
 
746
  width: 25rem;
747
  height: 35rem;
748
  padding: 0.5rem 1rem 0.1rem;
@@ -762,6 +809,7 @@ img.hf-logo {
762
  transform-origin: center;
763
  transform: rotateX(var(--card-rx)) rotateY(var(--card-ry)) scale(var(--card-scale));
764
  transition: transform 0.5s ease-out;
 
765
  }
766
 
767
  .pokecard[data-displayed='true'] {
 
57
  main {
58
  padding: 3rem 0;
59
  }
 
 
 
 
 
 
60
  }
61
 
62
  @media (max-width: 1280px) {
63
+ section.info h1 {
64
  font-size: 3rem;
65
  }
66
 
 
122
  transition: font-size 0.5s ease;
123
  }
124
 
125
+ @media (prefers-reduced-motion) {
126
+ .info h1 {
127
+ transition: none;
128
+ }
129
+ }
130
+
131
  .info label {
132
  width: 100%;
133
  text-align: center;
 
184
  .output .actions {
185
  display: flex;
186
  flex-direction: row;
187
+ flex-wrap: wrap;
188
  justify-content: center;
189
  align-items: center;
190
  gap: 1rem;
 
579
  }
580
  }
581
 
582
+ [data-mode='booster'] .booster {
583
  display: block;
584
  }
585
 
 
604
  transform: scale(0);
605
  }
606
 
607
+ [data-mode='booster'][data-state='completed'] .back {
608
+ display: none;
609
+ }
610
+
611
  [data-mode='card'][data-state='completed'] .booster {
612
  --booster-scale: 0;
613
  }
 
616
  transform: scale(1);
617
  }
618
 
619
+ @media (prefers-reduced-motion) {
620
+ @keyframes pulse {
621
+ from { opacity: 1; }
622
+ to { opacity: 0.6; }
623
+ }
624
+
625
+ @keyframes fade {
626
+ from { opacity: 1; }
627
+ to { opacity: 0; }
628
+ }
629
+
630
+ .card-slot .pokecard {
631
+ transition: none;
632
+ }
633
+
634
+ [data-mode='booster']:is([data-state='generating'], [data-state='completed']) .scene {
635
+ animation: 1.5s pulse alternate ease-in-out infinite forwards;
636
+ }
637
+
638
+ [data-state='generating'] .booster {
639
+ animation: 10s bounce infinite ease-out;
640
+ }
641
+
642
+ [data-mode='booster'][data-state='completed'] .booster {
643
+ animation: 1s fade ease-in forwards;
644
+ }
645
+
646
+ [data-state='completed'] .card-slot {
647
+ transition: opacity 1s ease-in;
648
+ }
649
+
650
+ [data-mode='booster'][data-state='completed'] .card-slot {
651
+ transform: scale(1);
652
+ opacity: 0;
653
+ }
654
+
655
+ [data-mode='card'][data-state='completed'] .card-slot {
656
+ opacity: 1;
657
+ }
658
+ }
659
+
660
 
661
  /* Pokémon Card */
662
 
 
789
  --card-scale: 1;
790
  display: flex;
791
  flex-direction: column;
792
+ position: relative;
793
  width: 25rem;
794
  height: 35rem;
795
  padding: 0.5rem 1rem 0.1rem;
 
809
  transform-origin: center;
810
  transform: rotateX(var(--card-rx)) rotateY(var(--card-ry)) scale(var(--card-scale));
811
  transition: transform 0.5s ease-out;
812
+ filter: drop-shadow(0 0.75rem 1rem hsl(0 0% 50% / 50%));
813
  }
814
 
815
  .pokecard[data-displayed='true'] {