-
Notifications
You must be signed in to change notification settings - Fork 0
/
apportionment.html
551 lines (467 loc) · 15.9 KB
/
apportionment.html
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PrefTools Apportionment</title>
<link rel="stylesheet" href="pref.tools.css">
<link rel="stylesheet" href="hystmodal.min.css">
<style>
:root {
--form-control-color: rgb(0, 105, 143);
--button-active-color: rgb(49, 166, 209);
--button-hover-color: rgb(9, 120, 160);
}
main {
gap: 0;
}
section#content {
padding-bottom: 1em;
}
aside {
z-index: 2;
position: sticky;
}
aside h1 a {
text-decoration: none;
}
aside input[type=checkbox] {
accent-color: rgb(7, 57, 77);
width: 1.5em;
height: 1.5em;
}
aside .checkbox-option {
display: flex;
gap: 0.3em;
align-items: center;
}
#house-size-controls {
accent-color: rgb(213, 225, 232);
display: flex;
flex-direction: column;
align-items: stretch;
gap: 0.5em;
border: 1px solid rgba(255, 255, 255, 0.269);
padding: 1em;
border-radius: 0.5em;
}
#house-size-controls>div {
text-align: center;
}
#house-size {
width: 3em;
background-color: rgb(213, 225, 232);
border: 0;
border-radius: 5px;
padding: 3px;
padding-left: 6px;
}
#party-inputs {
top: 0;
display: flex;
flex-direction: column;
gap: 0.4em;
width: 12em;
/* background: rgb(155, 172, 180);
background: var(--button-active-color); */
background: rgb(227, 242, 247);
box-shadow: 3px 0px 5px #aaa;
padding: 6em 1.7em 1em 2em;
box-sizing: border-box;
}
.input-size {
position: relative;
display: flex;
justify-content: stretch;
}
.input-size label {
width: 2.5em;
height: 2.2em;
font-size: 100%;
flex: 0 0 2em;
display: grid;
place-content: center;
border: 1px solid black;
border-right: 0px;
border-radius: 5px 0 0 5px;
margin-right: 0;
color: white;
text-shadow: 0px 0px 3px black;
box-sizing: border-box;
cursor: pointer;
}
.input-size .trash {
display: none;
}
.input-size:hover .trash {
display: inline-block;
color: white;
width: 1em;
height: 1em;
}
.input-size:hover .party-name {
display: none;
}
.input-size input {
min-width: none;
width: 100%;
height: 2.2em;
background-color: rgb(252, 252, 252);
border: 1px solid black;
border-left: 0px;
border-radius: 0 5px 5px 0;
padding: 1px 2px 1px 12px;
font-size: 100%;
box-sizing: border-box;
text-align: right;
}
.input-size button {
display: none;
}
.input-size .tooltip {
--tooltip-color: rgba(0, 0, 0, 0.8);
background-color: var(--tooltip-color);
box-sizing: border-box;
border-radius: 5px;
height: 2.93em;
padding: 3px 5px;
font-size: 74%;
color: white;
position: absolute;
top: 0;
right: 0;
transform: translate(calc(100% + 10px));
opacity: 0;
transition: opacity 0.1s;
z-index: 2;
pointer-events: none;
}
.input-size .tooltip:before {
content: "";
position: absolute;
width: 0;
height: 0;
border-width: 8px;
border-style: solid;
border-color: transparent var(--tooltip-color) transparent transparent;
top: 50%;
left: 0;
transform: translate(-100%, -50%);
}
.input-size:hover .tooltip {
opacity: 1;
pointer-events: auto;
}
#add-party-button {
height: 1.8em;
display: grid;
place-content: center;
font-weight: 500;
background-color: rgb(220, 220, 220);
border-radius: 5px;
cursor: pointer;
border: 1px solid black;
}
#add-party-button:active {
transform: scale(0.96);
}
#tabular {
width: 100%;
flex: 1;
display: flex;
align-content: stretch;
}
.method-bar {
flex: 1;
flex-basis: 5em;
cursor: pointer;
margin-right: 0.3em;
}
.method-bar#method-adams {
margin-right: 0;
}
.method-bar:hover .slices {
border: 3px solid orange;
margin-top: -3px;
}
.method-bar:active .slices {
transform: scaleX(0.97) scaleY(0.997);
}
.column-header {
width: 100%;
text-align: center;
margin-bottom: 0.2em;
/* font-size: 100%; */
font-size: calc((100vw - 39em) / 32);
font-weight: 500;
}
.focussed {
flex: 0 0 7em;
transition: flex 0.2s;
}
.collapsed {
overflow: hidden;
flex: 0 0 0;
opacity: 0.4;
margin-right: 0em;
transition:
flex 0.2s 0.2s,
margin-right 0s 0.4s,
opacity 0.1s;
}
.collapsed .column-header {
overflow: hidden;
white-space: nowrap;
}
#explanation {
display: block;
width: 0;
overflow: hidden;
opacity: 0;
flex: 0 0 0;
background-color: #eee;
border: 1px solid #ccc;
border-radius: 7px;
margin: 0;
padding: 0;
height: 90vh;
font-size: 90%;
}
#explanation.visible {
opacity: 1;
flex: 1;
padding: 1em;
margin-left: 1em;
transition:
opacity 0.1s 0.5s,
padding-left 0s 0.5s,
padding-right 0s 0.5s,
padding-top 0.1s 0.5s,
margin-left 0s 0.5s,
flex 0s 0.5s;
box-shadow: inset 0px 0px 5px #aaa;
overflow: scroll;
}
#explanation h2 {
margin: 0;
font-size: 110%;
}
#explanation-modal-content {
padding: 0rem 1rem 0.5rem 1rem;
}
#explanation-modal span.party-name {
display: block;
width: 1.8em;
text-align: center;
color: white;
text-shadow: 0px 0px 3px black;
border: 1px solid black;
border-radius: 5px;
}
#explanation-modal table {
border-collapse: collapse;
margin: 0.5rem 0;
}
#explanation-modal table thead tr {
border-bottom: 2px solid #0000001f;
}
#explanation-modal table thead,
#explanation-modal table tr:nth-child(2n) {
background-color: #00000008;
}
#explanation-modal td,
#explanation-modal th {
padding: 0.3em 0.6em;
border: 1px solid #0000001f;
}
@media screen and (min-width: 1200px) {
.column-header {
font-size: 110%;
}
}
@media screen and (max-width: 1200px) {
aside {
width: 22em;
min-width: 22em;
}
aside h1 {
font-size: 130%;
}
}
@media screen and (max-width: 1024px) {
aside {
width: 16em;
min-width: 16em;
font-size: 93%;
}
#party-inputs {
width: 8em;
padding-left: 1em;
padding-right: 0.5em;
font-size: 93%;
}
#house-size {
width: 2.8em;
}
.column-header {
font-size: calc((100vw - 27em) / 30);
}
}
@media screen and (max-width: 768px) {
aside {
min-width: 13em;
width: 13em;
font-size: 75%;
padding: 1em;
}
#house-size-input {
width: 80px;
}
#party-inputs {
width: 7.5em;
padding-left: 0.5em;
padding-right: 0.5em;
font-size: 80%;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
.input-size label {
width: 1.8em;
flex: 0 0 1.8em;
}
.input-size input {
padding-left: 5px;
}
.column-header {
font-size: calc((100vw - 22em) / 30);
}
}
@media screen and (max-width: 600px) {
aside {
min-width: 100%;
gap: 0.5em;
font-size: 100%;
position: static;
padding-bottom: 0;
}
aside button,
#house-size-controls {
padding: 0.5em;
}
#house-size {
width: 3em;
}
#party-inputs {
width: 100%;
font-size: 100%;
flex-direction: row;
flex-wrap: wrap;
padding: 0.5em;
box-shadow: none;
margin-bottom: 0.3em;
gap: 0.3em;
}
.input-size label {
width: 1.4em;
flex: 0 0 1.4em;
}
.input-size input {
width: 3.8em;
padding-left: 4px;
}
.tip {
margin: 0;
}
.hide-when-small {
display: none;
}
.column-header {
font-size: calc(100vw / 35);
}
#tabular {
gap: 0.1em;
}
.slices {
max-height: 500px !important;
}
}
.slices {
border: 1px solid #999;
border-bottom: 0;
}
.slice {
box-sizing: border-box;
height: 20%;
width: 100%;
background-color: indigo;
color: white;
text-shadow: 0px 0px 4px black;
display: flex;
justify-content: center;
align-items: center;
/* overflow: hidden; */
}
.few-seats {
font-size: 80%;
}
.hystmodal__window {
width: 720px;
}
</style>
</head>
<body>
<div>
<main>
<aside>
<h1><a href="https://pref.tools">
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="users-gear"
class="svg-inline--fa fa-users-gear" role="img" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 640 512">
<path fill="currentColor"
d="M512 160c44.18 0 80-35.82 80-80S556.2 0 512 0c-44.18 0-80 35.82-80 80S467.8 160 512 160zM128 160c44.18 0 80-35.82 80-80S172.2 0 128 0C83.82 0 48 35.82 48 80S83.82 160 128 160zM319.9 320c57.41 0 103.1-46.56 103.1-104c0-57.44-46.54-104-103.1-104c-57.41 0-103.1 46.56-103.1 104C215.9 273.4 262.5 320 319.9 320zM368 400c0-16.69 3.398-32.46 8.619-47.36C374.3 352.5 372.2 352 369.9 352H270.1C191.6 352 128 411.7 128 485.3C128 500.1 140.7 512 156.4 512h266.1C389.5 485.6 368 445.5 368 400zM183.9 216c0-5.449 .9824-10.63 1.609-15.91C174.6 194.1 162.6 192 149.9 192H88.08C39.44 192 0 233.8 0 285.3C0 295.6 7.887 304 17.62 304h199.5C196.7 280.2 183.9 249.7 183.9 216zM551.9 192h-61.84c-12.8 0-24.88 3.037-35.86 8.24C454.8 205.5 455.8 210.6 455.8 216c0 21.47-5.625 41.38-14.65 59.34C462.2 263.4 486.1 256 512 256c42.48 0 80.27 18.74 106.6 48h3.756C632.1 304 640 295.6 640 285.3C640 233.8 600.6 192 551.9 192zM618.1 366.7c-5.025-16.01-13.59-30.62-24.75-42.71c-1.674-1.861-4.467-2.326-6.699-1.023l-19.17 11.07c-8.096-6.887-17.4-12.28-27.45-15.82V295.1c0-2.514-1.861-4.746-4.281-5.213c-16.56-3.723-33.5-3.629-49.32 0C484.9 291.2 483.1 293.5 483.1 295.1v22.24c-10.05 3.537-19.36 8.932-27.45 15.82l-19.26-11.07c-2.139-1.303-4.932-.8379-6.697 1.023c-11.17 12.1-19.73 26.71-24.66 42.71c-.7441 2.512 .2793 5.117 2.42 6.326l19.17 11.17c-1.859 10.42-1.859 21.21 0 31.64l-19.17 11.17c-2.234 1.209-3.164 3.816-2.42 6.328c4.932 16.01 13.49 30.52 24.66 42.71c1.766 1.863 4.467 2.328 6.697 1.025l19.26-11.07c8.094 6.887 17.4 12.28 27.45 15.82v22.24c0 2.514 1.77 4.746 4.188 5.211c16.66 3.723 33.5 3.629 49.32 0c2.42-.4648 4.281-2.697 4.281-5.211v-22.24c10.05-3.535 19.36-8.932 27.45-15.82l19.17 11.07c2.141 1.303 5.025 .8379 6.699-1.025c11.17-12.1 19.73-26.7 24.75-42.71c.7441-2.512-.2773-5.119-2.512-6.328l-19.17-11.17c1.953-10.42 1.953-21.22 0-31.64l19.17-11.17C618.7 371.8 619.7 369.2 618.1 366.7zM512 432c-17.67 0-32-14.33-32-32c0-17.67 14.33-32 32-32s32 14.33 32 32C544 417.7 529.7 432 512 432z">
</path>
</svg> Pref.Tools</a>: Apportionment</h1>
<div id="house-size-controls">
<div>
<label for="house-size-input">House size <em>h</em> = </label>
<input type="number" id="house-size-input" value="100" min="1">
</div>
<input type="range" id="house-size-range" min="1" max="100">
</div>
<button id="random-button"><strong>Generate random input</strong></button>
<!-- <div class="checkbox-option">
<input type="checkbox" id="big-house-size-allowed">
<label for="big-house-size-allowed">Allow big house sizes</label>
</div> -->
<p class="tip"><strong>Tip</strong>: Click on a method to see more details.</p>
<p class="tip hide-when-small"><strong>Tip</strong>: Paste a list of numbers into this page.</p>
<p id="credits">
<a href="https://github.com/DominikPeters/apportionment-app">GitHub</a> ·
built by <a href="https://dominik-peters.de">Dominik Peters</a>
· updated Nov 2023
</p>
</aside>
<div id="party-inputs">
</div>
<section id="content">
<div id="tabular">
</div>
</section>
<div class="hystmodal" id="explanation-modal" aria-hidden="true">
<div class="hystmodal__wrap">
<div class="hystmodal__window" role="dialog" aria-modal="true">
<button data-hystclose class="hystmodal__close">Close</button>
<div id="explanation-modal-content">
</div>
</div>
</div>
</div>
</main>
</div>
<script src="hystmodal.min.js"></script>
<script type="module" src="main.js"></script>
</body>
</html>