List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] css: Optional support for dark mode
@ 2023-01-01 21:15 Samuel Lidén Borell
  2023-01-02  0:51 ` Jason A. Donenfeld
  0 siblings, 1 reply; 11+ messages in thread
From: Samuel Lidén Borell @ 2023-01-01 21:15 UTC (permalink / raw)
  To: cgit; +Cc: Samuel Lidén Borell

Modern browsers have a "dark mode" preference, which enables alternate
CSS rules on web sites that support this.

This patch adds an optional dark color scheme, that can be copied into
cgit.css. The color scheme is then auto-detected via a @media query.

Note that filters that use color (such as source highlighters), and
logotypes, may need to be updated to work with a black background. So
this goes into a separate file, that can be copied into cgit.css for
those who want to enable support for dark mode.

Signed-off-by: Samuel Lidén Borell <samuel@kodafritt.se>
---
 contrib/css/cgit_dark.css | 131 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 131 insertions(+)
 create mode 100644 contrib/css/cgit_dark.css

diff --git a/contrib/css/cgit_dark.css b/contrib/css/cgit_dark.css
new file mode 100644
index 0000000..464d765
--- /dev/null
+++ b/contrib/css/cgit_dark.css
@@ -0,0 +1,131 @@
+/*
+	Automatic dark mode via @media queries. This is supported in modern
+	web browsers. Older browser will just ignore it.
+
+	To enable this, append this file to your cgit.css file.
+
+	Plase note: Any filters that you use that use colored text, must also
+	have CSS rules for dark mode, or the text may become invisible (black
+	on black). If you use a custom logotype, you should also check that it
+	is legible on a black background.
+*/
+:root { color-scheme: light dark; }
+@media (prefers-color-scheme: dark) {
+	html, div#cgit { color: #ccc; background: black; }
+	div#cgit a { color: #66f; }
+	div#cgit table#header td.main a { color: #fff; }
+	div#cgit table#header td.sub { color: #888; }
+	div#cgit table.tabs { border-bottom-color: #333; }
+	div#cgit table.tabs td a { color: #888; }
+	div#cgit table.tabs td a.active { color: #fff; background-color: #333; }
+	div#cgit div.path { color: #fff; background-color: #111; }
+	div#cgit div.content { border-bottom-color: #bbb; }
+	div#cgit table.list tr { background: black; }
+	div#cgit table.list tr.logheader { background: #111; }
+	div#cgit table.list tr:nth-child(even) { background: #080808; }
+	div#cgit table.list tr:nth-child(odd) { background: black; }
+	div#cgit table.list tr:hover { background: #111; }
+	div#cgit table.list tr.nohover { background: black; }
+	div#cgit table.list tr.nohover:hover { background: black; }
+	div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { background: #080808; }
+	div#cgit table.list tr.nohover-highlight:hover:nth-child(odd) { background: black; }
+	div#cgit table.list td.commitgraph .column1 { color: #f55; }
+	div#cgit table.list td.commitgraph .column2 { color: #5f5; }
+	div#cgit table.list td.commitgraph .column3 { color: #ff5; }
+	div#cgit table.list td.commitgraph .column4 { color: #55f; }
+	div#cgit table.list td.commitgraph .column5 { color: #f5f; }
+	div#cgit table.list td.commitgraph .column6 { color: #5ff; }
+	div#cgit table.list td a { color: white; }
+	div#cgit table.list td a.ls-dir { color: #66f; }
+	div#cgit table.list td a:hover { color: #66f; }
+	div#cgit table#downloads { border-color: #888; }
+	div#cgit table#downloads th { background-color: #333; }
+	div#cgit div#blob { border-color: white; }
+	div#cgit table.blob { border-top-color: white; }
+	div#cgit table.blob td.hashes,
+	div#cgit table.blob td.lines { color: white; }
+	div#cgit table.blob td.linenumbers { border-right-color: gray; }
+	div#cgit table.blob td.linenumbers a,
+	div#cgit table.ssdiff td.lineno a { color: gray; }
+	div#cgit table.blob td.linenumbers a:hover,
+	div#cgit table.ssdiff td.lineno a:hover { color: white; }
+	div#cgit table.blame div.alt:nth-child(even) { background: #111; }
+	div#cgit table.blame div.alt:nth-child(odd) { background: black; }
+	div#cgit table.bin-blob { border-color: white; }
+	div#cgit table.bin-blob th { border-color: #888; }
+	div#cgit table.bin-blob td { border-left-color: #888; }
+	div#cgit div.cgit-panel table { border-color: #555; background-color: #111; }
+	div#cgit div.notes { border-color: #661; background-color: #220; }
+	div#cgit table.diffstat { border: #555; background-color: #111; }
+	div#cgit table.diffstat td span.modechange { color: #c66; }
+	div#cgit table.diffstat td.add a { color: #6c6; }
+	div#cgit table.diffstat td.del a { color: #c66; }
+	div#cgit table.diffstat td.upd a { color: #66c; }
+	div#cgit table.diffstat td.graph td.add { background-color: #3a3; }
+	div#cgit table.diffstat td.graph td.rem { background-color: #a33; }
+	div#cgit div.diffstat-summary { color: #777; }
+	div#cgit table.diff td div.head { color: white; }
+	div#cgit table.diff td div.hunk { color: #66f; }
+	div#cgit table.diff td div.add { color: #6c6; }
+	div#cgit table.diff td div.del { color: #c66; }
+	div#cgit table.list td.reposection { color: #777; }
+	div#cgit ul.pager a { color: #888; }
+	div#cgit span.age-mins { color: #7f7; }
+	div#cgit span.age-hours { color: #7f7; }
+	div#cgit span.age-days { color: #bfb; }
+	div#cgit span.age-weeks { color: #bbb; }
+	div#cgit span.age-months { color: #777; }
+	div#cgit span.age-years { color: #444; }
+	div#cgit span.insertions { color: #7f7; }
+	div#cgit span.deletions { color: #f77; }
+	div#cgit div.footer { color: #333; }
+	div#cgit div.footer a { color: #333; }
+	div#cgit a.branch-deco { color: #fff; background-color: #007700; border-color: #88ff88; }
+	div#cgit a.tag-deco { color: #fff; background-color: #777700; border-color: #ffff88; }
+	div#cgit a.tag-annotated-deco { color: #fff; background-color: #773300; border-color: #ffff88; }
+	div#cgit a.remote-deco { color: #fff; background-color: #000033; border-color: #8888ff; }
+	div#cgit a.deco { color: #fff; background-color: #770000; border-color: #ff8888; }
+	div#cgit table.stats { border-color: white; }
+	div#cgit table.stats th { background-color: #111; border-color: white; }
+	div#cgit table.stats td { border-color: white; }
+	div#cgit table.stats td.sum { color: #f33; }
+	div#cgit table.vgraph { border-color: white; }
+	div#cgit table.vgraph th { background-color: #111; border-color: black; }
+	div#cgit table.vgraph div.bar { background-color: #111; }
+	div#cgit table.hgraph { border-color: white; }
+	div#cgit table.hgraph th { background-color: #111; border-color: white; }
+	div#cgit table.hgraph div.bar { background-color: #111; }
+	div#cgit table.ssdiff td { border-left-color: #555; border-right-color: #555; }
+	div#cgit table.ssdiff td.add { color: white; background: #030; }
+	div#cgit table.ssdiff td.add_dark { color: white; background: #353; }
+	div#cgit table.ssdiff span.add { background: #030; }
+	div#cgit table.ssdiff td.del { color: white; background: #300; }
+	div#cgit table.ssdiff td.del_dark { color: white; background: #533; }
+	div#cgit table.ssdiff span.del { background: #300; }
+	div#cgit table.ssdiff td.changed { color: white; background: #330; }
+	div#cgit table.ssdiff td.changed_dark { color: white; background: #553; }
+	div#cgit table.ssdiff td.lineno { color: white; background: #111; }
+	div#cgit table.ssdiff td.hunk { color: white; background: #003; border-top-color: #555; border-bottom-color: #555; }
+	div#cgit table.ssdiff td.head { border-top-color: #555; border-bottom-color: #555; }
+	div#cgit table.ssdiff td.head div.head { color: white; }
+	div#cgit table.ssdiff td.foot { border-top-color: #555; }
+
+	/* If you use filters that use colored text, such as a source
+	   highlighter, you will need to add styles for it as well.
+
+	   Here is an example, based on the example CSS in the file
+	   filters/syntax-highlighting.sh */
+	div#cgit table.blob .num { color:#ff814f; }
+	div#cgit table.blob .esc { color:#ff00ff; }
+	div#cgit table.blob .str { color:#fc4040; }
+	div#cgit table.blob .pps { color:#ffff7f; }
+	div#cgit table.blob .slc { color:#7f7c7f; }
+	div#cgit table.blob .com { color:#7e7c7e; }
+	div#cgit table.blob .ppc { color:#7dff7d; }
+	div#cgit table.blob .opt { color:#ffffff; }
+	div#cgit table.blob .lin { color:#aaaaaa; }
+	div#cgit table.blob .kwa { color:#ffffff; }
+	div#cgit table.blob .kwb { color:#51a8ff; }
+	div#cgit table.blob .kwc { color:#ffffff; }
+	div#cgit table.blob .kwd { color:#7e7efe; }
+}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH RESEND v2] css: Support for dark mode
  2023-01-02  0:51 ` Jason A. Donenfeld
