Skip to content

Commit ed1029f

Browse files
authored
Merge pull request #48 from de-soot/main
edited posts
2 parents 116d4f2 + 8536d79 commit ed1029f

File tree

12 files changed

+130
-103
lines changed

12 files changed

+130
-103
lines changed

_posts/2024-09-07-dark-mode.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
layout: post
3-
title: Dark Mode on Websites with CSS @media Queries
3+
title: Dark Mode with CSS @media Queries
44
date: 2024-09-07
55
categories: dark mode, dark theme, night mode, night theme, colour scheme, jekyll, css, github pages, static websites
66
permalink: /dark-mode
77
---
88

99
# Why Dark Mode
1010

11-
For users visiting your website in a dark room or at night, it is often less straining for the eyes if your webpage to be displayed in [dark mode][dark-mode].
11+
For users visiting a website in a dark room at night, it would be less straining for their eyes if the webpage was displayed in a darker colour to match the environment, which is what [dark mode][dark-mode] does.
1212

1313
<img src="https://zerowidthjoiner.net/uploads/2020/04-11/light-vs-dark.png" alt="Comparison image of light theme on the left and dark theme on the right.">
1414

@@ -19,12 +19,14 @@ From [MDN Web Docs][mdn]:
1919
2020
## For Non-Static-Site-Generator Websites
2121

22+
There also exists a [video guide by Eric Murphy on Youtube][yt-vid] if you prefer to follow along with a video.
23+
2224
### External Style Sheet
2325

24-
In your HTML document, you can either link an external CSS style sheet in your `<head>` if you wish to separate your code out more:
26+
To separate code between HTML and CSS, link an external CSS style sheet in the `<head>` tag in the HTML document. Like so:
2527

2628
```html
27-
<!-- something resembling this -->
29+
<!-- should resemble something like this -->
2830
<!DOCTYPE html>
2931
...
3032
<html>
@@ -73,8 +75,6 @@ You can also type out your CSS code in between `<style>` tags if you prefer ever
7375
</html>
7476
```
7577

76-
There also exists a [video guide by Eric Murphy on Youtube on how to do this similarly][yt-vid] if you prefer to follow along with a video or if you find reading this blog-style guide boring becuase Tiktok and Instagram Reels have fried your zoomer ADHD brain beyond repair.
77-
7878
## For Static-Site-Generator Websites
7979

