From 0fbcbf2340be4dac355740e7360e3587dd295b33 Mon Sep 17 00:00:00 2001 From: Georgia Stuart Date: Sun, 29 Jan 2023 14:14:27 -0600 Subject: [PATCH] Add dark mode (#24) Adds a dark mode option. Enable with `--dark-mode`. ![image](https://user-images.githubusercontent.com/8276147/215351169-d29dc7e0-ebdb-4e56-b897-02acb151d367.png) --------- Signed-off-by: Georgia Stuart --- .github/workflows/release.yml | 7 ++++--- .github/workflows/test.yml | 9 +++++---- README.md | 3 ++- src/generator.py | 10 +++++++--- src/input.css | 10 +++++++++- src/templates/annual_goals.html.j2 | 2 +- src/templates/annual_overview.html.j2 | 4 ++-- src/templates/daily.html.j2 | 22 +++++++++++----------- src/templates/frame.html.j2 | 2 +- src/templates/full_planner.html.j2 | 2 +- src/templates/journal_pages.html.j2 | 10 +++++----- src/templates/monthly.html.j2 | 10 +++++----- src/templates/monthly_goals.html.j2 | 2 +- src/templates/monthly_work_goals.html.j2 | 2 +- src/templates/snippets/journal_icons.html | 2 +- src/templates/weekly.html.j2 | 10 +++++----- src/templates/weekly_goals.html.j2 | 4 ++-- src/templates/weekly_work_goals.html.j2 | 4 ++-- tailwind.config.js | 3 +++ 19 files changed, 68 insertions(+), 50 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7dd0fa..5004978 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,6 +29,7 @@ jobs: - {arg: "--journals-per-page=1", suffix: "-full-pg-journal"} - {arg: "--journals-per-page=2", suffix: "-half-pg-journal"} - {arg: "--journals-per-page=4", suffix: "-quarter-pg-journal"} + dark-mode: [{arg: "--dark-mode", suffix: "-dark-mode"}, {arg: "--no-dark-mode", suffix: ""}] steps: - name: Checkout uses: actions/checkout@v3 @@ -47,12 +48,12 @@ jobs: - name: Install playwright browsers run: playwright install - name: Build planner pages - run: npm run build -- ${{ matrix.date-ranges.arg }} ${{ matrix.personal-goals.arg }} ${{ matrix.work-goals.arg }} ${{ matrix.daily-pages.arg }} ${{ matrix.weekly-pages.arg }} ${{ matrix.journal-pages.arg }} --file-suffix="-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}" + run: npm run build -- ${{ matrix.date-ranges.arg }} ${{ matrix.personal-goals.arg }} ${{ matrix.work-goals.arg }} ${{ matrix.daily-pages.arg }} ${{ matrix.weekly-pages.arg }} ${{ matrix.journal-pages.arg }} ${{ matrix.dark-mode.arg }} --file-suffix="-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}${{ matrix.dark-mode.suffix }}" - name: Upload planner pdf to artifacts uses: actions/upload-artifact@v3 with: - name: planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}.pdf - path: dest/planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}.pdf + name: planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}${{ matrix.dark-mode.suffix }}.pdf + path: dest/planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}${{ matrix.dark-mode.suffix }}.pdf deploy: needs: build runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8712757..82d15e4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: python-version: ["3.10"] - date-ranges: [{arg: "2022-11-01 2022-12-31", suffix: "2022-nov-dec"}] + date-ranges: [{arg: "2023-02-01 2023-02-28", suffix: "2023-feb"}] personal-goals: [{arg: "--personal-goals", suffix: ""}, {arg: "--no-personal-goals", suffix: "-no-personal-goals"}] work-goals: [{arg: "--work-goals", suffix: ""}, {arg: "--no-work-goals", suffix: "-no-work-goals"}] daily-pages: [{arg: "--daily-pages", suffix: ""}, {arg: "--no-daily-pages", suffix: "-no-daily"}] @@ -21,6 +21,7 @@ jobs: - {arg: "--journals-per-page=1", suffix: "-full-pg-journal"} - {arg: "--journals-per-page=2", suffix: "-half-pg-journal"} - {arg: "--journals-per-page=4", suffix: "-quarter-pg-journal"} + dark-mode: [{arg: "--dark-mode", suffix: "-dark-mode"}, {arg: "--no-dark-mode", suffix: ""}] steps: - name: Checkout uses: actions/checkout@v3 @@ -39,9 +40,9 @@ jobs: - name: Install playwright browsers run: playwright install - name: Build planner pages - run: npm run build -- ${{ matrix.date-ranges.arg }} ${{ matrix.personal-goals.arg }} ${{ matrix.work-goals.arg }} ${{ matrix.daily-pages.arg }} ${{ matrix.weekly-pages.arg }} ${{ matrix.journal-pages.arg }} --file-suffix="-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}" + run: npm run build -- ${{ matrix.date-ranges.arg }} ${{ matrix.personal-goals.arg }} ${{ matrix.work-goals.arg }} ${{ matrix.daily-pages.arg }} ${{ matrix.weekly-pages.arg }} ${{ matrix.journal-pages.arg }} ${{ matrix.dark-mode.arg }} --file-suffix="-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}${{ matrix.dark-mode.suffix }}" - name: Upload planner pdf to artifacts uses: actions/upload-artifact@v3 with: - name: planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}.pdf - path: dest/planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}.pdf + name: planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}${{ matrix.dark-mode.suffix }}.pdf + path: dest/planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}${{ matrix.dark-mode.suffix }}.pdf diff --git a/README.md b/README.md index 0bb925f..07ff2b5 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ technique, set margins to none and enable background images. ``` usage: Python Planner Generator [-h] [--start-time START_TIME] [--end-time END_TIME] [--file-suffix FILE_SUFFIX] [--work-goals | --no-work-goals] [--personal-goals | --no-personal-goals] - [--daily-pages | --no-daily-pages] [--weekly-pages | --no-weekly-pages] [--journals-per-page {0,1,2,4}] + [--daily-pages | --no-daily-pages] [--weekly-pages | --no-weekly-pages] [--journals-per-page {0,1,2,4}] [--dark-mode | --no-dark-mode] start end GoodNotes 5 Optimized PDF Planner @@ -111,4 +111,5 @@ options: --daily-pages, --no-daily-pages --weekly-pages, --no-weekly-pages --journals-per-page {0,1,2,4} + --dark-mode, --no-dark-mode ``` diff --git a/src/generator.py b/src/generator.py index cbc42e4..6eca78e 100644 --- a/src/generator.py +++ b/src/generator.py @@ -16,10 +16,13 @@ def generate_html(planner_html, out_file): with open(out_file, 'w') as fp: fp.write(planner_html) -def generate_pdf(html_file, css_file, out_file): +def generate_pdf(html_file, css_file, out_file, dark_mode: bool): with sync_playwright() as p: browser = p.chromium.launch() - page = browser.new_page() + if dark_mode: + page = browser.new_page(color_scheme='dark') + else: + page = browser.new_page(color_scheme='light') page.goto(f"file://{abspath(html_file)}") page.add_style_tag(path=abspath(css_file)) page.pdf(path=abspath(out_file), width='18.83in', height='11.77in', print_background=True) @@ -319,6 +322,7 @@ def build_journal_page(inp_date, j2_template: j2.Template): parser.add_argument('--daily-pages', action=BooleanOptionalAction, default=True) parser.add_argument('--weekly-pages', action=BooleanOptionalAction, default=True) parser.add_argument('--journals-per-page', default=0, type=int, choices=[0, 1, 2, 4]) + parser.add_argument('--dark-mode', action=BooleanOptionalAction, default=False) args = parser.parse_args() @@ -371,4 +375,4 @@ def build_journal_page(inp_date, j2_template: j2.Template): planner = build_planner(pages, env) generate_html(planner, f'./dest/index{args.file_suffix}.html') - generate_pdf(f'dest/index{args.file_suffix}.html', f'dest/main.css', f'dest/planner{args.file_suffix}.pdf') + generate_pdf(f'dest/index{args.file_suffix}.html', f'dest/main.css', f'dest/planner{args.file_suffix}.pdf', args.dark_mode) diff --git a/src/input.css b/src/input.css index 3d2dfc0..a366d4e 100644 --- a/src/input.css +++ b/src/input.css @@ -26,12 +26,16 @@ @apply font-playfair text-2xl h-5mm items-center text-center; } +.mini-cal-date-outside { + @apply mini-cal-date text-slate-300 dark:text-zinc-600; +} + .monthly-cal-day { @apply flex-grow flex font-bold font-playfair text-2xl h-10mm items-end justify-center text-center pb-2; } .monthly-cal-date { - @apply font-bold font-playfair text-2xl border-t border-l border-slate-800 pl-2 pb-2; + @apply font-bold font-playfair text-2xl border-t border-l border-slate-800 dark:border-zinc-400 pl-2 pb-2; } .monthly-cal .monthly-cal-date:nth-child(7n) { @@ -69,3 +73,7 @@ .reflection-header { @apply font-bold font-playfair text-4xl flex h-5mm items-center; } + +.lines { + @apply border-b border-slate-800 dark:border-zinc-400; +} diff --git a/src/templates/annual_goals.html.j2 b/src/templates/annual_goals.html.j2 index 9f974dc..055f271 100644 --- a/src/templates/annual_goals.html.j2 +++ b/src/templates/annual_goals.html.j2 @@ -5,7 +5,7 @@
{{ area[0].lower() }}
{% for i in range(10) %} -
+
{% endfor %}
{% endfor %} diff --git a/src/templates/annual_overview.html.j2 b/src/templates/annual_overview.html.j2 index 411d82b..5001a35 100644 --- a/src/templates/annual_overview.html.j2 +++ b/src/templates/annual_overview.html.j2 @@ -2,7 +2,7 @@
{{ year }}
{% for i in range(25) %} -
+
{% endfor %}
@@ -24,7 +24,7 @@ {% if cal_date[2] %} {% else %} - + {% endif %} {% endfor %}
diff --git a/src/templates/daily.html.j2 b/src/templates/daily.html.j2 index 913ceb4..9bbc603 100644 --- a/src/templates/daily.html.j2 +++ b/src/templates/daily.html.j2 @@ -1,4 +1,4 @@ -
+ {% for time in times %} -
{{ time }}
+
{{ time }}
{% if not loop.last %} -
+
{% endif %} {% endfor %}
@@ -22,7 +22,7 @@
highlight
{% for i in range(2) %} -
+
{% endfor %}
to do
@@ -31,8 +31,8 @@ {% for i in range(2) %}
{% for j in range(10) %} -
-
+
+
{% endfor %}
@@ -43,14 +43,14 @@
food
{% for i in range(7) %} -
+
{% endfor %}
learned today
{% for i in range(7) %} -
+
{% endfor %}
@@ -59,7 +59,7 @@
notes
{% for i in range(14 - ((mini_cal|length) // 7 % 5)) %} -
+
{% endfor %}
{{ date.strftime('%B').lower() }} @@ -75,12 +75,12 @@ {% for cal_date in mini_cal %} {% if cal_date[2] %} {% if cal_date[1] == date.strftime('%Y-%m-%d') %} - + {% else %} {% endif %} {% else %} - + {% endif %} {% endfor %}
diff --git a/src/templates/frame.html.j2 b/src/templates/frame.html.j2 index 2f0ab20..ff6c8e9 100644 --- a/src/templates/frame.html.j2 +++ b/src/templates/frame.html.j2 @@ -2,7 +2,7 @@
{{ content|safe }}
-
+
{% if journal_link %} {% endif %} diff --git a/src/templates/full_planner.html.j2 b/src/templates/full_planner.html.j2 index 4a0e015..983a089 100644 --- a/src/templates/full_planner.html.j2 +++ b/src/templates/full_planner.html.j2 @@ -11,7 +11,7 @@ - + {% for page in pages %} {{ page|safe }} {% endfor %} diff --git a/src/templates/journal_pages.html.j2 b/src/templates/journal_pages.html.j2 index 36d9eff..4aa235e 100644 --- a/src/templates/journal_pages.html.j2 +++ b/src/templates/journal_pages.html.j2 @@ -8,17 +8,17 @@ {{ days[0].strftime('W%-W').lower() }}
-
+
{% include "snippets/journal_icons.html" %}
{% for i in range(lines[journals_per_page]) %} -
+
{% endfor %}
{% for i in range(lines[journals_per_page] + 2) %} -
+
{% endfor %}
@@ -32,11 +32,11 @@ {{ day.strftime('W%-W').lower() }}
-
+
{% include "snippets/journal_icons.html" %}
{% for i in range(lines[journals_per_page]) %} -
+
{% endfor %}
{% endfor %} diff --git a/src/templates/monthly.html.j2 b/src/templates/monthly.html.j2 index 9c8e0be..6ffcd3c 100644 --- a/src/templates/monthly.html.j2 +++ b/src/templates/monthly.html.j2 @@ -4,7 +4,7 @@ {{ month.strftime('%b %Y').lower() }} {% for i in range(24) %} -
+
{% endfor %}
@@ -22,15 +22,15 @@
{{ cal_date[0] }}
{% if loop.index0 % 7 == 0 %} - + {% endif %}
{% else %} -
+
{{ cal_date[0] }}
{% if loop.index0 % 7 == 0 %} - + {% endif %}
{% endif %} @@ -38,7 +38,7 @@
{% if mini_cal|length // 7 < 6 %} {% for i in range(4) %} -
+
{% endfor %} {% endif %} diff --git a/src/templates/monthly_goals.html.j2 b/src/templates/monthly_goals.html.j2 index 4c86db3..5f3c319 100644 --- a/src/templates/monthly_goals.html.j2 +++ b/src/templates/monthly_goals.html.j2 @@ -5,7 +5,7 @@
{{ area[0].lower() }}
{% for i in range(10) %} -
+
{% endfor %}
{% endfor %} diff --git a/src/templates/monthly_work_goals.html.j2 b/src/templates/monthly_work_goals.html.j2 index f955f2b..52e8f76 100644 --- a/src/templates/monthly_work_goals.html.j2 +++ b/src/templates/monthly_work_goals.html.j2 @@ -1,6 +1,6 @@
{% for i in range(22) %} -
+
{% endfor %}
diff --git a/src/templates/snippets/journal_icons.html b/src/templates/snippets/journal_icons.html index 291772e..fd77896 100644 --- a/src/templates/snippets/journal_icons.html +++ b/src/templates/snippets/journal_icons.html @@ -1,5 +1,5 @@
-
+
diff --git a/src/templates/weekly.html.j2 b/src/templates/weekly.html.j2 index 2c9b8d5..4bc0504 100644 --- a/src/templates/weekly.html.j2 +++ b/src/templates/weekly.html.j2 @@ -3,15 +3,15 @@
{{ days[0].strftime('%Y W%-W') }}
{% for i in range(13) %} -
+
{% endfor %}
habits
{% for i in range(5) %} -
+
{% for day in ['m', 't', 'w', 't', 'f', 's', 's'] %}
-
{{ day }}
+
{{ day }}
{% endfor %}
@@ -21,9 +21,9 @@
{% for time in times %} -
{{ time }}
+
{{ time }}
{% if not loop.last %} -
+
{% endif %} {% endfor %}
diff --git a/src/templates/weekly_goals.html.j2 b/src/templates/weekly_goals.html.j2 index e891d30..15933cf 100644 --- a/src/templates/weekly_goals.html.j2 +++ b/src/templates/weekly_goals.html.j2 @@ -6,7 +6,7 @@
{{ area[0].lower() }}
{% for i in range(10) %} -
+
{% endfor %}
{% endfor %} @@ -15,7 +15,7 @@
reflections
{% for i in range(24) %} -
+
{% endfor %}
diff --git a/src/templates/weekly_work_goals.html.j2 b/src/templates/weekly_work_goals.html.j2 index af4ab47..17765b4 100644 --- a/src/templates/weekly_work_goals.html.j2 +++ b/src/templates/weekly_work_goals.html.j2 @@ -2,13 +2,13 @@
reflections
{% for i in range(25) %} -
+
{% endfor %}
diff --git a/tailwind.config.js b/tailwind.config.js index 6f0d0e5..e24ccb3 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -23,6 +23,9 @@ module.exports = { }, spacing: { '5mm': '10.4167mm' + }, + colors: { + 'dark': '#333333' } }, },