Skip to content

Commit b354214

Browse files
authored
onboarding modules (#1391)
1 parent 9a4db3a commit b354214

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1727
-62
lines changed

packages/pgml-components/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use sailfish::TemplateOnce;
55

6-
#[derive(Default, Clone, TemplateOnce)]
6+
#[derive(Default, Clone, TemplateOnce, Debug)]
77
#[template(path = "components/component.html")]
88
pub struct Component {
99
pub value: String,

pgml-dashboard/Cargo.lock

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pgml-dashboard/src/api/cms.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use yaml_rust::YamlLoader;
1414
use crate::{
1515
components::{cms::index_link::IndexLink, layouts::marketing::base::Theme, layouts::marketing::Base},
1616
guards::Cluster,
17-
responses::{Response, ResponseOk, Template},
17+
responses::{Error, Response, ResponseOk, Template},
1818
templates::docs::*,
1919
utils::{config, markdown::SearchResult},
2020
};
@@ -882,6 +882,37 @@ async fn careers_landing_page(cluster: &Cluster) -> Result<ResponseOk, crate::re
882882
Ok(ResponseOk(layout.render(page)))
883883
}
884884

885+
#[get("/components-library-demo?<search>")]
886+
async fn demo(search: Option<String>) -> Result<Response, Error> {
887+
#[cfg(not(debug_assertions))]
888+
{
889+
let _search = search;
890+
return Ok(Response::not_found());
891+
}
892+
893+
#[cfg(debug_assertions)]
894+
{
895+
use crate::components::dropdown::{DropdownFrame, DropdownItems};
896+
use crate::components::inputs::text::search::SearchOption;
897+
if let Some(search) = search {
898+
let candidates = vec!["hello", "world", "foo", "bar"]
899+
.into_iter()
900+
.filter(|c| c.starts_with(&search))
901+
.map(|c| SearchOption::new(c.into()).into())
902+
.collect::<Vec<pgml_components::Component>>();
903+
904+
Ok(Response::ok(
905+
DropdownFrame::rendered("model-search", DropdownItems::new(candidates).into()).render_once()?,
906+
))
907+
} else {
908+
let layout = Base::new("Demos", None).theme(Theme::Marketing);
909+
910+
let page = crate::components::pages::demo::Demo::new();
911+
Ok(Response::ok(layout.render(page)))
912+
}
913+
}
914+
}
915+
885916
pub fn routes() -> Vec<Route> {
886917
routes![
887918
blog_landing_page,
@@ -896,7 +927,8 @@ pub fn routes() -> Vec<Route> {
896927
get_docs_asset,
897928
get_user_guides,
898929
search,
899-
search_blog
930+
search_blog,
931+
demo,
900932
]
901933
}
902934

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
span[data-controller="badges-large-label"] {
2+
padding: 8px;
3+
background: #{$gray-500};
4+
font-weight: #{$font-weight-medium};
5+
border: 1px solid #{$neon-tint-100};
6+
7+
&.active {
8+
background: #{$neon-tint-100};
9+
border: 1px solid #{$neon-tint-600};
10+
}
11+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use crate::components::stimulus::StimulusAction;
2+
use pgml_components::component;
3+
use sailfish::TemplateOnce;
4+
5+
#[derive(Clone, Debug)]
6+
pub struct LabelCloseOptions {
7+
pub action: StimulusAction,
8+
pub url: String,
9+
}
10+
11+
#[derive(TemplateOnce, Default)]
12+
#[template(path = "badges/large/label/template.html")]
13+
pub struct Label {
14+
value: String,
15+
close_options: Option<LabelCloseOptions>,
16+
active: String,
17+
}
18+
19+
impl Label {
20+
pub fn new(value: &str) -> Label {
21+
Label {
22+
value: value.into(),
23+
close_options: None,
24+
active: "".into(),
25+
}
26+
}
27+
28+
pub fn close_options(mut self, options: LabelCloseOptions) -> Label {
29+
self.close_options = Some(options);
30+
self
31+
}
32+
33+
pub fn active(mut self) -> Label {
34+
self.active = "active".into();
35+
self
36+
}
37+
}
38+
39+
component!(Label);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<% use crate::components::badges::large::label::LabelCloseOptions; %>
2+
3+
<span data-controller="badges-large-label" class="d-inline-flex gap-2 align-items-center rounded-2 <%= active %>">
4+
<span><%= value %></span>
5+
<% if let Some(LabelCloseOptions { action, url }) = close_options { %>
6+
<a href="<%= url %>" data-action="<%= action %>" class="d-inline-flex align-items-center">
7+
<span class="material-symbols-outlined text-white">
8+
close
9+
</span>
10+
</a>
11+
<% } %>
12+
</span>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This file is automatically generated.
2+
// You shouldn't modify it manually.
3+
4+
// src/components/badges/large/label
5+
pub mod label;
6+
pub use label::Label;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file is automatically generated.
2+
// You shouldn't modify it manually.
3+
4+
// src/components/badges/large
5+
pub mod large;
6+
7+
// src/components/badges/small
8+
pub mod small;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
span[data-controller="badges-small-label"] {
2+
span {
3+
font-size: 12px;
4+
font-weight: #{$font-weight-normal};
5+
}
6+
7+
background: #{$gray-800};
8+
padding: 4px 8px;
9+
border-radius: 4px;
10+
11+
text-transform: uppercase;
12+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
use pgml_components::component;
2+
use sailfish::TemplateOnce;
3+
4+
#[derive(TemplateOnce, Default)]
5+
#[template(path = "badges/small/label/template.html")]
6+
pub struct Label {
7+
value: String,
8+
image_url: String,
9+
}
10+
11+
impl Label {
12+
pub fn check_circle(value: &str) -> Label {
13+
Label {
14+
value: value.into(),
15+
image_url: "/dashboard/static/images/icons/check_circle.svg".to_string(),
16+
}
17+
}
18+
19+
pub fn cancel(value: &str) -> Label {
20+
Label {
21+
value: value.into(),
22+
image_url: "/dashboard/static/images/icons/cancel.svg".to_string(),
23+
}
24+
}
25+
26+
pub fn outbound(value: &str) -> Label {
27+
Label {
28+
value: value.into(),
29+
image_url: "/dashboard/static/images/icons/outbound.svg".to_string(),
30+
}
31+
}
32+
33+
pub fn download_for_offline(value: &str) -> Label {
34+
Label {
35+
value: value.into(),
36+
image_url: "/dashboard/static/images/icons/download_for_offline.svg".to_string(),
37+
}
38+
}
39+
40+
pub fn forward_circle(value: &str) -> Label {
41+
Label {
42+
value: value.into(),
43+
image_url: "/dashboard/static/images/icons/forward_circle.svg".to_string(),
44+
}
45+
}
46+
}
47+
48+
component!(Label);

0 commit comments

Comments
 (0)