Skip to content
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

Locale Switcher #75

Open
wants to merge 10 commits into
base: 0.5
Choose a base branch
from
Open

Locale Switcher #75

wants to merge 10 commits into from

Conversation

jeremybosma
Copy link
Member

No description provided.

src/components/LocaleSwitcher.astro Outdated Show resolved Hide resolved
src/components/LocaleSwitcher.astro Outdated Show resolved Hide resolved
src/components/LocaleSwitcher.astro Outdated Show resolved Hide resolved
Copy link

cloudflare-workers-and-pages bot commented Sep 30, 2024

Deploying ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9592310
Status: ✅  Deploy successful!
Preview URL: https://cdc66043.ui-eey.pages.dev
Branch Preview URL: https://0-5-localeswitcher.ui-eey.pages.dev

View logs

@@ -0,0 +1,27 @@
---
import Select from 'fulldev-ui/components/Select.astro'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destructure the props needed, and also a restprops

Astro.props.locales && (
<Select
name="locale-switcher"
options={Astro.props.locales}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the destructured props and also pass the restprops

@@ -0,0 +1,27 @@
---
import Select from 'fulldev-ui/components/Select.astro'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a type, you can use a modified version of ComponentProps You should omit values not needed, and add values that are unique for the LocaleSelect

const target = event.target
const selectedLocale = target.value
const currentUrl = new URL(window.location.href)
currentUrl.pathname = '/' + selectedLocale + currentUrl.pathname
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a template string instead, like /${selectedLocale}....etc

const target = event.target
const selectedLocale = target.value
const currentUrl = new URL(window.location.href)
currentUrl.pathname = '/' + selectedLocale + currentUrl.pathname
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this a new const instead

@@ -0,0 +1,18 @@
---
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it a habit to turn PascalCase in component names to kebab-case in md/mdx etc

So locale-select.mdx

import LocaleSelect from 'fulldev-ui/components/LocaleSelect.astro'
---

<LocaleSelect />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will be invisible because there are no locales passes as props, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants