Skip to content

Commit

Permalink
Merge pull request #7 from opensass/custom
Browse files Browse the repository at this point in the history
feat: allow users to drag og canvas elements && improve prompts
  • Loading branch information
wiseaidev authored Dec 15, 2024
2 parents 699c894 + d4b1e7f commit a67500c
Show file tree
Hide file tree
Showing 23 changed files with 317 additions and 141 deletions.
8 changes: 4 additions & 4 deletions src/components/dashboard/chat/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use crate::server::og::request::GetOGsForUserRequest;
use gloo_storage::Storage;

use crate::theme::Theme;
use crate::theme::THEME;
use bson::oid::ObjectId;
use chrono::Utc;
use dioxus::prelude::*;
Expand Down Expand Up @@ -44,6 +43,7 @@ pub fn ChatPanel(conversation_id: Signal<ObjectId>, user_token: Signal<String>)
let mut ogs = use_signal(Vec::<OG>::new);
let mut thinking = use_signal(|| false);
let mut loading = use_signal(|| false);
let theme = use_context::<Signal<Theme>>();

let _ = use_resource(move || async move {
let now = Utc::now().timestamp();
Expand Down Expand Up @@ -159,7 +159,7 @@ pub fn ChatPanel(conversation_id: Signal<ObjectId>, user_token: Signal<String>)
div {
class: format!(
"flex flex-col h-full {}",
if *THEME.read() == Theme::Dark { "bg-gray-900 text-white" } else { "bg-white text-gray-900" }
if theme() == Theme::Dark { "bg-gray-900 text-white" } else { "bg-white text-gray-900" }
),

div {
Expand All @@ -168,7 +168,7 @@ pub fn ChatPanel(conversation_id: Signal<ObjectId>, user_token: Signal<String>)
select {
class: format!(
"p-2 rounded-lg mb-2 md:mb-0 flex-grow w-full md:w-auto truncate {}",
if *THEME.read() == Theme::Dark { "bg-gray-700 text-white" } else { "bg-gray-100 text-black" }
if theme() == Theme::Dark { "bg-gray-700 text-white" } else { "bg-gray-100 text-black" }
),
onchange: move |evt| handle_og_change(evt.value()),
option { value: "", "Select a og" },
Expand All @@ -184,7 +184,7 @@ pub fn ChatPanel(conversation_id: Signal<ObjectId>, user_token: Signal<String>)
input {
class: format!(
"flex-1 p-2 rounded-lg border w-full {}",
if *THEME.read() == Theme::Dark { "bg-gray-700 text-white border-gray-600" } else { "border-gray-300" }
if theme() == Theme::Dark { "bg-gray-700 text-white border-gray-600" } else { "border-gray-300" }
),
r#type: "text",
placeholder: "Type your query here...",
Expand Down
4 changes: 2 additions & 2 deletions src/components/dashboard/chat/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::server::conversation::model::Conversation;
use crate::server::conversation::request::CreateConversationRequest;
use crate::server::conversation::request::GetConversationsRequest;
use crate::theme::Theme;
use crate::theme::THEME;
use bson::oid::ObjectId;
use chrono::Utc;

Expand All @@ -19,6 +18,7 @@ pub fn ConversationsSidebar(
) -> Element {
let token_clone = token.clone();
let og_id_clone = og_id.clone();
let theme = use_context::<Signal<Theme>>();

use_effect(move || {
let token = token.clone();
Expand All @@ -34,7 +34,7 @@ pub fn ConversationsSidebar(

rsx! {
div {
class: format!("p-4 {}", if *THEME.read() == Theme::Dark { "border-gray-600 bg-gray-900" } else { "border-gray-200" }),
class: format!("p-4 {}", if theme() == Theme::Dark { "border-gray-600 bg-gray-900" } else { "border-gray-200" }),

h3 { class: "text-lg font-semibold mb-4 text-blue-500", "Conversations" }

Expand Down
5 changes: 3 additions & 2 deletions src/components/dashboard/fields/input.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::theme::Theme;
use crate::theme::THEME;
use dioxus::prelude::*;

#[component]
Expand All @@ -10,7 +9,8 @@ pub fn InputField(
validate: fn(&str) -> bool,
required: bool,
) -> Element {
let dark_mode = *THEME.read() == Theme::Dark;
let theme = use_context::<Signal<Theme>>();
let dark_mode = theme() == Theme::Dark;

let handle_input = move |e: Event<FormData>| {
let input_value = e.value().clone();
Expand All @@ -20,6 +20,7 @@ pub fn InputField(

rsx! {
div {
class: "flex-grow w-full",
label {
class: format!("block text-sm font-medium {}", if dark_mode { "text-gray-300" } else { "text-gray-700" }),
"{label}"
Expand Down
4 changes: 2 additions & 2 deletions src/components/dashboard/fields/number.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::theme::Theme;
use crate::theme::THEME;
use dioxus::prelude::*;

#[component]
pub fn NumberField(label: &'static str, value: Signal<u64>, required: bool) -> Element {
let dark_mode = *THEME.read() == Theme::Dark;
let theme = use_context::<Signal<Theme>>();
let dark_mode = theme() == Theme::Dark;
rsx! {
div {
label { class: format!("block text-sm font-medium {}", if dark_mode { "text-gray-300" } else { "text-gray-700" }), "{label}" }
Expand Down
4 changes: 2 additions & 2 deletions src/components/dashboard/fields/select.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::theme::Theme;
use crate::theme::THEME;
use dioxus::prelude::*;

#[component]
Expand All @@ -8,7 +7,8 @@ pub fn SelectField(
options: Vec<&'static str>,
selected: Signal<String>,
) -> Element {
let dark_mode = *THEME.read() == Theme::Dark;
let theme = use_context::<Signal<Theme>>();
let dark_mode = theme() == Theme::Dark;
rsx! {
div {
label { class: format!("block text-sm font-medium {}", if dark_mode { "text-gray-300" } else { "text-gray-700" }), "{label}" }
Expand Down
13 changes: 6 additions & 7 deletions src/components/dashboard/navbar.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use crate::components::spinner::Spinner;
use crate::components::spinner::SpinnerSize;
use crate::pages::dashboard::toggle_theme;
use crate::theme::Theme;
use crate::theme::ThemeToggle;
use dioxus::prelude::*;
use gloo_storage::Storage;
use gloo_storage::{LocalStorage, SessionStorage};

#[component]
pub fn Navbar(dark_mode: bool) -> Element {
pub fn Navbar() -> Element {
let mut show_dropdown = use_signal(|| false);
let mut loading = use_signal(|| false);
let navigator = use_navigator();
let theme = use_context::<Signal<Theme>>();
let dark_mode = theme() == Theme::Dark;

let handle_logout = move |e: Event<MouseData>| {
e.stop_propagation();
Expand All @@ -25,11 +28,7 @@ pub fn Navbar(dark_mode: bool) -> Element {
h1 { class: "text-2xl font-semibold", "Dashboard" }

div { class: "flex items-center space-x-4",
button {
onclick: |_| toggle_theme(),
class: "p-2 rounded-full text-lg",
if dark_mode { "🌙" } else { "🌞" }
}
ThemeToggle {}

div { class: "relative",
button {
Expand Down
Loading

0 comments on commit a67500c

Please sign in to comment.