From 661a29708550799eaf2037638ef236440ea51d8b Mon Sep 17 00:00:00 2001 From: BrewingWeasel Date: Sat, 28 Oct 2023 20:07:37 -0400 Subject: [PATCH] feat: allow setting custom css --- shared/src/lib.rs | 1 + src-tauri/build.rs | 2 +- src-tauri/src/main.rs | 1 + src-ui/src/main.rs | 8 +- src-ui/src/settings.rs | 392 +++++++++++++++++++++++------------------ src-ui/style.css | 72 -------- 6 files changed, 233 insertions(+), 243 deletions(-) diff --git a/shared/src/lib.rs b/shared/src/lib.rs index a8f8f09..f667fc7 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -29,4 +29,5 @@ pub struct Settings { pub model: String, pub dicts: Vec, pub to_remove: Option, + pub css: Option, } diff --git a/src-tauri/build.rs b/src-tauri/build.rs index 795b9b7..d860e1e 100644 --- a/src-tauri/build.rs +++ b/src-tauri/build.rs @@ -1,3 +1,3 @@ fn main() { - tauri_build::build() + tauri_build::build() } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 749e01e..44bfcfd 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -37,6 +37,7 @@ Back:$def", model: String::new(), dicts: Vec::new(), to_remove: None, + css: None, }, } } diff --git a/src-ui/src/main.rs b/src-ui/src/main.rs index 0dbca91..05164aa 100644 --- a/src-ui/src/main.rs +++ b/src-ui/src/main.rs @@ -38,6 +38,9 @@ fn App() -> impl IntoView { let settings = create_resource(|| (), |_| async move { get_settings().await }); view! { + @@ -47,10 +50,9 @@ fn App() -> impl IntoView { + diff --git a/src-ui/src/settings.rs b/src-ui/src/settings.rs index 8d627aa..bd1858f 100644 --- a/src-ui/src/settings.rs +++ b/src-ui/src/settings.rs @@ -38,6 +38,8 @@ pub fn SettingsChanger(settings: Resource<(), Settings>) -> impl IntoView { let (note, set_note) = create_signal(old_settings.note_type); let (note_fields, set_note_fields) = create_signal(old_settings.note_fields); + let (css, set_css) = create_signal(old_settings.css.unwrap_or_default()); + let new_dicts = old_settings .dicts .clone() @@ -50,39 +52,64 @@ pub fn SettingsChanger(settings: Resource<(), Settings>) -> impl IntoView { view! {
-

Grammatical parsing

-
- - -
-
-

Anki Settings

- -
- -
- - -
- - -
- - +

Grammatical parsing

+
+ + +
+
+

Anki Settings

+ +
+ +
+ + +
+ + +
+

Styling

+ +
+ +
} .into_view() @@ -97,16 +124,17 @@ fn SimpleTextSetting( ) -> impl IntoView { view! {
- - {desc} +
+ prop:value=readsig + /> + } } @@ -119,16 +147,17 @@ fn SimpleTextAreaSetting( ) -> impl IntoView { view! {
- - +
} } @@ -144,7 +173,9 @@ fn DictionaryList(dicts: ReadSignal, set_dicts: WriteSignal) view! {

Dictionaries

- +
, set_dicts: WriteSignal) view! {
-
@@ -180,51 +215,53 @@ fn DictionaryRepresentation( let is_file = move || matches!(rdict(), Dictionary::File(_, _)); view! { {move || match rdict() { Dictionary::Url(url) => { let (read_sig, write_sig) = create_signal(url); view! {
- // TODO: make generic function for this - + // TODO: make generic function for this + +
} .into_view() @@ -233,94 +270,115 @@ fn DictionaryRepresentation( let (read_filename, write_filename) = create_signal(filename); let is_stardict = matches!(dict_type, DictFileType::StarDict); view! { + // TODO: make generic function for this + + // TODO: make generic function for this +
- // TODO: make generic function for this - + // TODO: make generic function for this + +
- + {if let DictFileType::TextSplitAt(delim) = dict_type { let (read_delim, write_delim) = create_signal(delim); Some( view! {
- // TODO: make generic function for this -
+ // TODO: make generic function for this + + +
}, ) } else { diff --git a/src-ui/style.css b/src-ui/style.css index 533c36c..18ddb67 100644 --- a/src-ui/style.css +++ b/src-ui/style.css @@ -249,75 +249,3 @@ select { .navbar a:hover { background: #44415a; } - -/* BELOW HERE IS SPECIFIC TO DICT IM USING TODO: ADD SETTING FOR CUSTOM CSS */ - -.Gen { - color: #eb6f92; -} - -.Ins { - color: #f6c177; -} - -.Acc { - color: #31748f; -} - -.Loc { - color: #9ccfd8; -} - -.Nom { - color: #ebbcba; -} - -.Dat { - color: #c4a7e7; -} - -.Voc { - color: #c4a7e7; -} - -.Ill { - color: #31748f; -} - -.dzRecord { - text-align: center; -} -.dz_homonym { - color: #eb6f92; - display: inline-block; -} - -.dz_valnumber { - color: #e0def4; - font-weight: bold; - padding: 0px; - display: inline-block; -} - -.dz_forms, .dz_tags, .dz_tag { - color: #c4a7e7; - font-style: italic; - display: inline-block; -} - -.dz_grammar { - color: #6e6a86; - display: inline-block; -} - -.dz_example { - color: #e0def4; - display: inline-block; -} - -.dz_antraste { - font-weight: bold; - color: #f6c177; - display: inline-block; -} -