8080
It is a little bit less straightforward to do this with a static site generator like Jekyll (which has native support with Github Pages and is what this website uses) or Hugo as you have to override the theme's CSS style sheet.
@@ -104,17 +104,11 @@ And you should get something like this after adding the dark mode code.
104104
}
105105
```
106106

107-
For other static-site-generator generated websites, you can refer to the official documentation found online for information on how to override your theme's CSS.
108-
109-
# Why Not Use a Toggleable Button Instead (Rant Warning)
110-
111-
Rather than defaulting to light or dark mode and having a separate button (that uses Javascript) for the user to manually switch to their preferred theme, it might be better to automatically default to what they already set their browser's preferred theme to. This is so they do not get flashbanged by their monitors at night if your website defaults to light theme and they open their browser to your website for the first time, or without toggling it to dark mode the last time they visited, or just simply because your website does not store cookies about their previously toggled theme either due to your lack of know how, respect for user privacy, or plain laziness.
112-
113-
You can also include the button to toggle themes on the website alongside if you like having more buttons on your website for showing off your Javascript skills to potential employers (I know the tech job market out there is rough for fresh grads right now) or just want to follow the current web trend on including more and more unnecessary Javascript bloat on websites with features that can be done easily with simple HTML and CSS.
107+
For other static-site-generator websites, you can refer to the official documentation found online for information on how to override your theme's CSS.
114108

115109
# Configure Giscus Theme
116110

117-
To set it to match your website (if you have done the CSS `@media` trick shown above), simply set the `<script>`'s `data-theme` attribute value to `"preferred_color_scheme"` as shown below.
111+
To set `giscus` comments to match the website if you have done the CSS `@media` trick shown above, simply set the `<script>`'s `data-theme` attribute value to `"preferred_color_scheme"` as shown below.
118112

119113
```html
120114
<script src="https://giscus.app/client.js"
@@ -128,9 +122,18 @@ To set it to match your website (if you have done the CSS `@media` trick shown a
128122
</script>
129123
```
130124

131-
Read more on adding Giscus comments to your website at [my previous blog post about it][giscus-blog].
125+
# Why Not Use a Toggleable Button Instead
126+
127+
Rather than defaulting to light or dark mode and having a separate button for the user to manually switch to their preferred theme, it might be better to automatically default to what they already set their browser's preferred theme to.
128+
129+
This is so they do not get flashbanged by their monitors at night if your website defaults to light theme and they open their browser to your website for the first time, if they did not toggle it to dark mode the last time they visited, or if your website does not store cookies about their previously toggled theme.
130+
131+
You can also include the button to toggle themes on the website alongside defaulting it if you want, but I find this an unnecessary use of [Javascript][js].
132+
133+
If you found this blog post useful, leave a comment down below! Check out how to add `giscus` comments to your own website on [my previous blog post guide for it][giscus-blog].
132134

133135
[mdn]: https://developer.mozilla.org/en-US
136+
[js]: https://www.javascript.com
134137
[css]: https://developer.mozilla.org/en-US/docs/Web/CSS
135138
[at-rule]: https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
136139
[style-sheet]: https://en.wikipedia.org/wiki/Style_sheet_(web_development)

_posts/2024-09-07-justify-text.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,43 @@ categories: justify, text-align, jekyll, css
66
permalink: /justify-text
77
---
88

9-
You may have noticed while reading my blog posts that the way the text are aligned are a little different from the usual way the ones from other websites are --- that they always align as blocks of text no matter how you change your browser window's size. This is because using CSS, I have justified the text on my website.
9+
You may have noticed while reading my blog posts that the way the text are aligned are a little different from the usual way the ones from other websites are --- that they always align as blocks of text no matter how you change your browser window's size. This is because I have justified the text on my website using CSS.
1010

1111
# How to Justify
1212

1313
It is actually pretty simple --- to justify your body text, just add this to your CSS style sheet:
1414

1515
```css
1616
body {
17-
...
1817
text-align: justify;
1918
}
2019
```
2120

22-
This will justify your text so it all aligns neatly in a block-like shape.
21+
This will justify your text so it all aligns neatly without jagged edges.
2322

2423
# How to Hyphenate
2524

26-
Though there is a way to do this with Javascript using [Hyphenopoly.js][hyphenopoly], hyphenation already has built-in functionality in CSS and it is widely supported by browsers, so it is a no-brainer to do it the CSS way, unless your target audience has a `user-agent` that does not support CSS' `hyphens` property for some reason.
25+
Although there is a way to do this with Javascript using [Hyphenopoly.js][hyphenopoly], hyphenation is a built-in functionality in CSS and it is widely supported by browsers.
2726

2827
To add hyphenation to your body text, simply add the `hyphens` property to your body section in your CSS style sheet and set it to `auto`, like so:
2928

3029
```css
3130
body {
32-
...
3331
hyphens: auto
3432
}
3533
```
3634

37-
So now your text wraps words using hyphens, but why do we need to use hyphens when we can make blocks of text by just justifying?
38-
3935
# Why Hyphenate
4036

41-
Text justification can make your paragraphs look tidier, but this has the potential side-effect of awkwardly stretching out whitespace in between words --- which can create or worsen an often undesirable effect commonly referred to as 'rivers of white,' which are known to trip up dyslexic readers, making your writing less accessible as a result.
37+
So now your text wraps words using hyphens, but why do we need to use hyphens that ruin the perfect edges that justifying makes?
38+
39+
Text justification can make your paragraphs look tidier, but this has the potential side-effect of awkwardly stretching out the whitespace between words --- which can create and worsen an undesirable effect commonly referred to as 'rivers of white', which is known to trip up dyslexic readers and decrease accessibility.
4240

4341
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Typographic_river_marking.svg/1280px-Typographic_river_marking.svg.png" alt="Image from Wikipedia with visual marking around an example of a 'rivers of white' effect.">
4442

45-
This is also a highly-cited reason as to why justification is generally [not][applewood] [recommended][max] for text output on browsers and on the web.
43+
This is also a common reason as to why justification is generally [not][applewood] [recommended][max] for text output on the web.
44+
45+
By hyphenating, even though it does not solve it completely, it will reduce the effect dramatically.
4646

4747
# Other Blogs That Justify
4848

@@ -62,3 +62,20 @@ Here are a list of other blogsites that I know of that use justified text:
6262
[applewood]: https://applewoodinteractive.com/accessibility/rivers-of-white-why-you-should-never-justify-your-text
6363
[pubdeliver]: https://publicdelivery.org
6464
[hyphenopoly]: https://mnater.github.io/Hyphenopoly
65+
66+
<script src="https://giscus.app/client.js"
67+
data-repo="de-soot/de-soot.github.io"
68+
data-repo-id="R_kgDOK6_5tA"
69+
data-category="Announcements"
70+
data-category-id="DIC_kwDOK6_5tM4CflCT"
71+
data-mapping="title"
72+
data-strict="0"
73+
data-reactions-enabled="1"
74+
data-emit-metadata="0"
75+
data-input-position="top"
76+
data-theme="preferred_color_scheme"
77+
data-lang="en"
78+
data-loading="lazy"
79+
crossorigin="anonymous"
80+
async>
81+
</script>

_site/404.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h2 class="footer-heading">de_soot</h2>
6868
<div class="footer-col-wrapper">
6969
<div class="footer-col footer-col-1">
7070
<ul class="contact-list">
71-
<li class="p-name">de_soot</li><li><a class="u-email" href="mailto:[email protected]">[email protected]</a></li></ul>
71+
<li class="p-name">de_soot</li></ul>
7272
</div>
7373

7474
<div class="footer-col footer-col-2"><ul class="social-media-list"><li><a href="https://github.com/de-soot"><svg class="svg-icon"><use xlink:href="/assets/minima-social-icons.svg#github"></use></svg> <span class="username">de-soot</span></a></li></ul>

_site/about.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h1 class="post-title">About</h1>
4343
</header>
4444

4545
<div class="post-content">
46-
<p>This is the website where I write about whatever inspires me to write in form of <a href="/blogs">blogs</a>. It is made using <a href="https://jekyllrb.com">Jekyll</a>’s <a href="https://github.com/jekyll/minima">Minima</a> theme and is hosted for free on <a href="https://pages.github.com">Github Pages</a>.</p>
46+
<p>This is the website where I write about whatever inspires me to write in form of <a href="/">blogs</a>. It is made using <a href="https://jekyllrb.com">Jekyll</a>’s <a href="https://github.com/jekyll/minima">Minima</a> theme and is hosted for free on <a href="https://pages.github.com">Github Pages</a>.</p>
4747

4848
<p>The <code class="language-plaintext highlighter-rouge">source code</code> for this website can be found on its <a href="https://github.com/de-soot/de-soot.github.io">Github repository</a>.</p>
4949

@@ -63,7 +63,7 @@ <h2 class="footer-heading">de_soot</h2>
6363
<div class="footer-col-wrapper">
6464
<div class="footer-col footer-col-1">
6565
<ul class="contact-list">
66-
<li class="p-name">de_soot</li><li><a class="u-email" href="mailto:[email protected]">[email protected]</a></li></ul>
66+
<li class="p-name">de_soot</li></ul>
6767
</div>
6868

6969
<div class="footer-col footer-col-2"><ul class="social-media-list"><li><a href="https://github.com/de-soot"><svg class="svg-icon"><use xlink:href="/assets/minima-social-icons.svg#github"></use></svg> <span class="username">de-soot</span></a></li></ul>

_site/assets/main.css

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,13 @@ table td { border: 1px solid #e8e8e8; }
197197

198198
body { background-color: #fafafa; font-size: 1.2rem; }
199199

200-
h2, h3, p, ol, ul { font-family: serif; }
201-
202200
h1 { color: #0d0d0d; font-family: sans-serif; font-weight: bold; }
203201

204-
h2 { color: #1a1a1a; }
202+
h2 { color: #1a1a1a; font-family: sans-serif; }
205203

206-
h3 { color: #262626; }
204+
h3 { color: #262626; font-family: sans-serif; }
207205

208-
p, ol, ul { color: #333333; hyphens: auto; text-align: justify; line-height: 1.75; }
206+
p, ol, ul { font-family: serif; color: #333333; hyphens: auto; text-align: justify; line-height: 1.75; }
209207

210208
@media (prefers-color-scheme: dark) { body { background-color: #262626; }
211209
h1 { color: #f2f2f2; }

0 commit comments

Comments
 (0)