Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

set active pagination on render#1408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
chillenberger merged 1 commit intomasterfromdan-pagination-set-active
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletionspgml-dashboard/src/components/pagination/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,8 @@ pub struct Pagination {
count: usize,
timed: bool,
identifier: u16,
active_index: Option<usize>,
clickable: bool,
}

impl Pagination {
Expand All@@ -15,13 +17,27 @@ impl Pagination {
count,
timed: false,
identifier: identifier,
active_index: None,
clickable: true,
}
}

pub fn timed(mut self) -> Self {
self.timed = true;
self
}

// When the user wantes to set the active index on render.
pub fn active_index(mut self, index: usize) -> Self {
self.active_index = Some(index);
self
}

// Prevents hover states.
pub fn not_clickable(mut self) -> Self {
self.clickable = false;
self
}
}

component!(Pagination);
30 changes: 28 additions & 2 deletionspgml-dashboard/src/components/pagination/pagination.scss
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
div[data-controller="pagination"] {
$active-color: #00E0FF;

.pagination-container {
display: flex;
Expand All@@ -15,6 +16,26 @@ div[data-controller="pagination"] {
transition: width 0.25s;
}

.pagination-item-container-animation {
animation: IndicatorGrow 0.3s;
animation-fill-mode: forwards;

.pagination-item {
background-color: $active-color;
width: 100%;
}
}

.pagination-item-container-animation-reverse {
animation: IndicatorShrink 0.3s;
animation-fill-mode: forwards;

.pagination-item {
background-color: #{$gray-700};
width: 100%;
}
}

.pagination-item-container-clickable:not(.pagination-item-active) {
cursor: pointer;
&:hover {
Expand All@@ -26,14 +47,14 @@ div[data-controller="pagination"] {

.pagination-item-active {
.pagination-item {
background-color:#00E0FF;
background-color:$active-color;
width: 100%;
}
}

.pagination-item-timed-active {
.pagination-item {
background-color:#00E0FF;
background-color:$active-color;
animation: IndicatorGrow 4500ms;
animation-fill-mode: forwards;
}
Expand All@@ -44,6 +65,11 @@ div[data-controller="pagination"] {
100% {width: 4rem;}
}

@keyframes IndicatorShrink {
0% {width: 4rem;}
100% {width: 1rem;}
}

.pagination-item {
width: 1rem;
height: 1rem;
Expand Down
13 changes: 10 additions & 3 deletionspgml-dashboard/src/components/pagination/template.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
<%
let active_class = if timed { "pagination-item-timed-active" } else { "pagination-item-active" };
let clickable_class = if timed { "" } else { "pagination-item-container-clickable" };
let clickable_class = if timed|| !clickable{ "" } else { "pagination-item-container-clickable" };
%>

<div
Expand All@@ -11,8 +11,15 @@
>
<div class="pagination-container w-100 mt-4 pt-3">
<% if count > 1 {
for i in 0..count { %>
<div class="pagination-item-container <%- clickable_class %>" data-pagination-target="paginationItem">
for i in 0..count {
let make_active = match active_index {
Some(index) if i == index => "pagination-item-container-animation",
Some(index) if i + 1 == index => "pagination-item-container-animation-reverse",
Some(index) if i == count - 1 && index == 0 => "pagination-item-container-animation-reverse",
_ => ""
};
%>
<div class="pagination-item-container <%- clickable_class %> <%- make_active %>" data-pagination-target="paginationItem">
<div class="pagination-item" data-action="click->pagination#change" data-pagination-index-param="<%- i %>"></div>
</div>
<% }
Expand Down
17 changes: 17 additions & 0 deletionspgml-dashboard/templates/content/playground.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,12 +11,28 @@
use crate::components::cards::marketing::Slider as SliderCard;
use crate::components::icons::Checkmark;
use crate::components::Slider;
use crate::components::pagination::Pagination;
%>

<div class="min-height: 100vh;" data-controller="playground">
<h1 class="h1">Playground</h1>
<p>This is a space to display components.</p>

<div style="margin-bottom: 14rem;">
<%+ Pagination::new(3, 1)
.active_index(0)
.not_clickable() %>

<%+ Pagination::new(3, 1)
.active_index(1)
.not_clickable() %>

<%+ Pagination::new(3, 1)
.active_index(2)
.not_clickable() %>

</div>

<h3 class="h3">icons</h3>
<div class="mb-5">
<%+ GithubIcon::new() %>
Expand DownExpand Up@@ -271,3 +287,4 @@ <h3 class="h3">Inputs</h3>
])
)%>
</div>


[8]ページ先頭

©2009-2025 Movatter.jp