|
73 | 73 | function daysBetween(startDate: Date, endDate: Date) {
|
74 | 74 | return (treatAsUTC(endDate) - treatAsUTC(startDate)) / MSPerDay;
|
75 | 75 | }
|
| 76 | + function daysUntilPlug(plug: Plug) { |
| 77 | + return plug.estPublishDate |
| 78 | + ? Math.round(daysBetween(new Date(Date.now()), plug.estPublishDate)) |
| 79 | + : 0; |
| 80 | + } |
| 81 | + function addS(n: number) { |
| 82 | + return n + (n == 1 ? ' day' : ' days'); |
| 83 | + } |
76 | 84 | </script>
|
77 | 85 |
|
78 | 86 | <div class="grid">
|
79 | 87 | {#each plugs as plug}
|
80 | 88 | <a
|
81 | 89 | class="card"
|
82 |
| - style={`--days-left: "${ |
| 90 | + style={`--days-left: "${addS( |
83 | 91 | plug.estPublishDate ? Math.round(daysBetween(new Date(Date.now()), plug.estPublishDate)) : 0
|
84 |
| - } days"; --days-percent: ${ |
| 92 | + )}"; --days-percent: ${ |
85 | 93 | (plug.estPublishDate
|
86 | 94 | ? Math.round(daysBetween(new Date(Date.now()), plug.estPublishDate))
|
87 | 95 | : 0) / 160
|
|
143 | 151 | /* filter: grayscale(1); */
|
144 | 152 | border-color: var(--gold-700) !important;
|
145 | 153 | filter: blur(calc(var(--days-percent, 0) * 0.2rem)) opacity(calc(1 - var(--days-percent, 0)));
|
146 |
| - transform-origin: calc(100% * var(--days-percent, 0)) 0; |
| 154 | + transform-origin: calc(100% * var(--days-percent, 0)) calc(60% * var(--days-percent, 0)); |
147 | 155 | z-index: -1;
|
148 | 156 | transform: scale(calc(1 - var(--days-percent, 0)));
|
149 | 157 | background-image: linear-gradient(135deg, var(--gold-100) 40%, var(--gold-500) 40%);
|
|
0 commit comments