From 3e91f343033ffc8cdf7e295e7c0cab5486c062a0 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sat, 24 May 2025 12:18:23 +0200 Subject: [PATCH] Add search frontend code --- Cargo.lock | 32 +++--- backend/scss/calendar.scss | 6 +- backend/scss/constants.scss | 30 ++++- backend/scss/main.scss | 63 +++++------ backend/scss/mixins.scss | 2 +- backend/scss/modal-dialog.scss | 4 +- backend/scss/search.scss | 73 ++++++++++++ backend/scss/toast.scss | 4 +- backend/sql/version_1.sql | 8 +- backend/src/data/db/recipe.rs | 15 ++- backend/src/services/ron/recipe.rs | 35 +++++- backend/templates/base_with_header.html | 2 + backend/templates/search.html | 17 +++ backend/translations/english.ron | 2 + backend/translations/french.ron | 2 + common/src/consts.rs | 2 + common/src/translation.rs | 2 + common/src/web_api.rs | 1 + frontend/Cargo.toml | 1 + frontend/src/lib.rs | 4 + frontend/src/pages/recipe_edit.rs | 4 +- frontend/src/search.rs | 143 ++++++++++++++++++++++++ 22 files changed, 379 insertions(+), 73 deletions(-) create mode 100644 backend/scss/search.scss create mode 100644 backend/templates/search.html create mode 100644 frontend/src/search.rs diff --git a/Cargo.lock b/Cargo.lock index f1c5419..1d9eca9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -100,12 +100,12 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.7" +version = "3.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +checksum = "6680de5231bd6ee4c6191b8a1325daa282b415391ec9d3a37bd34f2060dc73fa" dependencies = [ "anstyle", - "once_cell", + "once_cell_polyfill", "windows-sys 0.59.0", ] @@ -499,9 +499,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.23" +version = "1.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4ac86a9e5bc1e2b3449ab9d7d3a6a405e3d1bb28d7b9be8614f55846ae3766" +checksum = "16595d3be041c03b09d08d0858631facccee9221e579704070e6e9e4915d3bc7" dependencies = [ "shlex", ] @@ -2011,12 +2011,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] -name = "onig" -version = "6.4.0" +name = "once_cell_polyfill" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + +[[package]] +name = "onig" +version = "6.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "336b9c63443aceef14bea841b899035ae3abe89b7c486aaf4c5bd8aafedac3f0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.9.1", "libc", "once_cell", "onig_sys", @@ -2024,9 +2030,9 @@ dependencies = [ [[package]] name = "onig_sys" -version = "69.8.1" +version = "69.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" +checksum = "c7f86c6eef3d6df15f23bcfb6af487cbd2fed4e5581d58d5bf1f5f8b7f6727dc" dependencies = [ "cc", "pkg-config", @@ -2628,9 +2634,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" [[package]] name = "ryu" diff --git a/backend/scss/calendar.scss b/backend/scss/calendar.scss index b9fa2f6..35add0e 100644 --- a/backend/scss/calendar.scss +++ b/backend/scss/calendar.scss @@ -14,7 +14,7 @@ .svg-arrow { display: block; - margin: consts.$margin calc(consts.$margin / 2); + margin: var(--margin) calc(var(--margin) / 2); fill: consts.$link-color; width: 0.8rem; height: 0.8rem; @@ -34,7 +34,7 @@ } .year { - margin: consts.$margin; + margin: var(--margin); } .month { @@ -82,7 +82,7 @@ } .remove-scheduled-recipe { - padding: 0px calc(consts.$margin / 2); + padding: 0px calc(var(--margin) / 2); } } } diff --git a/backend/scss/constants.scss b/backend/scss/constants.scss index 28b84b7..336cee1 100644 --- a/backend/scss/constants.scss +++ b/backend/scss/constants.scss @@ -2,6 +2,25 @@ $dark-theme: false !default; +$mobile-width: 1080px; + +// Dynamic values depending of the screen width. +@media (min-width: calc($mobile-width + 1px)) { + :root { + --margin: 5px; + --title-font-size: 180%; + --logo-size: 50px; + } +} + +@media (max-width: $mobile-width) { + :root { + --margin: 3px; + --title-font-size: 130%; + --logo-size: 40px; + } +} + $color-1: #B29B89; $color-2: #89B29B; $color-3: #9B89B2; @@ -9,21 +28,22 @@ $color-highlight: #cf2d2dff; $text-color: color.adjust($color-1, $lightness: -30%); $text-highlight: color.adjust($color-1, $lightness: +30%); +$text-dimished: color.adjust($color-1, $lightness: -15%, $saturation: -15%); $link-color: color.adjust($color-3, $lightness: -25%); $link-hover-color: color.adjust($color-3, $lightness: +20%); @if $dark-theme { + $color-highlight: color.adjust($color-highlight, $lightness: +10%); + $text-color: color.adjust($color-1, $lightness: -10%); $text-highlight: color.adjust($color-1, $lightness: +10%); - $color-highlight: color.adjust($color-highlight, $lightness: +10%); + $text-dimished: color.adjust($color-1, $lightness: -20%, $saturation: -15%); $link-color: color.adjust($color-3, $lightness: -5%); $link-hover-color: color.adjust($color-3, $lightness: +10%); $color-1: color.adjust($color-1, $lightness: -47%); $color-2: color.adjust($color-2, $lightness: -47%); - $color-3: color.adjust($color-2, $lightness: -47%); -} - -$margin: 5px; \ No newline at end of file + $color-3: color.adjust($color-3, $lightness: -50%); +} \ No newline at end of file diff --git a/backend/scss/main.scss b/backend/scss/main.scss index 473af2f..b921626 100644 --- a/backend/scss/main.scss +++ b/backend/scss/main.scss @@ -4,6 +4,7 @@ $dark-theme: false !default; @use 'constants' as consts with ($dark-theme: $dark-theme); @use 'calendar'; +@use 'search'; @use 'toast'; @use 'modal-dialog'; @use 'mixins'; @@ -40,26 +41,26 @@ body { } .footer-container { - margin: consts.$margin; + margin: var(--margin); align-self: center; font-size: 0.7em; } /// HEADER /// .header-container { - margin: calc(2 * consts.$margin); + margin: calc(2 * var(--margin)); display: flex; align-items: flex-end; justify-content: space-between; .title { - font-size: 180%; + font-size: var(--title-font-size); font-style: italic; .logo { - width: 50px; - height: 50px; + width: var(--logo-size); + height: var(--logo-size); vertical-align: bottom; margin: 0px 10px 0px 0px; @@ -68,16 +69,16 @@ body { .header-menu { .user-menu { - margin: consts.$margin; + margin: var(--margin); .user-edit-link { - margin-left: consts.$margin; + margin-left: var(--margin); } } #select-website-language { - margin: consts.$margin; - padding: consts.$margin; + margin: var(--margin); + padding: var(--margin); } } } @@ -87,16 +88,16 @@ body { flex-direction: row; #recipes-list { - margin: calc(2 * consts.$margin); + margin: calc(2 * var(--margin)); ul { padding-left: 20px; li { - margin-bottom: calc(consts.$margin / 2); + margin-bottom: calc(var(--margin) / 2); a { - padding: calc(consts.$margin / 2); + padding: calc(var(--margin) / 2); } } } @@ -130,7 +131,7 @@ body { } .content { - margin: calc(2 * consts.$margin); + margin: calc(2 * var(--margin)); flex-grow: 1; @@ -250,13 +251,11 @@ body { } } - // #dev-panel { - // } - form { display: grid; + //