Skip to content

Commit

Permalink
fix(clerk-js): Use the new rethemed badge (#2370)
Browse files Browse the repository at this point in the history
* fix(clerk-js): Use the new rethemed badge

* fix(clerk-js): Remove the checkmark from the active user avatar
  • Loading branch information
anagstef authored Dec 15, 2023
1 parent a86a5fc commit cee08c7
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .changeset/gentle-berries-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
14 changes: 6 additions & 8 deletions packages/clerk-js/src/ui/common/NotificationCountBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, NotificationBadge } from '../customizables';
import { Flex, NotificationBadge } from '../customizables';
import { useDelayedVisibility, usePrefersReducedMotion } from '../hooks';
import type { ThemableCssProp } from '../styledSystem';
import { animations } from '../styledSystem';
Expand All @@ -21,19 +21,17 @@ export const NotificationCountBadge = ({ notificationCount, containerSx }: Notif
});

return (
<Box
<Flex
justify='center'
align='center'
sx={[
t => ({
position: 'absolute',
top: `-${t.space.$2}`,
right: `-${t.space.$1}`,
width: t.sizes.$2,
height: t.sizes.$2,
marginLeft: t.space.$1x5,
}),
containerSx,
]}
>
{showNotification && <NotificationBadge sx={enterExitAnimation}>{notificationCount}</NotificationBadge>}
</Box>
</Flex>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const OrganizationSwitcherPopover = React.forwardRef<HTMLDivElement, Orga
icon={CogFilled}
label={localizationKeys('organizationSwitcher.action__manageOrganization')}
onClick={handleManageOrganizationClicked}
trailing={<NotificationCountBadgeManageButton sx={{ right: 0 }} />}
trailing={<NotificationCountBadgeManageButton />}
/>
);

Expand Down Expand Up @@ -205,6 +205,7 @@ export const OrganizationSwitcherPopover = React.forwardRef<HTMLDivElement, Orga
sx={t => ({
padding: `${t.space.$4} ${t.space.$5}`,
borderBottom: `${t.borders.$normal} ${t.colors.$blackAlpha100}`,
width: '100%',
})}
title={localizationKeys('organizationSwitcher.personalWorkspace')}
/>
Expand Down Expand Up @@ -232,9 +233,13 @@ const NotificationCountBadgeManageButton = withGate(
membershipRequests: isDomainsEnabled || undefined,
});

if (!membershipRequests?.count) {
return null;
}

return (
<NotificationCountBadge
notificationCount={membershipRequests?.count || 0}
notificationCount={membershipRequests.count}
containerSx={sx}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,16 @@ const NotificationCountBadgeSwitcherTrigger = () => {
const notificationCount =
(userInvitations.count || 0) + (userSuggestions.count || 0) + (membershipRequests?.count || 0);

if (!notificationCount) {
return null;
}

return (
<NotificationCountBadge
containerSx={t => ({
marginLeft: `${t.space.$2}`,
position: 'absolute',
top: `-${t.space.$2}`,
right: 0,
})}
notificationCount={notificationCount}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const CreateOrganizationButton = ({
label={localizationKeys('organizationSwitcher.action__createOrganization')}
onClick={onCreateOrganizationClick}
sx={t => ({
borderBottom: 'none',
color: t.colors.$blackAlpha600,
':hover': {
color: t.colors.$blackAlpha600,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const SingleSessionActions = (props: SessionActionsProps) => {
t => ({
borderBottomLeftRadius: t.radii.$lg,
borderBottomRightRadius: t.radii.$lg,
borderBottom: 'none',
':hover': {
backgroundColor: t.colors.$danger50,
color: t.colors.$danger400,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import type { ActiveSessionResource } from '@clerk/types';
import React from 'react';

import { useEnvironment, useUserButtonContext } from '../../contexts';
import { descriptors, Icon, localizationKeys } from '../../customizables';
import { descriptors, localizationKeys } from '../../customizables';
import { Action, Actions, PopoverCard, PreviewButton, RootBox, SecondaryActions, UserPreview } from '../../elements';
import { Add, CheckmarkFilled, SignOut, SwitchArrowRight } from '../../icons';
import { Add, SignOut, SwitchArrowRight } from '../../icons';
import type { PropsOfComponent } from '../../styledSystem';
import { MultiSessionActions, SingleSessionActions } from './SessionActions';
import { useMultisessionActions } from './useMultisessionActions';
Expand Down Expand Up @@ -69,7 +69,7 @@ export const UserButtonPopover = React.forwardRef<HTMLDivElement, UserButtonPopo
onClick={handleSignOutAllClicked}
variant='ghostDanger'
sx={t => ({
color: t.colors.$blackAlpha700,
color: t.colors.$blackAlpha600,
padding: `${t.space.$2} ${t.space.$3}`,
borderBottom: 'none',
borderRadius: t.radii.$lg,
Expand All @@ -85,7 +85,6 @@ export const UserButtonPopover = React.forwardRef<HTMLDivElement, UserButtonPopo
key={session.id}
icon={SwitchArrowRight}
sx={t => ({
height: t.sizes.$20,
borderRadius: 0,
borderBottom: `${t.borders.$normal} ${t.colors.$blackAlpha100}`,
backgroundColor: t.colors.$colorBackground,
Expand Down Expand Up @@ -116,13 +115,6 @@ export const UserButtonPopover = React.forwardRef<HTMLDivElement, UserButtonPopo
sx={t => ({
padding: `${t.space.$4} ${t.space.$5}`,
})}
icon={
<Icon
icon={CheckmarkFilled}
sx={t => ({ width: t.sizes.$3x5, height: t.sizes.$3x5 })}
/>
}
iconSx={t => ({ left: 'unset', right: 0, color: t.colors.$primary500 })}
/>
{authConfig.singleSessionMode ? (
<SingleSessionActions
Expand Down
7 changes: 1 addition & 6 deletions packages/clerk-js/src/ui/elements/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export const ExtraSmallAction = (props: Omit<ActionProps, 'label'>) => {
elementDescriptor={iconBoxElementDescriptor}
elementId={iconBoxElementId}
justify='center'
// sx={[theme => ({ flex: `0 0 ${theme.sizes.$9}` }), iconBoxSx]}
>
{status.isLoading ? (
<Spinner
Expand Down Expand Up @@ -172,7 +171,7 @@ export const Action = (props: ActionProps) => {
return (
<Button
size='md'
variant='ghost'
variant='ghostAction'
textVariant='buttonLarge'
focusRing={false}
hoverAsFocus
Expand All @@ -184,10 +183,6 @@ export const Action = (props: ActionProps) => {
gap: t.space.$3,
padding: `${t.space.$4} ${t.space.$5}`,
justifyContent: 'flex-start',
color: t.colors.$blackAlpha600,
':hover': {
color: t.colors.$blackAlpha600,
},
}),
sx,
]}
Expand Down
8 changes: 8 additions & 0 deletions packages/clerk-js/src/ui/primitives/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ const { applyVariants, filterProps } = createVariants((theme, props: OwnProps) =
: undefined,
'&:active': { backgroundColor: theme.colors.$transparent },
},
ghostAction: {
color: theme.colors.$blackAlpha600,
'&:hover': { backgroundColor: theme.colors.$blackAlpha50, color: theme.colors.$blackAlpha600 },
'&:focus': props.hoverAsFocus
? { backgroundColor: theme.colors.$blackAlpha50, color: theme.colors.$blackAlpha600 }
: undefined,
'&:active': { backgroundColor: theme.colors.$transparent },
},
ghostPrimary: {
color: theme.colors.$primary500,
'&:hover': { backgroundColor: theme.colors.$blackAlpha50, color: theme.colors.$primary500 },
Expand Down
10 changes: 5 additions & 5 deletions packages/clerk-js/src/ui/primitives/NotificationBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ const vars = createCssVariables('accent', 'bg');
const { applyVariants, filterProps } = createVariants(theme => ({
base: {
color: vars.accent,
backgroundColor: vars.bg,
borderRadius: theme.radii.$sm,
background: vars.bg,
borderRadius: theme.radii.$lg,
height: theme.space.$4,
minWidth: theme.space.$4,
padding: `${theme.space.$0x5}`,
minWidth: theme.space.$5,
padding: `${theme.space.$0x5} ${theme.space.$1}`,
display: 'inline-flex',
},
variants: {
textVariant: { ...common.textVariants(theme) },
colorScheme: {
primary: {
[vars.accent]: theme.colors.$colorTextOnPrimaryBackground,
[vars.bg]: theme.colors.$primary500,
[vars.bg]: `linear-gradient(180deg, ${theme.colors.$whiteAlpha300} 0%, ${theme.colors.$transparent} 100%), ${theme.colors.$primary500}`,
},
},
},
Expand Down

0 comments on commit cee08c7

Please sign in to comment.