-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/bump-dx
- Loading branch information
Showing
119 changed files
with
1,915 additions
and
1,085 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use dioxus_native_core::NodeId; | ||
use rustc_hash::FxHashMap; | ||
use std::sync::{Arc, Mutex, MutexGuard}; | ||
|
||
#[derive(Default, Clone)] | ||
pub struct Layers { | ||
pub layers: Arc<Mutex<FxHashMap<i16, Vec<NodeId>>>>, | ||
} | ||
|
||
impl Layers { | ||
pub fn insert_node_in_layer(&self, node_id: NodeId, layer_n: i16) { | ||
let mut layers = self.layers.lock().unwrap(); | ||
let layer = layers.entry(layer_n).or_default(); | ||
layer.push(node_id); | ||
} | ||
|
||
pub fn remove_node_from_layer(&self, node_id: NodeId, layer_n: i16) { | ||
let mut layers = self.layers.lock().unwrap(); | ||
let layer = layers.get_mut(&layer_n).unwrap(); | ||
layer.retain(|id| *id != node_id); | ||
|
||
if layer.is_empty() { | ||
layers.remove(&layer_n); | ||
} | ||
} | ||
|
||
pub fn layers(&self) -> MutexGuard<FxHashMap<i16, Vec<NodeId>>> { | ||
self.layers.lock().unwrap() | ||
} | ||
|
||
pub fn len_layers(&self) -> usize { | ||
self.layers.lock().unwrap().len() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
mod event_messages; | ||
mod layers; | ||
mod layout; | ||
mod paragraphs; | ||
|
||
pub use event_messages::*; | ||
pub use layers::*; | ||
pub use layout::*; | ||
pub use paragraphs::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use dioxus_native_core::NodeId; | ||
use rustc_hash::FxHashMap; | ||
use std::sync::{Arc, Mutex, MutexGuard}; | ||
use uuid::Uuid; | ||
|
||
#[derive(Default, Clone)] | ||
pub struct ParagraphElements { | ||
pub paragraphs: Arc<Mutex<FxHashMap<Uuid, Vec<NodeId>>>>, | ||
} | ||
|
||
impl ParagraphElements { | ||
pub fn insert_paragraph(&self, node_id: NodeId, text_id: Uuid) { | ||
let mut paragraphs = self.paragraphs.lock().unwrap(); | ||
let text_group = paragraphs.entry(text_id).or_default(); | ||
|
||
text_group.push(node_id); | ||
} | ||
|
||
pub fn paragraphs(&self) -> MutexGuard<FxHashMap<Uuid, Vec<NodeId>>> { | ||
self.paragraphs.lock().unwrap() | ||
} | ||
|
||
pub fn remove_paragraph(&self, node_id: NodeId, text_id: &Uuid) { | ||
let mut paragraphs = self.paragraphs.lock().unwrap(); | ||
let text_group = paragraphs.get_mut(text_id); | ||
|
||
if let Some(text_group) = text_group { | ||
text_group.retain(|id| *id != node_id); | ||
|
||
if text_group.is_empty() { | ||
paragraphs.remove(text_id); | ||
} | ||
} | ||
} | ||
|
||
pub fn len_paragraphs(&self) -> usize { | ||
self.paragraphs.lock().unwrap().len() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use dioxus::prelude::*; | ||
use dioxus_router::{hooks::use_route, prelude::Routable}; | ||
use freya_hooks::ActivableRouteContext; | ||
|
||
#[allow(non_snake_case)] | ||
#[component] | ||
pub fn ActivableRoute<T: Clone + PartialEq + Routable + 'static>( | ||
children: Element, | ||
route: T, | ||
) -> Element { | ||
let current_route = use_route::<T>(); | ||
let is_active = current_route == route; | ||
let mut ctx = use_context_provider::<ActivableRouteContext>(|| { | ||
ActivableRouteContext(Signal::new(is_active)) | ||
}); | ||
|
||
if *ctx.0.read() != is_active { | ||
*ctx.0.write() = is_active; | ||
} | ||
|
||
rsx!({ children }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.