Skip to content

onboarding modules #1391

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/pgml-components/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use sailfish::TemplateOnce;

#[derive(Default, Clone, TemplateOnce)]
#[derive(Default, Clone, TemplateOnce, Debug)]
#[template(path = "components/component.html")]
pub struct Component {
pub value: String,
Expand Down
13 changes: 7 additions & 6 deletions pgml-dashboard/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 34 additions & 2 deletions pgml-dashboard/src/api/cms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use yaml_rust::YamlLoader;
use crate::{
components::{cms::index_link::IndexLink, layouts::marketing::base::Theme, layouts::marketing::Base},
guards::Cluster,
responses::{Response, ResponseOk, Template},
responses::{Error, Response, ResponseOk, Template},
templates::docs::*,
utils::{config, markdown::SearchResult},
};
Expand Down Expand Up @@ -882,6 +882,37 @@ async fn careers_landing_page(cluster: &Cluster) -> Result<ResponseOk, crate::re
Ok(ResponseOk(layout.render(page)))
}

#[get("/components-library-demo?<search>")]
async fn demo(search: Option<String>) -> Result<Response, Error> {
#[cfg(not(debug_assertions))]
{
let _search = search;
return Ok(Response::not_found());
}

#[cfg(debug_assertions)]
{
use crate::components::dropdown::{DropdownFrame, DropdownItems};
use crate::components::inputs::text::search::SearchOption;
if let Some(search) = search {
let candidates = vec!["hello", "world", "foo", "bar"]
.into_iter()
.filter(|c| c.starts_with(&search))
.map(|c| SearchOption::new(c.into()).into())
.collect::<Vec<pgml_components::Component>>();

Ok(Response::ok(
DropdownFrame::rendered("model-search", DropdownItems::new(candidates).into()).render_once()?,
))
} else {
let layout = Base::new("Demos", None).theme(Theme::Marketing);

let page = crate::components::pages::demo::Demo::new();
Ok(Response::ok(layout.render(page)))
}
}
}

