summaryrefslogtreecommitdiff
path: root/resources/css.org
blob: 4ca2638cce0cb49755284693b1190becedb2f2fe (plain)
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
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
# -*- mode: org; -*-

#+TITLE: Global CSS file
#+SUBTITLE: Site-wide styling informations.
#+AUTHOR: Marius Peter
#+DATE: <2022-01-30 Sun>
#+OPTIONS: toc:nil
#+PROPERTY: header-args :tangle mlnp.css

#+DESCRIPTION: Styling information for the entire following websites: mlnp.fr, wiki.mlnp.fr, and blog.mlnp.fr.
#+KEYWORDS: org-mode emacs blendux mlnp literate programming
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="mlnp.css" />
#+TOC: headlines 2


#+begin_abstract
This page describes the /entire/ website's styling
*information*. After experimenting with =flexbox= and =grid= layouts,
I decided to go with a plain linear document flow. This maximizes
design legibility and the accessibility of affordances. The beginning
of this document contains a placeholder section to test
#+end_abstract


* First level heading
SCHEDULED: <2022-02-18 Fri> DEADLINE: <2022-02-18 Fri>

** Second level heading
<2022-02-18 Fri>

*** Third level heading
<2022-02-18 Fri 12:48>

**** Fourth level heading. This is styled like a list item by default.

