From df7c597a8bae0fd922786a1dc3eb33c31bf333e6 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 13 Apr 2021 14:25:34 +0200 Subject: [PATCH 01/11] Add option not include default css in stdHtml --- qt/aqt/webview.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index 484a76622..e9421d4f3 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -456,13 +456,14 @@ body {{ zoom: {zoom}; background: {background}; direction: {lang_dir}; {font} }} js: Optional[List[str]] = None, head: str = "", context: Optional[Any] = None, + default_css = True, ) -> None: web_content = WebContent( body=body, head=head, js=["js/webview.js"] + (["js/vendor/jquery.min.js"] if js is None else js), - css=["css/webview.css"] + ([] if css is None else css), + css=(["css/webview.css"] if default_css else []) + ([] if css is None else css), ) gui_hooks.webview_will_set_content(web_content, context) From fbc21f0090d2587011fa01974ef15de970667f3a Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 13 Apr 2021 14:30:47 +0200 Subject: [PATCH 02/11] Add base.scss --- ts/sass/_base.scss | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ts/sass/_base.scss diff --git a/ts/sass/_base.scss b/ts/sass/_base.scss new file mode 100644 index 000000000..226db3e55 --- /dev/null +++ b/ts/sass/_base.scss @@ -0,0 +1,15 @@ +@use 'vars'; + +$body-color: var(--text-fg); +$body-bg: var(--window-bg); +$font-weight-base: 500; + +$link-hover-color: var(--link); +$link-hover-decoration: none; + +@import 'ts/node_modules/bootstrap/scss/bootstrap-reboot'; +@import 'ts/node_modules/bootstrap/scss/bootstrap-utilities'; + +body { + overscroll-behavior: none; +} From 825509ba0ca4a9c65daed42257c36f7a6d37a56c Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 13 Apr 2021 16:01:41 +0200 Subject: [PATCH 03/11] Move card_counts and split off fusion_vars --- qt/aqt/data/web/css/_card_counts.scss | 34 ------------- qt/aqt/data/web/css/deckbrowser.scss | 4 +- qt/aqt/data/web/css/overview.scss | 2 +- qt/aqt/data/web/css/reviewer-bottom.scss | 2 +- ts/sass/_buttons.scss | 18 +++---- ts/sass/_card_counts.scss | 15 ++++++ ts/sass/_fusion_vars.scss | 7 +++ ts/sass/buttons.scss | 65 ++++++++++++++++++++++++ ts/sass/card_counts.scss | 15 ++++++ ts/sass/scrollbar.scss | 4 +- 10 files changed, 114 insertions(+), 52 deletions(-) delete mode 100644 qt/aqt/data/web/css/_card_counts.scss create mode 100644 ts/sass/_card_counts.scss create mode 100644 ts/sass/_fusion_vars.scss create mode 100644 ts/sass/buttons.scss create mode 100644 ts/sass/card_counts.scss diff --git a/qt/aqt/data/web/css/_card_counts.scss b/qt/aqt/data/web/css/_card_counts.scss deleted file mode 100644 index 2c26a1b4f..000000000 --- a/qt/aqt/data/web/css/_card_counts.scss +++ /dev/null @@ -1,34 +0,0 @@ -.review-count { - color: var(--review-count); -} - -.new-count { - color: var(--new-count); -} - -.learn-count { - color: var(--learn-count); -} - -.zero-count { - color: var(--zero-count); -} - -.nightMode { - .review-count { - color: var(--review-count); - } - - .new-count { - color: var(--new-count); - } - - .learn-count { - color: var(--learn-count); - } - - .zero-count { - color: var(--zero-count); - } -} - diff --git a/qt/aqt/data/web/css/deckbrowser.scss b/qt/aqt/data/web/css/deckbrowser.scss index e425978db..21d7d54b7 100644 --- a/qt/aqt/data/web/css/deckbrowser.scss +++ b/qt/aqt/data/web/css/deckbrowser.scss @@ -1,7 +1,7 @@ /* Copyright: Ankitects Pty Ltd and contributors * License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */ -@use 'card_counts'; +@use 'ts/sass/card_counts'; a.deck { color: var(--text-fg); @@ -84,4 +84,4 @@ body { div { margin: 1em; } -} \ No newline at end of file +} diff --git a/qt/aqt/data/web/css/overview.scss b/qt/aqt/data/web/css/overview.scss index 688d84d6e..7b9c4587e 100644 --- a/qt/aqt/data/web/css/overview.scss +++ b/qt/aqt/data/web/css/overview.scss @@ -1,7 +1,7 @@ /* Copyright: Ankitects Pty Ltd and contributors * License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */ -@use 'card_counts'; +@use 'ts/sass/card_counts'; .smallLink { font-size: 10px; diff --git a/qt/aqt/data/web/css/reviewer-bottom.scss b/qt/aqt/data/web/css/reviewer-bottom.scss index d9fa6c4ee..5f1ac2684 100644 --- a/qt/aqt/data/web/css/reviewer-bottom.scss +++ b/qt/aqt/data/web/css/reviewer-bottom.scss @@ -1,7 +1,7 @@ /* Copyright: Ankitects Pty Ltd and contributors * License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */ -@use 'card_counts'; +@use 'ts/sass/card_counts'; body { margin: 0; diff --git a/ts/sass/_buttons.scss b/ts/sass/_buttons.scss index d0a96de75..bddc3baff 100644 --- a/ts/sass/_buttons.scss +++ b/ts/sass/_buttons.scss @@ -1,10 +1,4 @@ -/* night-mode-specific colours */ -$fusion-button-gradient-start: #555555; -$fusion-button-gradient-end: #656565; -$fusion-button-outline: #222222; -$fusion-button-hover-bg: #656565; -$fusion-button-border: #646464; -$fusion-button-base-bg: #454545; +@use 'fusion_vars'; .isWin { button { @@ -37,11 +31,11 @@ $fusion-button-base-bg: #454545; /* match the fusion button gradient */ background: linear-gradient( 0deg, - $fusion-button-gradient-start 0%, - $fusion-button-gradient-end 100% + fusion_vars.$button-gradient-start 0%, + fusion_vars.$button-gradient-end 100% ); - box-shadow: 0 0 3px $fusion-button-outline; - border: 1px solid $fusion-button-border; + box-shadow: 0 0 3px fusion_vars.$button-outline; + border: 1px solid fusion_vars.$button-border; border-radius: 2px; padding: 10px; @@ -50,7 +44,7 @@ $fusion-button-base-bg: #454545; } button:hover { - background: $fusion-button-hover-bg; + background: fusion_vars.$button-hover-bg; } } diff --git a/ts/sass/_card_counts.scss b/ts/sass/_card_counts.scss new file mode 100644 index 000000000..93296e3e1 --- /dev/null +++ b/ts/sass/_card_counts.scss @@ -0,0 +1,15 @@ +.review-count { + color: var(--review-count); +} + +.new-count { + color: var(--new-count); +} + +.learn-count { + color: var(--learn-count); +} + +.zero-count { + color: var(--zero-count); +} diff --git a/ts/sass/_fusion_vars.scss b/ts/sass/_fusion_vars.scss new file mode 100644 index 000000000..559d0a23b --- /dev/null +++ b/ts/sass/_fusion_vars.scss @@ -0,0 +1,7 @@ +/* night-mode-specific colours */ +$fusion-button-gradient-start: #555555; +$fusion-button-gradient-end: #656565; +$fusion-button-outline: #222222; +$fusion-button-hover-bg: #656565; +$fusion-button-border: #646464; +$fusion-button-base-bg: #454545; diff --git a/ts/sass/buttons.scss b/ts/sass/buttons.scss new file mode 100644 index 000000000..bddc3baff --- /dev/null +++ b/ts/sass/buttons.scss @@ -0,0 +1,65 @@ +@use 'fusion_vars'; + +.isWin { + button { + font-size: 12px; + } +} + +.isMac { + button { + font-size: 13px; + } +} + +.isLin { + button { + font-size: 14px; + + -webkit-appearance: none; + border-radius: 3px; + padding: 5px; + border: 1px solid var(--border); + } +} + +.nightMode { + button { + -webkit-appearance: none; + color: var(--text-fg); + + /* match the fusion button gradient */ + background: linear-gradient( + 0deg, + fusion_vars.$button-gradient-start 0%, + fusion_vars.$button-gradient-end 100% + ); + box-shadow: 0 0 3px fusion_vars.$button-outline; + border: 1px solid fusion_vars.$button-border; + + border-radius: 2px; + padding: 10px; + padding-top: 3px; + padding-bottom: 3px; + } + + button:hover { + background: fusion_vars.$button-hover-bg; + } +} + +/* imitate standard macOS dark mode buttons */ +.isMac.nightMode.macos-dark-mode button:not(.linkb) { + background: #656565; + box-shadow: 0 1px 2px #222222; + border-top-color: #848484; + border-top-width: 0.5px; + border-bottom: 0; + border-left: 0; + border-right: 0; + padding-top: 2px; + padding-bottom: 2px; + padding-left: 15px; + padding-right: 15px; + color: #e5e5e5; +} diff --git a/ts/sass/card_counts.scss b/ts/sass/card_counts.scss new file mode 100644 index 000000000..93296e3e1 --- /dev/null +++ b/ts/sass/card_counts.scss @@ -0,0 +1,15 @@ +.review-count { + color: var(--review-count); +} + +.new-count { + color: var(--new-count); +} + +.learn-count { + color: var(--learn-count); +} + +.zero-count { + color: var(--zero-count); +} diff --git a/ts/sass/scrollbar.scss b/ts/sass/scrollbar.scss index 714d19b03..5b0bc321c 100644 --- a/ts/sass/scrollbar.scss +++ b/ts/sass/scrollbar.scss @@ -2,7 +2,7 @@ * License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */ @use 'vars'; -@use 'buttons'; +@use 'fusion_vars'; @mixin night-mode { &::-webkit-scrollbar { @@ -18,7 +18,7 @@ } &::-webkit-scrollbar-thumb { - background: buttons.$fusion-button-hover-bg; + background: fusion_vars.$button-hover-bg; border-radius: 8px; &:horizontal { From fee6ee7319af4e123eb386671dcd9ce90b990b80 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 13 Apr 2021 16:15:40 +0200 Subject: [PATCH 04/11] Do not include webview.css for editor --- qt/aqt/editor.py | 3 +- ts/editor/editor.scss | 9 ++++-- ts/sass/_buttons.scss | 65 --------------------------------------- ts/sass/_card_counts.scss | 15 --------- ts/sass/_fusion_vars.scss | 12 ++++---- 5 files changed, 13 insertions(+), 91 deletions(-) delete mode 100644 ts/sass/_buttons.scss delete mode 100644 ts/sass/_card_counts.scss diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index 08539a8e3..e6db3b05f 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -232,15 +232,14 @@ class Editor: self.web.stdHtml( _html % (bgcol, topbuts, tr.editing_show_duplicates()), css=[ - "css/vendor/bootstrap.min.css", "css/editor.css", ], js=[ "js/vendor/jquery.min.js", - "js/vendor/bootstrap.bundle.min.js", "js/editor.js", ], context=self, + default_css=False, ) self.web.eval("preventButtonFocus();") diff --git a/ts/editor/editor.scss b/ts/editor/editor.scss index 3e16a0392..a23c4bbfe 100644 --- a/ts/editor/editor.scss +++ b/ts/editor/editor.scss @@ -1,9 +1,12 @@ /* Copyright: Ankitects Pty Ltd and contributors * License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */ -body { - color: var(--text-fg); - background-color: var(--bg-color); +@use 'ts/sass/base'; +@use 'ts/sass/buttons'; +@use 'ts/sass/scrollbar'; + +.nightMode { + @include scrollbar.night-mode; } #fields { diff --git a/ts/sass/_buttons.scss b/ts/sass/_buttons.scss deleted file mode 100644 index bddc3baff..000000000 --- a/ts/sass/_buttons.scss +++ /dev/null @@ -1,65 +0,0 @@ -@use 'fusion_vars'; - -.isWin { - button { - font-size: 12px; - } -} - -.isMac { - button { - font-size: 13px; - } -} - -.isLin { - button { - font-size: 14px; - - -webkit-appearance: none; - border-radius: 3px; - padding: 5px; - border: 1px solid var(--border); - } -} - -.nightMode { - button { - -webkit-appearance: none; - color: var(--text-fg); - - /* match the fusion button gradient */ - background: linear-gradient( - 0deg, - fusion_vars.$button-gradient-start 0%, - fusion_vars.$button-gradient-end 100% - ); - box-shadow: 0 0 3px fusion_vars.$button-outline; - border: 1px solid fusion_vars.$button-border; - - border-radius: 2px; - padding: 10px; - padding-top: 3px; - padding-bottom: 3px; - } - - button:hover { - background: fusion_vars.$button-hover-bg; - } -} - -/* imitate standard macOS dark mode buttons */ -.isMac.nightMode.macos-dark-mode button:not(.linkb) { - background: #656565; - box-shadow: 0 1px 2px #222222; - border-top-color: #848484; - border-top-width: 0.5px; - border-bottom: 0; - border-left: 0; - border-right: 0; - padding-top: 2px; - padding-bottom: 2px; - padding-left: 15px; - padding-right: 15px; - color: #e5e5e5; -} diff --git a/ts/sass/_card_counts.scss b/ts/sass/_card_counts.scss deleted file mode 100644 index 93296e3e1..000000000 --- a/ts/sass/_card_counts.scss +++ /dev/null @@ -1,15 +0,0 @@ -.review-count { - color: var(--review-count); -} - -.new-count { - color: var(--new-count); -} - -.learn-count { - color: var(--learn-count); -} - -.zero-count { - color: var(--zero-count); -} diff --git a/ts/sass/_fusion_vars.scss b/ts/sass/_fusion_vars.scss index 559d0a23b..9b91fb531 100644 --- a/ts/sass/_fusion_vars.scss +++ b/ts/sass/_fusion_vars.scss @@ -1,7 +1,7 @@ /* night-mode-specific colours */ -$fusion-button-gradient-start: #555555; -$fusion-button-gradient-end: #656565; -$fusion-button-outline: #222222; -$fusion-button-hover-bg: #656565; -$fusion-button-border: #646464; -$fusion-button-base-bg: #454545; +$button-gradient-start: #555555; +$button-gradient-end: #656565; +$button-outline: #222222; +$button-hover-bg: #656565; +$button-border: #646464; +$button-base-bg: #454545; From 8f0f8f9af8db2d9f85b499da828b9ab7ade5cf5d Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 13 Apr 2021 16:49:47 +0200 Subject: [PATCH 05/11] Use graphs-base and congrats-base --- qt/aqt/data/web/css/BUILD.bazel | 1 - qt/aqt/data/web/css/vendor/BUILD.bazel | 17 ----------------- qt/aqt/data/web/pages/BUILD.bazel | 2 ++ ts/congrats/BUILD.bazel | 15 ++++++++++++--- ts/congrats/CongratsPage.svelte | 2 -- ts/congrats/congrats-base.scss | 6 ++++++ ts/congrats/congrats.html | 1 + ts/graphs/BUILD.bazel | 9 ++++++++- ts/graphs/GraphsPage.svelte | 2 -- ts/graphs/graphs-base.scss | 6 ++++++ ts/graphs/graphs.html | 1 + ts/sass/_base.scss | 4 ++-- ts/sass/card_counts.scss | 8 ++++---- 13 files changed, 42 insertions(+), 32 deletions(-) delete mode 100644 qt/aqt/data/web/css/vendor/BUILD.bazel create mode 100644 ts/congrats/congrats-base.scss create mode 100644 ts/graphs/graphs-base.scss diff --git a/qt/aqt/data/web/css/BUILD.bazel b/qt/aqt/data/web/css/BUILD.bazel index f27b9d463..ff0045e68 100644 --- a/qt/aqt/data/web/css/BUILD.bazel +++ b/qt/aqt/data/web/css/BUILD.bazel @@ -32,7 +32,6 @@ filegroup( "core.css", "css_local", "editor", - "//qt/aqt/data/web/css/vendor", ], visibility = ["//qt:__subpackages__"], ) diff --git a/qt/aqt/data/web/css/vendor/BUILD.bazel b/qt/aqt/data/web/css/vendor/BUILD.bazel deleted file mode 100644 index 591f16a5c..000000000 --- a/qt/aqt/data/web/css/vendor/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("//ts:vendor.bzl", "copy_bootstrap_css") - -copy_bootstrap_css(name = "bootstrap") - -files = [ - "bootstrap", -] - -directories = [] - -filegroup( - name = "vendor", - srcs = glob(["*.css"]) + - ["//qt/aqt/data/web/css/vendor:{}".format(file) for file in files] + - ["//qt/aqt/data/web/css/vendor/{}".format(dir) for dir in directories], - visibility = ["//qt:__subpackages__"], -) diff --git a/qt/aqt/data/web/pages/BUILD.bazel b/qt/aqt/data/web/pages/BUILD.bazel index 0140a7e8f..cf5066349 100644 --- a/qt/aqt/data/web/pages/BUILD.bazel +++ b/qt/aqt/data/web/pages/BUILD.bazel @@ -3,6 +3,7 @@ load("//ts:copy.bzl", "copy_files_into_group") copy_files_into_group( name = "graphs_page", srcs = [ + "graphs-base.css", "graphs.css", "graphs.html", "graphs.js", @@ -13,6 +14,7 @@ copy_files_into_group( copy_files_into_group( name = "congrats_page", srcs = [ + "congrats-base.css", "congrats.css", "congrats.html", "congrats.js", diff --git a/ts/congrats/BUILD.bazel b/ts/congrats/BUILD.bazel index cf72428fe..a5f27dbd8 100644 --- a/ts/congrats/BUILD.bazel +++ b/ts/congrats/BUILD.bazel @@ -3,12 +3,20 @@ load("//ts:prettier.bzl", "prettier_test") load("//ts:eslint.bzl", "eslint_test") load("//ts/svelte:svelte.bzl", "svelte", "svelte_check") load("//ts:esbuild.bzl", "esbuild") +load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") + +sass_binary( + name = "base_css", + src = "congrats-base.scss", + visibility = ["//visibility:public"], +) svelte( name = "CongratsPage", entry_point = "CongratsPage.svelte", ) + ts_library( name = "index", srcs = ["index.ts"], @@ -16,6 +24,7 @@ ts_library( "CongratsPage", "lib", "//ts/lib", + "@npm//svelte", "@npm//svelte2tsx", ], ) @@ -47,11 +56,11 @@ esbuild( output_css = True, visibility = ["//visibility:public"], deps = [ - "CongratsPage", - "index", "//ts/lib", "//ts/lib:backend_proto", - "//ts/sass:core_css", + "CongratsPage", + ":index", + ":base_css", ], ) diff --git a/ts/congrats/CongratsPage.svelte b/ts/congrats/CongratsPage.svelte index 4f7e01c9e..5367bb64b 100644 --- a/ts/congrats/CongratsPage.svelte +++ b/ts/congrats/CongratsPage.svelte @@ -3,8 +3,6 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> diff --git a/ts/graphs/BUILD.bazel b/ts/graphs/BUILD.bazel index aa2aea72a..2d34efbe0 100644 --- a/ts/graphs/BUILD.bazel +++ b/ts/graphs/BUILD.bazel @@ -3,6 +3,13 @@ load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte_check") load("//ts:prettier.bzl", "prettier_test") load("//ts:eslint.bzl", "eslint_test") load("//ts:esbuild.bzl", "esbuild") +load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") + +sass_binary( + name = "base_css", + src = "graphs-base.scss", + visibility = ["//visibility:public"], +) svelte_files = glob(["*.svelte"]) @@ -67,7 +74,7 @@ esbuild( "//ts/lib", "//ts/lib:backend_proto", ":index", - "//ts/sass:core_css", + ":base_css", ] + svelte_names, ) diff --git a/ts/graphs/GraphsPage.svelte b/ts/graphs/GraphsPage.svelte index 18ba6fa0e..9df8d38ad 100644 --- a/ts/graphs/GraphsPage.svelte +++ b/ts/graphs/GraphsPage.svelte @@ -3,8 +3,6 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> diff --git a/ts/sass/_base.scss b/ts/sass/_base.scss index 226db3e55..0bf9582d5 100644 --- a/ts/sass/_base.scss +++ b/ts/sass/_base.scss @@ -7,8 +7,8 @@ $font-weight-base: 500; $link-hover-color: var(--link); $link-hover-decoration: none; -@import 'ts/node_modules/bootstrap/scss/bootstrap-reboot'; -@import 'ts/node_modules/bootstrap/scss/bootstrap-utilities'; +@import "ts/node_modules/bootstrap/scss/bootstrap-reboot"; +@import "ts/node_modules/bootstrap/scss/bootstrap-utilities"; body { overscroll-behavior: none; diff --git a/ts/sass/card_counts.scss b/ts/sass/card_counts.scss index 93296e3e1..86bb2a520 100644 --- a/ts/sass/card_counts.scss +++ b/ts/sass/card_counts.scss @@ -1,15 +1,15 @@ .review-count { - color: var(--review-count); + color: var(--review-count); } .new-count { - color: var(--new-count); + color: var(--new-count); } .learn-count { - color: var(--learn-count); + color: var(--learn-count); } .zero-count { - color: var(--zero-count); + color: var(--zero-count); } From 85808e4cbfc296c32f5c75677faa3517afd40502 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 13 Apr 2021 16:56:53 +0200 Subject: [PATCH 06/11] Make h1 explicitly bold in Graph.svelte --- ts/graphs/Graph.svelte | 1 + ts/sass/_base.scss | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/graphs/Graph.svelte b/ts/graphs/Graph.svelte index bc7b285a9..e987a1b97 100644 --- a/ts/graphs/Graph.svelte +++ b/ts/graphs/Graph.svelte @@ -57,6 +57,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html text-align: center; margin-bottom: 0.25em; margin-top: 1.5em; + font-weight: bold; } .subtitle { diff --git a/ts/sass/_base.scss b/ts/sass/_base.scss index 0bf9582d5..9bfada916 100644 --- a/ts/sass/_base.scss +++ b/ts/sass/_base.scss @@ -2,7 +2,6 @@ $body-color: var(--text-fg); $body-bg: var(--window-bg); -$font-weight-base: 500; $link-hover-color: var(--link); $link-hover-decoration: none; From ffd159f9a059a54aec1c31e1967e4c17c3de6909 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 13 Apr 2021 17:19:19 +0200 Subject: [PATCH 07/11] Declare dependencies in data/web/css --- qt/aqt/data/web/css/BUILD.bazel | 6 ++++++ qt/aqt/data/web/css/compile_sass.bzl | 4 ++-- ts/sass/BUILD.bazel | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/qt/aqt/data/web/css/BUILD.bazel b/qt/aqt/data/web/css/BUILD.bazel index ff0045e68..b2772e3d2 100644 --- a/qt/aqt/data/web/css/BUILD.bazel +++ b/qt/aqt/data/web/css/BUILD.bazel @@ -8,6 +8,12 @@ compile_sass( exclude = ["_*.scss"], ), group = "css_local", + deps = [ + "//ts/sass:core_lib", + "//ts/sass:buttons_lib", + "//ts/sass:scrollbar_lib", + "//ts/sass:card_counts_lib", + ], visibility = ["//visibility:private"], ) diff --git a/qt/aqt/data/web/css/compile_sass.bzl b/qt/aqt/data/web/css/compile_sass.bzl index f6c731cb5..b4835f532 100644 --- a/qt/aqt/data/web/css/compile_sass.bzl +++ b/qt/aqt/data/web/css/compile_sass.bzl @@ -1,6 +1,6 @@ load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") -def compile_sass(group, srcs, visibility): +def compile_sass(group, srcs, visibility, deps): css_files = [] for scss_file in srcs: base = scss_file.replace(".scss", "") @@ -12,7 +12,7 @@ def compile_sass(group, srcs, visibility): name = name, src = scss_file, sourcemap = False, - deps = ["//ts/sass:core_lib"], + deps = deps, ) native.filegroup( diff --git a/ts/sass/BUILD.bazel b/ts/sass/BUILD.bazel index 5c2484788..fdbc177ad 100644 --- a/ts/sass/BUILD.bazel +++ b/ts/sass/BUILD.bazel @@ -9,6 +9,24 @@ sass_binary( ], ) +sass_library( + name = "buttons_lib", + srcs = [ + "_fusion_vars.scss", + "buttons.scss", + ], + visibility = ["//visibility:public"], +) + + +sass_library( + name = "card_counts_lib", + srcs = [ + "card_counts.scss", + ], + visibility = ["//visibility:public"], +) + sass_library( name = "core_lib", srcs = [ @@ -18,6 +36,14 @@ sass_library( visibility = ["//visibility:public"], ) +sass_library( + name = "scrollbar_lib", + srcs = [ + "scrollbar.scss", + ], + visibility = ["//visibility:public"], +) + # qt package extracts colours from source file exports_files( ["_vars.scss"], From a76f1d64ad8cbb04b523c34ae93bef2958552a07 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 13 Apr 2021 17:24:06 +0200 Subject: [PATCH 08/11] Move compile_sass.bzl to /ts + Remove core.css from data/web (unused?) --- qt/aqt/data/web/css/BUILD.bazel | 9 +-------- {qt/aqt/data/web/css => ts}/compile_sass.bzl | 0 ts/sass/BUILD.bazel | 12 +----------- 3 files changed, 2 insertions(+), 19 deletions(-) rename {qt/aqt/data/web/css => ts}/compile_sass.bzl (100%) diff --git a/qt/aqt/data/web/css/BUILD.bazel b/qt/aqt/data/web/css/BUILD.bazel index b2772e3d2..e29acf7ed 100644 --- a/qt/aqt/data/web/css/BUILD.bazel +++ b/qt/aqt/data/web/css/BUILD.bazel @@ -1,6 +1,6 @@ load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load("//ts:copy.bzl", "copy_files_into_group") -load("compile_sass.bzl", "compile_sass") +load("//ts:compile_sass.bzl", "compile_sass") compile_sass( srcs = glob( @@ -17,12 +17,6 @@ compile_sass( visibility = ["//visibility:private"], ) -copy_file( - name = "core_css", - src = "//ts/sass:core.css", - out = "core.css", -) - copy_files_into_group( name = "editor", srcs = [ @@ -35,7 +29,6 @@ copy_files_into_group( filegroup( name = "css", srcs = [ - "core.css", "css_local", "editor", ], diff --git a/qt/aqt/data/web/css/compile_sass.bzl b/ts/compile_sass.bzl similarity index 100% rename from qt/aqt/data/web/css/compile_sass.bzl rename to ts/compile_sass.bzl diff --git a/ts/sass/BUILD.bazel b/ts/sass/BUILD.bazel index fdbc177ad..0564eb324 100644 --- a/ts/sass/BUILD.bazel +++ b/ts/sass/BUILD.bazel @@ -1,13 +1,4 @@ -load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library") - -sass_binary( - name = "core_css", - src = "core.scss", - visibility = ["//visibility:public"], - deps = [ - ":core_lib", - ], -) +load("@io_bazel_rules_sass//:defs.bzl", "sass_library") sass_library( name = "buttons_lib", @@ -18,7 +9,6 @@ sass_library( visibility = ["//visibility:public"], ) - sass_library( name = "card_counts_lib", srcs = [ From cfb9ed267fd097fdaa3f9ff23173dfa6d707d077 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 13 Apr 2021 18:17:32 +0200 Subject: [PATCH 09/11] Create explicit dependencies for the congrats,editor,graphs scss files --- ts/compile_sass.bzl | 1 + ts/congrats/BUILD.bazel | 12 ++++++++---- ts/editor/BUILD.bazel | 24 ++++++++++++------------ ts/editor/editable.scss | 2 +- ts/graphs/BUILD.bazel | 12 ++++++++---- ts/sass/BUILD.bazel | 13 +++++++++++-- ts/sass/{_base.scss => base.scss} | 0 7 files changed, 41 insertions(+), 23 deletions(-) rename ts/sass/{_base.scss => base.scss} (100%) diff --git a/ts/compile_sass.bzl b/ts/compile_sass.bzl index b4835f532..642b53714 100644 --- a/ts/compile_sass.bzl +++ b/ts/compile_sass.bzl @@ -13,6 +13,7 @@ def compile_sass(group, srcs, visibility, deps): src = scss_file, sourcemap = False, deps = deps, + visibility = visibility, ) native.filegroup( diff --git a/ts/congrats/BUILD.bazel b/ts/congrats/BUILD.bazel index a5f27dbd8..8e41624f2 100644 --- a/ts/congrats/BUILD.bazel +++ b/ts/congrats/BUILD.bazel @@ -3,11 +3,15 @@ load("//ts:prettier.bzl", "prettier_test") load("//ts:eslint.bzl", "eslint_test") load("//ts/svelte:svelte.bzl", "svelte", "svelte_check") load("//ts:esbuild.bzl", "esbuild") -load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") +load("//ts:compile_sass.bzl", "compile_sass") -sass_binary( - name = "base_css", - src = "congrats-base.scss", +compile_sass( + group = "base_css", + srcs = ["congrats-base.scss"], + deps = [ + "//ts/sass:base_lib", + "//ts/sass:scrollbar_lib", + ], visibility = ["//visibility:public"], ) diff --git a/ts/editor/BUILD.bazel b/ts/editor/BUILD.bazel index f2a6d6b0a..9b4253a8b 100644 --- a/ts/editor/BUILD.bazel +++ b/ts/editor/BUILD.bazel @@ -3,17 +3,16 @@ load("//ts:prettier.bzl", "prettier_test") load("//ts:eslint.bzl", "eslint_test") load("//ts:esbuild.bzl", "esbuild") load("//ts:vendor.bzl", "copy_bootstrap_icons") -load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") +load("//ts:compile_sass.bzl", "compile_sass") -sass_binary( - name = "editor_css", - src = "editor.scss", - visibility = ["//visibility:public"], -) - -sass_binary( - name = "editable_css", - src = "editable.scss", +compile_sass( + group = "base_css", + srcs = ["editor.scss", "editable.scss"], + deps = [ + "//ts/sass:base_lib", + "//ts/sass:buttons_lib", + "//ts/sass:scrollbar_lib", + ], visibility = ["//visibility:public"], ) @@ -42,8 +41,9 @@ esbuild( entry_point = "index_wrapper.ts", visibility = ["//visibility:public"], deps = [ - "bootstrap-icons", - "editor_ts", + ":bootstrap-icons", + ":editor_ts", + "base_css", ], ) diff --git a/ts/editor/editable.scss b/ts/editor/editable.scss index f819b8fb3..9cd7186f3 100644 --- a/ts/editor/editable.scss +++ b/ts/editor/editable.scss @@ -1,4 +1,4 @@ -@use '../sass/scrollbar'; +@use 'ts/sass/scrollbar'; anki-editable { display: block; diff --git a/ts/graphs/BUILD.bazel b/ts/graphs/BUILD.bazel index 2d34efbe0..05775e211 100644 --- a/ts/graphs/BUILD.bazel +++ b/ts/graphs/BUILD.bazel @@ -3,11 +3,15 @@ load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte_check") load("//ts:prettier.bzl", "prettier_test") load("//ts:eslint.bzl", "eslint_test") load("//ts:esbuild.bzl", "esbuild") -load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") +load("//ts:compile_sass.bzl", "compile_sass") -sass_binary( - name = "base_css", - src = "graphs-base.scss", +compile_sass( + group = "base_css", + srcs = ["graphs-base.scss"], + deps = [ + "//ts/sass:base_lib", + "//ts/sass:scrollbar_lib", + ], visibility = ["//visibility:public"], ) diff --git a/ts/sass/BUILD.bazel b/ts/sass/BUILD.bazel index 0564eb324..ea0f4c633 100644 --- a/ts/sass/BUILD.bazel +++ b/ts/sass/BUILD.bazel @@ -1,5 +1,14 @@ load("@io_bazel_rules_sass//:defs.bzl", "sass_library") +sass_library( + name = "base_lib", + srcs = [ + "_vars.scss", + "base.scss", + ], + visibility = ["//visibility:public"], +) + sass_library( name = "buttons_lib", srcs = [ @@ -36,6 +45,6 @@ sass_library( # qt package extracts colours from source file exports_files( - ["_vars.scss"], - visibility = ["//qt:__subpackages__"], + ["_vars.scss"] + glob(["*.scss"], exclude = ["_*.scss"]), + visibility = ["//qt:__subpackages__", "//ts:__subpackages__"], ) diff --git a/ts/sass/_base.scss b/ts/sass/base.scss similarity index 100% rename from ts/sass/_base.scss rename to ts/sass/base.scss From 191e3cf69b7356b0e8cb186f6da439ca3446d31c Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 13 Apr 2021 18:24:21 +0200 Subject: [PATCH 10/11] Satisfy formatter --- qt/aqt/webview.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index e9421d4f3..2ff300d5f 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -456,14 +456,15 @@ body {{ zoom: {zoom}; background: {background}; direction: {lang_dir}; {font} }} js: Optional[List[str]] = None, head: str = "", context: Optional[Any] = None, - default_css = True, + default_css=True, ) -> None: web_content = WebContent( body=body, head=head, js=["js/webview.js"] + (["js/vendor/jquery.min.js"] if js is None else js), - css=(["css/webview.css"] if default_css else []) + ([] if css is None else css), + css=(["css/webview.css"] if default_css else []) + + ([] if css is None else css), ) gui_hooks.webview_will_set_content(web_content, context) From e530b969986d95d2e363df9be007c4dddfb1a691 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 14 Apr 2021 11:28:40 +1000 Subject: [PATCH 11/11] add missing type annotation --- qt/aqt/webview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index 2ff300d5f..e9a3d1b17 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -456,7 +456,7 @@ body {{ zoom: {zoom}; background: {background}; direction: {lang_dir}; {font} }} js: Optional[List[str]] = None, head: str = "", context: Optional[Any] = None, - default_css=True, + default_css: bool = True, ) -> None: web_content = WebContent(