@ 2023-01-01 21:15   ` Samuel Lidén Borell
  2023-01-11 20:54     ` Jason A. Donenfeld
  0 siblings, 1 reply; 11+ messages in thread
From: Samuel Lidén Borell @ 2023-01-01 21:15 UTC (permalink / raw)
  To: cgit

Modern browsers have a "dark mode" preference, which enables alternate
styles on web sites that support this.

This patch adds a dark color scheme, that is automatically activated
via a CSS @media query.

Note that filters that use color (such as source highlighters) and
logotypes may need to be updated to work with a black background!
See the updated files in the filters/ directory.

Signed-off-by: Samuel Lidén Borell <samuel@kodafritt.se>
---
 cgit.css                        | 103 ++++++++++++++++++++++++++++++++
 filters/html-converters/md2html |  28 ++++++++-
 filters/syntax-highlighting.py  |   8 ++-
 filters/syntax-highlighting.sh  |  73 +++++++++++++++-------
 4 files changed, 187 insertions(+), 25 deletions(-)

diff --git a/cgit.css b/cgit.css
index 1b848cf..1d5c6d0 100644
--- a/cgit.css
+++ b/cgit.css
@@ -897,3 +897,106 @@ div#cgit table.ssdiff td.space {
 div#cgit table.ssdiff td.space div {
 	min-height: 3em;
 }
+
+/* Color overrides for browsers running in dark mode */
+:root { color-scheme: light dark; }
+@media (prefers-color-scheme: dark) {
+	html, div#cgit { color: #ccc; background: black; }
+	div#cgit a { color: #66f; }
+	div#cgit table#header td.main a { color: #eee; }
+	div#cgit table#header td.sub { color: #888; }
+	div#cgit table.tabs { border-bottom-color: #333; }
+	div#cgit table.tabs td a { color: #888; }
+	div#cgit table.tabs td a.active { color: #eee; background-color: #333; }
+	div#cgit div.path { color: #eee; background-color: #111; }
+	div#cgit div.content { border-bottom-color: #bbb; }
+	div#cgit table.list tr { background: black; }
+	div#cgit table.list tr.logheader { background: #111; }
+	div#cgit table.list tr:nth-child(even) { background: #080808; }
+	div#cgit table.list tr:nth-child(odd) { background: black; }
+	div#cgit table.list tr:hover { background: #111; }
+	div#cgit table.list tr.nohover { background: black; }
+	div#cgit table.list tr.nohover:hover { background: black; }
+	div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { background: #080808; }
+	div#cgit table.list tr.nohover-highlight:hover:nth-child(odd) { background: black; }
+	div#cgit table.list td.commitgraph .column1 { color: #f55; }
+	div#cgit table.list td.commitgraph .column2 { color: #5f5; }
+	div#cgit table.list td.commitgraph .column3 { color: #ff5; }
+	div#cgit table.list td.commitgraph .column4 { color: #55f; }
+	div#cgit table.list td.commitgraph .column5 { color: #f5f; }
+	div#cgit table.list td.commitgraph .column6 { color: #5ff; }
+	div#cgit table.list td a { color: #eee; }
+	div#cgit table.list td a.ls-dir { color: #66f; }
+	div#cgit table.list td a:hover { color: #66f; }
+	div#cgit table#downloads { border-color: #888; }
+	div#cgit table#downloads th { background-color: #333; }
+	div#cgit div#blob { border-color: #eee; }
+	div#cgit table.blob { border-top-color: #eee; }
+	div#cgit table.blob td.hashes,
+	div#cgit table.blob td.lines { color: #eee; }
+	div#cgit table.blob td.linenumbers { border-right-color: gray; }
+	div#cgit table.blob td.linenumbers a,
+	div#cgit table.ssdiff td.lineno a { color: gray; }
+	div#cgit table.blob td.linenumbers a:hover,
+	div#cgit table.ssdiff td.lineno a:hover { color: #eee; }
+	div#cgit table.blame div.alt:nth-child(even) { background: #111; }
+	div#cgit table.blame div.alt:nth-child(odd) { background: black; }
+	div#cgit table.bin-blob { border-color: #eee; }
+	div#cgit table.bin-blob th { border-color: #888; }
+	div#cgit table.bin-blob td { border-left-color: #888; }
+	div#cgit div.cgit-panel table { border-color: #555; background-color: #111; }
+	div#cgit div.notes { border-color: #661; background-color: #220; }
+	div#cgit table.diffstat { border: #555; background-color: #111; }
+	div#cgit table.diffstat td span.modechange { color: #c66; }
+	div#cgit table.diffstat td.add a { color: #6c6; }
+	div#cgit table.diffstat td.del a { color: #c66; }
+	div#cgit table.diffstat td.upd a { color: #66c; }
+	div#cgit table.diffstat td.graph td.add { background-color: #3a3; }
+	div#cgit table.diffstat td.graph td.rem { background-color: #a33; }
+	div#cgit div.diffstat-summary { color: #777; }
+	div#cgit table.diff td div.head { color: #eee; }
+	div#cgit table.diff td div.hunk { color: #66f; }
+	div#cgit table.diff td div.add { color: #6c6; }
+	div#cgit table.diff td div.del { color: #c66; }
+	div#cgit table.list td.reposection { color: #777; }
+	div#cgit ul.pager a { color: #888; }
+	div#cgit span.age-mins { color: #7f7; }
+	div#cgit span.age-hours { color: #7f7; }
+	div#cgit span.age-days { color: #bfb; }
+	div#cgit span.age-weeks { color: #bbb; }
+	div#cgit span.age-months { color: #777; }
+	div#cgit span.age-years { color: #444; }
+	div#cgit span.insertions { color: #7f7; }
+	div#cgit span.deletions { color: #f77; }
+	div#cgit div.footer { color: #333; }
+	div#cgit div.footer a { color: #333; }
+	div#cgit a.branch-deco { color: #dfd; background-color: #050; border-color: #6c6; }
+	div#cgit a.tag-deco { color: #ffd; background-color: #777700; border-color: #ffff88; }
+	div#cgit a.tag-annotated-deco { color: #fed; background-color: #850; border-color: #fc8; }
+	div#cgit a.remote-deco { color: #ddf; background-color: #336; border-color: #66f; }
+	div#cgit a.deco { color: #fdd; background-color: #a33; border-color: #ff8888; }
+	div#cgit table.stats { border-color: #eee; }
+	div#cgit table.stats th { background-color: #111; border-color: #eee; }
+	div#cgit table.stats td { border-color: #eee; }
+	div#cgit table.stats td.sum { color: #f33; }
+	div#cgit table.vgraph { border-color: #eee; }
+	div#cgit table.vgraph th { background-color: #111; border-color: black; }
+	div#cgit table.vgraph div.bar { background-color: #111; }
+	div#cgit table.hgraph { border-color: #eee; }
+	div#cgit table.hgraph th { background-color: #111; border-color: #eee; }
+	div#cgit table.hgraph div.bar { background-color: #111; }
+	div#cgit table.ssdiff td { border-left-color: #555; border-right-color: #555; }
+	div#cgit table.ssdiff td.add { color: #eee; background: #030; }
+	div#cgit table.ssdiff td.add_dark { color: #eee; background: #353; }
+	div#cgit table.ssdiff span.add { background: #030; }
+	div#cgit table.ssdiff td.del { color: #eee; background: #300; }
+	div#cgit table.ssdiff td.del_dark { color: #eee; background: #533; }
+	div#cgit table.ssdiff span.del { background: #300; }
+	div#cgit table.ssdiff td.changed { color: #eee; background: #330; }
+	div#cgit table.ssdiff td.changed_dark { color: #eee; background: #553; }
+	div#cgit table.ssdiff td.lineno { color: #eee; background: #111; }
+	div#cgit table.ssdiff td.hunk { color: #eee; background: #003; border-top-color: #555; border-bottom-color: #555; }
+	div#cgit table.ssdiff td.head { border-top-color: #555; border-bottom-color: #555; }
+	div#cgit table.ssdiff td.head div.head { color: #eee; }
+	div#cgit table.ssdiff td.foot { border-top-color: #555; }
+}
diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html
index 59f43a8..097a5d0 100755
--- a/filters/html-converters/md2html
+++ b/filters/html-converters/md2html
@@ -4,6 +4,11 @@ import sys
 import io
 from pygments.formatters import HtmlFormatter
 from markdown.extensions.toc import TocExtension
+
+# The dark style is automatically selected if the browser is in dark mode
+light_style='pastie'
+dark_style='monokai'
+
 sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
 sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
 sys.stdout.write('''
@@ -284,9 +289,28 @@ div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#
     border: none;
 }
 ''')
-sys.stdout.write(HtmlFormatter(style='pastie').get_style_defs('.highlight'))
+sys.stdout.write(HtmlFormatter(style=light_style).get_style_defs('.highlight'))
 sys.stdout.write('''
-</style>   
+@media (prefers-color-scheme: dark) {
+.markdown-body a.absent { color: #f33; }
+.markdown-body h1 .mini-icon-link, .markdown-body h2 .mini-icon-link, .markdown-body h3 .mini-icon-link, .markdown-body h4 .mini-icon-link, .markdown-body h5 .mini-icon-link, .markdown-body h6 .mini-icon-link { color: #eee; }
+div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#cgit .markdown-body h3 a.toclink, div#cgit .markdown-body h4 a.toclink, div#cgit .markdown-body h5 a.toclink, div#cgit .markdown-body h6 a.toclink { color: #eee; }
+.markdown-body h1 { color: #eee; }
+.markdown-body h2 { border-bottom-color: #333; color: #eee; }
+.markdown-body h6 { color: #888; }
+.markdown-body hr { border-color: #333; }
+.markdown-body blockquote { border-left-color: #222; color: #888; }
+.markdown-body table th, .markdown-body table td { border-color: #333; }
+.markdown-body table tr { border-top-color: #333; background-color: #111; }
+.markdown-body table tr:nth-child(2n) { background-color: #070707; }
+.markdown-body span.frame span span { color: #ccc; }
+.markdown-body code, .markdown-body tt { border-color: #151515; background-color: #070707; }
+.markdown-body .highlight pre, .markdown-body pre { background-color: #070707; border-color: #333; }
+''')
+sys.stdout.write(HtmlFormatter(style=dark_style, nobackground=True).get_style_defs('.highlight'))
+sys.stdout.write('\n}\n') # end of dark mode
+sys.stdout.write('''
+</style>
 ''')
 sys.stdout.write("<div class='markdown-body'>")
 sys.stdout.flush()
diff --git a/filters/syntax-highlighting.py b/filters/syntax-highlighting.py
index e912594..672201d 100755
--- a/filters/syntax-highlighting.py
+++ b/filters/syntax-highlighting.py
@@ -29,12 +29,15 @@ from pygments.lexers import guess_lexer
 from pygments.lexers import guess_lexer_for_filename
 from pygments.formatters import HtmlFormatter
 
+# The dark style is automatically selected if the browser is in dark mode
+light_style='pastie'
+dark_style='monokai'
 
 sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='replace')
 sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
 data = sys.stdin.read()
 filename = sys.argv[1]
-formatter = HtmlFormatter(style='pastie', nobackground=True)
+formatter = HtmlFormatter(style=light_style, nobackground=True)
 
 try:
 	lexer = guess_lexer_for_filename(filename, data)
