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

Commit9e90df6

Browse files
committed
subscribe use turbo frames, all unsubscribe, add module to careers page
1 parent5a3cbce commit9e90df6

File tree

7 files changed

+105
-38
lines changed

7 files changed

+105
-38
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-
pubstructNewsletterSubscribe{}
6+
pubstructNewsletterSubscribe{
7+
success:Option<bool>,
8+
error_message:Option<String>,
9+
email:Option<String>,
10+
}
711

812
implNewsletterSubscribe{
913
pubfnnew() ->NewsletterSubscribe{
10-
NewsletterSubscribe{}
14+
NewsletterSubscribe{
15+
success:None,
16+
error_message:None,
17+
email:None,
18+
}
19+
}
20+
21+
pubfnsuccess(mutself,success:bool) ->Self{
22+
self.success =Some(success);
23+
self
24+
}
25+
26+
pubfnerror_message(mutself,error_message:&str) ->Self{
27+
self.error_message =Some(error_message.to_owned());
28+
self
29+
}
30+
31+
pubfnemail(mutself,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+
@includemedia-breakpoint-up(xl) {
22+
left:0px;
23+
}
24+
}
1225
}

‎pgml-dashboard/src/components/cards/newsletter_subscribe/newsletter_subscribe_controller.js

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,54 @@
1-
<divdata-controller="cards-newsletter-subscribe">
2-
<divclass="d-flex flex-column flex-lg-row gap-4 justify-content-center align-items-center newsletter-subscribe-container p-5 rounded-4">
3-
<divclass="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#"<spanclass="material-symbols-outlined m-auto pe-2 text-error">warning</span>"#),
18+
_ => Component::from("")
19+
};
720

8-
<formaction="/newsletter_subscribe"class="d-flex flex-column justify-content-center align-items-center gap-3 w-100"style="flex: 3"method="post"data-cards-newsletter-subscribe-target="form">
9-
<divclass="input-group p-1 ps-3 subscribe-input">
10-
<inputtype="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> -->
12-
<buttontype="button"class="btn btn-primary rounded-2 d-none d-md-block"data-action="cards-newsletter-subscribe#submitRequest">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-frameid="newsletter-subscribe-frame">
34+
<divdata-controller="cards-newsletter-subscribe">
35+
<divclass="d-flex flex-column flex-lg-row gap-5 justify-content-between align-items-center newsletter-subscribe-container p-5 rounded-4">
36+
<divclass="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+
<divclass="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+
<formaction="/newsletter_subscribe"class="d-flex flex-lg-row flex-column gap-3 w-100"method="post">
43+
<divclass="input-group p-1 ps-3 subscribe-input">
44+
<inputtype="email"class="form-control border-0"placeholder="<%- email_placeholder %>"name="email"autocomplete="off"<% if email.is_some() {%>value="<%- email.unwrap() %><% } %>">
45+
<%+ error_icon %>
46+
<buttontype="submit"class="btn btn-primary rounded-2 d-none d-md-block">Subscribe</button>
47+
</div>
48+
<buttontype="submit"class="btn btn-primary rounded-2 d-md-none mx-auto">Subscribe</button>
49+
</form>
50+
<pclass="message <%- success_class %> position-absolute body-small-text"><%- message %></p>
1351
</div>
14-
<buttontype="submit"class="btn btn-primary rounded-2 d-md-none"data-action="cards-newsletter-subscribe#submitRequest">Subscribe</button>
15-
</form>
52+
</div>
1653
</div>
17-
</div>
54+
</turbo-frame>

‎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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
use crate::components::sections::common_resources::{Cards, CommonResources};
55
use crate::components::pages::blog::blog_search::call::Call as BlogSearchCall;
66
use crate::components::cards::NewsletterSubscribe;
7-
8-
7+
use crate::utils::config::standalone_dashboard;
98

109
let cards = featured_cards.iter().map(|card| {
1110
ArticlePreview::new(card).featured().render_once().unwrap()
@@ -37,9 +36,12 @@ <h1>PostgresML <span class="text-gradient-blue">Blog</span></h1>
3736
<%+ BlogSearchCall::new() %>
3837
</div>
3938

39+
40+
<% if !standalone_dashboard() { %>
4041
<divclass="mt-5 container">
4142
<%+ NewsletterSubscribe::new() %>
4243
</div>
44+
<% } %>
4345

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

‎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
<divdata-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+
<divclass="mt-5 container">
91+
<%+ NewsletterSubscribe::new() %>
92+
</div>
93+
<% } %>
94+
95+
<divclass="mt-5">
96+
<%+ CommonResources::new().show(Vec::from([Cards::Contribute, Cards::Docs, Cards::Community])) %>
97+
</div>
8898

8999
</div>
90100
</div>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp