Skip to content

Update language picker #130

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 16 commits into from
Jan 15, 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 astro-i18next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
export default {
defaultLocale: "en",
showDefaultLocale: true,
locales: ["en", "zh", "es"],
locales: ["en", "es"],
load: ["server", "client"],
}
33 changes: 30 additions & 3 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@
}
},
"NewsletterCTA": {
"title": "Stay updated on the latest Scroll news",
"placeholder": "Enter your email address",
"buttonText": "Sign up"
"title": "Stay up-to-date on the latest Scroll Developer news",
"text": "Roadmap updates, virtual and live events, ecosystem opportunities and more",
"placeholder": "your email address here",
"thankYouForSubscribing": "Thank you for subscribing!",
"correctEmail": "Please use a correct email address.",
"pleaseInsertEmail": "Please insert your email."
}
},
"sidebar": {
Expand Down Expand Up @@ -152,6 +155,30 @@
"additionalResources": "Additional Resources"
}
},
"footer": {
"aboutScroll": {
"title": "About Scroll",
"bugBounty": "Bug Bounty",
"joinUs": "Join Us",
"healthStatus": "Health Status",
"privacyPolicy": "Privacy Policy",
"termsAndConditions": "Terms and Conditions"
},
"resources": {
"title": "Resources",
"scrollDocsURL": "https://docs.scroll.io/",
"blog": "Blog",
"documentation": "Documentation",
"pressKit": "Press Kit"
},
"followUs": {
"title": "Follow Us"
}
},
"pageNotFound": {
"title": "Page not found",
"text": "We're sorry, but we couldn't find the page you were looking for."
},
"notTranslated": {
"notTranslated": "This page has not been translated yet."
}
Expand Down
36 changes: 32 additions & 4 deletions public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@
}
},
"NewsletterCTA": {
"title": "Stay updated on the latest Scroll news",
"placeholder": "Enter your email address",
"buttonText": "Sign up"
"title": "Mantente actualizado con las más recientes noticias sobre el Desarrollo de Scroll",
"text": "Roadmap, actualizaciones, eventos virtuales y presenciales, oportunidades en el ecosistema y más",
"placeholder": "tu correo electrónico aquí",
"thankYouForSubscribing": "¡Gracias por suscribirte!",
"correctEmail": "Por favor usa un correo electrónico válido.",
"pleaseInsertEmail": "Por favor ingresa tu correo electrónico."
}
},
"sidebar": {
Expand Down Expand Up @@ -152,7 +155,32 @@
"additionalResources": "Recursos Adicionales"
}
},
"footer": {
"aboutScroll": {
"title": "Acerca de Scroll",
"bugBounty": "Cazarecompensas de bugs",
"joinUs": "Únete a nosotros",
"healthStatus": "Estado de servicios",
"privacyPolicy": "Políticas de privacidad",
"termsAndConditions": "Terminos y condiciones"
},
"resources": {
"title": "Recursos",
"scrollDocsURL": "https://docs.scroll.io/es",
"blog": "Blog",
"documentation": "Documentación",
"pressKit": "Kit de Prensa"
},
"followUs": {
"title": "Síguenos"
}
},
"pageNotFound": {
"title": "Página no encontrada",
"text": "Lo sentimos, pero no pudimos encontrar la página que buscas."
},
"notTranslated": {
"notTranslated": "Esta página no ha sido traducida aún."
}
},
"This email cannot be added to this list. Please enter a different email address.": "Este correo electrónico no puede ser añadido a la lista. Por favor ingresa uno diferente."
}
10 changes: 10 additions & 0 deletions src/components/Footer/Footer.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
import Subscribe from "./Subscribe/Subscribe.tsx"
import PureFooter from "./PureFooter/PureFooter.tsx"
import i18next from "i18next"
---

<div>
<Subscribe client:idle lang={i18next.language} />
<PureFooter />
</div>
15 changes: 0 additions & 15 deletions src/components/Footer/Footer.tsx

This file was deleted.

13 changes: 6 additions & 7 deletions src/components/Footer/PureFooter/PureFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState, useEffect } from "preact/hooks"
import { aboutList, mediaList, resourceList } from "../helper.tsx"
import styles from "./PureFooter.module.css"
import { t } from "i18next"

const Footer = () => {
return (
Expand All @@ -9,28 +10,28 @@ const Footer = () => {
<img src="/scroll-white.svg" style={{ width: "80px" }} />
</a>
<div className={styles.about}>
<p className={styles.title}>About Scroll</p>
<p className={styles.title}>{ t("footer.aboutScroll.title") }</p>
<ul>
{aboutList.map((item) => (
<li key={item.name} className={styles.content}>
<a href={item.href}>{item.name}</a>
<a href={item.href}>{t(item.name)}</a>
</li>
))}
</ul>
</div>
<div className={styles.resource}>
<p className={styles.title}>Resources</p>
<p className={styles.title}>{ t("footer.resources.title") }</p>
<ul>
{resourceList.map((item) => (
<li key={item.name} className={styles.content}>
<a href={item.href}>{item.name}</a>
<a href={item.href}>{t(item.name)}</a>
</li>
))}
</ul>
</div>

<div className={styles.follow}>
<p className={styles.title}>Follow Us</p>
<p className={styles.title}>{ t("footer.followUs.title") }</p>
<div>
{mediaList.map((item) => (
<a external href={item.href} key={item.name} target="_blank">
Expand All @@ -39,8 +40,6 @@ const Footer = () => {
))}
</div>
</div>

<p className={styles.version}>© Version 1.0.0 Scroll Ltd 2023</p>
</div>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Footer/Subscribe/EmailInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react"
import styles from "./EmailInput.module.css"
import ArrowSvg from "~/assets/svgs/footer/arrow-right.svg?react"
import { clsx } from "~/lib"
import { t } from "i18next"

const EmailInput = (props) => {
const { end, onClick, onEnter, ...restProps } = props
Expand All @@ -23,7 +24,7 @@ const EmailInput = (props) => {
<button className={clsx(styles.iconButton, "dark:text-black")} onClick={onClick} disabled={end}>
<ArrowSvg></ArrowSvg>
</button>
<div className={clsx(styles.success, "dark:text-black", "dark:bg-white")}>Thank you for subscribing!</div>
<div className={clsx(styles.success, "dark:text-black", "dark:bg-white")}>{ t("landing.NewsletterCTA.thankYouForSubscribing") }</div>
</div>
<input
placeholder="your email address here"
Expand Down
17 changes: 10 additions & 7 deletions src/components/Footer/Subscribe/Subscribe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useState, useEffect } from "preact/hooks"
import MailchimpSubscribe from "react-mailchimp-subscribe"
import SubscribeSvg from "~/assets/svgs/footer/subscribe.svg?react"
import { clsx } from "~/lib"
import i18next, { changeLanguage, t } from "i18next"

import EmailInput from "./EmailInput.tsx"
import styles from "./Subscribe.module.css"
Expand All @@ -14,21 +15,23 @@ const isValidEmail = (email: string): boolean => {
return emailRegex.test(email)
}

export default function Subscribe() {
export default function Subscribe(props) {
const [email, setEmail] = useState("")
const [customMessage, setCustomMessage] = useState("")
const [emailValid, setEmailValid] = useState(false)

i18next.changeLanguage(props.lang)

useEffect(() => {
setCustomMessage("")
setEmailValid(isValidEmail(email))
}, [email])

const handleSubmit = (subscribe) => {
if (!email) {
setCustomMessage("Please insert your email.")
setCustomMessage(t("landing.NewsletterCTA.pleaseInsertEmail"))
} else if (!emailValid) {
setCustomMessage("Please use a correct email address.")
setCustomMessage(t("landing.NewsletterCTA.correctEmail"))
} else {
subscribe({ EMAIL: email })
setEmail("")
Expand All @@ -47,9 +50,9 @@ export default function Subscribe() {
</span>

<div className={styles.copyBox}>
<div className={styles.subscribeTitle}>Stay up-to-date on the latest Scroll Developer news</div>
<div className={styles.subscribeTitle}>{ t("landing.NewsletterCTA.title") }</div>
<div className={styles.subscribeText}>
Roadmap updates, virtual and live events, ecosystem opportunities and more
{ t("landing.NewsletterCTA.text") }
</div>
</div>
<MailchimpSubscribe
Expand All @@ -62,11 +65,11 @@ export default function Subscribe() {
onChange={handleChangeEmail}
onClick={() => handleSubmit(subscribe)}
onEnter={() => handleSubmit(subscribe)}
placeholder="your email address here"
placeholder= { t("landing.NewsletterCTA.placeholder") }
end={status === "success"}
/>
{customMessage && <div className={styles.errorMessage}>{customMessage}</div>}
{status === "error" && <div className={styles.errorMessage}>{message}</div>}
{status === "error" && <div className={styles.errorMessage}>{t(message)}</div>}
</div>
)}
/>
Expand Down
16 changes: 8 additions & 8 deletions src/components/Footer/helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,38 @@ const TwitterIcon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (

export const aboutList = [
{
name: "Bug Bounty",
name: "footer.aboutScroll.bugBounty",
href: "https://immunefi.com/bounty/scroll/",
},
{
name: "Join Us",
name: "footer.aboutScroll.joinUs",
href: "https://jobs.lever.co/ScrollFoundation",
},
{
name: "Health Status",
name: "footer.aboutScroll.healthStatus",
href: "https://status.scroll.io/",
},
{
name: "Privacy Policy",
name: "footer.aboutScroll.privacyPolicy",
href: "https://scroll.io/privacy-policy",
},
{
name: "Terms and Conditions",
name: "footer.aboutScroll.termsAndConditions",
href: "https://scroll.io/terms-and-conditions",
},
]

export const resourceList = [
{
name: "Blog",
name: "footer.resources.blog",
href: "https://scroll.io/blog",
},
{
name: "Documentation",
name: "footer.resources.documentation",
href: "https://docs.scroll.io/",
},
{
name: "Press Kit",
name: "footer.resources.pressKit",
href: "https://scrollzkp.notion.site/Scroll-Rebrand-Assets-5bb83465f56f40989c4f772b39ed3a06",
},
]
Expand Down
36 changes: 34 additions & 2 deletions src/components/Header/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ const section = frontmatter?.section ?? ""
</div>
)
}
<ThemeModeToggle client:only="preact" dark={dark} />
<LanguageSelector class="language-selector" />
<span class="theme-item">
<ThemeModeToggle client:only="preact" dark={dark} />
</span>
<LanguageSelector class="language-selector" dark={dark} />
<a href="https://github.com/scroll-tech/scroll-documentation" class="github-url" target="_blank" rel="nofollow">
<span
class={clsx(
Expand Down Expand Up @@ -113,6 +115,7 @@ const section = frontmatter?.section ?? ""
padding-top: 7px;
@apply text-black dark:text-white;
color: var(--textColor);
white-space: nowrap;
}
.nav-link:hover {
@apply text-link;
Expand Down Expand Up @@ -243,4 +246,33 @@ const section = frontmatter?.section ?? ""
grid-template-columns: minmax(230px, 1fr) 5fr;
}
}

/* Very Hacky way to make Spanish not break at narrow screens */

@media (max-width: 72em) and (min-width: 50em) {
.queryResults {
grid-template-columns: 1fr !important;
}

.search-item,
.github-url {
display: none;
}
}

@media (max-width: 62em) and (min-width: 50em) {
.theme-item {
display: none;
}
}

@media (max-width: 58em) and (min-width: 50em) {
.tools {
transform: scale(0.85);
}

.navbar {
gap: 25px;
}
}
</style>
Loading