-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(astro): Allow child elements in unstyled Astro components (#4122)
- Loading branch information
1 parent
64f433b
commit 17e6c2e
Showing
7 changed files
with
135 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
"@clerk/astro": patch | ||
--- | ||
|
||
Allow child elements in unstyled Astro components. | ||
|
||
Usage: | ||
|
||
```astro | ||
--- | ||
import { SignInButton } from '@clerk/components/astro' | ||
--- | ||
<SignInButton asChild> | ||
<button>Sign in with Clerk</button> | ||
</SignInButton> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 27 additions & 6 deletions
33
packages/astro/src/astro-components/unstyled/SignOutButton.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* This function is used when an element is passed as a default slot and we need | ||
* to add an attribute to it so that we can reference it in a click listener. | ||
*/ | ||
export function addUnstyledAttributeToFirstTag(html: string, attributeValue: string): string { | ||
return html.replace(/(<[^>]+)>/, `$1 data-clerk-unstyled-id="${attributeValue}">`); | ||
} | ||
|
||
/** | ||
* Logs a deprecation warning when the 'as' prop is used. | ||
*/ | ||
export function logAsPropUsageDeprecation() { | ||
if (import.meta.env.PROD) { | ||
return; | ||
} | ||
|
||
console.warn( | ||
`[@clerk/astro] The 'as' prop is deprecated and will be removed in a future version. ` + | ||
`Use the default slot with the 'asChild' prop instead. `, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters