Skip to content

chore(astro): Add unstyled components - #3656

Merged
wobsoriano merged 26 commits into
mainfrom
rob/eco-2-export-unstyled-components
Jul 9, 2024
Merged

chore(astro): Add unstyled components#3656
wobsoriano merged 26 commits into
mainfrom
rob/eco-2-export-unstyled-components

Conversation

@wobsoriano

@wobsoriano wobsoriano commented Jul 2, 2024

Copy link
Copy Markdown
Member

Description

This PR is tackling ECO-2 and adds unstyled sign in, sign up, and sign out components for both Astro and React.

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-bot Bot commented Jul 2, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0d9ccf9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/astro Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wobsoriano
wobsoriano force-pushed the rob/eco-2-export-unstyled-components branch from 1216188 to dc34eb8 Compare July 3, 2024 22:44
@wobsoriano wobsoriano changed the title feat(astro): Add unstyled components chore(astro): Add unstyled components Jul 3, 2024
Base automatically changed from elef/introduce-astro-sdk to main July 4, 2024 09:51
@wobsoriano
wobsoriano force-pushed the rob/eco-2-export-unstyled-components branch 2 times, most recently from 5e251ae to 5aa67d0 Compare July 4, 2024 15:57
Comment thread packages/astro/src/astro-components/react/SignInButton.astro Outdated
Comment thread packages/astro/src/astro-components/unstyled/SignInButton.astro Outdated
Comment on lines +6 to +8
import { customAlphabet, urlAlphabet } from "nanoid";

const safeId = customAlphabet(urlAlphabet, 10)();

@wobsoriano wobsoriano Jul 4, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Starting to notice we're repeating this piece of logic in all our Astro components. I'll make a ticket that will address this

@wobsoriano
wobsoriano marked this pull request as ready for review July 4, 2024 16:09
@wobsoriano
wobsoriano requested a review from panteliselef July 4, 2024 16:09
@wobsoriano
wobsoriano marked this pull request as draft July 4, 2024 16:24
@wobsoriano
wobsoriano marked this pull request as ready for review July 4, 2024 17:58
Comment thread packages/astro/src/astro-components/unstyled/SignInButton.astro Outdated
Comment thread packages/astro/src/astro-components/unstyled/SignInButton.astro Outdated
Comment on lines +1 to +15
---
import type { SignInButtonProps } from "@clerk/astro/client/react";
type Props = SignInButtonProps

import { SignInButton as SignInButtonReact } from "@clerk/astro/client/react";

const props = {
...Astro.props
}
---

<SignInButtonReact
client:load
{...props}
/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So in general we still are not sure if we are keeping astro-components/react. Do you think we should ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think we should just drop it. Unstyled components won't benefit here anyway since islands don't support React.cloneElement

Comment thread packages/astro/src/astro-components/unstyled/SignInButton.astro Outdated
Comment on lines +24 to +26
btn.addEventListener("click", () => {
window.Clerk.signOut({ redirectUrl })
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know that this is how it is implemented in clerk-react but can you find out if we maybe need to respect all the functionality signOut provides ? Type here

@wobsoriano wobsoriano Jul 8, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nice catch. I think we need to respect the sessionId since it's needed if a user wants to sign out of a specific session.

Also, looking at the SignOutButton reference, the callback is never stated and it's recommended to migrate to redirectUrl in the Core 2 migration doc. So are we looking at deprecation of the callback property in the future here?

The signOutCallback prop on the component has been removed. Instead, you can use the redirectUrl prop

@wobsoriano wobsoriano Jul 9, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added sessionId to sign out options. We had a small discussion in Slack about this. signOutCallback is removed.

Here's a reference to where the sessionId was accidentally ignored

Comment thread packages/astro/src/client/react/types.ts
Comment thread packages/astro/src/client/react/utils.tsx
@wobsoriano
wobsoriano force-pushed the rob/eco-2-export-unstyled-components branch from 3118dbf to d405525 Compare July 8, 2024 19:19
chore(astro): use data attribute in referencing unstyled components
@wobsoriano
wobsoriano force-pushed the rob/eco-2-export-unstyled-components branch from 0c22841 to 45ae288 Compare July 8, 2024 19:34
@wobsoriano
wobsoriano merged commit 7ffb4b0 into main Jul 9, 2024
@wobsoriano
wobsoriano deleted the rob/eco-2-export-unstyled-components branch July 9, 2024 19:44
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.

4 participants