Skip to content

Commit a1ae457

Browse files
authored
fix(clerk-js): Button variants and color alignments (clerk#2711)
* fix(clerk-js): Remove usage of the secondaryDanger button * fix(clerk-js): Align primary button with designs * feat(clerk-js): Add colorTextLabel variable * feat(clerk-js): Auto generated secondary button hover color * fix(clerk-js): Remove ghost primary button variant * chore(clerk-js): Have all session actions in one place * refactor(clerk-js): Refactor button variants into variants and color schemes
1 parent 4b7130c commit a1ae457

40 files changed

+355
-415
lines changed

.changeset/funny-pianos-double.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/clerk-js/src/ui/common/RemoveResourceForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const RemoveResourceForm = withCardStateProvider((props: RemoveFormProps)
3535
localizationKey={messageLine2}
3636
/>
3737
<FormButtons
38-
variant='primaryDanger'
38+
colorScheme='danger'
3939
onReset={onReset}
4040
/>
4141
</Form.Root>

packages/clerk-js/src/ui/components/OrganizationList/OrganizationListPage.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useState } from 'react';
33

44
import { useEnvironment, useOrganizationListContext } from '../../contexts';
55
import { Box, Col, descriptors, Flex, localizationKeys, Spinner } from '../../customizables';
6-
import { Action, Card, Header, SecondaryActions, useCardState, withCardStateProvider } from '../../elements';
6+
import { Action, Actions, Card, Header, useCardState, withCardStateProvider } from '../../elements';
77
import { useInView } from '../../hooks';
88
import { Add } from '../../icons';
99
import { CreateOrganizationForm } from '../CreateOrganization/CreateOrganizationForm';
@@ -149,7 +149,7 @@ const OrganizationListPageList = (props: { onCreateOrganizationClick: () => void
149149
sx={t => ({ borderTop: `${t.borders.$normal} ${t.colors.$blackAlpha100}` })}
150150
>
151151
<PreviewListItems>
152-
<SecondaryActions role='menu'>
152+
<Actions role='menu'>
153153
<PersonalAccountPreview />
154154
{(userMemberships.count || 0) > 0 &&
155155
userMemberships.data?.map(inv => {
@@ -183,7 +183,7 @@ const OrganizationListPageList = (props: { onCreateOrganizationClick: () => void
183183
})}
184184

185185
{(hasNextPage || isLoading) && <PreviewListSpinner ref={ref} />}
186-
</SecondaryActions>
186+
</Actions>
187187
</PreviewListItems>
188188

189189
<Action

packages/clerk-js/src/ui/components/OrganizationList/shared.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const PreviewListItemButton = (props: Parameters<typeof Button>[0]) => {
9797
<Button
9898
elementDescriptor={descriptors.organizationListPreviewItemActionButton}
9999
textVariant='buttonSmall'
100-
variant='secondary'
100+
variant='outline'
101101
size='xs'
102102
{...props}
103103
/>

packages/clerk-js/src/ui/components/OrganizationProfile/ActionConfirmationPage.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ type ActionConfirmationPageProps = FormProps & {
107107
successMessage: LocalizationKey;
108108
submitLabel: LocalizationKey;
109109
onConfirmation: () => Promise<any>;
110-
variant?: 'primaryDanger' | 'primary';
110+
colorScheme?: 'danger' | 'primary';
111111
};
112112

113113
const ActionConfirmationPage = withCardStateProvider((props: ActionConfirmationPageProps) => {
@@ -122,7 +122,7 @@ const ActionConfirmationPage = withCardStateProvider((props: ActionConfirmationP
122122
onSuccess,
123123
onReset,
124124
onConfirmation,
125-
variant = 'primaryDanger',
125+
colorScheme = 'danger',
126126
} = props;
127127
const wizard = useWizard();
128128
const card = useCardState();
@@ -174,7 +174,7 @@ const ActionConfirmationPage = withCardStateProvider((props: ActionConfirmationP
174174
<FormButtonContainer>
175175
<Form.SubmitButton
176176
block={false}
177-
variant={variant}
177+
colorScheme={colorScheme}
178178
localizationKey={submitLabel}
179179
isDisabled={!canSubmit}
180180
/>

packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationGeneralPage.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ const OrganizationLeaveSection = () => {
192192
<Action.Trigger value='leave'>
193193
<ProfileSection.Button
194194
id='organizationDanger'
195-
variant='ghostDanger'
195+
variant='ghost'
196+
colorScheme='danger'
196197
localizationKey={localizationKeys(
197198
'organizationProfile.profilePage.dangerSection.leaveOrganization.title',
198199
)}
@@ -237,7 +238,8 @@ const OrganizationDeleteSection = () => {
237238
<Action.Trigger value='delete'>
238239
<ProfileSection.Button
239240
id='organizationDanger'
240-
variant='ghostDanger'
241+
variant='ghost'
242+
colorScheme='danger'
241243
localizationKey={localizationKeys(
242244
'organizationProfile.profilePage.dangerSection.deleteOrganization.title',
243245
)}

packages/clerk-js/src/ui/components/OrganizationProfile/RequestToJoinList.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ const AcceptRejectRequestButtons = (props: { onAccept: () => unknown; onReject:
109109

110110
<Button
111111
textVariant='buttonSmall'
112-
variant='primary'
113112
isLoading={card.isLoading && card.loadingMetadata === 'accept'}
114113
isDisabled={card.isLoading && card.loadingMetadata !== 'accept'}
115114
onClick={props.onAccept}

packages/clerk-js/src/ui/components/OrganizationSwitcher/OrganizationSwitcherTrigger.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const OrganizationSwitcherTrigger = withAvatarShimmer(
3131
<Button
3232
elementDescriptor={descriptors.organizationSwitcherTrigger}
3333
variant='ghost'
34+
colorScheme='neutral'
3435
hoverAsFocus
3536
focusRing={false}
3637
sx={[

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

+3-3
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, SecondaryActions } from '../../elements';
5+
import { Action, Actions } from '../../elements';
66
import { Add } from '../../icons';
77
import { UserInvitationSuggestionList } from './UserInvitationSuggestionList';
88
import type { UserMembershipListProps } from './UserMembershipList';
@@ -55,13 +55,13 @@ export const OrganizationActionList = (props: OrganizationActionListProps) => {
5555
return (
5656
<>
5757
<UserInvitationSuggestionList onOrganizationClick={onOrganizationClick} />
58-
<SecondaryActions
58+
<Actions
5959
elementDescriptor={descriptors.organizationSwitcherPopoverActions}
6060
role='menu'
6161
>
6262
<UserMembershipList {...{ onPersonalWorkspaceClick, onOrganizationClick }} />
6363
<CreateOrganizationButton {...{ onCreateOrganizationClick }} />
64-
</SecondaryActions>
64+
</Actions>
6565
</>
6666
);
6767
};

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ const AcceptRejectSuggestionButtons = (props: OrganizationSuggestionResource) =>
6767
<Button
6868
elementDescriptor={descriptors.organizationSwitcherInvitationAcceptButton}
6969
textVariant='buttonSmall'
70-
variant='secondary'
70+
variant='outline'
71+
colorScheme='neutral'
7172
size='sm'
7273
isLoading={card.isLoading}
7374
onClick={handleAccept}
@@ -83,7 +84,8 @@ const AcceptRejectInvitationButtons = (props: { onAccept: () => void }) => {
8384
<Button
8485
elementDescriptor={descriptors.organizationSwitcherInvitationAcceptButton}
8586
textVariant='buttonSmall'
86-
variant='secondary'
87+
variant='outline'
88+
colorScheme='neutral'
8789
size='xs'
8890
isLoading={card.isLoading}
8991
onClick={props.onAccept}

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

+3-22
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { useEnvironment, useSignInContext, useSignOutContext } from '../../conte
33
import { Col, descriptors, Flow, localizationKeys } from '../../customizables';
44
import { Action, Actions, Card, Header, PreviewButton, UserPreview, withCardStateProvider } from '../../elements';
55
import { useCardState } from '../../elements/contexts';
6-
import { Add, SignOut, SwitchArrowRight } from '../../icons';
6+
import { Add, SwitchArrowRight } from '../../icons';
7+
import { SignOutAllActions } from '../UserButton/SessionActions';
78
import { useMultisessionActions } from '../UserButton/useMultisessionActions';
89

910
const _SignInAccountSwitcher = () => {
@@ -44,7 +45,6 @@ const _SignInAccountSwitcher = () => {
4445
justifyContent: 'flex-start',
4546
borderRadius: 0,
4647
borderBottom: `${theme.borders.$normal} ${theme.colors.$blackAlpha100}`,
47-
backgroundColor: theme.colors.$colorBackground,
4848
})}
4949
icon={SwitchArrowRight}
5050
>
@@ -94,26 +94,7 @@ const _SignInAccountSwitcher = () => {
9494
width: '100%',
9595
}}
9696
>
97-
<Action
98-
elementDescriptor={descriptors.userButtonPopoverActionButton}
99-
elementId={descriptors.userButtonPopoverActionButton.setId('signOutAll')}
100-
iconBoxElementDescriptor={descriptors.userButtonPopoverActionButtonIconBox}
101-
iconBoxElementId={descriptors.userButtonPopoverActionButtonIconBox.setId('signOutAll')}
102-
iconElementDescriptor={descriptors.userButtonPopoverActionButtonIcon}
103-
iconElementId={descriptors.userButtonPopoverActionButtonIcon.setId('signOutAll')}
104-
icon={SignOut}
105-
label={localizationKeys('userButton.action__signOutAll')}
106-
onClick={handleSignOutAllClicked}
107-
variant='ghostDanger'
108-
sx={t => ({
109-
color: t.colors.$colorTextSecondary,
110-
padding: `${t.space.$2} ${t.space.$3}`,
111-
borderBottom: 'none',
112-
width: '100%',
113-
borderRadius: t.radii.$lg,
114-
})}
115-
spinnerSize='md'
116-
/>
97+
<SignOutAllActions handleSignOutAllClicked={handleSignOutAllClicked} />
11798
</Card.Action>
11899
</Card.Footer>
119100
</Card.Root>

0 commit comments

Comments
 (0)