This repository was archived by the owner on Mar 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-images.html
265 lines (223 loc) · 10.4 KB
/
test-images.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="apple-touch-icon" sizes="180x180" href="img/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png">
<link rel="shortcut icon" href="img/favicon.ico">
<link rel="stylesheet" href="./dist/bootstrap-dark.css">
<style>
@media (prefers-color-scheme: dark) {
img.special {
opacity: .75;
filter: brightness(.8) contrast(1.2);
transition: all .5s ease-in-out, filter .5s ease-in-out;
}
img.special:hover {
opacity: 1;
filter: none;
}
}
@media (prefers-color-scheme: dark) {
#vino-avatar #spec {
/* opacity: 0; */
visibility: hidden;
}
#vino-avatar #beard {
opacity: 1;
}
}
@media (prefers-color-scheme: no-preference), (prefers-color-scheme: light) {
.black-back {
background-color: #000;
}
}
</style>
<title>More about dark mode images</title>
</head>
<body>
<header>
<nav class="navbar navbar-dark navbar-expand-lg navbar-light bg-primary">
<div class="container">
<a class="navbar-brand">bootstrap-dark</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto" id="nav-links"></ul>
</div>
</div>
</nav>
</header>
<main>
<div class="container mt-5 mb-5">
<div class="row"><div class="col">
<h1>Dark Mode Images</h1>
<p>Read the <a href="readme.html">README.md</a> for more information on these concepts.</p>
<h2>Apply CSS to the image</h2>
<p class="text-center">
<img class="special img-thumbnail" src="./img/a-bug.jpg" width="320" height="240">
<small><br>Image:
"<a href="https://vlad.studio/wallpaper/bug">A Bug</a>"
© Vlad Gerasimov - <a href="https://vlad.studio/">http://vlad.studio</a></small>
</p>
<p>
<div class="card-deck">
<div class="card mx-auto op-img-eg" style="max-width:320px">
<div class="display-block black-back">
<img src="./img/a-bug.jpg" width="100%" height="240" style="opacity:0.75 !important; filter: none">
</div>
<div class="card-body">
<p class="card-text text-center"><code>opacity: 0.75;</code><small><br>(On black background)</small></p>
</div>
</div>
<div class="card mx-auto" style="max-width:320px">
<img src="./img/a-bug.jpg" width="100%" height="240" style="opacity:1 !important; filter: grayscale(50%)">
<div class="card-body">
<p class="card-text text-center"><code>filter: grayscale(50%);</code></p>
</div>
</div>
<div class="card mx-auto" style="max-width:320px">
<img src="./img/a-bug.jpg" width="100%" height="240" style="opacity:1 !important; filter: brightness(.8) contrast(1.2)">
<div class="card-body">
<p class="card-text text-center"><code>filter: brightness(.8) contrast(1.2)</code></p>
</div>
</div>
</div>
</p>
<h2>Use Responsive Images</h2>
<p class="text-center">
<a href="#" data-toggle="modal" data-target="#exampleModal"><picture>
<source srcset="./img/when-the-day-comes.jpg" media="(prefers-color-scheme: dark)">
<img src="./img/when-the-night-comes.jpg" width="320" height="240" class="img-thumbnail">
</picture></a>
<small><br>Image:
<span class="d-dark-none">"<a href="https://vlad.studio/wallpaper/when_the_night_comes">When The Night Comes</a>"</span>
<span class="d-none d-dark-inline">"<a href="https://vlad.studio/wallpaper/when_the_day_comes">When The Day Comes</a>"</span>
© Vlad Gerasimov - <a href="https://vlad.studio/">http://vlad.studio</a></small>
</p>
<div id="exampleModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Responsive Images</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body text-center">
<picture>
<source srcset="./img/when-the-day-comes.jpg" media="(prefers-color-scheme: dark)">
<img src="./img/when-the-night-comes.jpg" class="img-fluid" style="width:100%">
</picture><!--
<small><br>Image:
<span class="d-dark-none">"<a href="https://vlad.studio/wallpaper/when_the_night_comes">When The Night Comes</a>"</span>
<span class="d-none d-dark-inline">"<a href="https://vlad.studio/wallpaper/when_the_day_comes">When The Day Comes</a>"</span>
© Vlad Gerasimov - <a href="https://vlad.studio/">http://vlad.studio</a></small> -->
</div>
</div>
</div>
</div>
<h2>SVG ...</h2>
</div></div>
<div class="row"><div class="col-md-6">
<p>... as in-line DOM elements that can be styled with CSS.</p>
<p class="text-center">
<style>
@media (prefers-color-scheme: dark) {
#icon #darkmode {
fill: #efefef;
}
}
</style>
<svg width="128" height="128" id="icon"
viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="darkmode" fill="#101010" fill-rule="nonzero">
<path d="M50,1.78e-15 C77.61,1.78e-15 100,22.39 100,50 C100,77.61 77.61,100 50,100 C22.39,100 0,77.61 0,50 C0,22.39 22.39,1.78e-15 50,1.78e-15 Z M50,6 C26,6 6,26 6,50 C6,74 26,94 50,94 L50,75 C64,75 75,64 75,50 C75,36 64,25 50,25 L50,6 Z"></path>
<path d="M50,25 C50,25 50,75 50,75 C36,75 25,64 25,50 C25,36 36,25 50,25 Z"></path>
</g>
</svg>
<small class="text-info"><br>As in-line <code><svg></code><br></small>
</p>
<hr>
<p>
It's not only color SVG attributes (e.g. `<code>fill</code>` & `<code>stroke</code>`) that can be manipulated. Also try `<code>visibility</code>` & `<code>opacity</code>`.<br>
</p>
<p class="text-center">
<img id="vino-avatar" height="240" width="100%" src="./img/silvino-avatar.svg">
<small><br>² Uses <a href="https://github.com/iconic/SVGInjector">SVGInjector</a> © Waybury to convert to in-line.</small>
</p>
</div><div class="col-md-6">
<p>... with the dark mode media query internal to the SVG.</p>
<p class="text-center">
<img height="128" width="128" src="./img/dark-mode.svg">
<small class="text-info"><br>As <code><img></code><br><b><i>[³ Only works on Firefox & Opera browsers]</i></b></small>
</p>
<p class="text-center">
<object height="128" width="128" type="image/svg+xml" data="./img/dark-mode.svg"></object>
<small class="text-info"><br>As <code><object></code></small>
</p>
<p class="text-center">
<embed height="128" width="128" type="image/svg+xml" src="./img/dark-mode.svg" />
<small class="text-info"><br>As <code><embed></code></small>
</p>
<p class="text-center">
<iframe height="128" width="128" frameborder="0" src="./img/dark-mode.svg"></iframe>
<small class="text-info"><br>As <code><iframe></code></small>
</p>
</div></div>
</div>
</main>
<footer id="copyright" class="text-center">
<small class="text-muted">© 2020</small>
</footer>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.bundle.min.js"></script>
<!-- from: https://github.com/iconic/SVGInjector -->
<script src="https://cdn.jsdelivr.net/gh/iconic/[email protected]/dist/svg-injector.min.js"></script>
<script>
$(document).ready(function() {
// only works if jQuery loaded
$('[data-toggle="tooltip"]').tooltip();
// ----- Replace SVG ----------------------
/*
There are a number of ways to use SVG on a page (object, embed, iframe,
img, CSS background-image) but to unlock the full potential of SVG,
including full element-level CSS styling and evaluation of embedded
JavaScript, the full SVG markup must be included directly in the DOM.
*/
var svg = document.querySelectorAll("#vino-avatar");
var $w = svg[0].getAttribute("width");
var $h = svg[0].getAttribute("height");
// Options
var $injectorOptions = {
evalScripts: 'once',
// pngFallback: 'assets/png',
each: function(svg) {
// Callback after each SVG is injected
svg.setAttribute('width', $w);
svg.setAttribute('height', $h);
}
};
// Trigger the injection
SVGInjector(svg, $injectorOptions);
// ----- Nav & Copyright ------------------
$.ajax( {
url: './navbar.htm', type: 'get',
success: function(content) {
$("#nav-links").html( content );
$("#nav-tests").addClass("active");
$("#nav-images").addClass("active");
}
} );
$.ajax( {
url: './copyright.htm', type: 'get',
success: function(content) {
$("#copyright").html( content );
}
} );
});
</script>
</body>
</html>