-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from picture-pro/39-add-component-for-photodeck
39 add component for photodeck
- Loading branch information
Showing
3 changed files
with
59 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,43 @@ | ||
use leptos::*; | ||
|
||
use crate::components::photo::Photo; | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] | ||
pub enum PhotoDeckDisplayMode { | ||
Flat, | ||
#[default] | ||
Stacked, | ||
} | ||
|
||
#[component] | ||
pub fn PhotoDeck(ids: Vec<core_types::PhotoRecordId>) -> impl IntoView { | ||
view! { | ||
{ ids.into_iter().map(|photo_id| { | ||
pub fn PhotoDeck( | ||
ids: Vec<core_types::PhotoRecordId>, | ||
#[prop(optional)] display_mode: PhotoDeckDisplayMode, | ||
) -> impl IntoView { | ||
match display_mode { | ||
PhotoDeckDisplayMode::Flat => view! { | ||
<div class="flex flex-wrap gap-2 items-center"> | ||
{ ids.into_iter().map(|id| view! { <Photo photo_id={id} /> }).collect::<Vec<_>>() } | ||
</div> | ||
} | ||
.into_view(), | ||
PhotoDeckDisplayMode::Stacked => { | ||
let count = ids.len(); | ||
view! { | ||
<crate::components::photo::Photo photo_id=photo_id /> | ||
<div class="grid"> | ||
{ ids.into_iter().enumerate().map(|(i, id)| view! { | ||
<Photo | ||
photo_id={id} | ||
rotation={i as f32 * 16.0} | ||
scale={1.0 - (i as f32 * 0.05)} | ||
z_index={count as i32 - i as i32} | ||
opacity={1.0 - (i as f32 * 0.1)} | ||
extra_class="col-start-1 row-start-1" | ||
/> | ||
}).collect::<Vec<_>>() } | ||
</div> | ||
} | ||
.into_view() | ||
}).collect::<Vec<_>>() } | ||
} | ||
} | ||
} |
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