Skip to content

Commit f7bfa73

Browse files
committed
Demo: Improve layout and design.
This adds support for a light/dark theme based on the OS color scheme setting.
1 parent 73e59bc commit f7bfa73

File tree

2 files changed

+89
-43
lines changed

2 files changed

+89
-43
lines changed

css/demo.css

+83-37
Original file line numberDiff line numberDiff line change
@@ -13,59 +13,105 @@ body {
1313
max-width: 750px;
1414
margin: 0 auto;
1515
padding: 1em;
16-
font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, sans-serif;
17-
font-size: 1em;
18-
line-height: 1.4em;
19-
background: #222;
20-
color: #fff;
21-
-webkit-text-size-adjust: 100%;
22-
-ms-text-size-adjust: 100%;
16+
font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
17+
sans-serif;
18+
line-height: 1.4;
19+
background: #212121;
20+
color: #dedede;
2321
}
2422
a {
25-
color: orange;
23+
color: #61afef;
2624
text-decoration: none;
2725
}
28-
img {
29-
border: 0;
30-
vertical-align: middle;
26+
a:visited {
27+
color: #56b6c2;
3128
}
32-
h1 {
33-
line-height: 1em;
29+
a:hover {
30+
color: #98c379;
3431
}
35-
h2,
36-
h3 {
37-
margin-top: 2em;
32+
figure,
33+
tr {
34+
background: #363636;
35+
}
36+
tr:nth-child(odd) {
37+
background: #414141;
38+
}
39+
td,
40+
th {
41+
padding: 10px;
42+
text-align: left;
3843
}
3944
table {
4045
width: 100%;
4146
word-wrap: break-word;
4247
table-layout: fixed;
4348
border-collapse: collapse;
49+
}
50+
figure {
51+
margin: 0;
52+
padding: 10px;
53+
border-radius: 5px;
54+
display: inline-block;
55+
}
56+
figure,
57+
table {
4458
margin-bottom: 20px;
4559
}
46-
tr {
47-
background: #fff;
48-
color: #222;
60+
img,
61+
canvas {
62+
border: 0;
63+
vertical-align: middle;
4964
}
50-
tr:nth-child(odd) {
51-
background: #eee;
52-
color: #222;
65+
h1,
66+
h2,
67+
h3,
68+
h4,
69+
h5,
70+
h6 {
71+
margin-top: 1.5em;
72+
margin-bottom: 0.5em;
5373
}
54-
td,
55-
th {
56-
padding: 10px;
57-
text-align: left;
74+
h1 {
75+
margin-top: 0.5em;
5876
}
59-
#result,
60-
#thumbnail {
61-
margin-bottom: 20px;
62-
padding: 20px;
63-
background: #fff;
64-
color: #222;
65-
text-align: center;
77+
button,
78+
input,
79+
select,
80+
textarea {
81+
box-sizing: border-box;
82+
font-family: inherit;
83+
font-size: 100%;
84+
line-height: 1.15;
85+
margin: 0;
86+
padding: 5px;
6687
}
67-
.jcrop-holder {
68-
margin: 0 auto;
88+
input[type='file'] {
89+
padding: inherit;
90+
}
91+
92+
@media (prefers-color-scheme: light) {
93+
body {
94+
background: #ececec;
95+
color: #212121;
96+
}
97+
a {
98+
filter: brightness(75%);
99+
}
100+
figure,
101+
tr {
102+
background: #fff;
103+
color: #212121;
104+
}
105+
tr:nth-child(odd) {
106+
background: #f6f6f6;
107+
}
108+
}
109+
110+
#url {
111+
width: 100%;
112+
}
113+
#result {
114+
display: block;
69115
}
70116

71117
@media (min-width: 481px) {
@@ -76,7 +122,7 @@ th {
76122
#navigation li {
77123
display: inline-block;
78124
}
79-
#navigation li:not(:first-child):before {
80-
content: '| ';
125+
#navigation li:not(:first-child)::before {
126+
content: ' | ';
81127
}
82128
}

index.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ <h2>Select an image file</h2>
8282
<input type="url" id="url" placeholder="Image URL" />
8383
</p>
8484
<p>Or <strong>drag &amp; drop</strong> an image file onto this webpage.</p>
85+
<h3>Options</h3>
8586
<p>
8687
<label for="orientation">Orientation:</label>
8788
<select id="orientation">
@@ -110,19 +111,18 @@ <h2>Result</h2>
110111
<button type="button" id="crop">Crop</button>
111112
<button type="button" id="cancel">Cancel</button>
112113
</p>
113-
<div id="result">
114-
<p style="display: none;">
114+
<figure id="result">
115+
<figcaption style="display: none;">
115116
This demo works only in browsers with support for the
116117
<a href="https://developer.mozilla.org/en/DOM/window.URL">URL</a> or
117118
<a href="https://developer.mozilla.org/en/DOM/FileReader">FileReader</a>
118119
API.
119-
</p>
120-
</div>
120+
</figcaption>
121+
</figure>
121122
<div id="meta" style="display: none;">
122123
<h3>Image metadata</h3>
123-
<div id="thumbnail" style="display: none;"></div>
124+
<figure id="thumbnail" style="display: none;"></figure>
124125
</div>
125-
126126
<script src="js/vendor/canvas-to-blob.js"></script>
127127
<script src="js/load-image.js"></script>
128128
<script src="js/load-image-scale.js"></script>

0 commit comments

Comments
 (0)