-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
760 lines (681 loc) · 26.3 KB
/
index.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
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
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#196EC2"/>
<meta name="description" content="A starter app highlighting patterns to use in a vanilla CSS app">
<meta name="keywords" content="css,tailwind,pico,bootstrap,html,style,react,mui,material,design">
<title>CSS Starter</title>
<link rel="stylesheet" href="./css/reset.css">
<link rel="stylesheet" href="./css/theme.css">
<link rel="stylesheet" href="./css/typography.css">
<link rel="stylesheet" href="./css/layout.css">
<link rel="stylesheet" href="./css/menu.css">
<link rel="stylesheet" href="./css/forms.css">
<link rel="stylesheet" href="./css/buttons.css">
<link rel="stylesheet" href="./css/tables.css">
<link rel="stylesheet" href="./css/modals.css">
<link rel="stylesheet" href="./css/dropdowns.css">
<link rel="stylesheet" href="./css/tooltips.css">
<link rel="stylesheet" href="./css/cards.css">
<link rel="stylesheet" href="./css/toggles.css">
<link rel="stylesheet" href="./css/flash.css">
<link rel="stylesheet" href="./css/accordions.css">
<link rel="icon" href="favicon.ico" sizes="48x48">
<link rel="icon" href="favicon.svg" sizes="any" type="image/svg+xml"/>
</head>
<body>
<header>
<ul>
<li class="heading">
<svg class="logo">
<use xlink:href="images/icons.svg#logo"></use>
</svg>
</li>
<li class="heading">
<h1>CSS Starter</h1>
</li>
<li class="menu-toggle" onclick="document.querySelector('body').classList.toggle('menu-open')">
<svg class="open">
<use xlink:href="images/icons.svg#menu"></use>
</svg>
<svg class="close">
<use xlink:href="images/icons.svg#close"></use>
</svg>
</li>
</ul>
<ul>
<li class="dropdown">
<a href="#" class="button" aria-haspopup="true">
<svg>
<use xlink:href="images/icons.svg#account"></use>
</svg>
My account
</a>
<ul class="menu" aria-label="submenu">
<li><a href="#">Another account</a></li>
<li><a href="#">Some other account</a></li>
</ul>
</li>
<li>
<a href="#" aria-label="log out">
<svg>
<use xlink:href="images/icons.svg#log-out"></use>
</svg>
</a>
</li>
</ul>
</header>
<nav>
<div class="scrollable">
<h2>Components</h2>
<ul>
<li>
<a href="#typography">
<svg>
<use xlink:href="images/icons.svg#text"></use>
</svg>
Typography
</a>
</li>
<li>
<a href="#forms">
<svg>
<use xlink:href="images/icons.svg#list"></use>
</svg>
Forms
</a>
</li>
<li>
<a href="#tables">
<svg>
<use xlink:href="images/icons.svg#table"></use>
</svg>
Tables
</a>
</li>
<li>
<a href="#modals">
<svg>
<use xlink:href="images/icons.svg#dialog"></use>
</svg>
Modals
</a>
</li>
<li>
<a href="#tooltips">
<svg>
<use xlink:href="images/icons.svg#tooltip"></use>
</svg>
Tooltips
</a>
</li>
<li>
<a href="#cards">
<svg>
<use xlink:href="images/icons.svg#cards"></use>
</svg>
Cards
</a>
</li>
<li>
<a href="#buttons">
<svg>
<use xlink:href="images/icons.svg#button"></use>
</svg>
Buttons
</a>
</li>
<li>
<a href="#code">
<svg>
<use xlink:href="images/icons.svg#code"></use>
</svg>
Code
</a>
</li>
<li>
<a href="#toggles">
<svg>
<use xlink:href="images/icons.svg#toggle"></use>
</svg>
Toggles
</a>
</li>
<li>
<a href="#flash-messages">
<svg>
<use xlink:href="images/icons.svg#flash"></use>
</svg>
Flash messages
</a>
</li>
<li>
<a href="#accordions">
<svg>
<use xlink:href="images/icons.svg#accordion"></use>
</svg>
Accordions
</a>
</li>
</ul>
<h2>Patterns</h2>
<ul>
<li>
<a href="#theming">
<svg>
<use xlink:href="images/icons.svg#palette"></use>
</svg>
Theming
</a>
</li>
<li>
<a href="#icons">
<svg>
<use xlink:href="images/icons.svg#image"></use>
</svg>
Icons
</a>
</li>
<li>
<a href="#favicon">
<svg>
<use xlink:href="images/icons.svg#logo"></use>
</svg>
Favicon
</a>
</li>
<li>
<a href="#sidebar">
<svg>
<use xlink:href="images/icons.svg#sidebar"></use>
</svg>
Sidebar
</a>
</li>
</ul>
</div>
</nav>
<main>
<section>
<h1>CSS Starter</h1>
<p>
The CSS Starter contains components and patterns for building pure CSS UI.
It is not a CSS framework!
</p>
<p>
To build a site with the CSS starter, start from scratch with only a
<a href="http://meyerweb.com/eric/tools/css/reset/">reset</a> and a blank CSS file.
Build your styles as you build your markup.
Pull styles, markup, and patterns from the starter as you need them.
As your styles differ from the starter styles, modify the styles rather than overriding them.
</p>
<p>
These are some great resources to build and maintain clean CSS codebases.
</p>
<ul class="bulleted">
<li><a href="https://www.joshwcomeau.com/tutorials/css/">Josh Comeau</a></li>
<li><a href="https://css-tricks.com/guides/">CSS Tricks</a></li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/CSS">MDN Web Docs</a></li>
<li><a href="https://web.dev/patterns/layout">web.dev</a></li>
<li><a href="https://www.htmhell.dev/tips/">HTMHell</a></li>
<li><a href="https://caniuse.com">Can I use</a></li>
</ul>
</section>
<section id="typography">
<h1>Typography</h1>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.
</p>
<ol class="numbered">
<li>Some</li>
<li>list</li>
<li>items</li>
</ol>
<ul class="bulleted">
<li>Some</li>
<li>list</li>
<li>items</li>
</ul>
</section>
<section id="forms">
<h1>Forms</h1>
<form action="#">
<fieldset>
<label>
Name
<input type="text" required name="name">
</label>
<label>
Phone
<input type="tel" required name="phone">
</label>
<label>
Type
<select name="phone-type">
<option value="" disabled selected hidden>Select one...</option>
<option value="mobile">Mobile</option>
<option value="home">Home</option>
<option value="work">Work</option>
</select>
</label>
</fieldset>
<fieldset class="vertical">
<legend>Subscription</legend>
<label class="radio"><input type="radio" name="subscription" value="free">Free</label>
<label class="radio"><input type="radio" name="subscription" value="basic">Basic</label>
<label class="radio"><input type="radio" name="subscription" value="pro">Pro</label>
</fieldset>
<fieldset>
<label>
Email
<input type="email" required name="email">
</label>
<label>
Password
<input type="password" required name="password">
</label>
</fieldset>
<fieldset>
<label class="checkbox">
<input type="checkbox" name="terms-and-conditions">
<span>I agree to the <a href="#">terms and conditions</a></span>
</label>
</fieldset>
<fieldset class="actions">
<button class="secondary" type="button">Cancel</button>
<button type="submit">Submit</button>
</fieldset>
</form>
<h2>Inline form</h2>
<form action="#">
<fieldset>
<label>
Search
<input type="search" name="query">
</label>
<button type="submit">Search</button>
</fieldset>
</form>
</section>
<section id="tables">
<h1>Tables</h1>
<div class="table-scroll-wrapper">
<table>
<thead>
<tr>
<th role="columnheader"></th>
<th role="columnheader">Heading</th>
<th role="columnheader">Heading</th>
<th role="columnheader">Heading</th>
<th role="columnheader">Heading</th>
<th role="columnheader">Heading</th>
</tr>
</thead>
<tbody>
<tr>
<th role="rowheader">Row</th>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
<tr>
<th role="rowheader">Row</th>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
<tr>
<th role="rowheader">Row</th>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
</tbody>
<tfoot>
<tr>
<th role="rowheader">Total</th>
<td>Total</td>
<td>Total</td>
<td>Total</td>
<td>Total</td>
<td>Total</td>
</tr>
</tfoot>
</table>
</div>
</section>
<section id="modals">
<h1>Modals</h1>
<dialog>
<article>
<h2>Warning</h2>
Are you absolutely sure?
</article>
<footer>
<form method="dialog">
<fieldset class="actions">
<button class="secondary" value="no">No</button>
<button value="yes">Yes</button>
</fieldset>
</form>
</footer>
</dialog>
<p>Click <a href="javascript:document.querySelector('dialog').showModal()">here</a> to open the modal</p>
</section>
<section id="tooltips">
<h1>Tooltips</h1>
<p>
<a href="javascript:{}" data-tooltip="Here is some additional info">Hover over me</a> to see a tooltip.
</p>
<p>
<a href="javascript:{}"
data-tooltip="Here is some additional info. What do you think of it? I'd say it's very nice.">
Hover over me
</a> to see a tooltip with a ton of text.
</p>
</section>
<section id="cards">
<h1>Cards</h1>
<ul class="card-list">
<li class="card">
<h2>Lorem ipsum</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce consequat, enim id efficitur porta,
diam sem porta sapien, ut dignissim velit erat quis sapien. Nullam vulputate enim placerat tortor
consequat, vulputate blandit nunc tempor. Integer purus augue, fringilla eu molestie in, consequat
at turpis.
</p>
</li>
<li class="card">
<h2>Orci varius</h2>
<p>
Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Phasellus vel
pulvinar orci, ac auctor urna. Nulla aliquam enim rutrum, auctor urna at, facilisis metus. Vivamus
euismod arcu ut leo tincidunt auctor. Vestibulum auctor neque leo, vitae dignissim tellus lobortis
vitae. Fusce vestibulum eleifend tortor et convallis. Aliquam congue nec ipsum id accumsan. Ut et
sagittis velit. Vestibulum lacinia, diam vitae sodales euismod, nulla diam molestie velit, vitae
iaculis neque nisl sit amet metus. Cras vehicula auctor fermentum.
</p>
</li>
<li class="card">
<h2>Mauris felis</h2>
<p>
Mauris felis lorem, condimentum vel lobortis et, condimentum eu libero. Fusce eget iaculis metus.
Pellentesque quis ligula eget sem bibendum ultrices. Maecenas et ante id ex ultrices sagittis.
Suspendisse malesuada eleifend arcu congue tempus. Pellentesque sed dictum ex. Pellentesque orci mi,
vestibulum quis enim at, posuere iaculis neque.
</p>
</li>
</ul>
</section>
<section id="buttons">
<h1>Buttons</h1>
<fieldset>
<button>Primary</button>
<button class="loading">Primary</button>
<button>
<svg>
<use xlink:href="images/icons.svg#table"></use>
</svg>
Primary
</button>
<button class="secondary">Secondary</button>
<button class="secondary loading">Secondary</button>
<button class="secondary">
<svg>
<use xlink:href="images/icons.svg#account"></use>
</svg>
Secondary
</button>
<button class="alert">Alert</button>
<button class="alert loading">Alert</button>
<button class="alert">
<svg>
<use xlink:href="images/icons.svg#dialog"></use>
</svg>
Alert
</button>
</fieldset>
</section>
<section id="code">
<h1>Code</h1>
<p>
Code can be displayed inline with the <code><code></code> tag, or in a block
</p>
<pre><code>like this,
with <pre> and <code></code></pre>
</section>
<section id="toggles">
<h1>Toggles</h1>
<p>
Toggles should be used for actions that take effect on click, as opposed to checkboxes, which should be used
for actions that take effect when a form is submitted.
</p>
<fieldset>
<label class="toggle">
<input type="checkbox" name="turn-it-up-to-eleven">
Turn it up to eleven
</label>
</fieldset>
</section>
<section id="flash-messages">
<h1>Flash messages</h1>
<fieldset>
<button onclick="flash('This is a flash message')">Display message</button>
<button onclick="flash('This is an alert message', true)" class="alert">Display alert</button>
</fieldset>
</section>
<section id="accordions">
<h1>Accordions</h1>
<p>
If a group of <code><details></code> elements all have the same <code>name</code> attribute, most
browsers will only allow one of them to be open at a time.
Firefox <a href="https://caniuse.com/mdn-html_elements_details_name">doesn't support this</a>, but it's
supported by most other browsers, and degrades relatively gracefully.
</p>
<details name="accordion-demo">
<summary>
This is an accordion summary
</summary>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce consequat, enim id efficitur porta, diam
sem porta sapien, ut dignissim velit erat quis sapien.
Nullam vulputate enim placerat tortor consequat, vulputate blandit nunc tempor.
Integer purus augue, fringilla eu molestie in, consequat at turpis.
</p>
</details>
<details name="accordion-demo">
<summary>
This is another accordion summary
</summary>
<ul class="bulleted">
<li>Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</li>
<li>Phasellus vel pulvinar orci, ac auctor urna.</li>
<li>Nulla aliquam enim rutrum, auctor urna at, facilisis metus.</li>
</ul>
</details>
</section>
<section id="theming">
<h1>Theming</h1>
<p>
The <a href="./css/theme.css">theme.css</a> file contains colors, icons, and other variables that make up
this site's theme.
</p>
<h2>Variables</h2>
<p>
Theme variables are defined on <code>:root</code> so they can be used in all elements.
Color variables are at the top of the <code>:root</code> styles. These define all colors to be used in the
CSS files. Color variables must only be used in the theme file, and should not be imported from other CSS
files.
</p>
<p>
Below the color variable we define variables like <code>--text-color</code> and <code>--border-color</code>
that we intend to use in other CSS files. These variables should reference color variables, and define our
default theme. We can define an alternate theme (with <code>@media (prefers-color-scheme: dark)</code>,
perhaps) by overriding these variables.
</p>
<pre><code>:root {
/* Color variables */
--white: #EEEEEE;
--black: #333333;
/* Default theme variables */
--text-color: var(--black);
--background-color: var(--white);
}
@media (prefers-color-scheme: dark) {
:root {
/* Dark theme variables */
--text-color: var(--white);
--background-color: var(--black);
}
}</code></pre>
<h2>Browser theme</h2>
<p>
Set the <code>accent-color</code> property on the <code>html</code> tag so checkboxes and outlines match
your site's theme.
</p>
<pre><code>html {
accent-color: var(--primary);
}</code></pre>
<p>
Add a meta tag that sets the theme color to the <code>head</code> of your document to style browser chrome
when a user visits your site.
</p>
<pre><code><meta name="theme-color" content="#196EC2"/></code></pre>
</section>
<section id="icons">
<h1>Icons</h1>
<p>
Use SVG icons whenever possible and practical. They can scale to any size, accept
CSS styles, and are usually smaller that other image formats.
</p>
<h2>Variables</h2>
<p>
To use our theme's CSS variables in SVG icons, we have to include SVGs into the page a bit differently.
The usual method on an image tag doesn't work, because the SVGs aren't a part of the DOM.
</p>
<pre><code><img src="/images/spinner.svg" alt="loading"></code></pre>
<p>
Instead, we must include the full SVG directly with an <code><svg></code> tag or reference from an
<code><svg></code> tag using a <code><use></code> tag.
</p>
<pre><code><svg>
<use xlink:href="/images/spinner.svg#icon"></use>
</svg></code></pre>
<p>
This ensures that the SVG is a part of the DOM, so will be able to use our CSS variables. If we use our
theme's CSS variables to style our SVGs we'll be able to use the same icons for different themes (light and
dark mode, for example).
</p>
<h2>Sprites</h2>
<p>
This site uses <a href="./images/icons.svg">an SVG sprite file</a> to include many SVGs in one file. This
helps a bit with performance since the browser makes fewer requests to load icons and can help when changing
multiple icons at once. It's very cumbersome to reference SVG sprites in a CSS file, so we use separate
files for SVGs referenced from CSS.
</p>
</section>
<section id="favicon">
<h1>Favicon</h1>
<p>
The starter uses an SVG favicon for modern browsers and provides an ico fallback for
<a href="https://caniuse.com/link-icon-svg">browsers without SVG favicon support</a> (like Safari and IE).
The <a href="favicon.svg">SVG favicon</a> uses a <code>@media (prefers-color-scheme: dark)</code> query to
serve a different color favicon depending on the user's color scheme. The
<a href="favicon.ico">ico favicon</a> consists of a dark icon on a light background so that it displays well
on any background color.
</p>
</section>
<section id="sidebar">
<h1>Sidebar</h1>
<p>
The starter's sidebar follows a pattern seen in many apps. On wide screens the sidebar is permanently
displayed on the left side of the page and the page's content is displayed to its right. On narrower screens
the sidebar is hidden by default, and is only displayed when a user clicks on the menu icon.
</p>
<p>
This layout is achieved with <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/grid">CSS Grid</a>,
in particular <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas">grid template
areas</a>. The default layout defines areas for each of the top-level layout elements, placing the
<code>nav</code> in the <code>sidebar</code> area.
</p>
<pre><code>body {
...
grid-template-areas: 'header header'
'sidebar main'
'footer footer';
}
nav {
grid-area: sidebar;
}</code></pre>
<p>
On small screens, we omit the sidebar from the grid layout and position the sidebar absolutely, using the
<code>left</code> property to toggle its visibility.
</p>
<pre><code>@media screen and (max-width: 800px) {
body {
...
grid-template-areas: 'header'
'main'
'footer';
}
nav {
grid-area: unset;
position: absolute;
top: var(--header-height);
bottom: 0;
left: calc(-1 * var(--nav-width));
}
.menu-open nav {
left: 0;
}
}
</code></pre>
</section>
</main>
<footer>
<ul>
<li><a href="https://doineedacssframework.com">Do I need a CSS framework?</a></li>
<li><a href="https://www.infoq.com/articles/no-need-css-framework/">You don't need a CSS framework</a></li>
<li><a href="https://github.com/initialcapacity/css-starter">View on GitHub</a></li>
<li><a href="https://initialcapacity.io">Initial Capacity</a></li>
</ul>
<span>
<script>document.write("©" + new Date().getFullYear());</script>
Initial Capacity, Inc.
</span>
</footer>
<ul class="flash-container" data-flash-container></ul>
<script>
document.querySelectorAll("nav a").forEach(element => {
element.addEventListener("click", () => document.querySelector('body').classList.remove('menu-open'))
})
const flashContainer = document.querySelector("[data-flash-container]");
const flash = (message, error = false) => {
const messageElement = document.createElement("li");
messageElement.classList.add("message");
if (error) {
messageElement.classList.add("error")
}
messageElement.innerText = message;
flashContainer.appendChild(messageElement);
}
</script>
</body>
</html>