pub fn routes() -> Vec<Route> {
routes![
blog_landing_page,
Expand All @@ -896,7 +927,8 @@ pub fn routes() -> Vec<Route> {
get_docs_asset,
get_user_guides,
search,
search_blog
search_blog,
demo,
]
}

Expand Down
11 changes: 11 additions & 0 deletions pgml-dashboard/src/components/badges/large/label/label.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
span[data-controller="badges-large-label"] {
padding: 8px;
background: #{$gray-500};
font-weight: #{$font-weight-medium};
border: 1px solid #{$neon-tint-100};

&.active {
background: #{$neon-tint-100};
border: 1px solid #{$neon-tint-600};
}
}
39 changes: 39 additions & 0 deletions pgml-dashboard/src/components/badges/large/label/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use crate::components::stimulus::StimulusAction;
use pgml_components::component;
use sailfish::TemplateOnce;

#[derive(Clone, Debug)]
pub struct LabelCloseOptions {
pub action: StimulusAction,
pub url: String,
}

#[derive(TemplateOnce, Default)]
#[template(path = "badges/large/label/template.html")]
pub struct Label {
value: String,
close_options: Option<LabelCloseOptions>,
active: String,
}

impl Label {
pub fn new(value: &str) -> Label {
Label {
value: value.into(),
close_options: None,
active: "".into(),
}
}

pub fn close_options(mut self, options: LabelCloseOptions) -> Label {
self.close_options = Some(options);
self
}

pub fn active(mut self) -> Label {
self.active = "active".into();
self
}
}

component!(Label);
12 changes: 12 additions & 0 deletions pgml-dashboard/src/components/badges/large/label/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% use crate::components::badges::large::label::LabelCloseOptions; %>

<span data-controller="badges-large-label" class="d-inline-flex gap-2 align-items-center rounded-2 <%= active %>">
<span><%= value %></span>
<% if let Some(LabelCloseOptions { action, url }) = close_options { %>
<a href="<%= url %>" data-action="<%= action %>" class="d-inline-flex align-items-center">
<span class="material-symbols-outlined text-white">
close
</span>
</a>
<% } %>
</span>
6 changes: 6 additions & 0 deletions pgml-dashboard/src/components/badges/large/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is automatically generated.
// You shouldn't modify it manually.

// src/components/badges/large/label
pub mod label;
pub use label::Label;
8 changes: 8 additions & 0 deletions pgml-dashboard/src/components/badges/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file is automatically generated.
// You shouldn't modify it manually.

// src/components/badges/large
pub mod large;

// src/components/badges/small
pub mod small;
12 changes: 12 additions & 0 deletions pgml-dashboard/src/components/badges/small/label/label.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
span[data-controller="badges-small-label"] {
span {
font-size: 12px;
font-weight: #{$font-weight-normal};
}

background: #{$gray-800};
padding: 4px 8px;
border-radius: 4px;

text-transform: uppercase;
}
48 changes: 48 additions & 0 deletions pgml-dashboard/src/components/badges/small/label/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use pgml_components::component;
use sailfish::TemplateOnce;

#[derive(TemplateOnce, Default)]
#[template(path = "badges/small/label/template.html")]
pub struct Label {
value: String,
image_url: String,
}

impl Label {
pub fn check_circle(value: &str) -> Label {
Label {
value: value.into(),
image_url: "/dashboard/static/images/icons/check_circle.svg".to_string(),
}
}

pub fn cancel(value: &str) -> Label {
Label {
value: value.into(),
image_url: "/dashboard/static/images/icons/cancel.svg".to_string(),
}
}

pub fn outbound(value: &str) -> Label {
Label {
value: value.into(),
image_url: "/dashboard/static/images/icons/outbound.svg".to_string(),
}
}

pub fn download_for_offline(value: &str) -> Label {
Label {
value: value.into(),
image_url: "/dashboard/static/images/icons/download_for_offline.svg".to_string(),
}
}

pub fn forward_circle(value: &str) -> Label {
Label {
value: value.into(),
image_url: "/dashboard/static/images/icons/forward_circle.svg".to_string(),
}
}
}

component!(Label);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<span data-controller="badges-small-label" class="d-inline-flex gap-2 align-items-center">
<img src="<%= image_url %>" alt="icon" aria-hidden="true" width="14" height="15">
<span><%= value %></span>
</span>
6 changes: 6 additions & 0 deletions pgml-dashboard/src/components/badges/small/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is automatically generated.
// You shouldn't modify it manually.

// src/components/badges/small/label
pub mod label;
pub use label::Label;
4 changes: 4 additions & 0 deletions pgml-dashboard/src/components/cards/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ pub mod blog;
// src/components/cards/newsletter_subscribe
pub mod newsletter_subscribe;
pub use newsletter_subscribe::NewsletterSubscribe;

// src/components/cards/rgb
pub mod rgb;
pub use rgb::Rgb;
38 changes: 38 additions & 0 deletions pgml-dashboard/src/components/cards/rgb/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use pgml_components::{component, Component};
use sailfish::TemplateOnce;

#[derive(TemplateOnce)]
#[template(path = "cards/rgb/template.html")]
pub struct Rgb {
value: Component,
active: bool,
link: Option<String>,
}

impl Default for Rgb {
fn default() -> Self {
Rgb::new("RGB card".into())
}
}

impl Rgb {
pub fn new(value: Component) -> Rgb {
Rgb {
value,
active: false,
link: None,
}
}

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

pub fn link(mut self, link: &str) -> Self {
self.link = Some(link.to_string());
self
}
}

component!(Rgb);
6 changes: 6 additions & 0 deletions pgml-dashboard/src/components/cards/rgb/rgb.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
div[data-controller="cards-rgb"] {
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't tell but If this doesn't have a hover state, it needs one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, it doesn't have one. I don't think there is one in the design. I'll flag it for review and follow up with a PR.

.card {
--bs-card-bg: transparent;
--bs-card-border-color: #{$gray-700};
}
}
17 changes: 17 additions & 0 deletions pgml-dashboard/src/components/cards/rgb/rgb_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
// Activate this card (add RGB).
active() {
this.element
.querySelector(".card")
.classList.add("main-gradient-border-card-1");
}

// Deactivate this card (remove RGB).
inactive() {
this.element
.querySelector(".card")
.classList.remove("main-gradient-border-card-1");
}
}
11 changes: 11 additions & 0 deletions pgml-dashboard/src/components/cards/rgb/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% let active = if active { "main-gradient-border-card-1 active" } else { "" }; %>
<div data-controller="cards-rgb">
<div class="card <%= active %>">
<div class="card-body">
<%+ value %>
<% if let Some(link) = link { %>
<a href="<%= link %>" class="stretched-link"></a>
<% } %>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion pgml-dashboard/src/components/dropdown/dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
}

@mixin dropdown-menu($primary-color: null) {
padding: 20px 0px 40px 0px;
padding: 20px 0px 20px 0px;
overflow-y: auto;

@if ($primary-color) {
Expand Down
8 changes: 8 additions & 0 deletions pgml-dashboard/src/components/dropdown/dropdown_frame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% if let Some(src) = src { %>
<turbo-frame src="<%= src %>" id="<%= id %>">
</turbo-frame>
<% } else { %>
<turbo-frame id="<%= id %>">
<%+ content %>
</turbo-frame>
<% } %>
3 changes: 3 additions & 0 deletions pgml-dashboard/src/components/dropdown/dropdown_items.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% for item in items { %>
<%+ item %>
<% } %>
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy