refactor(features): update title handling to accept dynamic titles array and improve localization support

This commit is contained in:
taroj1205 2025-05-22 21:35:58 +12:00
parent d49e07f060
commit e5941d1a9d
No known key found for this signature in database
GPG key ID: 0FCB6CFFE0981AB7
6 changed files with 22 additions and 21 deletions

View file

@ -19,7 +19,11 @@ const {
}, },
} = getUI(locale) } = getUI(locale)
const { title1 = features.title1, title2 = features.title2, title3 = features.title3 } = Astro.props interface Props {
titles?: string[]
}
const { titles } = Astro.props
const descriptions = Object.values(features.featureTabs).map((tab) => tab.description) const descriptions = Object.values(features.featureTabs).map((tab) => tab.description)
--- ---
@ -29,15 +33,18 @@ const descriptions = Object.values(features.featureTabs).map((tab) => tab.descri
class="relative flex w-full flex-col py-12 text-start lg:py-36" class="relative flex w-full flex-col py-12 text-start lg:py-36"
> >
<Description class="mb-2 text-4xl sm:text-6xl font-bold"> <Description class="mb-2 text-4xl sm:text-6xl font-bold">
<motion.span client:load {...getTitleAnimation(0.2)}> {(titles || features.titles).map((title, index) => (
{title1} title !== '\n' ? (
</motion.span> <motion.span
<motion.span client:load {...getTitleAnimation(0.4)}> client:load
{title2} {...getTitleAnimation(0.2 + index * 0.2)}
</motion.span> >
<motion.span client:load {...getTitleAnimation(0.6)}> {title}
{title3}
</motion.span> </motion.span>
) : (
<br class="hidden md:block" />
)
))}
</Description> </Description>
<motion.p client:load {...getTitleAnimation(0.6)} className="lg:w-1/2"> <motion.p client:load {...getTitleAnimation(0.6)} className="lg:w-1/2">
{features.description} {features.description}

View file

@ -21,7 +21,7 @@ const {
<section id="sponsors" class:list={['py-12', !showSponsors && 'hidden']}> <section id="sponsors" class:list={['py-12', !showSponsors && 'hidden']}>
<div class="mx-auto flex flex-col text-center"> <div class="mx-auto flex flex-col text-center">
<motion.span client:load {...getTitleAnimation(0.2)}> <motion.span client:load {...getTitleAnimation(0.2)}>
<Description class="mb-2 text-6xl font-bold">Our Sponsors</Description> <Description class="mb-2 text-6xl font-bold">{sponsors.title}</Description>
</motion.span> </motion.span>
<motion.span client:load {...getTitleAnimation(0.4)}> <motion.span client:load {...getTitleAnimation(0.4)}>
<Description set:html={sponsors.description} /> <Description set:html={sponsors.description} />

View file

@ -13,7 +13,7 @@ export const i18n = {
* Type definition for UI translations based on the English translation * Type definition for UI translations based on the English translation
* @typedef {Object} UIProps * @typedef {Object} UIProps
*/ */
export type UIProps = typeof UI_EN export type UIProps = typeof UI_EN | typeof UI_JA
export const getIntlLocale = (locale: string) => { export const getIntlLocale = (locale: string) => {
return i18n.LOCALES.find((l) => l.value === locale)?.intl return i18n.LOCALES.find((l) => l.value === locale)?.intl

View file

@ -21,9 +21,7 @@
} }
}, },
"features": { "features": {
"title1": "Productivity", "titles": ["Productivity", "at", "its best"],
"title2": "at",
"title3": "its best",
"description": "Zen Browser is packed with features that help you stay productive and focused. Browsers should be tools that help you get things done, not distractions that keep you from your work.", "description": "Zen Browser is packed with features that help you stay productive and focused. Browsers should be tools that help you get things done, not distractions that keep you from your work.",
"featureTabs": { "featureTabs": {
"workspaces": { "workspaces": {

View file

@ -21,9 +21,7 @@
} }
}, },
"features": { "features": {
"title1": "生産性", "titles": ["生産性", "の", "極み"],
"title2": "の",
"title3": "極み",
"description": "Zenは、生産性と集中力を高める機能が満載です。ブラウザーは作業の妨げではなく、作業を助けるツールであるべきです。", "description": "Zenは、生産性と集中力を高める機能が満載です。ブラウザーは作業の妨げではなく、作業を助けるツールであるべきです。",
"featureTabs": { "featureTabs": {
"workspaces": { "workspaces": {

View file

@ -15,9 +15,7 @@ const {
<Layout title={layout.welcome.title} description={layout.welcome.description}> <Layout title={layout.welcome.title} description={layout.welcome.description}>
<main class="container"> <main class="container">
<Features <Features
title1={welcome.title[0]} titles={welcome.title}
title2={welcome.title[1]}
title3={welcome.title[2]}
/> />
</main> </main>
</Layout> </Layout>