@@ -51,5 +54,8 @@ except TypeError:
 # printout pygments' css definitions as well
 sys.stdout.write('<style>')
 sys.stdout.write(formatter.get_style_defs('.highlight'))
+sys.stdout.write('\n@media (prefers-color-scheme: dark) {\n')
+sys.stdout.write(HtmlFormatter(style=dark_style, nobackground=True).get_style_defs('.highlight'))
+sys.stdout.write('\n}\n')
 sys.stdout.write('</style>')
 sys.stdout.write(highlight(data, lexer, formatter, outfile=None))
diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh
index 840bc34..7ef01c4 100755
--- a/filters/syntax-highlighting.sh
+++ b/filters/syntax-highlighting.sh
@@ -25,6 +25,20 @@
 # table.blob .kwb  { color:#830000; }
 # table.blob .kwc  { color:#000000; font-weight:bold; }
 # table.blob .kwd  { color:#010181; }
+# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */
+# 	table.blob .num  { color:#ff814f; }
+# 	table.blob .esc  { color:#ff00ff; }
+# 	table.blob .str  { color:#fc4040; }
+# 	table.blob .dstr { color:#ffff7e; }
+# 	table.blob .slc  { color:#7f7c7f; }
+# 	table.blob .com  { color:#7e7c7e; }
+# 	table.blob .dir  { color:#7dff7d; }
+# 	table.blob .sym  { color:#eeeeee; }
+# 	table.blob .kwa  { color:#eeeeee; }
+# 	table.blob .kwb  { color:#51a8ff; }
+# 	table.blob .kwc  { color:#eeeeee; }
+# 	table.blob .kwd  { color:#7e7efe; }
+# }
 #
 #
 # Style definition file generated by highlight 2.6.14, http://www.andre-simon.de/
@@ -45,28 +59,26 @@
 # .hl.kwb  { color:#830000; }
 # .hl.kwc  { color:#000000; font-weight:bold; }
 # .hl.kwd  { color:#010181; }
-#
-#
-# Style definition file generated by highlight 3.8, http://www.andre-simon.de/
-#
-# body.hl { background-color:#e0eaee; }
-# pre.hl  { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New';}
-# .hl.num { color:#b07e00; }
-# .hl.esc { color:#ff00ff; }
-# .hl.str { color:#bf0303; }
-# .hl.pps { color:#818100; }
-# .hl.slc { color:#838183; font-style:italic; }
-# .hl.com { color:#838183; font-style:italic; }
-# .hl.ppc { color:#008200; }
-# .hl.opt { color:#000000; }
-# .hl.lin { color:#555555; }
-# .hl.kwa { color:#000000; font-weight:bold; }
-# .hl.kwb { color:#0057ae; }
-# .hl.kwc { color:#000000; font-weight:bold; }
-# .hl.kwd { color:#010181; }
-#
-#
-# Style definition file generated by highlight 3.13, http://www.andre-simon.de/
+# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */
+# 	pre.hl  { color:#eeeeee; background-color:#111; }
+# 	.hl.num  { color:#ff814f; }
+# 	.hl.esc  { color:#ff00ff; }
+# 	.hl.str  { color:#fc4040; }
+# 	.hl.dstr { color:#ffff7e; }
+# 	.hl.slc  { color:#7f7c7f; }
+# 	.hl.com  { color:#7e7c7e; }
+# 	.hl.dir  { color:#7dff7d; }
+# 	.hl.sym  { color:#eeeeee; }
+# 	.hl.line { color:#aaaaaa; }
+# 	.hl.mark { background-color:#444400; }
+# 	.hl.kwa  { color:#eeeeee; }
+# 	.hl.kwb  { color:#51a8ff; }
+# 	.hl.kwc  { color:#eeeeee; }
+# 	.hl.kwd  { color:#7e7efe; }
+# }
+#
+#
+# Style definition file generated by highlight 3.8 / 3.13 / 3.41, http://www.andre-simon.de/
 #
 # body.hl { background-color:#e0eaee; }
 # pre.hl  { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New',monospace;}
@@ -84,6 +96,23 @@
 # .hl.kwb { color:#0057ae; }
 # .hl.kwc { color:#000000; font-weight:bold; }
 # .hl.kwd { color:#010181; }
+# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */
+# 	pre.hl  { color:#eeeeee; background-color:#111; }
+# 	.hl.num { color:#ff814f; }
+# 	.hl.esc { color:#ff00ff; }
+# 	.hl.str { color:#fc4040; }
+# 	.hl.pps { color:#ffff7f; }
+# 	.hl.slc { color:#7f7c7f; }
+# 	.hl.com { color:#7e7c7e; }
+# 	.hl.ppc { color:#7dff7d; }
+# 	.hl.opt { color:#eeeeee; }
+# 	.hl.ipl { color:#51a8ff; }
+# 	.hl.lin { color:#aaaaaa; }
+# 	.hl.kwa { color:#eeeeee; }
+# 	.hl.kwb { color:#51a8ff; }
+# 	.hl.kwc { color:#eeeeee; }
+# 	.hl.kwd { color:#7e7efe; }
+# }
 #
 #
 # The following environment variables can be used to retrieve the configuration
-- 
2.30.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] css: Optional support for dark mode
  2023-01-01 21:15 [PATCH] css: Optional support for dark mode Samuel Lidén Borell
@ 2023-01-02  0:51 ` Jason A. Donenfeld
  2023-01-01 21:15   ` [PATCH RESEND v2] css: Support " Samuel Lidén Borell
  0 siblings, 1 reply; 11+ messages in thread
From: Jason A. Donenfeld @ 2023-01-02  0:51 UTC (permalink / raw)
  To: samuel; +Cc: cgit

Hi Samuel,

On Sun, Jan 1, 2023 at 10:41 PM Samuel Lidén Borell <samuel@kodafritt.se> wrote:
>
> Modern browsers have a "dark mode" preference, which enables alternate
> CSS rules on web sites that support this.
>
> This patch adds an optional dark color scheme, that can be copied into
> cgit.css. The color scheme is then auto-detected via a @media query.
>
> Note that filters that use color (such as source highlighters), and
> logotypes, may need to be updated to work with a black background. So
> this goes into a separate file, that can be copied into cgit.css for
> those who want to enable support for dark mode.

Rather, let's just include this in the default cgit.css file, people
will just fix whatever source filters being used. That means the ones
in-tree should be updated first. Specifically, syntax-highlighting.py
and maybe even syntax-highlighting.sh should be updated.

Jason

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RESEND v2] css: Support for dark mode
  2023-01-01 21:15   ` [PATCH RESEND v2] css: Support " Samuel Lidén Borell
@ 2023-01-11 20:54     ` Jason A. Donenfeld
  2023-01-11 20:56       ` Jason A. Donenfeld
  0 siblings, 1 reply; 11+ messages in thread
From: Jason A. Donenfeld @ 2023-01-11 20:54 UTC (permalink / raw)
  To: samuel; +Cc: cgit

Hmm. I applied this on the git.zx2c4.com server to test it, and
strings are somewhat illegible: https://git.zx2c4.com/cgit/tree/cgit.c

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RESEND v2] css: Support for dark mode
  2023-01-11 20:54     ` Jason A. Donenfeld
