dashboard / myheats / change low width table design to description tables #2 rss

accepted · opened on 2024-10-08 by sam
Help
checkout latest patchset:
ssh pr.in0rdr.ch print pr-2 | git am -3
checkout any patchset in a patch request:
ssh pr.in0rdr.ch print ps-X | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.in0rdr.ch pr add 2
add review to patch request:
git format-patch main --stdout | ssh pr.in0rdr.ch pr add --review 2
accept PR:
ssh pr.in0rdr.ch pr accept 2
close PR:
ssh pr.in0rdr.ch pr close 2

Logs

sam created pr with ps-2 on 2024-10-08
in0rdr_ changed status on 2024-10-10 {"status":"accepted"}

Patchsets

ps-2 by sam on 2024-10-08T22:18:28Z

change low width table design to description tables

index.html link
+2 -2
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
diff --git a/index.html b/index.html
index 05d71f0..3d94e61 100644
--- a/index.html
+++ b/index.html
@@ -3,7 +3,7 @@
   <head>
     <meta charset="UTF-8" />
     <link rel="icon" type="image/x-icon" href="/favicon.ico" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <meta name="viewport" content="width=device-width" />
     <link rel="apple-touch-icon" href="/logo192.png" />
     <!--
       manifest.json provides metadata used when your web app is installed on a
@@ -13,7 +13,7 @@
     <title>My Heats</title>
   </head>
   <body>
-    <noscript>You need to enable JavaScript to run this app.</noscript>
+    <noscript>Why You scared of JavaScript so much, failure.</noscript>
     <div id="root"></div>
     <script type="module" src="/src/frontend/main.jsx"></script>
   </body>
src/frontend/App.jsx link
+2 -2
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
diff --git a/src/frontend/App.jsx b/src/frontend/App.jsx
index b8f6357..1ef94c4 100644
--- a/src/frontend/App.jsx
+++ b/src/frontend/App.jsx
@@ -65,7 +65,7 @@ function Layout() {
   }, [])
 
   return (
-    <Fragment>
+    <>
       <nav className={theme}>
         <ul>
           <li>
@@ -123,7 +123,7 @@ function Layout() {
           }
         </span>
       </footer>
-    </Fragment>
+    </>
   )
 }
 
src/frontend/Leaderboard.jsx link
+150 -100
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
diff --git a/src/frontend/Leaderboard.jsx b/src/frontend/Leaderboard.jsx
index 1e44ddc..b345b12 100644
--- a/src/frontend/Leaderboard.jsx
+++ b/src/frontend/Leaderboard.jsx
@@ -204,46 +204,51 @@ function NewHeatForm(leaderboard, rankingComp, selectHeatRef, selectRankRef, ses
       <p>
         Create new heat with top N athletes from the sorted leaderboard (<i>* required</i>).
       </p>
-      <form method='post' onSubmit={e => newHeatFromLeaderboard(
-          e,
-          leaderboard,
-          rankingComp,
-          selectHeatRef,
-          selectRankRef,
-          session,
-        )}>
-        <table>
-          <thead>
-            <tr>
-              <th>New heat name *</th>
-              <th>Location</th>
-              <th>Planned start</th>
-              <th>Include top N</th>
-              <td></td>
-            </tr>
-          </thead>
-          <tbody>
-            <tr>
-              <td data-title='New heat name *'>
-                <input type='text' name='name' />
-              </td>
-              <td data-title='Location'>
-                <input type='text' name='location' />
-              </td>
-              <td data-title='Planned start'>
-                <input
-                  type='time'
-                  name='planned_start' />
-              </td>
-              <td data-title='Include top N'>
-                <input type='number' name='size' />
-              </td>
-              <td>
-                <button type='submit'>&#43; new</button>
-              </td>
-            </tr>
-          </tbody>
-        </table>
+      <form
+        method="post"
+        onSubmit={(e) =>
+          newHeatFromLeaderboard(
+            e,
+            leaderboard,
+            rankingComp,
+            selectHeatRef,
+            selectRankRef,
+            session
+          )
+        }
+      >
+        <div className="table-container">
+          <table>
+            <thead>
+              <tr>
+                <th>New heat name *</th>
+                <th>Location</th>
+                <th>Planned start</th>
+                <th>Include top N</th>
+                <td></td>
+              </tr>
+            </thead>
+            <tbody>
+              <tr>
+                <td data-title="New heat name *">
+                  <input type="text" name="name" />
+                </td>
+                <td data-title="Location">
+                  <input type="text" name="location" />
+                </td>
+                <td data-title="Planned start">
+                  <input type="time" name="planned_start" />
+                </td>
+                <td data-title="Include top N">
+                  <input type="number" name="size" />
+                </td>
+                <td>
+                  <button type="submit">&#43; new</button>
+                </td>
+              </tr>
+            </tbody>
+          </table>
+        </div>
       </form>
     </div>
   )
