1
- ---
2
-
3
- export const COLORS = {
4
- rainbow: [
5
- ' hsl(0deg 0% 18%)' ,
6
- ' hsl(30deg 60% 30%)' ,
7
- ' hsl(0deg 90% 55%)' ,
8
- ' hsl(30deg 95% 65%)' ,
9
- ' hsl(55deg 90% 65%)' ,
10
- ' hsl(100deg 65% 45%)' ,
11
- ' hsl(220deg 80% 55%)' ,
12
- ' hsl(265deg 80% 50%)' ,
13
- ],
14
- ' rainbow-original' : [
15
- ' hsl(0deg 90% 55%)' ,
16
- ' hsl(30deg 95% 65%)' ,
17
- ' hsl(55deg 90% 65%)' ,
18
- ' hsl(100deg 65% 45%)' ,
19
- ' hsl(220deg 80% 55%)' ,
20
- ' hsl(265deg 80% 50%)' ,
21
- ],
22
- trans: [
23
- ' hsl(200deg 85% 70%)' ,
24
- ' hsl(350deg 85% 85%)' ,
25
- ' hsl(0deg 0% 100%)' ,
26
- ' hsl(350deg 85% 85%)' ,
27
- ' hsl(200deg 85% 70%)' ,
28
- ],
29
- pan: [
30
- ' hsl(331deg 100% 55%)' ,
31
- ' hsl(50deg 100% 50%)' ,
32
- ' hsl(200deg 100% 55%)' ,
33
- ]
34
- };
35
-
36
- const variant = ' rainbow-original' ; // rainbow | rainbow-original | trans | pan
37
- const width = 200 ;
38
- const numOfColumns = 20 ;
39
- const staggeredDelay = 50 ;
40
- const billow = 10 ;
41
-
42
- const colors = COLORS [variant ];
43
- const friendlyWidth =
44
- Math .round (width / numOfColumns ) * numOfColumns ;
45
-
46
- const firstColumnDelay = numOfColumns * staggeredDelay * - 1 ;
47
-
48
- function generateGradientString(colors ) {
49
- const numOfColors = colors .length ;
50
- const segmentHeight = 100 / numOfColors ;
51
-
52
- const gradientStops = colors .map ((color , index ) => {
53
- const from = index * segmentHeight ;
54
- const to = (index + 1 ) * segmentHeight ;
55
-
56
- return ` ${color } ${from }% ${to }% ` ;
57
- });
58
-
59
- return ` linear-gradient(to bottom, ${gradientStops .join (' , ' )}) ` ;
60
- }
61
-
62
- function range(n ) {
63
- return Array .from ({ length: n }, (_ , i ) => i );
64
- }
65
-
66
- ---
67
-
68
- <div style =" position: relative" onclick =" window .open (' https:// en.wikipedia.org/wiki/Pride_Month', '_blank')" >
69
- <div class =" flag" style ={ { width: friendlyWidth }} >
70
- { range (numOfColumns ).map ((columnIndex ) => (
71
- <div
72
- class = " column"
73
- style = { {
74
- ' --billow' : columnIndex / numOfColumns * billow + ' px' ,
75
- background: generateGradientString (colors ),
76
- animationDelay:
77
- firstColumnDelay + columnIndex * staggeredDelay + ' ms' ,
78
- }}
79
- />
80
- ))}
81
- </div >
82
- <span class =" flag-text" >
83
- Pride Month
84
- </span >
85
- </div >
86
-
87
-
88
- <style >
89
- @keyframes oscillate {
90
- from {
91
- transform: translateY(var(--billow));
92
- }
93
- to {
94
- transform: translateY(calc(var(--billow) * -1));
95
- }
96
- }
97
-
98
- .flag {
99
- display: flex;
100
- aspect-ratio: 12 / 2;
101
- animation-duration: 600ms;
102
- cursor: pointer;
103
- }
104
-
105
- .flag-text {
106
- position: absolute;
107
- top: 50%;
108
- left: 50%;
109
- transform: translate(-50%, -50%);
110
- font-size: 2rem;
111
- font-weight: bold;
112
- text-shadow: 0 0 10px black, 0 0 20px black;
113
- color: white !important;
114
- user-select: none;
115
- cursor: pointer;
116
- text-wrap: nowrap;
117
- }
118
-
119
- .column {
120
- flex: 1;
121
- display: flex;
122
- flex-direction: column;
123
- animation: oscillate 500ms alternate infinite ease-in-out both;
124
- margin: 0 !important;
125
- }
126
-
127
- .column:first-child {
128
- border-top-left-radius: 8px;
129
- border-bottom-left-radius: 8px;
130
- }
131
-
132
- .column:last-child {
133
- border-top-right-radius: 8px;
134
- border-bottom-right-radius: 8px;
135
- }
136
- </style >
1
+ ---
2
+ export const COLORS = {
3
+ rainbow: [
4
+ ' hsl(0deg 0% 18%)' ,
5
+ ' hsl(30deg 60% 30%)' ,
6
+ ' hsl(0deg 90% 55%)' ,
7
+ ' hsl(30deg 95% 65%)' ,
8
+ ' hsl(55deg 90% 65%)' ,
9
+ ' hsl(100deg 65% 45%)' ,
10
+ ' hsl(220deg 80% 55%)' ,
11
+ ' hsl(265deg 80% 50%)' ,
12
+ ],
13
+ ' rainbow-original' : [' hsl(0deg 90% 55%)' , ' hsl(30deg 95% 65%)' , ' hsl(55deg 90% 65%)' , ' hsl(100deg 65% 45%)' , ' hsl(220deg 80% 55%)' , ' hsl(265deg 80% 50%)' ],
14
+ trans: [' hsl(200deg 85% 70%)' , ' hsl(350deg 85% 85%)' , ' hsl(0deg 0% 100%)' , ' hsl(350deg 85% 85%)' , ' hsl(200deg 85% 70%)' ],
15
+ pan: [' hsl(331deg 100% 55%)' , ' hsl(50deg 100% 50%)' , ' hsl(200deg 100% 55%)' ],
16
+ };
17
+
18
+ const variant = ' rainbow-original' ; // rainbow | rainbow-original | trans | pan
19
+ const width = 200 ;
20
+ const numOfColumns = 20 ;
21
+ const staggeredDelay = 50 ;
22
+ const billow = 10 ;
23
+
24
+ const colors = COLORS [variant ];
25
+ const friendlyWidth = Math .round (width / numOfColumns ) * numOfColumns ;
26
+
27
+ const firstColumnDelay = numOfColumns * staggeredDelay * - 1 ;
28
+
29
+ function generateGradientString(colors ) {
30
+ const numOfColors = colors .length ;
31
+ const segmentHeight = 100 / numOfColors ;
32
+
33
+ const gradientStops = colors .map ((color , index ) => {
34
+ const from = index * segmentHeight ;
35
+ const to = (index + 1 ) * segmentHeight ;
36
+
37
+ return ` ${color } ${from }% ${to }% ` ;
38
+ });
39
+
40
+ return ` linear-gradient(to bottom, ${gradientStops .join (' , ' )}) ` ;
41
+ }
42
+
43
+ function range(n ) {
44
+ return Array .from ({ length: n }, (_ , i ) => i );
45
+ }
46
+ ---
47
+
48
+ <div style =" position: relative" onclick =" window .open (' https:// en.wikipedia.org/wiki/Pride_Month', '_blank')" >
49
+ <div class =" flag" style ={ { width: friendlyWidth }} >
50
+ {
51
+ range (numOfColumns ).map (columnIndex => (
52
+ <div
53
+ class = " column"
54
+ style = { {
55
+ ' --billow' : (columnIndex / numOfColumns ) * billow + ' px' ,
56
+ background: generateGradientString (colors ),
57
+ animationDelay: firstColumnDelay + columnIndex * staggeredDelay + ' ms' ,
58
+ }}
59
+ />
60
+ ))
61
+ }
62
+ </div >
63
+ <span class =" flag-text" > Pride Month </span >
64
+ </div >
65
+
66
+ <style >
67
+ @keyframes oscillate {
68
+ from {
69
+ transform: translateY(var(--billow));
70
+ }
71
+ to {
72
+ transform: translateY(calc(var(--billow) * -1));
73
+ }
74
+ }
75
+
76
+ .flag {
77
+ display: flex;
78
+ aspect-ratio: 12 / 2;
79
+ animation-duration: 600ms;
80
+ cursor: pointer;
81
+ }
82
+
83
+ .flag-text {
84
+ position: absolute;
85
+ top: 50%;
86
+ left: 50%;
87
+ transform: translate(-50%, -50%);
88
+ font-size: 2rem;
89
+ font-weight: bold;
90
+ text-shadow:
91
+ 0 0 10px black,
92
+ 0 0 20px black;
93
+ color: white !important;
94
+ user-select: none;
95
+ cursor: pointer;
96
+ text-wrap: nowrap;
97
+ }
98
+
99
+ .column {
100
+ flex: 1;
101
+ display: flex;
102
+ flex-direction: column;
103
+ animation: oscillate 500ms alternate infinite ease-in-out both;
104
+ margin: 0 !important;
105
+ }
106
+
107
+ .column:first-child {
108
+ border-top-left-radius: 8px;
109
+ border-bottom-left-radius: 8px;
110
+ }
111
+
112
+ .column:last-child {
113
+ border-top-right-radius: 8px;
114
+ border-bottom-right-radius: 8px;
115
+ }
116
+ </style >
0 commit comments