From e418456a826ec47cbeaf3316c6c56345ec8efbf6 Mon Sep 17 00:00:00 2001 From: xeovalyte Date: Fri, 19 Jul 2024 12:17:49 +0200 Subject: [PATCH] Added a membersstore for storing temp information --- assets/tailwind.css | 129 +++++++++++++++++++++++++++++ src/util.rs | 1 + src/util/model.rs | 1 + src/util/model/member.rs | 15 ++++ src/util/model/member/migration.rs | 42 ++++++++++ 5 files changed, 188 insertions(+) create mode 100644 src/util/model.rs create mode 100644 src/util/model/member.rs create mode 100644 src/util/model/member/migration.rs diff --git a/assets/tailwind.css b/assets/tailwind.css index 6cc5c8a..31af7e5 100644 --- a/assets/tailwind.css +++ b/assets/tailwind.css @@ -881,6 +881,31 @@ html { } } +.input { + flex-shrink: 1; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + height: 3rem; + padding-left: 1rem; + padding-right: 1rem; + font-size: 1rem; + line-height: 2; + line-height: 1.5rem; + border-radius: var(--rounded-btn, 0.5rem); + border-width: 1px; + border-color: transparent; + --tw-bg-opacity: 1; + background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity))); +} + +.input[type="number"]::-webkit-inner-spin-button, +.input-md[type="number"]::-webkit-inner-spin-button { + margin-top: -1rem; + margin-bottom: -1rem; + margin-inline-end: -1rem; +} + .navbar { display: flex; align-items: center; @@ -999,10 +1024,114 @@ html { } } +.input input { + --tw-bg-opacity: 1; + background-color: var(--fallback-p,oklch(var(--p)/var(--tw-bg-opacity))); + background-color: transparent; +} + +.input input:focus { + outline: 2px solid transparent; + outline-offset: 2px; +} + +.input[list]::-webkit-calendar-picker-indicator { + line-height: 1em; +} + +.input:focus, + .input:focus-within { + box-shadow: none; + border-color: var(--fallback-bc,oklch(var(--bc)/0.2)); + outline-style: solid; + outline-width: 2px; + outline-offset: 2px; + outline-color: var(--fallback-bc,oklch(var(--bc)/0.2)); +} + +.input:has(> input[disabled]), + .input-disabled, + .input:disabled, + .input[disabled] { + cursor: not-allowed; + --tw-border-opacity: 1; + border-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-border-opacity))); + --tw-bg-opacity: 1; + background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity))); + color: var(--fallback-bc,oklch(var(--bc)/0.4)); +} + +.input:has(> input[disabled])::-moz-placeholder, .input-disabled::-moz-placeholder, .input:disabled::-moz-placeholder, .input[disabled]::-moz-placeholder { + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-placeholder-opacity))); + --tw-placeholder-opacity: 0.2; +} + +.input:has(> input[disabled])::placeholder, + .input-disabled::placeholder, + .input:disabled::placeholder, + .input[disabled]::placeholder { + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-placeholder-opacity))); + --tw-placeholder-opacity: 0.2; +} + +.input:has(> input[disabled]) > input[disabled] { + cursor: not-allowed; +} + +.input::-webkit-date-and-time-value { + text-align: inherit; +} + .join > :where(*:not(:first-child)):is(.btn) { margin-inline-start: calc(var(--border-btn) * -1); } +.mockup-browser .mockup-browser-toolbar .input { + position: relative; + margin-left: auto; + margin-right: auto; + display: block; + height: 1.75rem; + width: 24rem; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + --tw-bg-opacity: 1; + background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity))); + padding-left: 2rem; + direction: ltr; +} + +.mockup-browser .mockup-browser-toolbar .input:before { + content: ""; + position: absolute; + left: 0.5rem; + top: 50%; + aspect-ratio: 1 / 1; + height: 0.75rem; + --tw-translate-y: -50%; + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); + border-radius: 9999px; + border-width: 2px; + border-color: currentColor; + opacity: 0.6; +} + +.mockup-browser .mockup-browser-toolbar .input:after { + content: ""; + position: absolute; + left: 1.25rem; + top: 50%; + height: 0.5rem; + --tw-translate-y: 25%; + --tw-rotate: -45deg; + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); + border-radius: 9999px; + border-width: 1px; + border-color: currentColor; + opacity: 0.6; +} + @keyframes modal-pop { 0% { opacity: 0; diff --git a/src/util.rs b/src/util.rs index f25c84a..6b47d0d 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,2 +1,3 @@ +pub mod model; #[cfg(feature = "server")] pub mod surrealdb; diff --git a/src/util/model.rs b/src/util/model.rs new file mode 100644 index 0000000..0dd2a03 --- /dev/null +++ b/src/util/model.rs @@ -0,0 +1 @@ +pub mod member; diff --git a/src/util/model/member.rs b/src/util/model/member.rs new file mode 100644 index 0000000..1b91281 --- /dev/null +++ b/src/util/model/member.rs @@ -0,0 +1,15 @@ +mod migration; + +pub struct Member { + id: String, + name: Name, + hours: Vec, + groups: Vec, + diploma: Option, + registration_token: Option, +} + +pub struct Name { + first: String, + last: String, +} diff --git a/src/util/model/member/migration.rs b/src/util/model/member/migration.rs new file mode 100644 index 0000000..a2e49e7 --- /dev/null +++ b/src/util/model/member/migration.rs @@ -0,0 +1,42 @@ +use super::Member; +use once_cell::sync::Lazy; +use std::collections::HashMap; + +// Create a store for saving information when migrating to a new members list +static MEMBERS_STORE: Lazy = Lazy::new(|| MembersStore::new()); + +struct MembersStore { + store: HashMap>, + count: u16, +} + +impl MembersStore { + fn new() -> Self { + Self { + store: HashMap::new(), + count: 0, + } + } + + fn insert(&mut self, input: Vec) -> u16 { + let count = self.count + 1; + self.store.insert(count, input); + count + } + + fn get(&self, key: &u16) -> Option<&Vec> { + self.store.get(key) + } + + fn remove(&mut self, key: &u16) -> Option> { + self.store.remove(key) + } +} + +impl Member { + async fn migrate() {} +} + +fn csv_to_vec(input: String) -> Result, ()> { + Ok(vec![]) +}