@@ -351,85 +356,130 @@ function Leaderboard({session}) {
   }, [heatSelection]);
 
   return (
-    <div>
-      <div className='Leaderboard'>
+    <>
+      <div className="Leaderboard">
         <header>
-          <button disabled={!loading} className='loading' >↺ loading</button>
-          <button className={`show-details ${details ? 'toggled' : ''}`} onClick={() => showDetails(!details)}>
-            <div className='thumb'></div>
-            <span>{details ? 'less' : 'more'}</span>
+          <button disabled={!loading} className="loading">
+            ↺ loading
           </button>
-          <label htmlFor='heat'>Heats to display</label>
+          <button
+            className={`show-details ${details ? "toggled" : ""}`}
+            onClick={() => showDetails(!details)}
+          >
+            <div className="thumb"></div>
+            <span>{details ? "less" : "more"}</span>
+          </button>
+          <label htmlFor="heat">Heats to display</label>
           <Select
             closeMenuOnSelect={false}
             isMulti
             options={heatOpts}
-            onChange={h => setHeatSelection(h)}
+            onChange={(h) => setHeatSelection(h)}
             ref={selectHeatRef}
-            id='heat' />
-           <label htmlFor='rank' className={details ? '' : 'hidden'}>Rank by</label>
-           <Select
+            id="heat"
+          />
+          <label htmlFor="rank" className={details ? "" : "hidden"}>
+            Rank by
+          </label>
+          <Select
             closeMenuOnSelect={false}
             isMulti
             options={rankOpts}
             defaultValue={rankOpts[0].options[3]}
-            onChange={h => setRankingComp(h)}
+            onChange={(h) => setRankingComp(h)}
             ref={selectRankRef}
-            className={details ? '' : 'hidden'}
-            id='rank' />
+            className={details ? "" : "hidden"}
+            id="rank"
+          />
         </header>
-        <table className={details ? 'leaderboard' : 'hide-rank'}>
-          <thead>
-            <tr>
-              <th className={details ? 'right' : 'hidden'}>Rank</th>
-              <th className='right'>Start Nr.</th>
-              <th>Name</th>
-              <th className={details ? '' : 'hidden'}>Birthday</th>
-              <th className={details ? '' : 'hidden'}>School</th>
-              {heatSelection.map(h => (
-                <th className={details ? 'right' : 'hidden'} key={h.value}>{h.label}</th>
+        <div className="table-container">
+          <table className={details ? "leaderboard" : "hide-rank"}>
+            <thead>
+              <tr>
+                <th className={details ? "right" : "hidden"}>Rank</th>
+                <th className="right">Start Nr.</th>
+                <th>Name</th>
+                <th className={details ? "" : "hidden"}>Birthday</th>
+                <th className={details ? "" : "hidden"}>School</th>
+                {heatSelection.map((h) => (
+                  <th className={details ? "right" : "hidden"} key={h.value}>
+                    {h.label}
+                  </th>
+                ))}
+                <th className={details ? "right" : "hidden"}>Best</th>
+                <th className={details ? "right" : "hidden"}>Worst</th>
+                <th className="right">Total</th>
+              </tr>
+            </thead>
+            <tbody>
+              {leaderboard.sort(rankByHeat(rankingComp)).map((i) => (
+                <tr key={i.id}>
+                  <td className={details ? "right" : "hidden"}></td>
+                  <td data-title="Start Nr." className="right">
+                    {i.nr}
+                  </td>
+                  <td data-title="Name">
+                    {i.firstname} {i.lastname}
+                  </td>
+                  <td data-title="Birthday" className={details ? "" : "hidden"}>
+                    {i.birthday
+                      ? new Date(i.birthday).toLocaleDateString(
+                          locale,
+                          dateOptions
+                        )
+                      : ""}
+                  </td>
+                  <td data-title="School" className={details ? "" : "hidden"}>
+                    {i.school}
+                  </td>
+                  {heatSelection.map((h) => (
+                    // list all scores from the judges seperated with '+' signs, show sum on right side
+                    <td
+                      key={h.value}
+                      className={details ? "right" : "hidden"}
+                      data-title={h.label}
+                    >
+                      {formatScores(i, h)}
+                    </td>
+                  ))}
+                  <td
+                    className={details ? "right" : "hidden"}
+                    data-title="Best"
+                  >
+                    {i.bestHeat}
+                  </td>
+                  <td
+                    className={details ? "right" : "hidden"}
+                    data-title="Worst"
+                  >
+                    {i.worstHeat}
+                  </td>
+                  <td className="right total" data-title="Total">
+                    {i.sum}
+                  </td>
+                </tr>
               ))}
-              <th className={details ? 'right' : 'hidden'}>Best</th>
-              <th className={details ? 'right' : 'hidden'}>Worst</th>
-              <th className='right'>Total</th>
-            </tr>
-          </thead>
-          <tbody>
-          {leaderboard.sort(rankByHeat(rankingComp)).map(i => (
-            <tr key={i.id}>
-              <td className={details ? 'right' : 'hidden'}></td>
-              <td data-title='Start Nr.' className='right'>{i.nr}</td>
-              <td data-title='Name'>{i.firstname} {i.lastname}</td>
-              <td data-title='Birthday' className={details ? '' : 'hidden'}>
-                {i.birthday ? new Date(i.birthday).toLocaleDateString(locale, dateOptions) : ''}
-              </td>
-              <td data-title='School' className={details ? '' : 'hidden'}>{i.school}</td>
-              {heatSelection.map(h => (
-                <Fragment key={h.value}>
-                  {/* list all scores from the judges seperated with '+' signs, show sum on right side */}
-                  <td className={details ? 'right' : 'hidden'} data-title={h.label}>{formatScores(i, h)}</td>
-                </Fragment>
-              ))}
-              <td className={details ? 'right' : 'hidden'} data-title='Best'>{i.bestHeat}</td>
-              <td className={details ? 'right' : 'hidden'} data-title='Worst'>{i.worstHeat}</td>
-              <td className='right total' data-title='Total'>{i.sum}</td>
-            </tr>
-          ))}
-          </tbody>
-        </table>
+            </tbody>
+          </table>
+        </div>
       </div>
       <ExportForm
         leaderboard={leaderboard}
         heatSelection={heatSelection}
-        rankingComp={rankingComp} />
-      {session.auth ? <NewHeatForm
-        leaderboard={leaderboard}
         rankingComp={rankingComp}
-        selectHeatRef={selectHeatRef}
-        selectRankRef={selectRankRef}
-        session={session}
-      /> : ''}
-    </div>
+      />
+      {session.auth ? (
+        <NewHeatForm
+          leaderboard={leaderboard}
+          rankingComp={rankingComp}
+          selectHeatRef={selectHeatRef}
+          selectRankRef={selectRankRef}
+          session={session}
+        />
+      ) : (
+        ""
+      )}
+    </>
   )
 }
 
src/frontend/css/App.css link
+37 -36
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
diff --git a/src/frontend/css/App.css b/src/frontend/css/App.css
index ba26e36..ad1fc99 100644
--- a/src/frontend/css/App.css
+++ b/src/frontend/css/App.css
@@ -99,10 +99,11 @@ footer span button {
 }
 
 .loginForm, .exportForm {
-  margin: 30px;
+  margin: auto;
+  padding: 3rem;
 }
 .loginForm button, .loginForm input, .exportForm button {
-  width: 250px;
+  width: 100%;
   display: block;
 }
 
@@ -125,6 +126,11 @@ footer span button {
   padding: 0 20px;
 }
 
+.table-container {
+  padding-top: 1rem;
+  overflow-x: auto;
+}
+
 .Scoring ul {
   display: flex;
   flex-direction: row;
@@ -214,55 +220,50 @@ td.total {
 }
 
 /* https://css-tricks.com/making-tables-responsive-with-minimal-css */
-@media(max-width: 1100px) {
+/* Mobile / Small screen styles */
+@media (max-width: 768px) {
+  table.leaderboard {
+    display: block;
+  }
+
   table.leaderboard thead {
-    left: -9999px;
-    position: absolute;
-    visibility: hidden;
+    display: none;
   }
 
-  table.leaderboard tr {
-    display: flex;
-    flex-direction: row;
-    flex-wrap: wrap;
-    padding: 20px 0;
+  table.leaderboard tbody,
+  table.leaderboard tr,
+  table.leaderboard td {
+    display: block;
   }
 
-  table.leaderboard tr:not(:last-child) {
-    border-bottom: 1px solid #e1e1e7;
+  table.leaderboard tr {
+    padding: 2rem;
   }
 
   table.leaderboard td {
-    margin: 0 -1px -1px 0;
-    padding-top: 35px;
-    margin-bottom: 25px;
+    display: flex;
+    padding: 10px;
+    border-bottom: 1px solid #ddd;
     position: relative;
-    width: 35%;
-    text-align: left !important;
   }
 
-  table.leaderboard td:before {
-    content: attr(data-title);
-    position: absolute;
-    top: 3px;
-    left: 20px;
+  table.leaderboard:not(.hide-rank) tr td:first-child::before {
+    content: counter(rowNumber) ". Rank";
+  }
+
+  table.leaderboard td[data-title]:before {
+    content: attr(data-title) ": ";
+    display: inline-block;
+    width: 50%;
+    padding-right: 1rem;
+    text-align: right;
+    align-content: center;
     font-size: 0.8em;
     text-transform: uppercase;
     color: #b0b0b6;
   }
 
-  table.leaderboard td:nth-child(-n+6) {
-    /* background: rgb(236, 236, 236); */
-  }
-
-  table td button {
-    position: absolute;
-    bottom: 0;
-    height: 50px;
-    width: 100%;
-  }
-
-  table td:empty {
-    display: none;
+  table.leaderboard tr {
+    border-bottom: 1px solid #ddd;
   }
 }
src/frontend/css/index.css link
+7 -1
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
diff --git a/src/frontend/css/index.css b/src/frontend/css/index.css
index ae40ae5..59eaa31 100644
--- a/src/frontend/css/index.css
+++ b/src/frontend/css/index.css
@@ -1,8 +1,13 @@
 * {
   padding: 0;
   margin: 0;
+  box-sizing: border-box;
   font-family: monospace;
-  font-size: 18px;
+  font-size: 1.125rem;
+}
+
+html, body {
+  height: 100%;
 }
 
 a {
@@ -21,6 +26,7 @@ button, input {
   background: white;
   border: 1px solid #f3f2f7;
   color: black;
+  white-space: nowrap;
 }
 
 button {