Skip to content

Commit a72acbd

Browse files
committed
Add dark theme support
1 parent cbd5e00 commit a72acbd

File tree

7 files changed

+64
-25
lines changed

7 files changed

+64
-25
lines changed

landing_page/public/base.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,38 @@ code {
2020
line-height: 1.5;
2121
font-size: 0.8rem;
2222
}
23+
24+
:root {
25+
--background: #ffffff;
26+
--dark-background: #eeeeee;
27+
--border-color: #cccccc;
28+
--button-hover: #f5f5f5;
29+
--text-color: #000000;
30+
--text-grey: #888888;
31+
--icon-hover: #000000;
32+
--navbar-background: rgba(255, 255, 255, 0.9);
33+
34+
--window-border: rgb(223, 234, 255);
35+
--window-bg: rgb(241, 246, 255);
36+
}
37+
38+
@media (prefers-color-scheme: dark) {
39+
:root {
40+
--background: #222222;
41+
--dark-background: #000000;
42+
--border-color: #444444;
43+
--button-hover: #0a0a0a;
44+
--text-color: #ffffff;
45+
--text-grey: #888888;
46+
--icon-hover: #ffffff;
47+
--navbar-background: rgba(34, 34, 34, 0.9);
48+
49+
--window-bg: rgb(45, 46, 50);
50+
--window-border: rgb(109, 110, 112);
51+
}
52+
}
53+
54+
body {
55+
background: var(--background);
56+
color: var(--text-color);
57+
}

landing_page/src/components/button.gleam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn primary_class() {
88
s.class([
99
s.display("block"),
1010
s.text_decoration("none"),
11-
s.background("#eee"),
11+
s.background("var(--dark-background)"),
1212
s.border_radius(px(6)),
1313
s.padding_("9px 16px"),
1414
s.font_size(rem(1.0)),
@@ -55,8 +55,8 @@ pub fn example(color, text) {
5555
pub fn link(link, content) {
5656
s.class([
5757
s.compose(primary_class()),
58-
s.background("#fff"),
59-
s.border("1px solid #ccc"),
58+
s.background("var(--background)"),
59+
s.border("1px solid var(--border-color)"),
6060
])
6161
|> sh.a([a.href(link)], [h.text(content)])
6262
}

landing_page/src/components/copy_button.gleam

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn on_copy(text, set_copied) {
3939

4040
fn code_install() {
4141
s.class([
42-
s.border("1px solid #ccc"),
42+
s.border("1px solid var(--border-color)"),
4343
s.border_radius(px(8)),
4444
s.display("flex"),
4545
s.align_items("center"),
@@ -48,14 +48,20 @@ fn code_install() {
4848
s.gap(px(9)),
4949
s.font_size(rem(0.7)),
5050
s.font_weight("450"),
51-
s.background("white"),
51+
s.background("var(--background)"),
5252
s.cursor("pointer"),
53-
s.hover([s.background("#f5f5f5")]),
53+
s.color("var(--text-color)"),
54+
s.hover([s.background("var(--button-hover)")]),
5455
])
5556
}
5657

5758
fn sm_button_class() {
58-
s.class([s.background("#eee"), s.border_radius(px(6)), s.padding(px(4))])
59+
s.class([
60+
s.background("var(--dark-background)"),
61+
s.border_radius(px(6)),
62+
s.padding(px(4)),
63+
s.color("inherit"),
64+
])
5965
}
6066

6167
pub fn title(text) {

landing_page/src/components/footer.gleam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn footer_details(children) {
3333
s.font_size(rem(0.8)),
3434
s.line_height("1.4"),
3535
s.font_weight("500"),
36-
s.color("#888"),
36+
s.color("var(--text-grey)"),
3737
])
3838
|> sh.div([], children)
3939
}

landing_page/src/components/navbar.gleam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ pub fn nav(attributes, children) {
2525
s.padding(px(18)),
2626
s.margin(px(18)),
2727
s.gap(px(36)),
28-
s.background("rgba(255, 255, 255, 0.9)"),
28+
s.background("var(--navbar-background)"),
2929
s.position("sticky"),
3030
s.border_radius(px(10)),
3131
s.top(px(18)),
32-
s.border("1px solid #eee"),
32+
s.border("1px solid var(--dark-background)"),
3333
s.backdrop_filter("blur(8px)"),
3434
])
3535
|> sh.nav(attributes, children)
@@ -39,7 +39,7 @@ fn external_icon(url, icon) {
3939
s.class([
4040
s.color("#aaa"),
4141
s.transition("all .3s"),
42-
s.hover([s.color("#000000")]),
42+
s.hover([s.color("var(--text-color)")]),
4343
])
4444
|> sh.a([a.href(url)], [icons.small(icon)])
4545
}

landing_page/src/components/windows.gleam

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import sketch as s
55
import sketch/redraw/html as sh
66
import sketch/size.{percent, px}
77

8-
const border = "rgb(223, 234, 255)"
9-
108
pub fn scaffold(children) {
119
s.class([
12-
s.background("rgb(241, 246, 255)"),
10+
s.background("var(--window-bg)"),
1311
s.border_radius(px(10)),
14-
s.border("1px solid " <> border),
12+
s.border("1px solid var(--window-border)"),
1513
s.overflow("hidden"),
1614
s.flex("1"),
1715
s.display("flex"),
@@ -24,9 +22,9 @@ pub fn scaffold(children) {
2422

2523
pub fn render(children) {
2624
s.class([
27-
s.background("rgb(241, 246, 255)"),
25+
s.background("var(--window-bg)"),
2826
s.border_radius(px(10)),
29-
s.border("1px solid " <> border),
27+
s.border("1px solid var(--window-border)"),
3028
s.overflow("hidden"),
3129
s.flex("1"),
3230
s.margin(px(24)),
@@ -44,7 +42,7 @@ pub fn traffic_lights() {
4442
s.display("flex"),
4543
s.gap(px(5)),
4644
s.padding(px(10)),
47-
s.border_bottom("1px solid " <> border),
45+
s.border_bottom("1px solid var(--window-border)"),
4846
])
4947
|> sh.div([], [
5048
traffic_light(Red),
@@ -77,7 +75,7 @@ fn traffic_light(color) {
7775
pub fn editor(content) {
7876
let content = a.inner_html(ffi.highlight(content))
7977
s.class([
80-
s.background("#fff"),
78+
s.background("var(--background)"),
8179
s.padding(px(10)),
8280
s.display("flex"),
8381
s.overflow("auto"),
@@ -89,7 +87,7 @@ pub fn editor(content) {
8987
pub fn css(content) {
9088
let content = a.inner_html(ffi.highlight_css(content))
9189
s.class([
92-
s.background("#fff"),
90+
s.background("var(--background)"),
9391
s.padding(px(10)),
9492
s.display("flex"),
9593
s.max_height(px(400)),
@@ -102,7 +100,7 @@ pub fn css(content) {
102100
pub fn html(content) {
103101
let content = a.inner_html(ffi.highlight_xml(content))
104102
s.class([
105-
s.background("#fff"),
103+
s.background("var(--background)"),
106104
s.padding(px(10)),
107105
s.display("flex"),
108106
s.max_height(px(400)),

landing_page/src/landing_page.gleam

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn scroll_to(id: String) {
7777
fn lustre_section() {
7878
let copy_button = copy_button.copy_button()
7979
use <- redraw.component__("LustreSection")
80-
section("lustre-section", "#eee", [
80+
section("lustre-section", "var(--dark-background)", [
8181
column([], [
8282
copy_button.title("Sketch Lustre"),
8383
copy_button(#("gleam add sketch sketch_lustre")),
@@ -108,7 +108,7 @@ fn lustre_section() {
108108
fn redraw_section() {
109109
let copy_button = copy_button.copy_button()
110110
use <- redraw.component__("RedrawSection")
111-
section("redraw-section", "#fff", [
111+
section("redraw-section", "var(--background)", [
112112
column([], [
113113
copy_button.title("Sketch Redraw"),
114114
copy_button(#("gleam add sketch sketch_redraw")),
@@ -139,7 +139,7 @@ fn redraw_section() {
139139
fn plain_css_section() {
140140
let copy_button = copy_button.copy_button()
141141
use <- redraw.component__("PlainCssSection")
142-
section("plain-css-section", "#eee", [
142+
section("plain-css-section", "var(--dark-background)", [
143143
column([], [
144144
copy_button.title("Sketch CSS"),
145145
copy_button(#("gleam add sketch sketch_css")),
@@ -171,7 +171,7 @@ fn plain_css_section() {
171171
fn wisp_section() {
172172
let copy_button = copy_button.copy_button()
173173
use <- redraw.component__("WispSection")
174-
section("wisp-section", "#fff", [
174+
section("wisp-section", "var(--background)", [
175175
column([], [
176176
copy_button.title("Sketch SSR"),
177177
copy_button(#("gleam add sketch")),

0 commit comments

Comments
 (0)