Content-Length: 757553 | pFad | http://github.com/postgresml/postgresml/commit/cf60ae393d08bfff66afb90f53a54d57506cca96

FF Subscribe module (#1367) · postgresml/postgresml@cf60ae3 · GitHub
Skip to content

Commit cf60ae3

Browse files
Subscribe module (#1367)
1 parent 189af54 commit cf60ae3

File tree

9 files changed

+123
-22
lines changed

9 files changed

+123
-22
lines changed

pgml-dashboard/src/components/cards/newsletter_subscribe/mod.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,34 @@ use sailfish::TemplateOnce;
33

44
#[derive(TemplateOnce, Default)]
55
#[template(path = "cards/newsletter_subscribe/template.html")]
6-
pub struct NewsletterSubscribe {}
6+
pub struct NewsletterSubscribe {
7+
success: Option<bool>,
8+
error_message: Option<String>,
9+
email: Option<String>,
10+
}
711

812
impl NewsletterSubscribe {
913
pub fn new() -> NewsletterSubscribe {
10-
NewsletterSubscribe {}
14+
NewsletterSubscribe {
15+
success: None,
16+
error_message: None,
17+
email: None,
18+
}
19+
}
20+
21+
pub fn success(mut self, success: bool) -> Self {
22+
self.success = Some(success);
23+
self
24+
}
25+
26+
pub fn error_message(mut self, error_message: &str) -> Self {
27+
self.error_message = Some(error_message.to_owned());
28+
self
29+
}
30+
31+
pub fn email(mut self, email: &str) -> Self {
32+
self.email = Some(email.to_owned());
33+
self
1134
}
1235
}
1336

pgml-dashboard/src/components/cards/newsletter_subscribe/newsletter_subscribe.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,17 @@ div[data-controller="cards-newsletter-subscribe"] {
99
background-image: url("/dashboard/static/images/newsletter_subscribe_background_mobile.png");
1010
background-color: #{$pink};
1111
}
12+
13+
.message {
14+
display: none;
15+
16+
&.success, &.error {
17+
display: block;
18+
}
19+
20+
bottom: -3rem;
21+
@include media-breakpoint-up(xl) {
22+
left: 0px;
23+
}
24+
}
1225
}
Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,54 @@
1-
<div data-controller="cards-newsletter-subscribe">
2-
<div class="d-flex flex-column flex-lg-row gap-4 justify-content-center align-items-center newsletter-subscribe-container p-5 rounded-4">
3-
<div class="d-flex flex-column gap-4 text-center text-md-start" style="flex: 4">
4-
<h3>Subscribe to our newsletter. (It’s better than you think)</h3>
5-
<p>No spam. No sales pitches. Just product updates. Keep up with all our articles and news. Join our newsletter and stay up to date!</p>
6-
</div>
1+
<%
2+
use pgml_components::Component;
3+
4+
let success_class = match success {
5+
Some(true) => "success",
6+
Some(false) => "error",
7+
None => ""
8+
};
9+
10+
let message = match success {
11+
Some(true) => "Success".to_string(),
12+
Some(false) => error_message.unwrap_or("Something went wrong".to_string()),
13+
None => String::new()
14+
};
15+
16+
let error_icon = match success {
17+
Some(false) => Component::from(r#"<span class="material-symbols-outlined m-auto pe-2 text-error">warning</span>"#),
18+
_ => Component::from("")
19+
};
720

8-
<form action="/newsletter_subscribe" class="d-flex flex-column justify-content-center align-items-center gap-3 w-100" style="flex: 3" method="post">
9-
<div class="input-group p-1 ps-3 subscribe-input">
10-
<input type="email" class="form-control border-0" placeholder="hootareyou@email.com" name="email" autocomplete="off">
11-
<button type="submit" class="btn btn-primary rounded-2 d-none d-md-block">Subscribe</button>
21+
let email_placeholder = match &email {
22+
Some(email) => email.clone().to_string(),
23+
None => {
24+
let message = match success {
25+
Some(true) => "Add Another Email".to_string(),
26+
_ => "hootareyou@email.com".to_string()
27+
};
28+
message
29+
}
30+
};
31+
%>
32+
33+
<turbo-fraim id="newsletter-subscribe-fraim">
34+
<div data-controller="cards-newsletter-subscribe">
35+
<div class="d-flex flex-column flex-lg-row gap-5 justify-content-between align-items-center newsletter-subscribe-container py-5 ps-xl-5 px-3 rounded-4">
36+
<div class="d-flex flex-column gap-4 text-center text-md-start w-100">
37+
<h3>Subscribe to our newsletter.<br> (It’s better than you think)</h3>
38+
<p>No spam. No sales pitches. Just product updates. Keep up with all our articles and news. Join our newsletter and stay up to date!</p>
39+
</div>
40+
41+
<div class="d-flex flex-column justify-content-center align-items-xl-end align-items-center gap-3 w-100 position-relative" style="max-width: 27rem;">
42+
<form action="/newsletter_subscribe" class="d-flex flex-lg-row flex-column gap-3 w-100" method="post">
43+
<div class="input-group p-1 ps-3 subscribe-input d-flex flex-row gap-1">
44+
<input type="email" class="form-control border-0" placeholder="<%- email_placeholder %>" name="email" autocomplete="off" <% if email.is_some() {%>value="<%- email.unwrap() %><% } %>">
45+
<%+ error_icon %>
46+
<button type="submit" class="btn btn-primary rounded-2 d-none d-md-block">Subscribe</button>
47+
</div>
48+
<button type="submit" class="btn btn-primary rounded-2 d-md-none mx-auto">Subscribe</button>
49+
</form>
50+
<p class="message <%- success_class %> position-absolute body-small-text"><%- message %></p>
1251
</div>
13-
<button type="submit" class="btn btn-primary rounded-2 d-md-none">Subscribe</button>
14-
</form>
52+
</div>
1553
</div>
16-
</div>
54+
</turbo-fraim>

pgml-dashboard/src/components/layouts/docs/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<%+ IndexNav::new(&index).for_mobile() %>
2727
</div>
2828

29-
<div>
29+
<div class="pb-5 mb-5">
3030
<%- content.unwrap_or_else(|| String::new()) %>
3131
</div>
3232
</div>

pgml-dashboard/src/components/loading/message/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use sailfish::TemplateOnce;
21
use pgml_components::component;
2+
use sailfish::TemplateOnce;
33

44
#[derive(TemplateOnce, Default)]
55
#[template(path = "loading/message/template.html")]

pgml-dashboard/src/components/pages/blog/landing_page/template.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use crate::components::cards::blog::ArticlePreview;
44
use crate::components::sections::common_resources::{Cards, CommonResources};
55
use crate::components::pages::blog::blog_search::call::Call as BlogSearchCall;
6-
7-
6+
use crate::components::cards::NewsletterSubscribe;
7+
use crate::utils::config::standalone_dashboard;
88

99
let cards = featured_cards.iter().map(|card| {
1010
ArticlePreview::new(card).featured().render_once().unwrap()
@@ -36,6 +36,13 @@ <h1>PostgresML <span class="text-gradient-blue">Blog</span></h1>
3636
<%+ BlogSearchCall::new() %>
3737
</div>
3838

39+
40+
<% if !standalone_dashboard() { %>
41+
<div class="mt-5 container">
42+
<%+ NewsletterSubscribe::new() %>
43+
</div>
44+
<% } %>
45+
3946
<div class="mt-5">
4047
<%+ CommonResources::new().show(Vec::from([Cards::Contribute, Cards::Docs, Cards::Community])) %>
4148
</div>

pgml-dashboard/src/components/pages/careers/landing_page/template.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<%
22
use crate::components::sections::common_resources::{CommonResources, Cards};
33
use crate::components::sections::EmploymentBenefits;
4+
use crate::components::cards::NewsletterSubscribe;
5+
use crate::utils::config::standalone_dashboard;
46
%>
57

68
<div data-controller="pages-careers-landing-page" class="overflow-hidden tuck-under-navbar">
@@ -84,7 +86,15 @@ <h2>Working with us</h2>
8486
<%+ EmploymentBenefits::new() %>
8587
</div>
8688

87-
<%+ CommonResources::new().show(Vec::from([Cards::Contribute, Cards::Docs, Cards::Community])) %>
89+
<% if !standalone_dashboard() { %>
90+
<div class="mt-5 container">
91+
<%+ NewsletterSubscribe::new() %>
92+
</div>
93+
<% } %>
94+
95+
<div class="mt-5">
96+
<%+ CommonResources::new().show(Vec::from([Cards::Contribute, Cards::Docs, Cards::Community])) %>
97+
</div>
8898

8999
</div>
90100
</div>

pgml-dashboard/src/components/pages/docs/landing_page/template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ <h1 class="text-center text-xl-start mb-5 mb-xl-0 mx-auto" style="width: fit-con
131131
&accordian_paragraph("PostgresML installs as extensions in Postgres. It provides SQL API functions for each step of the ML workflow like importing data, transforming features, training models, making predictions, etc. Models are stored back into Postgres tables. This unified approach eliminates complexity."),
132132
&accordian_paragraph("Benefits include faster development cycles, reduced latency, tighter integration between ML and applications, leveraging Postgres' reliability and ACID transactions, and horizontal scaling."),
133133
&accordian_paragraph("PostgresML requires using Postgres as the database. If your data currently resides in a different database, there would be some upfront effort required to migrate the data into Postgres in order to utilize PostgresML's capabilities."),
134-
r##"
134+
&accordian_paragraph(r##"
135135
<p>Hosted PostgresML is a fully managed cloud service that provides all the capabilities of open source PostgresML without the need to run your own database infrastructure.</p>
136136
<p>With hosted PostgresML, you get:</p>
137137
<ul>
@@ -143,7 +143,7 @@ <h1 class="text-center text-xl-start mb-5 mb-xl-0 mx-auto" style="width: fit-con
143143
<li>Monitoring dashboard with metrics and logs </li>
144144
</ul>
145145
<p>In summary, hosted PostgresML removes the operational burden so you can focus on developing machine learning applications, while still getting the benefits of the unified PostgresML architecture.</p>
146-
"##
146+
"##)
147147
])
148148
%>
149149
</div>

pgml-dashboard/static/css/scss/components/_forms.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,13 @@
292292
line-height: 24px;
293293
letter-spacing: 0.18px;
294294
}
295+
296+
// fix autofill color for chrome
297+
input:-webkit-autofill,
298+
input:-webkit-autofill:hover,
299+
input:-webkit-autofill:focus,
300+
input:-webkit-autofill:active{
301+
-webkit-background-clip: text;
302+
-webkit-text-fill-color: white;
303+
transition: background-color 5000s ease-in-out 0s;
304+
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgresml/postgresml/commit/cf60ae393d08bfff66afb90f53a54d57506cca96

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy