Skip to content

Commit 17846f3

Browse files
authored
fix(clerk-js): Fix border inconsistencies (clerk#2841)
* fix(clerk-js): Fix border inconsistencies * chore(repo): Add Changeset * fix(clerk-js): Don't apply borders to empty elements
1 parent 237d483 commit 17846f3

8 files changed

Lines changed: 56 additions & 39 deletions

File tree

‎.changeset/dirty-mayflies-heal.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

‎packages/clerk-js/src/ui/components/OrganizationSwitcher/OrganizationSwitcherPopover.tsx‎

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ export const OrganizationSwitcherPopover = React.forwardRef<HTMLDivElement, Orga
177177
sx={t => ({
178178
width: '100%',
179179
paddingRight: t.space.$5,
180-
borderBottom: `${t.borders.$normal} ${t.colors.$neutralAlpha100}`,
181180
})}
182181
>
183182
<OrganizationPreview
@@ -204,24 +203,28 @@ export const OrganizationSwitcherPopover = React.forwardRef<HTMLDivElement, Orga
204203
{...rest}
205204
>
206205
<PopoverCard.Content elementDescriptor={descriptors.organizationSwitcherPopoverMain}>
207-
{currentOrg
208-
? selectedOrganizationPreview(currentOrg)
209-
: !hidePersonal && (
210-
<PersonalWorkspacePreview
211-
user={userWithoutIdentifiers}
212-
sx={t => ({
213-
padding: `${t.space.$4} ${t.space.$5}`,
214-
borderBottom: `${t.borders.$normal} ${t.colors.$neutralAlpha100}`,
215-
width: '100%',
216-
})}
217-
title={localizationKeys('organizationSwitcher.personalWorkspace')}
218-
/>
219-
)}
220-
<OrganizationActionList
221-
onCreateOrganizationClick={handleCreateOrganizationClicked}
222-
onPersonalWorkspaceClick={handlePersonalWorkspaceClicked}
223-
onOrganizationClick={handleOrganizationClicked}
224-
/>
206+
<Actions
207+
elementDescriptor={descriptors.organizationSwitcherPopoverActions}
208+
role='menu'
209+
>
210+
{currentOrg
211+
? selectedOrganizationPreview(currentOrg)
212+
: !hidePersonal && (
213+
<PersonalWorkspacePreview
214+
user={userWithoutIdentifiers}
215+
sx={t => ({
216+
padding: `${t.space.$4} ${t.space.$5}`,
217+
width: '100%',
218+
})}
219+
title={localizationKeys('organizationSwitcher.personalWorkspace')}
220+
/>
221+
)}
222+
<OrganizationActionList
223+
onCreateOrganizationClick={handleCreateOrganizationClicked}
224+
onPersonalWorkspaceClick={handlePersonalWorkspaceClicked}
225+
onOrganizationClick={handleOrganizationClicked}
226+
/>
227+
</Actions>
225228
</PopoverCard.Content>
226229
<PopoverCard.Footer elementDescriptor={descriptors.organizationSwitcherPopoverFooter} />
227230
</PopoverCard.Root>

‎packages/clerk-js/src/ui/components/OrganizationSwitcher/OtherOrganizationActions.tsx‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useUser } from '@clerk/shared/react';
22
import React from 'react';
33

44
import { descriptors, localizationKeys } from '../../customizables';
5-
import { Action, Actions } from '../../elements';
5+
import { Action } from '../../elements';
66
import { Add } from '../../icons';
77
import { UserInvitationSuggestionList } from './UserInvitationSuggestionList';
88
import type { UserMembershipListProps } from './UserMembershipList';
@@ -33,7 +33,6 @@ const CreateOrganizationButton = ({
3333
label={localizationKeys('organizationSwitcher.action__createOrganization')}
3434
onClick={onCreateOrganizationClick}
3535
sx={t => ({
36-
borderTop: `${t.borders.$normal} ${t.colors.$neutralAlpha100}`,
3736
padding: `${t.space.$5} ${t.space.$5}`,
3837
})}
3938
iconSx={t => ({
@@ -55,13 +54,8 @@ export const OrganizationActionList = (props: OrganizationActionListProps) => {
5554
return (
5655
<>
5756
<UserInvitationSuggestionList onOrganizationClick={onOrganizationClick} />
58-
<Actions
59-
elementDescriptor={descriptors.organizationSwitcherPopoverActions}
60-
role='menu'
61-
>
62-
<UserMembershipList {...{ onPersonalWorkspaceClick, onOrganizationClick }} />
63-
<CreateOrganizationButton {...{ onCreateOrganizationClick }} />
64-
</Actions>
57+
<UserMembershipList {...{ onPersonalWorkspaceClick, onOrganizationClick }} />
58+
<CreateOrganizationButton {...{ onCreateOrganizationClick }} />
6559
</>
6660
);
6761
};

‎packages/clerk-js/src/ui/components/OrganizationSwitcher/UserInvitationSuggestionList.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ const Preview = (
109109
sx={t => ({
110110
justifyContent: 'space-between',
111111
padding: `${t.space.$4} ${t.space.$5}`,
112-
borderBottom: `${t.borders.$normal} ${t.colors.$neutralAlpha100}`,
113112
})}
114113
>
115114
<OrganizationPreview
@@ -225,6 +224,11 @@ export const UserInvitationSuggestionList = (props: UserInvitationSuggestionList
225224
// Solve weird bug with swr while running unit tests
226225
const userInvitationsData = userInvitations.data?.filter(a => !!a);
227226
const userSuggestionsData = userSuggestions.data?.filter(a => !!a);
227+
228+
if (!hasAnyData && !isLoading) {
229+
return null;
230+
}
231+
228232
return (
229233
<SwitcherInvitationActions
230234
showBorder={hasAnyData || isLoading}

‎packages/clerk-js/src/ui/components/OrganizationSwitcher/UserMembershipList.tsx‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ export const UserMembershipList = (props: UserMembershipListProps) => {
6464
// 4 items + 4px border (four 1px borders)
6565
maxHeight: `calc((4 * ${t.sizes.$17}) + 4px)`,
6666
overflowY: 'auto',
67-
...common.unstyledScrollbar(t),
68-
'> button:not(:first-of-type)': {
69-
borderTop: `${t.borders.$normal} ${t.colors.$neutralAlpha100} `,
67+
'> button,div': { border: `0 solid ${t.colors.$neutralAlpha100}` },
68+
'>:not([hidden])~:not([hidden])': {
69+
borderTopWidth: '1px',
70+
borderBottomWidth: '0',
7071
},
72+
...common.unstyledScrollbar(t),
7173
})}
7274
role='group'
7375
aria-label={hidePersonal ? 'List of all organization memberships' : 'List of all accounts'}
@@ -93,6 +95,9 @@ export const UserMembershipList = (props: UserMembershipListProps) => {
9395
icon={SwitchArrowRight}
9496
onClick={() => onOrganizationClick(organization)}
9597
role='menuitem'
98+
sx={t => ({
99+
border: `0 solid ${t.colors.$neutralAlpha100}`,
100+
})}
96101
>
97102
<OrganizationPreview
98103
elementId='organizationSwitcherListedOrganization'

‎packages/clerk-js/src/ui/components/SignIn/SignInAccountSwitcher.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ const _SignInAccountSwitcher = () => {
3333
<Col
3434
elementDescriptor={descriptors.main}
3535
gap={8}
36-
sx={t => ({ borderTop: `${t.borders.$normal} ${t.colors.$neutralAlpha100}` })}
36+
sx={t => ({
37+
borderTop: `${t.borders.$normal} ${t.colors.$neutralAlpha100}`,
38+
})}
3739
>
3840
<Actions role='menu'>
3941
{activeSessions.map(s => (

‎packages/clerk-js/src/ui/components/UserButton/SessionActions.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export const SingleSessionActions = (props: SingleSessionActionsProps) => {
2020
role='menu'
2121
elementDescriptor={descriptors.userButtonPopoverActions}
2222
elementId={descriptors.userButtonPopoverActions.setId('singleSession')}
23+
sx={t => ({
24+
borderTop: `${t.borders.$normal} ${t.colors.$neutralAlpha100}`,
25+
})}
2326
>
2427
<Action
2528
elementDescriptor={descriptors.userButtonPopoverActionButton}
@@ -83,9 +86,6 @@ export const MultiSessionActions = (props: MultiSessionActionsProps) => {
8386
role='menu'
8487
elementDescriptor={descriptors.userButtonPopoverActions}
8588
elementId={descriptors.userButtonPopoverActions.setId('multiSession')}
86-
sx={t => ({
87-
borderBottom: `${t.borders.$normal} ${t.colors.$neutralAlpha100}`,
88-
})}
8989
>
9090
<Flex
9191
justify='between'
@@ -115,7 +115,12 @@ export const MultiSessionActions = (props: MultiSessionActionsProps) => {
115115
/>
116116
</Flex>
117117
</SmallActions>
118-
<Actions role='menu'>
118+
<Actions
119+
role='menu'
120+
sx={t => ({
121+
borderTop: `${t.borders.$normal} ${t.colors.$neutralAlpha100}`,
122+
})}
123+
>
119124
{otherSessions.map(session => (
120125
<PreviewButton
121126
key={session.id}

‎packages/clerk-js/src/ui/elements/Actions.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ export const Actions = (props: PropsOfComponent<typeof Flex>) => {
1313
<Col
1414
sx={[
1515
t => ({
16-
'> button:not(:first-of-type)': {
17-
borderTop: `${t.borders.$normal} ${t.colors.$neutralAlpha100} `,
16+
'> button,div': { border: `0 solid ${t.colors.$neutralAlpha100}` },
17+
'>:not([hidden],:empty)~:not([hidden],:empty)': {
18+
borderTopWidth: '1px',
19+
borderBottomWidth: '0',
1820
},
1921
}),
2022
sx,

0 commit comments

Comments
 (0)