Skip to content

Commit

Permalink
feat(fe/modules): Added sticker hover animations and hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
MendyBerger committed Apr 4, 2024
1 parent b34f24a commit c86920c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
35 changes: 33 additions & 2 deletions shared/rust/src/domain/module/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ use crate::{
media::MediaLibrary,
};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{collections::HashSet, fmt::Debug, hash::Hash};
use strum_macros::{EnumIter, IntoStaticStr};
use std::{
collections::HashSet,
fmt::{self, Debug},
hash::Hash,
};
use strum_macros::{EnumIs, EnumIter, IntoStaticStr};

/// Memory Game Body.
pub mod memory;
Expand Down Expand Up @@ -603,6 +607,33 @@ impl Default for Transform {
}
}

#[derive(Clone, Copy, Serialize, Deserialize, Debug, PartialEq, EnumIs)]
pub enum HoverAnimation {
Grow,
Tilt,
Buzz,
}

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

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

/// 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
19 changes: 18 additions & 1 deletion shared/rust/src/domain/module/body/_groups/design.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::domain::module::body::{Audio, Background, Image, ModuleAssist, ThemeId, Transform};
use crate::domain::module::body::{
Audio, Background, HoverAnimation, Image, ModuleAssist, StickerHidden, ThemeId, Transform,
};
use derive_setters::Setters;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -81,6 +83,12 @@ pub struct Text {
pub value: String,
/// The Transform
pub transform: Transform,
/// Animation to run on hover
#[serde(default)]
pub hover_animation: Option<HoverAnimation>,
/// Hide on click
#[serde(default)]
pub hidden: Option<StickerHidden>,
}

impl Default for Text {
Expand All @@ -102,6 +110,8 @@ impl Text {
Self {
value,
transform: Transform::identity(),
hover_animation: None,
hidden: None,
}
}

Expand Down Expand Up @@ -129,6 +139,13 @@ pub struct Sprite {

/// Flip vertical
pub flip_vertical: bool,

/// Animation to run on hover
#[serde(default)]
pub hover_animation: Option<HoverAnimation>,
/// Hide on click
#[serde(default)]
pub hidden: Option<StickerHidden>,
}

#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
Expand Down

0 comments on commit c86920c

Please sign in to comment.