- Itemized list.
- This is the second item.
- This third item makes this list respect the [[https://en.wikipedia.org/wiki/Rule_of_three_(writing)][rule of three]].

| Category | Value           |
|----------+-----------------|
|        1 | A first value.  |
|        2 | A second value. |
|        3 | A third value!  |


* Global definitions
<2022-02-11 Fri>

These styles apply across the entire website, to every element.

#+BEGIN_SRC css
  body {
      background: linear-gradient(0deg, skyblue 10%, aliceblue 30%);
      background-attachment: fixed;
      margin: 0;
  }
#+END_SRC


** Colors

Declaring individual one-liner color rules enables efficient searching
for the relevant properties.


*** Variables

These colors variables can be accessed anywhere in the rest of the stylesheet.

#+NAME: colors
#+BEGIN_SRC css
  :root {
      --topnav: dodgerblue;
      --topnav-menu: royalblue;
  }
#+END_SRC


*** Background

We assign colors to the page element backgrounds.

#+BEGIN_SRC css
  .todo { background: tomato; }
  .done { background: forestgreen; }
  .timestamp { background: var(--topnav); }
  .title { background: var(--topnav); }
  #topnav { background: var(--topnav); }
  .button { background: var(--topnav-menu); }
  #topnav #hamburger { background: var(--topnav-menu); }
  #topnav #hamburger:hover { background: white; }
  #topnav #hamburger:hover .line { background: var(--topnav); }
  #topnav .button:hover { background: white; }
  #shadow { background: black; }
  thead { background: var(--topnav); }
  #topnav ul a:hover { background: white; }
  #org-div-home-and-up { background: var(--topnav); }
  #postamble { background: var(--topnav); }
  #outline-container-main-content
  .outline-3 { background: var(--topnav); }
#+END_SRC


*** Foreground

#+NAME: foreground
#+BEGIN_SRC css
  .todo, .done { color: white; }
  .timestamp { color: white; }
  .title { color: white; }
  .subtitle { color: lightgray; }
  .button { color: white; }
  #topnav #hamburger { color: white; }
  #topnav #hamburger:hover { color: var(--topnav-menu); }
  #topnav .button:hover { color: var(--topnav-menu); }
  #topnav ul a { color: white; }
  #topnav ul a:hover { color: var(--topnav-menu); }
  #org-div-home-and-up { color: white; }
  #postamble { color: white; }
  thead { color: white; }
#+END_SRC


** Typefaces

In the following section, we specify the fonts used across the
website. We use the following fonts for the [[https://en.wikipedia.org/wiki/Latin_script][Latin script]]:

- Public Sans :: A modern, smart sans serif font created by the
  [[https://public-sans.digital.gov/][USWDS]]. I use it for body text.
- Jost :: A modern geometric sans serif font by [[https://indestructibletype.com/Jost.html][indestructible
  type*]]. I use it for page title and subtitle.
- Hack :: A monospace typeface designed for source code. I love its
  legible characters and wide coverage, I use it frequently as a
  terminal font. Available at [[https://sourcefoundry.org/hack/][sourcefoundry]].
- Monoisome :: An alternative monospace typeface with great support
  for ligatures and icons. Get it from [[https://larsenwork.com/monoid/][larsenwork]].


We use the following fonts for other scripts:

- Cairo :: A simple, sans-serif typeface for Arabic script.
- Jost :: This font has good support for Cyrillic script.


*** Sans

#+NAME: faces-sans
#+BEGIN_SRC css
  @font-face {
      font-family: "Public Sans";
      src: url("fonts/PublicSans-Regular.otf");
  }
  @font-face {
      font-family: "Jost";
      src: url("fonts/Jost-Regular.ttf");
  }
  @font-face {
      font-family: "Cairo";
      src: url("fonts/Cairo-Regular.ttf");
  }
  @font-face {
      font-family: "Amiri";
      src: url("fonts/Amiri-Regular.ttf");
  }
#+END_SRC


*** Serif

#+NAME: faces-serif
#+BEGIN_SRC css
  /* None for now! */
#+END_SRC


*** Monospace

#+NAME: faces-monospace
#+BEGIN_SRC css
  @font-face {
      font-family: "Hack";
      src: url("fonts/Hack-Regular.ttf");
  }
  @font-face {
      font-family: "Monoisome";
      src: url("fonts/Monoisome-Regular.ttf");
  }
#+END_SRC


*** Assigning fonts to elements

We apply the previously defined font faces to the page elements.

#+NAME: fonts
#+BEGIN_SRC css
  #content { font-family: "Public Sans", sans-serif; }
  .title,
  h1, h2,
  h3, h4,
  #org-div-home-and-up,
  #topnav { font-family: "Jost", sans-serif; }
  pre,
  code, .src,
  .timestamp,
  #postamble { font-family: "Hack", monospace; }
  pre { font-size: 0.8em; line-height: 1em; }
#+END_SRC


** TODO Tab-select styling

Tab-selected content must appear with a wide, contrasted border. This
is an accessiblity concern.

#+BEGIN_SRC css
  a:focus {
      border: 0.2em solid aquamarine;
  }
#+END_SRC


* Homepage

Certains homepage sections are styled uniquely, for visual impact.

#+begin_src css
  #main-content, #text-main-content {
      display: none;
  }
  #outline-container-main-content {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      margin-top: 1em;
      gap: 1em;
  }
  #outline-container-main-content .outline-3 {
      max-width: 12em;
      padding: 0 1em;
      border-radius: 8px;
  }
#+end_src


* Main content

The following rule concerns all the content displayed on the page.

It concerns all children (not all descendants!) of the main ~#content~
section, except for the title and topnav sections.

#+BEGIN_SRC css
  #content > :not(.title, #topnav) {
      line-height: 1.5em;
      width: 60%;
      margin: auto;
  }
  p { text-align: justify; }
#+END_SRC


** TODO `Home' and `Up' links

#+BEGIN_SRC css
  #org-div-home-and-up {}
#+END_SRC


** Title and subtitle

#+BEGIN_SRC css
  .title {
      margin-top: 0;
      margin-bottom: 0;
      padding-top: 0.5em;
      padding-bottom: 0.5em;
  }
#+END_SRC


** Table of contents

The table of contents exported to HTML from Org mode takes the form of
an unordered list. We suppress bullet points that would otherwise
appear before each entry.

#+BEGIN_SRC css
  #table-of-contents ul {
      list-style-type: none;
  }
#+END_SRC


** Tables

Tables are susceptible to becoming very wide and tall. I choose to
make big tables fit in a predetermined footprint so as not to disrupt
document flow. This ensures we can scroll to the following section
without having to scroll the entire table.

Using the ~block~ display property has the additional benefit of
displaying a black border around the table; this provides an
additional visual cue that we have reached the table's horizontal or
vertical extremity.

#+BEGIN_SRC css
  .big-table {
      display: block;
      max-height: 20em;
      max-width: 100%;
      overflow: auto;
      scrollbar-width: thin;
  }
  table caption {
      margin: 0.5em;
      /* background: steelblue; */
  }
#+END_SRC

I also want table headers to stick to the top of the table. This
serves as a useful reminder of the

#+BEGIN_SRC css
  thead {
      position: sticky;
      top: 0;
  }
#+END_SRC


** Images

#+BEGIN_SRC css
.figure img { max-width: 100%; min-width: 30%; }
#+END_SRC


*** TODO Hero images

#+BEGIN_SRC css
  /* .figure { style max-width: 100%; min-width: 30%; } */
#+END_SRC


** Workflow states

Here, we define styling for TODO, DONE and other workflow state
keywords.

#+BEGIN_SRC css
  .todo, .done {
      /* line-height: 1em; */
      font-weight: bold;
      padding: 0 0.2em;
      border-radius: 4px;
      display: inline-block;
  }
#+END_SRC


** Timestamps

<2022-02-14 Mon>--<2022-02-21 Mon>

#+BEGIN_SRC css
  .timestamp {
      display: inline-block;
      padding: 0 0.2em;
      border-radius: 8px;
      white-space: nowrap;
  }
#+END_SRC


** Anchor links

Because of the sticky header, we require all content that can be
jumped to on the page to appear at an offset below this header.

#+BEGIN_SRC css
  h1, h2,
  h3, h4,
  h5, h6,
  #table-of-contents,
  table { scroll-margin-top: 4rem; }
#+END_SRC


** Postamble

#+BEGIN_SRC css
  #postamble {
      width: 18em;
      margin: 1em auto;
      padding: 1em;
      border-radius: 8px;
  }
#+END_SRC


* Responsive top navigation bar

On wide screens, the top navigation bar contains links to the other
top-level website pages. On narrow screens, it contains buttons that
act as shortcuts to the website's home, the page's table of contents,
and links to the other top-level website pages which are accessible
via a hamburger menu.

#+NAME: navbar
#+BEGIN_SRC css
  #topnav {
      z-index: 100;
      position: sticky;
      top: 0;
  }
#+END_SRC


** Components

In this section, we define the appearance of the components contained
inside the top navigation bar.


*** Hamburger menu

As of 2022, hamburger menus are still a contentious topic among UX
designers. It was previously celebrated by mobile designers for its
compact appearance and now universally recognizable function, however,
studies by Google show increased user engagement with interfaces
displaying the possible links or actions as tabs at the bottom of the
interface. I like hamburgers and wanted to challenge my CSS design
skills, so I went with this menu implementation.

In the website's mobile version, the hamburger menu will capture the
top-level navigation links to declutter the top navigation bar.


**** Suppressing the menu checkbox

The checkbox used to toggle the menu is never displayed. We use the
~#hamburger~ and ~#shadow~ labels to toggle the menu instead.

#+BEGIN_SRC css
  #menu-toggle { display: none; }
#+END_SRC


**** Design

The hamburger menu is comprised of three ~div~ elements with class
~.line~ stacked on top of each other, with IDs ~#one~, ~#two~, and
~#three~ respectively.

#+BEGIN_SRC css
  #topnav #hamburger {
      position: absolute;
      right: 0;
      margin: 0.5em;
      padding: 0.5em;
      height: 1.5em;
      width: 1.5em;
      border-radius: 8px;
  }
  #topnav #hamburger .line {
      position: relative;
      height: 0.2em;
      width: 100%;
      margin: 0.2em auto;
      background: white;
      border-radius: 2px;
  }
#+END_SRC


**** Animation

Our juicy hamburger should transform into a cross when activated, and
regain its meaty appearance when deactivated. Modern CSS engines are
powerful enough to animate individual icon components, enabling richer
visuals effects and enhanced affordance cues.


***** Hamburger

#+BEGIN_SRC css
  #menu-toggle:not(:checked) ~ #hamburger #one {
      transform: translateY(0) rotate(0);
      transition: transform 0.2s;
  }
  #menu-toggle:not(:checked) ~ #hamburger #two {
      transition: opacity 0.2s;
      opacity: 1;
  }
  #menu-toggle:not(:checked) ~ #hamburger #three {
      transform: translateY(0) rotate(0);
      transition: transform 0.2s;
  }

