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

Added an accordian and another star#1077

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
SilasMarvin merged 1 commit intomasterfromsilas-new-home
Oct 16, 2023
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/accordian/accordian.scss
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
div[data-controller="accordian"] {
.accordian-header {
cursor: pointer;
}

.accordian-body {
display: none;
height: 0px;
transition: all 0.5s ease-in-out;
}

.accordian-body.selected {
display: block;
height: auto;
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
titleClick(e) {
let target = e.currentTarget.getAttribute("data-value");
let elements = document.getElementsByClassName("accordian-body");
for (let i = 0; i < elements.length; i++) {
elements[i].classList.remove("selected");
}
elements = document.getElementsByClassName("accordian-header");
for (let i = 0; i < elements.length; i++) {
elements[i].classList.remove("selected");
}
let element = document.querySelector(`[data-accordian-target="${target}"]`);
element.classList.add("selected");
e.currentTarget.classList.add("selected");
}
}
36 changes: 36 additions & 0 deletionspgml-dashboard/src/components/accordian/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
use sailfish::TemplateOnce;
use pgml_components::component;

// This component will probably not work very well if two are on the same page at once. We can get
// around it if we include some randomness with the data values in the template.html but that
// doesn't feel very clean so I will leave this problem until we have need to fix it or a better
// idea of how to
#[derive(TemplateOnce, Default)]
#[template(path = "accordian/template.html")]
pub struct Accordian {
html_contents: Vec<String>,
Copy link
Contributor

@levkklevkkOct 16, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Usepgml_components::Component so the caller doesn't have torender_once().unwrap() the inputs.

html_titles: Vec<String>,
selected: usize
}

impl Accordian {
pub fn new() -> Accordian {
Accordian {
html_contents: Vec::new(),
html_titles: Vec::new(),
selected: 0,
}
}

pub fn html_contents<S: ToString>(mut self, html_contents: Vec<S>) -> Self {
self.html_contents = html_contents.into_iter().map(|s| s.to_string()).collect();
self
}

pub fn html_titles<S: ToString>(mut self, html_titles: Vec<S>) -> Self {
self.html_titles = html_titles.into_iter().map(|s| s.to_string()).collect();
self
}
}

component!(Accordian);
16 changes: 16 additions & 0 deletionspgml-dashboard/src/components/accordian/template.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<% use std::iter::zip; %>

<div data-controller="accordian">
<div class="accordian">
<% for i in (0..html_contents.len()) { %>
<div class="accordian-item">
<div class="accordian-header <% if i == selected { %> selected <% } %>" data-action="click->accordian#titleClick" data-value="accordian-body<%= i %>">
<%- html_titles[i] %>
</div>
<div class="accordian-body <% if i == selected { %> selected <% } %>" data-accordian-target="accordian-body<%= i %>">
<%- html_contents[i] %>
</div>
</div>
<% } %>
</div>
</div>
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@

<li class="menu-item d-flex align-items-center">
<li class="menu-item d-flex align-items-center" data-for="<%= value %>">
<button type="button" class="dropdown-item" data-action="<%- action %>"><%= value %></button>
</li>
4 changes: 4 additions & 0 deletionspgml-dashboard/src/components/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
// This file is automatically generated.
// You shouldn't modify it manually.

// src/components/accordian
pub mod accordian;
pub use accordian::Accordian;

// src/components/breadcrumbs
pub mod breadcrumbs;
pub use breadcrumbs::Breadcrumbs;
Expand Down
4 changes: 4 additions & 0 deletionspgml-dashboard/src/components/star/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,10 @@ const SVGS: Lazy<HashMap<&'static str, &'static str>> = Lazy::new(|| {
"party",
include_str!("../../../static/images/icons/stars/party.svg"),
);
map.insert(
"give_it_a_spin",
include_str!("../../../static/images/icons/stars/give_it_a_spin.svg"),
);
map
});

Expand Down
1 change: 1 addition & 0 deletionspgml-dashboard/static/css/modules.scss
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
// This file is automatically generated.
// There is no need to edit it manually.

@import "../../src/components/accordian/accordian.scss";
@import "../../src/components/chatbot/chatbot.scss";
@import "../../src/components/dropdown/dropdown.scss";
@import "../../src/components/inputs/range_group/range_group.scss";
Expand Down
31 changes: 31 additions & 0 deletionspgml-dashboard/static/images/icons/stars/give_it_a_spin.svg
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

[8]ページ先頭

©2009-2025 Movatter.jp