-
Notifications
You must be signed in to change notification settings - Fork 464
feat(ui): add Mosaic SubmitButton #9342
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,2 @@ | ||
| --- | ||
| --- | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| export { Button } from './button'; | ||
| export type { ButtonProps } from './button'; | ||
| export { SubmitButton } from './submit-button'; | ||
| export type { SubmitButtonProps } from './submit-button'; | ||
| // Named here rather than only inside `SubmitButtonProps`, so a consumer can type the object they | ||
| // pass to `spinDelay`. | ||
| export type { SpinDelayOptions } from '../../hooks/useSpinDelay'; |
53 changes: 53 additions & 0 deletions
53
packages/ui/src/mosaic/components/button/submit-button.styles.ts
This file contains hidden or 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,53 @@ | ||
| import * as stylex from '@stylexjs/stylex'; | ||
|
|
||
| export const styles = stylex.create({ | ||
| // The containing block the spinner centers against. Unconditional, so the button's stacking | ||
| // and its coarse-pointer `::after` overlay behave the same in both states. | ||
| root: { | ||
| position: 'relative', | ||
| }, | ||
| // Button gates its hover and pressed fills on `:enabled`, which a pending button still is — | ||
| // `aria-disabled` keeps it focusable, so the native attribute is out. Dropping pointer events | ||
| // stops `:hover` and `:active` matching for the pointer in one line, across every variant cell. | ||
| // Unlike `disabled` there's nothing lost by it: pending is self-explanatory and brief, so the | ||
| // button isn't carrying a tooltip that has to stay hoverable to explain itself. | ||
| // | ||
| // It doesn't cover the keyboard, though — a focused button still takes `:active` from space and | ||
| // enter with no pointer involved. That half is handled where the fills are declared, by the | ||
| // `:not([data-pending])` on each cell's active selector in `button.styles.ts`. | ||
| rootPending: { | ||
| pointerEvents: 'none', | ||
| }, | ||
|
|
||
| // One box around every child, so the whole content fades as a unit rather than per-run. It | ||
| // stands in for the button's own content row — `gap` picks up whatever the size axis set — | ||
| // so an icon and its label keep their spacing across the extra nesting level. | ||
| content: { | ||
| gap: 'inherit', | ||
| alignItems: 'center', | ||
| display: 'inline-flex', | ||
| // Releases the flex-item min-width floor so the label boxes inside can still clip. | ||
| minWidth: 0, | ||
| }, | ||
| // Opacity rather than unmounting the label or swapping in the spinner: the content keeps its | ||
| // box, so the button holds its width and nothing around it reflows when the state flips. | ||
| contentPending: { | ||
| opacity: 0, | ||
| }, | ||
|
|
||
| // Out of flow and centered by `inset: 0` + `margin: auto`, which resolves against the padding | ||
| // box on both axes without a transform and stays correct under any writing mode. | ||
| spinner: { | ||
| margin: 'auto', | ||
| insetBlock: 0, | ||
| insetInline: 0, | ||
| position: 'absolute', | ||
| }, | ||
| // The spinner mounts the instant the action starts but waits out `useSpinDelay` before it is | ||
| // drawn, so a fast action never flashes one. Hiding it with `opacity` rather than by not | ||
| // rendering it is what keeps the progressbar in the accessibility tree for the whole action — | ||
| // `visibility: hidden` or `display: none` would take it back out. | ||
| spinnerHidden: { | ||
| opacity: 0, | ||
| }, | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Add a
@clerk/uirelease entry.This PR adds public
SubmitButtonandSpinnerexports. The empty Changeset creates no package version or changelog entry. Add a minor@clerk/uiChangeset.As per coding guidelines, “Use Changesets for version management and changelogs.” Based on learnings, an empty Changeset is acceptable only when no published package release is involved.
Proposed Changeset
📝 Committable suggestion
🤖 Prompt for AI Agents
Sources: Coding guidelines, Learnings