#+END_SRC


***** Cross

#+BEGIN_SRC css
  #menu-toggle:checked ~ #hamburger #one {
      transform: translateY(0.4em) rotate(-45deg);
      transition: transform 0.2s;
  }
  #menu-toggle:checked ~ #hamburger #two {
      transition: opacity 0.2s;
      opacity: 0;
  }
  #menu-toggle:checked ~ #hamburger #three {
      transform: translateY(-0.4em) rotate(45deg);
      transition: transform 0.2s;
  }
#+END_SRC




*** Navigation buttons

These buttons appear in the website's narrow version. They present
useful shorcuts to the user, namely links to the homepage and to the
current page's table of contents.

#+BEGIN_SRC css
  #buttons {
      position: absolute;
      margin: 0.5em;
      padding: 0.5em 0;
  }
  .button {
      text-decoration: none;
      border-radius: 0 8px 8px 0;
      padding: 0.5em;
  }
#+END_SRC


** Wide screens


*** Top navigation links---wide

On wide screens, top-level links appears as a banner right under the
page title.

#+BEGIN_SRC css
  #topnav ul {
      display: flex;
      flex-direction: row;
      justify-content: center;
      position: relative;
      list-style-type: none;
      padding: 0.5em;
      margin: 0;
  }
  #topnav ul a {
      padding: 0.5em;
      text-decoration: none;
  }
#+END_SRC


*** Hide navigation buttons

When the top navigation bar is wide, the navigation buttons are hidden
from the viewport.

#+NAME: wide-hidden-buttons
#+BEGIN_SRC css
  #buttons {
      transform: translateX(-200%);
  }
#+END_SRC


*** Hide hamburger menu

The hamburger menu is tucked out of sight, to the right of the
viewport.

#+BEGIN_SRC css
  #hamburger {
      transform: translateX(200%);
  }
#+END_SRC


** Narrow screens

These styles apply to screens narrower than 500px.

#+BEGIN_SRC css :noweb no-export
  @media all and (max-width: 500px) {
      <<narrow-topnav>>
      <<narrow-buttons>>
      <<narrow-hamburger>>
      <<narrow-topnav-links>>
      <<narrow-topnav-menu-toggle>>
      <<narrow-topnav-shadow>>
      <<narrow-content>>
  }
#+END_SRC


*** Top navigation bar

#+NAME: narrow-topnav
#+BEGIN_SRC css :tangle no
  #topnav { height: 3.5em; }
#+END_SRC


*** Navigation buttons

On narrow screens, the navigation buttons become visible.

#+NAME: narrow-buttons
#+BEGIN_SRC css :tangle no
  #topnav #buttons {
      transform: translateX(0);
      transition: transform 1s;
  }
#+END_SRC


*** Hamburger icon

On narrow screens, the hamburger menu also becomes visible.

#+NAME: narrow-hamburger
#+BEGIN_SRC css :tangle no
  #topnav #hamburger {
      transform: translateX(0);
      transition: transform 1s;
  }
#+END_SRC


*** Clickable menu labels

Both the hamburger menu and the shadow cast when the menu is unfolded
should appear clickable to the user.

#+BEGIN_SRC css
  #hamburger, #shadow {
      cursor: pointer;
  }
#+END_SRC


*** TODO Top navigation links---narrow

The navigation links contained in the top banner are stacked into a
column, their visibility can be toggled thanks to the ~#hamburger~
label.

#+NAME: narrow-topnav-links
#+BEGIN_SRC css :tangle no
  #topnav ul {
      position: absolute;
      flex-direction: column;
      background: var(--topnav);
      height: calc(100vh - 3.5em);
      top: 3.5em;
      padding: 0 0.5em;
      justify-content: normal;
      overflow: auto;
  }
  #topnav ul a { display: block; }

#+END_SRC

Toggle appearance of the navigation menu.

#+NAME: narrow-topnav-menu-toggle
#+BEGIN_SRC css :tangle no
  #menu-toggle:not(:checked) ~ ul {
      transition: transform 0.5s;
      transform: translateX(-100%);
  }
  #menu-toggle:checked ~ ul {
      transition: transform 0.5s;
      transform: translateX(0);
  }
#+END_SRC


When the navigation menu is open, the area of the interface not
covered by the navigation links should be obscured. This affords a
larger ``quit'' area, this is more ergonomic for mobile users. This

#+NAME: narrow-topnav-shadow
#+BEGIN_SRC css :tangle no
  #shadow {
      display: block;
      position: absolute;
      height: calc(100vh - 3.5em);
      top: 3.5em;
      right: 0;
      width: 100%;
  }
  #topnav #menu-toggle:not(:checked) ~ #shadow {
      transition: opacity 0.5s;
      visibility: hidden;
      opacity: 0;
  }
  #topnav #menu-toggle:checked ~ #shadow {
      transition: opacity 0.5s;
      visibility: visible;
      opacity: 0.5;
  }
#+END_SRC


*** Narrow content

I'm gonna test the footnotes.[fn:1]

#+NAME: narrow-content
#+BEGIN_SRC css :tangle no
  #content > :not(.title, #topnav) { width: 90%; }
  #outline-container-main-content {
      flex-direction: column;
  }
#+END_SRC


* Footnotes

[fn:1] This footnote is just to test footnote appearance.
Copyright 2019--2026 Marius PETER