Skip to content

Commit

Permalink
feat(shared): Added show/hide effects
Browse files Browse the repository at this point in the history
  • Loading branch information
MendyBerger committed Apr 11, 2024
1 parent eb11656 commit abe6672
Showing 1 changed file with 51 additions and 6 deletions.
57 changes: 51 additions & 6 deletions shared/rust/src/domain/module/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,26 +614,71 @@ pub enum HoverAnimation {
Buzz,
}

impl fmt::Display for HoverAnimation {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let str = match self {
HoverAnimation::Grow => "Grow",
HoverAnimation::Tilt => "Tilt",
HoverAnimation::Buzz => "Buzz",
};
write!(f, "{str}")
}
}

impl HoverAnimation {
pub fn as_str(&self) -> &'static str {
match self {
HoverAnimation::Grow => "grow",
HoverAnimation::Tilt => "tilt",
HoverAnimation::Buzz => "buzz",
}
}
}

#[derive(Clone, Copy, Serialize, Deserialize, Debug, PartialEq, EnumIs)]
pub enum StickerHidden {
OnClick,
UntilClick,
OnClick(ShowHideAnimation),
UntilClick(ShowHideAnimation),
}

impl fmt::Display for HoverAnimation {
#[derive(Clone, Copy, Serialize, Deserialize, Debug, PartialEq, EnumIs, EnumIter, Default)]
pub enum ShowHideAnimation {
#[default]
Appear,
FadeInTop,
FadeInBottom,
FadeInLeft,
FadeInRight,
}

impl fmt::Display for ShowHideAnimation {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}",
match self {
HoverAnimation::Grow => "Grow",
HoverAnimation::Tilt => "Tilt",
HoverAnimation::Buzz => "Buzz",
ShowHideAnimation::Appear => "Appear",
ShowHideAnimation::FadeInTop => "Top",
ShowHideAnimation::FadeInBottom => "Bottom",
ShowHideAnimation::FadeInLeft => "Left",
ShowHideAnimation::FadeInRight => "Right",
}
)
}
}

impl ShowHideAnimation {
pub fn as_str(&self) -> &'static str {
match self {
ShowHideAnimation::Appear => "Appear",
ShowHideAnimation::FadeInTop => "fade-in-top",
ShowHideAnimation::FadeInBottom => "fade-in-bottom",
ShowHideAnimation::FadeInLeft => "fade-in-left",
ShowHideAnimation::FadeInRight => "fade-in-right",
}
}
}

/// Theme Ids. Used in various modules
/// See the frontend extension trait for more info
#[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug, EnumIter, IntoStaticStr)]
Expand Down

0 comments on commit abe6672

Please sign in to comment.