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

Tooltip#1429

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
levkk merged 1 commit intomasterfromlevkk-more-onboarding-components
Apr 29, 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
11 changes: 7 additions & 4 deletionspgml-dashboard/src/components/chatbot/chatbot_controller.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -400,10 +400,13 @@ export default class extends Controller {

showChatbotAlert(level, message) {
const toastElement = createToast(message, level);
showToast(toastElement, {
autohide: true,
delay: 7000,
});

if (toastElement) {
showToast(toastElement, {
autohide: true,
delay: 7000,
});
}
}

hideExampleQuestions() {
Expand Down
6 changes: 6 additions & 0 deletionspgml-dashboard/src/components/inputs/labels/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
// This file is automatically generated.
// You shouldn't modify it manually.

// src/components/inputs/labels/with_tooltip
pub mod with_tooltip;
pub use with_tooltip::WithTooltip;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
use pgml_components::{component, Component};
use sailfish::TemplateOnce;

#[derive(TemplateOnce, Default)]
#[template(path = "inputs/labels/with_tooltip/template.html")]
pub struct WithTooltip {
component: Component,
tooltip: String,
icon: String,
html: bool,
}

impl WithTooltip {
pub fn new(component: Component) -> WithTooltip {
WithTooltip {
component,
tooltip: String::new(),
icon: "info".to_string(),
html: false,
}
}

pub fn tooltip(mut self, tooltip: impl ToString) -> Self {
self.tooltip = tooltip.to_string();
self
}

pub fn tooltip_text(self, tooltip: impl ToString) -> Self {
self.tooltip(tooltip)
}

pub fn tooltip_html(mut self, tooltip: impl ToString) -> Self {
self.tooltip = tooltip.to_string();
self.html = true;
self
}

pub fn icon(mut self, icon: impl ToString) -> Self {
self.icon = icon.to_string();
self
}
}

component!(WithTooltip);
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
<span
data-controller="inputs-labels-with-tooltip enable-tooltip"
class="d-inline-flex gap-1 align-items-top"
>
<span><%+ component %></span>
<span
data-bs-toggle="tooltip"
data-bs-placement="right"
data-bs-title="<%- tooltip %>"
data-bs-html="<%= html %>"
class="material-symbols-outlined fw-bold"
>
<%= icon %>
</span>
</span>
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
span[data-controller="inputs-labels-with-tooltip enable-tooltip"] {
span[data-bs-toggle="tooltip"] {
color: #{$slate-tint-100};
font-size: 1.2rem;
}
}
3 changes: 3 additions & 0 deletionspgml-dashboard/src/components/inputs/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,9 @@
pub mod checkbox;
pub use checkbox::Checkbox;

// src/components/inputs/labels
pub mod labels;

// src/components/inputs/radio
pub mod radio;
pub use radio::Radio;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
div[data-controller="inputs-text-input"] {
--bs-danger: #{$peach-shade-100};

span.material-symbols-outlined{
span.inputs-text-input-icon{
margin-left: -40px;
color: #{$slate-shade-100};

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@

<% if let Some(icon) = icon { %>
<span
class="<%= icon_classes %>"
class="<%= icon_classes %> inputs-text-input-icon"
data-action="<%= icon_actions %>">
<%= icon %>
</span>
Expand Down
21 changes: 20 additions & 1 deletionpgml-dashboard/src/components/pages/demo/template.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@
<% use crate::components::inputs::select::{Select, Option}; %>
<% use crate::components::inputs::{SwitchV2, Radio, Checkbox}; %>
<% use crate::components::cards::{Rgb, Secondary, Primary}; %>
<% use crate::components::inputs::labels::WithTooltip; %>

<div class="container" data-controller="pages-demo">
<div class="py-5">
Expand DownExpand Up@@ -59,8 +60,14 @@
</div>

<div class="py-5">
<%
let label = WithTooltip::new("Name".into())
.tooltip("Your full name.")
.icon("info");
%>

<%+ Input::new()
.label("What is your name?".into())
.label(label.into())
.icon("person")
.placeholder("Enter your name")
.name("name")
Expand DownExpand Up@@ -201,4 +208,16 @@
</div>
</div>
</div>

<div class="py-5">
<%+ WithTooltip::new("Model".into())
.tooltip("A model is great, but two is better.")
.icon("help_outline") %>
</div>

<div class="py-5">
<%+ WithTooltip::new("Model".into())
.tooltip_html("A model is great<br>, but<br> two<br> is better.")
.icon("help_outline") %>
</div>
</div>
1 change: 1 addition & 0 deletionspgml-dashboard/static/css/modules.scss
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,7 @@
@import "../../src/components/icons/checkmark/checkmark.scss";
@import "../../src/components/icons/twitter/twitter.scss";
@import "../../src/components/inputs/checkbox/checkbox.scss";
@import "../../src/components/inputs/labels/with_tooltip/with_tooltip.scss";
@import "../../src/components/inputs/radio/radio.scss";
@import "../../src/components/inputs/range_group/range_group.scss";
@import "../../src/components/inputs/range_group_v_2/range_group_v_2.scss";
Expand Down
13 changes: 7 additions & 6 deletionspgml-dashboard/static/css/scss/components/_tooltips.scss
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
.tooltip {
--bs-tooltip-bg: #{$primary};
--bs-tooltip-color: #fff;
--bs-tooltip-arrow-width:0;
--bs-tooltip-arrow-height:0;
--bs-tooltip-bg: #{$gray-800};
--bs-tooltip-color:#{$white};
--bs-tooltip-arrow-width:29px;
--bs-tooltip-arrow-height:14px;
--bs-tooltip-margin: 0 0 1rem 0;
--bs-tooltip-padding-y: 16px;
--bs-tooltip-padding-x: 16px;
--bs-tooltip-padding-y: 10px;
--bs-tooltip-padding-x: 10px;
--bs-tooltip-opacity: 1.0;
}
5 changes: 4 additions & 1 deletionpgml-dashboard/static/js/copy.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,10 @@ export default class extends Controller {
navigator.clipboard.writeText(text)

const toastElement = createToast('Copied to clipboard');
showToast(toastElement);

if (toastElement) {
showToast(toastElement);
}
}

}
13 changes: 9 additions & 4 deletionspgml-dashboard/static/js/utilities/toast.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,12 +12,17 @@ function createToast(message) {
toastElement.appendChild(toastBodyElement);

const container = document.getElementById("toast-container");
container.appendChild(toastElement);

// remove from DOM when no longer needed
toastElement.addEventListener("hidden.bs.toast", (e) => e.target.remove());
if (container) {
container.appendChild(toastElement);

return toastElement;
// remove from DOM when no longer needed
toastElement.addEventListener("hidden.bs.toast", (e) => e.target.remove());

return toastElement;
} else {
return null;
}
}

function showToast(toastElement, config) {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp