-
Notifications
You must be signed in to change notification settings - Fork 475
feat(mosaic): add OrganizationProfile scaffold #9839
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
Open
prestonwebdev
wants to merge
7
commits into
main
Choose a base branch
from
prestonwebdev/org-profile-scaffold
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
da73504
feat(mosaic): Add OrganizationProfile scaffold with Tabs and ActionBar
prestonwebdev 7dd83b1
Merge origin/main into prestonwebdev/org-profile-scaffold
prestonwebdev 6c24670
ci(mosaic): raise the styles.css bundlewatch budget to 14KB
prestonwebdev dff326f
fix(mosaic): address review findings on the organization profile
prestonwebdev ca3cd45
fix(mosaic): drop the bulk-bar inset on the embedded organization pro…
prestonwebdev b0a747e
refactor(mosaic): separate organization profile prerequisites
prestonwebdev ffdfd21
docs(mosaic): scope organization profile changeset
prestonwebdev 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,5 @@ | ||
| --- | ||
| '@clerk/mosaic': patch | ||
| --- | ||
|
|
||
| Add an initial `OrganizationProfileView`: an organization profile surface built on the `Profile` shell, with a sidebar of General, Members, Security, Billing, and API Keys pages. The General page provides workspace detail editing and guarded leave and delete actions. The Members page is a first pass at a responsive members table with avatars, sortable columns, row selection, bulk actions, and empty and filtered-no-results states for members, invitations, and requests. New `organizationProfile` localization keys ship with it. | ||
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,6 +1,6 @@ | ||
| { | ||
| "files": [ | ||
| { "path": "./dist/index.js", "maxSize": "125KB" }, | ||
| { "path": "./dist/styles.css", "maxSize": "12KB" } | ||
| { "path": "./dist/styles.css", "maxSize": "14KB" } | ||
| ] | ||
| } |
82 changes: 82 additions & 0 deletions
82
packages/mosaic/src/components/action-bar/action-bar.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,82 @@ | ||
| import * as stylex from '@stylexjs/stylex'; | ||
|
|
||
| import { | ||
| colorVars, | ||
| durationVars, | ||
| easingVars, | ||
| fontWeightVars, | ||
| radiusVars, | ||
| shadowVars, | ||
| space, | ||
| typeScaleVars, | ||
| } from '../../tokens.stylex'; | ||
|
|
||
| const reduceMotion = '@media (prefers-reduced-motion: reduce)'; | ||
|
|
||
| export const styles = stylex.create({ | ||
| positioner: { | ||
| display: 'flex', | ||
| justifyContent: 'center', | ||
| pointerEvents: 'none', | ||
| zIndex: 1, | ||
| bottom: space['2'], | ||
| }, | ||
| // Anchored to the nearest positioned ancestor — for a bounded container. | ||
| positionerAbsolute: { | ||
| insetInline: 0, | ||
| position: 'absolute', | ||
| }, | ||
| // Pinned to the foot of the nearest scroll container, so it stays in view while its surface | ||
| // scrolls. `margin-block-start: auto` drops it to the bottom when the column has room to spare. | ||
| positionerSticky: { | ||
| marginBlockStart: 'auto', | ||
| position: 'sticky', | ||
| }, | ||
| bar: { | ||
| borderRadius: radiusVars['--cl-radius-lg'], | ||
| gap: space['1'], | ||
| paddingBlock: space['1'], | ||
| paddingInline: space['1'], | ||
| alignItems: 'center', | ||
| backgroundColor: colorVars['--cl-color-background'], | ||
| boxShadow: shadowVars['--cl-shadow-lg'], | ||
| display: 'flex', | ||
| opacity: { | ||
| default: 1, | ||
| ':is([data-open="false"])': 0, | ||
| }, | ||
| pointerEvents: { | ||
| default: 'auto', | ||
| ':is([data-open="false"])': 'none', | ||
| }, | ||
| transform: { | ||
| default: 'translateY(0)', | ||
| ':is([data-open="false"])': 'translateY(0.25rem)', | ||
| }, | ||
| transitionDuration: { | ||
| default: `${durationVars['--cl-duration-base']}, ${durationVars['--cl-duration-base']}`, | ||
| [reduceMotion]: `${durationVars['--cl-duration-instant']}, ${durationVars['--cl-duration-instant']}`, | ||
| ':is([data-open="false"])': `${durationVars['--cl-duration-instant']}, ${durationVars['--cl-duration-instant']}`, | ||
| }, | ||
| transitionProperty: 'opacity, transform', | ||
| transitionTimingFunction: { | ||
| default: `linear, ${easingVars['--cl-ease-enter']}`, | ||
| }, | ||
| maxWidth: 'calc(100% - 2 * var(--cl-spacing))', | ||
| }, | ||
| count: { | ||
| paddingInline: space['2'], | ||
| color: colorVars['--cl-color-foreground'], | ||
| fontSize: typeScaleVars['--cl-text-sm-size'], | ||
| fontWeight: fontWeightVars['--cl-font-medium'], | ||
| lineHeight: typeScaleVars['--cl-text-sm-leading'], | ||
| whiteSpace: 'nowrap', | ||
| }, | ||
| separator: { | ||
| marginBlock: space['1'], | ||
| marginInline: space['0.5'], | ||
| alignSelf: 'stretch', | ||
| backgroundColor: colorVars['--cl-color-border'], | ||
| width: '1px', | ||
| }, | ||
| }); |
73 changes: 73 additions & 0 deletions
73
packages/mosaic/src/components/action-bar/action-bar.test.tsx
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,73 @@ | ||
| import * as stylex from '@stylexjs/stylex'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import React from 'react'; | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { ActionBar } from './action-bar'; | ||
|
|
||
| const testStyles = stylex.create({ | ||
| positioner: { | ||
| bottom: '20px', | ||
| }, | ||
| }); | ||
|
|
||
| describe('Mosaic ActionBar', () => { | ||
| it('renders a toolbar with its count and reflects data-open', () => { | ||
| render( | ||
| <ActionBar.Root | ||
| open | ||
| aria-label='Bulk actions' | ||
| > | ||
| <ActionBar.Count>3 selected</ActionBar.Count> | ||
| </ActionBar.Root>, | ||
| ); | ||
| const bar = screen.getByRole('toolbar', { name: 'Bulk actions' }); | ||
| expect(bar).toHaveClass('cl-action-bar'); | ||
| expect(bar).toHaveAttribute('data-open', 'true'); | ||
| const count = screen.getByText('3 selected'); | ||
| expect(count).toHaveClass('cl-action-bar-count'); | ||
| expect(count.querySelector('.cl-icon')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('marks the bar inert while closed', () => { | ||
| render( | ||
| <ActionBar.Root | ||
| open={false} | ||
| aria-label='Bulk actions' | ||
| > | ||
| <ActionBar.Count>0 selected</ActionBar.Count> | ||
| </ActionBar.Root>, | ||
| ); | ||
| const bar = screen.getByRole('toolbar', { name: 'Bulk actions', hidden: true }); | ||
| expect(bar).toHaveAttribute('data-open', 'false'); | ||
| expect(bar.inert).toBe(true); | ||
| }); | ||
|
|
||
| it('styles the positioner independently from the bar', () => { | ||
| render( | ||
| <ActionBar.Root | ||
| open | ||
| aria-label='Bulk actions' | ||
| positionerXstyle={testStyles.positioner} | ||
| />, | ||
| ); | ||
| expect(screen.getByRole('toolbar', { name: 'Bulk actions' }).parentElement).toHaveClass( | ||
| ...(stylex.props(testStyles.positioner).className as string).split(' '), | ||
| ); | ||
| }); | ||
|
|
||
| it('dismisses with a labelled button', async () => { | ||
| const onDismiss = vi.fn(); | ||
| render( | ||
| <ActionBar.Root | ||
| open | ||
| aria-label='Bulk actions' | ||
| > | ||
| <ActionBar.Dismiss onClick={onDismiss} /> | ||
| </ActionBar.Root>, | ||
| ); | ||
| await userEvent.click(screen.getByRole('button', { name: 'Clear selection' })); | ||
| expect(onDismiss).toHaveBeenCalledOnce(); | ||
| }); | ||
| }); |
148 changes: 148 additions & 0 deletions
148
packages/mosaic/src/components/action-bar/action-bar.tsx
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,148 @@ | ||
| import * as stylex from '@stylexjs/stylex'; | ||
| import React from 'react'; | ||
|
|
||
| import { useRender } from '../../primitives/utils'; | ||
| import type { MosaicComponentProps, MosaicElementProps, XStyle } from '../../props'; | ||
| import { mergeStyleProps, themeProps } from '../../props'; | ||
| import { reset } from '../../utils/reset.styles'; | ||
| import { Button } from '../button'; | ||
| import { Icon } from '../icon'; | ||
| import { styles } from './action-bar.styles'; | ||
|
|
||
| export interface ActionBarRootProps extends MosaicComponentProps<'div'> { | ||
| /** Whether the bar is shown. Toggling it animates the bar in and out. */ | ||
| open: boolean; | ||
| /** | ||
| * Pins the bar to the foot of the nearest scroll container instead of a positioned ancestor, so | ||
| * it stays in view while a long surface scrolls (a `Profile` page, a modal). Place `ActionBar.Root` | ||
| * as the last child of that scrolling column. Off, the bar is absolute within the nearest | ||
| * positioned ancestor — give that ancestor `position: relative`. | ||
| * | ||
| * @default false | ||
| */ | ||
| sticky?: boolean; | ||
| positionerXstyle?: XStyle; | ||
| } | ||
|
|
||
| /** | ||
| * A floating bar of actions for a selection. It sits at the foot of its container — the nearest | ||
| * positioned ancestor, or the nearest scroll container with `sticky` — and animates in and out with | ||
| * `open`. While `open` is false it is inert and click-through, so the surface underneath stays | ||
| * usable. Compose a count, a separator, the actions, and a dismiss: | ||
| * | ||
| * @example | ||
| * <ActionBar.Root open={count > 0}> | ||
| * <ActionBar.Count>{count} selected</ActionBar.Count> | ||
| * <ActionBar.Separator /> | ||
| * <Menu.Root>…</Menu.Root> | ||
| * <Button color='negative' variant='ghost' shape='square' aria-label='Remove'> | ||
| * <Icon name='trash' /> | ||
| * </Button> | ||
| * <ActionBar.Separator /> | ||
| * <ActionBar.Dismiss onClick={clearSelection} /> | ||
| * </ActionBar.Root> | ||
| */ | ||
| const Root = React.forwardRef<HTMLDivElement, ActionBarRootProps>(function ActionBarRoot( | ||
| { open, sticky = false, render, xstyle, positionerXstyle, children, ...rest }, | ||
| ref, | ||
| ) { | ||
| const barRef = React.useRef<HTMLDivElement>(null); | ||
| React.useEffect(() => { | ||
| if (barRef.current) { | ||
| barRef.current.inert = !open; | ||
| } | ||
| }, [open]); | ||
|
|
||
| const bar = useRender({ | ||
| defaultTagName: 'div', | ||
| render, | ||
| ref: barRef, | ||
| props: { | ||
| ...mergeStyleProps(themeProps('action-bar', { open }), stylex.props(reset.base, styles.bar, xstyle), rest), | ||
| 'data-open': open, | ||
| role: 'toolbar', | ||
| children, | ||
| }, | ||
| }); | ||
|
|
||
| return ( | ||
| <div | ||
| ref={ref} | ||
| {...mergeStyleProps( | ||
| themeProps('action-bar-positioner', { sticky }), | ||
| stylex.props( | ||
| reset.base, | ||
| styles.positioner, | ||
| sticky ? styles.positionerSticky : styles.positionerAbsolute, | ||
| positionerXstyle, | ||
| ), | ||
| )} | ||
| > | ||
| {bar} | ||
| </div> | ||
| ); | ||
| }); | ||
|
|
||
| export type ActionBarCountProps = MosaicComponentProps<'div'>; | ||
|
|
||
| /** The leading count of what is selected, e.g. `3 selected`. */ | ||
| const Count = React.forwardRef<HTMLDivElement, ActionBarCountProps>(function ActionBarCount( | ||
| { render, xstyle, children, ...rest }, | ||
| ref, | ||
| ) { | ||
| return useRender({ | ||
| defaultTagName: 'div', | ||
| render, | ||
| ref, | ||
| props: { | ||
| ...mergeStyleProps(themeProps('action-bar-count'), stylex.props(reset.base, styles.count, xstyle), rest), | ||
| children, | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| export type ActionBarSeparatorProps = MosaicComponentProps<'div'>; | ||
|
|
||
| /** A vertical divider between groups of the bar. */ | ||
| const Separator = React.forwardRef<HTMLDivElement, ActionBarSeparatorProps>(function ActionBarSeparator( | ||
| { render, xstyle, ...rest }, | ||
| ref, | ||
| ) { | ||
| return useRender({ | ||
| defaultTagName: 'div', | ||
| render, | ||
| ref, | ||
| props: { | ||
| ...mergeStyleProps(themeProps('action-bar-separator'), stylex.props(reset.base, styles.separator), rest), | ||
| 'aria-hidden': true, | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| export type ActionBarDismissProps = MosaicElementProps<'button'>; | ||
|
|
||
| /** Dismisses the bar. A ghost icon button; defaults its label to "Clear selection". */ | ||
| const Dismiss = React.forwardRef<HTMLButtonElement, ActionBarDismissProps>(function ActionBarDismiss( | ||
| { xstyle, 'aria-label': ariaLabel, ...rest }, | ||
| ref, | ||
| ) { | ||
| return ( | ||
| <Button | ||
| ref={ref} | ||
| variant='ghost' | ||
| shape='square' | ||
| size='md' | ||
| aria-label={ariaLabel ?? 'Clear selection'} | ||
| {...mergeStyleProps(themeProps('action-bar-dismiss'), stylex.props(xstyle), rest)} | ||
| > | ||
| <Icon name='x' /> | ||
| </Button> | ||
| ); | ||
| }); | ||
|
|
||
| /** | ||
| * A floating bar of actions for a current selection, composed through `ActionBar.Root`, | ||
| * `ActionBar.Count`, `ActionBar.Separator`, and `ActionBar.Dismiss`. The actions themselves | ||
| * (a `Menu`, a `Button`) are whatever children you place between them. | ||
| */ | ||
| export const ActionBar = { Root, Count, Separator, Dismiss }; |
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,7 @@ | ||
| export { ActionBar } from './action-bar'; | ||
| export type { | ||
| ActionBarCountProps, | ||
| ActionBarDismissProps, | ||
| ActionBarRootProps, | ||
| ActionBarSeparatorProps, | ||
| } from './action-bar'; |
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 was deleted.
Oops, something went wrong.
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 | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: clerk/javascript
Length of output: 12508
🏁 Script executed:
cat -n .changeset/organization-profile-scaffold.md cat -n packages/mosaic/package.json rg -n "siblingCount|Pagination" packages/mosaicRepository: clerk/javascript
Length of output: 11123
🏁 Script executed:
Repository: clerk/javascript
Length of output: 4561
🏁 Script executed:
Repository: clerk/javascript
Length of output: 4500
Use a minor changeset for the
Pagination.siblingCountremoval.@clerk/mosaicis at0.0.1, and the repository guidance states that breaking changes can happen in minor releases. Changepatchtominor, or retainsiblingCountas a deprecated no-op for compatibility.🤖 Prompt for AI Agents