Skip to content

Subscribe module #1367

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 5 commits into from
Mar 12, 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
27 changes: 25 additions & 2 deletions pgml-dashboard/src/components/cards/newsletter_subscribe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,34 @@ use sailfish::TemplateOnce;

#[derive(TemplateOnce, Default)]
#[template(path = "cards/newsletter_subscribe/template.html")]
pub struct NewsletterSubscribe {}
pub struct NewsletterSubscribe {
success: Option<bool>,
error_message: Option<String>,
email: Option<String>,
}

impl NewsletterSubscribe {
pub fn new() -> NewsletterSubscribe {
NewsletterSubscribe {}
NewsletterSubscribe {
success: None,
error_message: None,
email: None,
}
}

pub fn success(mut self, success: bool) -> Self {
self.success = Some(success);
self
}

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,17 @@ div[data-controller="cards-newsletter-subscribe"] {
background-image: url("/dashboard/static/images/newsletter_subscribe_background_mobile.png");
background-color: #{$pink};
}

.message {
display: none;

&.success, &.error {
display: block;
}

bottom: -3rem;
@include media-breakpoint-up(xl) {
left: 0px;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,54 @@
<div data-controller="cards-newsletter-subscribe">
<div class="d-flex flex-column flex-lg-row gap-4 justify-content-center align-items-center newsletter-subscribe-container p-5 rounded-4">
<div class="d-flex flex-column gap-4 text-center text-md-start" style="flex: 4">
<h3>Subscribe to our newsletter. (It’s better than you think)</h3>
<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>
</div>
<%
use pgml_components::Component;

let success_class = match success {
Some(true) => "success",
Some(false) => "error",
None => ""
};

let message = match success {
Some(true) => "Success".to_string(),
Some(false) => error_message.unwrap_or("Something went wrong".to_string()),
None => String::new()
};

let error_icon = match success {
Some(false) => Component::from(r#"<span class="material-symbols-outlined m-auto pe-2 text-error">warning</span>"#),
_ => Component::from("")
};

<form action="/newsletter_subscribe" class="d-flex flex-column justify-content-center align-items-center gap-3 w-100" style="flex: 3" method="post">
<div class="input-group p-1 ps-3 subscribe-input">
<input type="email" class="form-control border-0" placeholder="hootareyou@email.com" name="email" autocomplete="off">
<button type="submit" class="btn btn-primary rounded-2 d-none d-md-block">Subscribe</button>
let email_placeholder = match &email {
Some(email) => email.clone().to_string(),
None => {
let message = match success {
Some(true) => "Add Another Email".to_string(),
_ => "hootareyou@email.com".to_string()
};
message
}
};
%>

<turbo-frame id="newsletter-subscribe-frame">
<div data-controller="cards-newsletter-subscribe">
<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">
<div class="d-flex flex-column gap-4 text-center text-md-start w-100">
<h3>Subscribe to our newsletter.<br> (It’s better than you think)</h3>
<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>
</div>

<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;">
<form action="/newsletter_subscribe" class="d-flex flex-lg-row flex-column gap-3 w-100" method="post">
<div class="input-group p-1 ps-3 subscribe-input d-flex flex-row gap-1">
<input type="email" class="form-control border-0" placeholder="<%- email_placeholder %>" name="email" autocomplete="off" <% if email.is_some() {%>value="<%- email.unwrap() %><% } %>">
<%+ error_icon %>
<button type="submit" class="btn btn-primary rounded-2 d-none d-md-block">Subscribe</button>
</div>
<button type="submit" class="btn btn-primary rounded-2 d-md-none mx-auto">Subscribe</button>
</form>
<p class="message <%- success_class %> position-absolute body-small-text"><%- message %></p>
</div>
<button type="submit" class="btn btn-primary rounded-2 d-md-none">Subscribe</button>
</form>
</div>
</div>
</div>
</turbo-frame>
2 changes: 1 addition & 1 deletion pgml-dashboard/src/components/layouts/docs/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<%+ IndexNav::new(&index).for_mobile() %>
</div>

<div>
<div class="pb-5 mb-5">
<%- content.unwrap_or_else(|| String::new()) %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion pgml-dashboard/src/components/loading/message/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sailfish::TemplateOnce;
use pgml_components::component;
use sailfish::TemplateOnce;

#[derive(TemplateOnce, Default)]
#[template(path = "loading/message/template.html")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use crate::components::cards::blog::ArticlePreview;
use crate::components::sections::common_resources::{Cards, CommonResources};
use crate::components::pages::blog::blog_search::call::Call as BlogSearchCall;


use crate::components::cards::NewsletterSubscribe;
use crate::utils::config::standalone_dashboard;

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


<% if !standalone_dashboard() { %>
<div class="mt-5 container">
<%+ NewsletterSubscribe::new() %>
</div>
<% } %>

<div class="mt-5">
<%+ CommonResources::new().show(Vec::from([Cards::Contribute, Cards::Docs, Cards::Community])) %>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<%
use crate::components::sections::common_resources::{CommonResources, Cards};
use crate::components::sections::EmploymentBenefits;
use crate::components::cards::NewsletterSubscribe;
use crate::utils::config::standalone_dashboard;
%>

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

<%+ CommonResources::new().show(Vec::from([Cards::Contribute, Cards::Docs, Cards::Community])) %>
<% if !standalone_dashboard() { %>
<div class="mt-5 container">
<%+ NewsletterSubscribe::new() %>
</div>
<% } %>

<div class="mt-5">
<%+ CommonResources::new().show(Vec::from([Cards::Contribute, Cards::Docs, Cards::Community])) %>
</div>

</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ <h1 class="text-center text-xl-start mb-5 mb-xl-0 mx-auto" style="width: fit-con
&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."),
&accordian_paragraph("Benefits include faster development cycles, reduced latency, tighter integration between ML and applications, leveraging Postgres' reliability and ACID transactions, and horizontal scaling."),
&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."),
r##"
&accordian_paragraph(r##"
<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>
<p>With hosted PostgresML, you get:</p>
<ul>
Expand All @@ -143,7 +143,7 @@ <h1 class="text-center text-xl-start mb-5 mb-xl-0 mx-auto" style="width: fit-con
<li>Monitoring dashboard with metrics and logs </li>
</ul>
<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>
"##
"##)
])
%>
</div>
Expand Down
10 changes: 10 additions & 0 deletions pgml-dashboard/static/css/scss/components/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,13 @@
line-height: 24px;
letter-spacing: 0.18px;
}

// fix autofill color for chrome
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active{
-webkit-background-clip: text;
-webkit-text-fill-color: white;
transition: background-color 5000s ease-in-out 0s;
}