@ 2023-01-11 20:56       ` Jason A. Donenfeld
  2023-01-12  0:33         ` Samuel Lidén Borell
  2023-01-12  0:33         ` Jason A. Donenfeld
  0 siblings, 2 replies; 11+ messages in thread
From: Jason A. Donenfeld @ 2023-01-11 20:56 UTC (permalink / raw)
  To: samuel; +Cc: cgit

It looks like the issue is that the string class for the light theme is:

.highlight .s {
    color: #dd2200;
    background-color: #fff0f0;
}

But for the dark theme it's:

@media (prefers-color-scheme: dark)
.highlight .s {
    color: #e6db74;
}

And so it winds up using the dark color, but with the light
background, because the dark theme doesn't specify a background.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RESEND v2] css: Support for dark mode
  2023-01-11 20:56       ` Jason A. Donenfeld
@ 2023-01-12  0:33         ` Samuel Lidén Borell
  2023-01-12  0:34           ` Jason A. Donenfeld
  2023-01-12  0:33         ` Jason A. Donenfeld
  1 sibling, 1 reply; 11+ messages in thread
From: Samuel Lidén Borell @ 2023-01-12  0:33 UTC (permalink / raw)
  To: cgit

Oops. I made a last minute change of the themes, and that broke things. Looks like some theme combinations don't work well.

I will send an updated patch with a working theme combo + a comment about this.

It could also be solved by also wrapping the light theme in a media query, but then older browsers will not show the highlighting.

Regards,
Samuel


On Wed, 11 Jan 2023 21:56:30 +0100, "Jason A. Donenfeld" <Jason@zx2c4.com> wrote:

> It looks like the issue is that the string class for the light theme is:
> 
> .highlight .s {
>     color: #dd2200;
>     background-color: #fff0f0;
> }
> 
> But for the dark theme it's:
> 
> @media (prefers-color-scheme: dark)
> .highlight .s {
>     color: #e6db74;
> }
> 
> And so it winds up using the dark color, but with the light
> background, because the dark theme doesn't specify a background.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RESEND v2] css: Support for dark mode
  2023-01-11 20:56       ` Jason A. Donenfeld
  2023-01-12  0:33         ` Samuel Lidén Borell
@ 2023-01-12  0:33         ` Jason A. Donenfeld
  2023-01-22 11:35           ` [PATCH v3] " Samuel Lidén Borell
  1 sibling, 1 reply; 11+ messages in thread
From: Jason A. Donenfeld @ 2023-01-12  0:33 UTC (permalink / raw)
  To: samuel; +Cc: cgit

On Wed, Jan 11, 2023 at 09:56:30PM +0100, Jason A. Donenfeld wrote:
> It looks like the issue is that the string class for the light theme is:
> 
> .highlight .s {
>     color: #dd2200;
>     background-color: #fff0f0;
> }
> 
> But for the dark theme it's:
> 
> @media (prefers-color-scheme: dark)
> .highlight .s {
>     color: #e6db74;
> }
> 
> And so it winds up using the dark color, but with the light
> background, because the dark theme doesn't specify a background.

I fixed this with the below diff. It uses an explicit `@media
(prefers-color-scheme: light) block`, which MDN says, "indicates that
user has notified that they prefer an interface that has a light theme,
or has not expressed an active preference." So this seems correct.

However, I also order the light *after* the dark for non-media-query
understanding browsers. I suspect the same should be done on all the
other files.

The below diff is now on git.zx2c4.com, so you can use that link earlier
to see what it's like. Unfortunately, I think a lot of the rest of the
styling is too dark or otherwise clashing. So you might want to give the
whole thing a second pass.

diff --git a/filters/syntax-highlighting.py b/filters/syntax-highlighting.py
index 672201d..fafa30e 100755
--- a/filters/syntax-highlighting.py
+++ b/filters/syntax-highlighting.py
@@ -53,9 +53,11 @@ except TypeError:
 # highlight! :-)
 # printout pygments' css definitions as well
 sys.stdout.write('<style>')
-sys.stdout.write(formatter.get_style_defs('.highlight'))
 sys.stdout.write('\n@media (prefers-color-scheme: dark) {\n')
 sys.stdout.write(HtmlFormatter(style=dark_style, nobackground=True).get_style_defs('.highlight'))
 sys.stdout.write('\n}\n')
+sys.stdout.write('\n@media (prefers-color-scheme: light) {\n')
+sys.stdout.write(HtmlFormatter(style=dark_style, nobackground=True).get_style_defs('.highlight'))
+sys.stdout.write('\n}\n')
 sys.stdout.write('</style>')
 sys.stdout.write(highlight(data, lexer, formatter, outfile=None))


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RESEND v2] css: Support for dark mode
  2023-01-12  0:33         ` Samuel Lidén Borell
@ 2023-01-12  0:34           ` Jason A. Donenfeld
  0 siblings, 0 replies; 11+ messages in thread
From: Jason A. Donenfeld @ 2023-01-12  0:34 UTC (permalink / raw)
  To: Samuel Lidén Borell; +Cc: cgit

On Thu, Jan 12, 2023 at 1:33 AM Samuel Lidén Borell <samuel@kodafritt.se> wrote:
>
> Oops. I made a last minute change of the themes, and that broke things. Looks like some theme combinations don't work well.
>
> I will send an updated patch with a working theme combo + a comment about this.
>
> It could also be solved by also wrapping the light theme in a media query, but then older browsers will not show the highlighting.

Heh, we just sent emails at the same time. See the one I just sent you
-- it has a diff for your consideration.


Jason

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3] css: Support for dark mode
  2023-01-12  0:33         ` Jason A. Donenfeld
@ 2023-01-22 11:35           ` Samuel Lidén Borell
  2023-01-22 13:04             ` Samuel Lidén Borell
  2023-01-27 20:42             ` Jason A. Donenfeld
  0 siblings, 2 replies; 11+ messages in thread
From: Samuel Lidén Borell @ 2023-01-22 11:35 UTC (permalink / raw)
  To: cgit

Modern browsers have a "dark mode" preference, which enables alternate
styles on web sites that support this.

This patch adds a dark color scheme, that is automatically activated
via a CSS @media query.

Older browsers that do not support color schemes will simply show the
light scheme, but possibly without syntax highlighting.

Note that filters that use color (such as source highlighters) and
logotypes may need to be updated to work with a black background!
See the updated files in the filters/ directory.

Signed-off-by: Samuel Lidén Borell <samuel@kodafritt.se>
---
 cgit.css                        | 113 ++++++++++++++++++++++++++++++++
 filters/html-converters/md2html |  30 ++++++++-
 filters/syntax-highlighting.py  |  14 +++-
 filters/syntax-highlighting.sh  | 104 ++++++++++++++++++-----------
 4 files changed, 217 insertions(+), 44 deletions(-)

diff --git a/cgit.css b/cgit.css
index 1b848cf..50a254a 100644
--- a/cgit.css
+++ b/cgit.css
@@ -897,3 +897,116 @@ div#cgit table.ssdiff td.space {
 div#cgit table.ssdiff td.space div {
 	min-height: 3em;
 }
+
+/*
+   Color overrides for browsers running in dark mode.
+   "only all and ..." forces very old browsers to ignore the media query:
+   https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#improving_compatibility_with_older_browsers
+*/
+:root { color-scheme: light dark; }
+@media only all and (prefers-color-scheme: dark) {
+	html, div#cgit { color: #eee; background: #171717; }
+	div#cgit a { color: #3af; }
+	div#cgit .diffstat-header a { color: #28d; }
+	div#cgit table#header td.main a { color: #eee; }
+	div#cgit table#header td.sub { color: #999; }
+	div#cgit table.tabs { border-bottom-color: #444; }
+	div#cgit table.tabs td a { color: #888; }
+	div#cgit table.tabs td a.active { color: #fff; background-color: #444; }
+	div#cgit div.path { color: #eee; background-color: #333; }
+	div#cgit div.content { border-bottom-color: #bbb; }
+	div#cgit table.list tr { background: #111; }
+	div#cgit table.list tr.logheader { background: #111; }
+	div#cgit table.list tr:nth-child(even) { background: #181818; }
+	div#cgit table.list tr:nth-child(odd) { background: #111; }
+	div#cgit table.list tr:hover { background: #222; }
+	div#cgit table.list tr.nohover { background: #111; }
+	div#cgit table.list tr.nohover:hover { background: #111; }
+	div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { background: #181818; }
+	div#cgit table.list tr.nohover-highlight:hover:nth-child(odd) { background: #111; }
+	div#cgit table.list td.commitgraph .column1 { color: #f55; }
+	div#cgit table.list td.commitgraph .column2 { color: #5f5; }
+	div#cgit table.list td.commitgraph .column3 { color: #ff5; }
+	div#cgit table.list td.commitgraph .column4 { color: #55f; }
+	div#cgit table.list td.commitgraph .column5 { color: #f5f; }
+	div#cgit table.list td.commitgraph .column6 { color: #5ff; }
+	div#cgit table.list td a { color: #eee; }
+	div#cgit table.list td a.ls-dir { color: #28d; }
+	div#cgit table.list td a:hover { color: #3af; }
+	div#cgit table#downloads { border-color: #888; }
+	div#cgit table#downloads th { background-color: #333; }
+	div#cgit div#blob { border-color: #eee; }
+	div#cgit table.blob { border-top-color: #eee; }
+	div#cgit table.blob td.hashes,
+	div#cgit table.blob td.lines { color: #eee; }
+	div#cgit table.blob td.linenumbers { border-right-color: gray; }
+	div#cgit table.blob td.linenumbers a,
+	div#cgit table.ssdiff td.lineno a { color: gray; }
+	div#cgit table.blob td.linenumbers a:hover,
+	div#cgit table.ssdiff td.lineno a:hover { color: #eee; }
+	div#cgit table.blame div.alt:nth-child(even) { background: #222; }
+	div#cgit table.blame div.alt:nth-child(odd) { background: #111; }
+	div#cgit table.bin-blob { border-color: #eee; }
+	div#cgit table.bin-blob th { border-color: #888; }
+	div#cgit table.bin-blob td { border-left-color: #888; }
+	div#cgit div.cgit-panel table { border-color: #555; background-color: #282828; }
+	div#cgit div.notes { border-color: #661; background-color: #220; }
+	div#cgit table.diffstat { border-color: #555; background-color: #282828; }
+	div#cgit table.diffstat td span.modechange { color: #c66; }
+	div#cgit table.diffstat td.add a { color: #6c6; }
+	div#cgit table.diffstat td.del a { color: #c66; }
+	div#cgit table.diffstat td.upd a { color: #3af; }
+	div#cgit table.diffstat td.graph td.add { background-color: #3a3; }
+	div#cgit table.diffstat td.graph td.rem { background-color: #a33; }
+	div#cgit div.diffstat-summary { color: #777; }
+	div#cgit table.diff td div.head { color: #eee; }
+	div#cgit table.diff td div.hunk { color: #28d; }
+	div#cgit table.diff td div.add { color: #6c6; }
+	div#cgit table.diff td div.del { color: #c66; }
+	div#cgit table.list td.reposection { color: #777; }
+	div#cgit ul.pager a { color: #888; }
+	div#cgit span.age-mins { color: #7f7; }
+	div#cgit span.age-hours { color: #7f7; }
+	div#cgit span.age-days { color: #9d9; }
+	div#cgit span.age-weeks { color: #bbb; }
+	div#cgit span.age-months { color: #888; }
+	div#cgit span.age-years { color: #666; }
+	div#cgit span.insertions { color: #7f7; }
+	div#cgit span.deletions { color: #e33; }
+	div#cgit div.footer { color: #555; }
+	div#cgit div.footer a { color: #555; }
+	div#cgit a.branch-deco { color: #fff; background-color: #361; border-color: #3b2; }
+	div#cgit a.tag-deco { color: #fff; background-color: #650; border-color: #ba3; }
+	div#cgit a.tag-annotated-deco { color: #fff; background-color: #840; border-color: #b96; }
+	div#cgit a.remote-deco { color: #fff; background-color: #348; border-color: #67c; }
+	div#cgit a.deco { color: #fff; background-color: #922; border-color: #d55; }
+	div#cgit a.branch-deco:hover, div#cgit table.list td a.branch-deco:hover,
+	div#cgit a.tag-deco:hover, div#cgit table.list td a.tag-deco:hover,
+	div#cgit a.tag-annotated-deco:hover, div#cgit table.list td a.tag-annotated-deco:hover,
+	div#cgit a.remote-deco:hover, div#cgit table.list td a.remote-deco:hover,
+	div#cgit a.deco:hover, div#cgit table.list td a.deco:hover { color: #fff; }
+	div#cgit table.stats { border-color: #555; }
+	div#cgit table.stats th { background-color: #333; border-color: #555; }
+	div#cgit table.stats td { border-color: #555; }
+	div#cgit table.stats td.sum { color: #5C7E9B; }
+	div#cgit table.vgraph { border-color: #eee; }
+	div#cgit table.vgraph th { background-color: #111; border-color: black; }
+	div#cgit table.vgraph div.bar { background-color: #111; }
+	div#cgit table.hgraph { border-color: #eee; }
+	div#cgit table.hgraph th { background-color: #111; border-color: #eee; }
+	div#cgit table.hgraph div.bar { background-color: #111; }
+	div#cgit table.ssdiff td { border-left-color: #555; border-right-color: #555; }
+	div#cgit table.ssdiff td.add { color: #eee; background: #353; }
+	div#cgit table.ssdiff td.add_dark { color: #eee; background: #030; }
+	div#cgit table.ssdiff span.add { background: #030; }
+	div#cgit table.ssdiff td.del { color: #eee; background: #533; }
+	div#cgit table.ssdiff td.del_dark { color: #eee; background: #411; }
+	div#cgit table.ssdiff span.del { background: #300; }
+	div#cgit table.ssdiff td.changed { color: #eee; background: #553; }
+	div#cgit table.ssdiff td.changed_dark { color: #eee; background: #330; }
+	div#cgit table.ssdiff td.lineno { color: #eee; background: #111; }
+	div#cgit table.ssdiff td.hunk { color: #eee; background: #0D3D64; border-top-color: #555; border-bottom-color: #555; }
+	div#cgit table.ssdiff td.head { border-top-color: #555; border-bottom-color: #555; }
+	div#cgit table.ssdiff td.head div.head { color: #eee; }
+	div#cgit table.ssdiff td.foot { border-top-color: #555; }
+}
diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html
index 59f43a8..627808a 100755
--- a/filters/html-converters/md2html
+++ b/filters/html-converters/md2html
@@ -4,6 +4,11 @@ import sys
 import io
 from pygments.formatters import HtmlFormatter
 from markdown.extensions.toc import TocExtension
+
+# The dark style is automatically selected if the browser is in dark mode
+light_style='pastie'
+dark_style='monokai'
+
 sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
 sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
 sys.stdout.write('''
@@ -283,10 +288,31 @@ div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#
     background-color: transparent;
     border: none;
 }
+@media only all and (prefers-color-scheme: dark) {
+.markdown-body a.absent { color: #f33; }
+.markdown-body h1 .mini-icon-link, .markdown-body h2 .mini-icon-link, .markdown-body h3 .mini-icon-link, .markdown-body h4 .mini-icon-link, .markdown-body h5 .mini-icon-link, .markdown-body h6 .mini-icon-link { color: #eee; }
+div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#cgit .markdown-body h3 a.toclink, div#cgit .markdown-body h4 a.toclink, div#cgit .markdown-body h5 a.toclink, div#cgit .markdown-body h6 a.toclink { color: #eee; }
+.markdown-body h1 { color: #eee; }
+.markdown-body h2 { border-bottom-color: #333; color: #eee; }
+.markdown-body h6 { color: #888; }
+.markdown-body hr { border-color: #333; }
+.markdown-body blockquote { border-left-color: #222; color: #888; }
+.markdown-body table th, .markdown-body table td { border-color: #333; }
+.markdown-body table tr { border-top-color: #333; background-color: #111; }
+.markdown-body table tr:nth-child(2n) { background-color: #070707; }
+.markdown-body span.frame span span { color: #ccc; }
+.markdown-body code, .markdown-body tt { border-color: #151515; background-color: #070707; }
+.markdown-body .highlight pre, .markdown-body pre { background-color: #070707; border-color: #333; }
 ''')
-sys.stdout.write(HtmlFormatter(style='pastie').get_style_defs('.highlight'))
+sys.stdout.write(HtmlFormatter(style=dark_style).get_style_defs('.highlight'))
 sys.stdout.write('''
-</style>   
+}
+@media (prefers-color-scheme: light) {
+''')
+sys.stdout.write(HtmlFormatter(style=light_style).get_style_defs('.highlight'))
+sys.stdout.write('''
+}
+</style>
 ''')
 sys.stdout.write("<div class='markdown-body'>")
 sys.stdout.flush()
diff --git a/filters/syntax-highlighting.py b/filters/syntax-highlighting.py
index e912594..f2c0fe1 100755
--- a/filters/syntax-highlighting.py
+++ b/filters/syntax-highlighting.py
@@ -29,12 +29,16 @@ from pygments.lexers import guess_lexer
 from pygments.lexers import guess_lexer_for_filename
 from pygments.formatters import HtmlFormatter
 
+# The dark style is automatically selected if the browser is in dark mode
+light_style='pastie'
+dark_style='monokai'
 
 sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='replace')
 sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
 data = sys.stdin.read()
 filename = sys.argv[1]
-formatter = HtmlFormatter(style='pastie', nobackground=True)
+light_formatter = HtmlFormatter(style=light_style, nobackground=True)
+dark_formatter = HtmlFormatter(style=dark_style, nobackground=True)
 
 try:
 	lexer = guess_lexer_for_filename(filename, data)
@@ -50,6 +54,10 @@ except TypeError:
 # highlight! :-)
 # printout pygments' css definitions as well
 sys.stdout.write('<style>')
-sys.stdout.write(formatter.get_style_defs('.highlight'))
+sys.stdout.write('\n@media only all and (prefers-color-scheme: dark) {\n')
+sys.stdout.write(dark_formatter.get_style_defs('.highlight'))
+sys.stdout.write('\n}\n@media (prefers-color-scheme: light) {\n')
+sys.stdout.write(light_formatter.get_style_defs('.highlight'))
+sys.stdout.write('\n}\n')
 sys.stdout.write('</style>')
-sys.stdout.write(highlight(data, lexer, formatter, outfile=None))
+sys.stdout.write(highlight(data, lexer, light_formatter, outfile=None))
diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh
index 840bc34..5d4e7c7 100755
--- a/filters/syntax-highlighting.sh
+++ b/filters/syntax-highlighting.sh
@@ -25,6 +25,20 @@
 # table.blob .kwb  { color:#830000; }
 # table.blob .kwc  { color:#000000; font-weight:bold; }
 # table.blob .kwd  { color:#010181; }
+# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */
+# 	table.blob .num  { color:#ff814f; }
+# 	table.blob .esc  { color:#f60; }
+# 	table.blob .str  { color:#cc0; }
+# 	table.blob .dstr { color:#ffff7e; }
+# 	table.blob .slc  { color:#7f7c7f; }
+# 	table.blob .com  { color:#7e7c7e; }
+# 	table.blob .dir  { color:#7dff7d; }
+# 	table.blob .sym  { color:#eeeeee; }
+# 	table.blob .kwa  { color:#bb0; }
+# 	table.blob .kwb  { color:#0a0; }
+# 	table.blob .kwc  { color:#eeeeee; }
+# 	table.blob .kwd  { color:#7e7efe; }
+# }
 #
 #
 # Style definition file generated by highlight 2.6.14, http://www.andre-simon.de/
@@ -45,45 +59,57 @@
 # .hl.kwb  { color:#830000; }
 # .hl.kwc  { color:#000000; font-weight:bold; }
 # .hl.kwd  { color:#010181; }
-#
-#
-# Style definition file generated by highlight 3.8, http://www.andre-simon.de/
-#
-# body.hl { background-color:#e0eaee; }
-# pre.hl  { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New';}
-# .hl.num { color:#b07e00; }
-# .hl.esc { color:#ff00ff; }
-# .hl.str { color:#bf0303; }
-# .hl.pps { color:#818100; }
-# .hl.slc { color:#838183; font-style:italic; }
-# .hl.com { color:#838183; font-style:italic; }
-# .hl.ppc { color:#008200; }
-# .hl.opt { color:#000000; }
-# .hl.lin { color:#555555; }
-# .hl.kwa { color:#000000; font-weight:bold; }
-# .hl.kwb { color:#0057ae; }
-# .hl.kwc { color:#000000; font-weight:bold; }
-# .hl.kwd { color:#010181; }
-#
-#
-# Style definition file generated by highlight 3.13, http://www.andre-simon.de/
-#
-# body.hl { background-color:#e0eaee; }
-# pre.hl  { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New',monospace;}
-# .hl.num { color:#b07e00; }
-# .hl.esc { color:#ff00ff; }
-# .hl.str { color:#bf0303; }
-# .hl.pps { color:#818100; }
-# .hl.slc { color:#838183; font-style:italic; }
-# .hl.com { color:#838183; font-style:italic; }
-# .hl.ppc { color:#008200; }
-# .hl.opt { color:#000000; }
-# .hl.ipl { color:#0057ae; }
-# .hl.lin { color:#555555; }
-# .hl.kwa { color:#000000; font-weight:bold; }
-# .hl.kwb { color:#0057ae; }
-# .hl.kwc { color:#000000; font-weight:bold; }
-# .hl.kwd { color:#010181; }
+# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */
+# 	pre.hl  { color:#eeeeee; background-color:#111; }
+# 	.hl.num  { color:#ff814f; }
+# 	.hl.esc  { color:#f60; }
+# 	.hl.str  { color:#cc0; }
+# 	.hl.dstr { color:#ffff7e; }
+# 	.hl.slc  { color:#7f7c7f; }
+# 	.hl.com  { color:#7e7c7e; }
+# 	.hl.dir  { color:#7dff7d; }
+# 	.hl.sym  { color:#eeeeee; }
+# 	.hl.line { color:#aaaaaa; }
+# 	.hl.mark { background-color:#444400; }
+# 	.hl.kwa  { color:#bb0; }
+# 	.hl.kwb  { color:#a0a; }
+# 	.hl.kwc  { color:#eeeeee; }
+# 	.hl.kwd  { color:#7e7efe; }
+# }
+#
+#
+# Style definition file generated by highlight 3.8 / 3.13 / 3.41, http://www.andre-simon.de/
+#
+# table.blob .num { color:#b07e00; }
+# table.blob .esc { color:#ff00ff; }
+# table.blob .str { color:#bf0303; }
+# table.blob .pps { color:#818100; }
+# table.blob .slc { color:#838183; font-style:italic; }
+# table.blob .com { color:#838183; font-style:italic; }
+# table.blob .ppc { color:#008200; }
+# table.blob .opt { color:#000000; }
+# table.blob .ipl { color:#0057ae; }
+# table.blob .lin { color:#555555; }
+# table.blob .kwa { color:#000000; font-weight:bold; }
+# table.blob .kwb { color:#0057ae; }
+# table.blob .kwc { color:#000000; font-weight:bold; }
+# table.blob .kwd { color:#010181; }
+# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */
+# 	table.blob .num { color:#ff814f; }
+# 	table.blob .esc { color:#f60; }
+# 	table.blob .str { color:#cc0; }
+# 	table.blob .pps { color:#ffff7f; }
+# 	table.blob .slc { color:#7f7c7f; }
+# 	table.blob .com { color:#7e7c7e; }
+# 	table.blob .ppc { color:#8dd; }
+# 	table.blob .opt { color:#eeeeee; }
+# 	table.blob .ipl { color:#51a8ff; }
+# 	table.blob .lin { color:#aaaaaa; }
+# 	table.blob .kwa { color:#bb0; }
+# 	table.blob .kwb { color:#0a0; }
+# 	table.blob .kwc { color:#eeeeee; }
+# 	table.blob .kwd { color:#7e7efe; }
+# }
 #
 #
 # The following environment variables can be used to retrieve the configuration
-- 
2.30.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] css: Support for dark mode
  2023-01-22 11:35           ` [PATCH v3] " Samuel Lidén Borell
@ 2023-01-22 13:04             ` Samuel Lidén Borell
  2023-01-27 20:42             ` Jason A. Donenfeld
  1 sibling, 0 replies; 11+ messages in thread
From: Samuel Lidén Borell @ 2023-01-22 13:04 UTC (permalink / raw)
  To: cgit

On Sun, 22 Jan 2023 12:35:09 +0100, Samuel Lidén Borell <samuel@kodafritt.se> wrote:

> Modern browsers have a "dark mode" preference, which enables alternate
> styles on web sites that support this.
> 
> This patch adds a dark color scheme, that is automatically activated
> via a CSS @media query.
> 
> Older browsers that do not support color schemes will simply show the
> light scheme, but possibly without syntax highlighting.
> 
> Note that filters that use color (such as source highlighters) and
> logotypes may need to be updated to work with a black background!
> See the updated files in the filters/ directory.

Just a description of the changes from the previous version of the patch:

* Improved the dark color scheme
* Fixed white pixels around code blocks in markdown pages
* Fixed invisible text in formatters by wrapping even the light CSS in media queries. Unfortunately this disables highlighting on old browsers, which instead show black text.
* Fixed CSS for highlight 3
* Added "only all and" to the dark media query, so it gets ignored by (extremely) old browsers.

Tested on Firefox 102.7.0 ESR, Firefox 109, Chromium 109 and Netsurf 3.10. Netsurf is a browser that does not support color schemes, and defaults to the light theme. Firefox has a "resist fingerprinting" mode, in which it always uses the light theme.

Regards,
Samuel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] css: Support for dark mode
  2023-01-22 11:35           ` [PATCH v3] " Samuel Lidén Borell
  2023-01-22 13:04             ` Samuel Lidén Borell
@ 2023-01-27 20:42             ` Jason A. Donenfeld
  1 sibling, 0 replies; 11+ messages in thread
From: Jason A. Donenfeld @ 2023-01-27 20:42 UTC (permalink / raw)
  To: Samuel Lidén Borell; +Cc: cgit

It still feels like the table shading is now way too dark in dark
mode. For all those various grays, there might be some transformation
to consider where you want the same distance from black that it
formerly had from white.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-01-27 20:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-01 21:15 [PATCH] css: Optional support for dark mode Samuel Lidén Borell
2023-01-02  0:51 ` Jason A. Donenfeld
2023-01-01 21:15   ` [PATCH RESEND v2] css: Support " Samuel Lidén Borell
2023-01-11 20:54     ` Jason A. Donenfeld
2023-01-11 20:56       ` Jason A. Donenfeld
2023-01-12  0:33         ` Samuel Lidén Borell
2023-01-12  0:34           ` Jason A. Donenfeld
2023-01-12  0:33         ` Jason A. Donenfeld
2023-01-22 11:35           ` [PATCH v3] " Samuel Lidén Borell
2023-01-22 13:04             ` Samuel Lidén Borell
2023-01-27 20:42             ` Jason A. Donenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).