Skip to content
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

feat(clerk-js): Retheme design and arrow on primary button #2121

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/early-forks-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 2 additions & 0 deletions .changeset/fluffy-chicken-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 2 additions & 0 deletions .changeset/hungry-news-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
3 changes: 2 additions & 1 deletion packages/clerk-js/src/ui.retheme/elements/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const FormSubmit = (props: PropsOfComponent<typeof Button>) => {
<Button
elementDescriptor={descriptors.formButtonPrimary}
block
textVariant='buttonExtraSmallBold'
hasArrow
textVariant='buttonSmallRegular'
isLoading={isLoading}
isDisabled={isDisabled}
type='submit'
Expand Down
20 changes: 10 additions & 10 deletions packages/clerk-js/src/ui.retheme/foundations/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ export const colors = Object.freeze({
transparent: 'transparent',
white: 'white',
black: 'black',
primary50: '#f0f3ff',
primary100: '#d1dcff',
primary200: '#91A7F7',
primary300: '#6684F5',
primary400: '#3B62F2',
primary500: '#103FEF',
primary600: '#0D33BF',
primary700: '#0A268F',
primary800: '#07195F',
primary900: '#030D30',
primary50: '#F7F7F8',
primary100: '#EEEEF0',
primary200: '#D9D9DE',
primary300: '#B7B8C2',
primary400: '#9394A1',
primary500: '#747686',
primary600: '#5E5F6E',
primary700: '#42434D',
primary800: '#2F3037',
primary900: '#212126',
danger50: '#FEF3F2',
danger100: '#FEE4E2',
danger200: '#FECDCA',
Expand Down
2 changes: 2 additions & 0 deletions packages/clerk-js/src/ui.retheme/foundations/shadows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const shadows = Object.freeze({
fabShadow: '0px 12px 24px rgba(0, 0, 0, 0.32)',
focusRing: '0 0 0 3px {{color}}',
focusRingInput: '0 0 0 1px {{color}}',
buttonShadow:
'0px 0px 0px 1px {{color}}, 0px 1px 1px 0px rgba(255, 255, 255, 0.07) inset, 0px 2px 3px 0px rgba(34, 42, 53, 0.20), 0px 1px 1px 0px rgba(0, 0, 0, 0.24)',
shadowShimmer: '1px 1px 2px rgba(0, 0, 0, 0.36)',
sm: '0 1px 1px 0 rgb(0 0 0 / 0.05)',
} as const);
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui.retheme/foundations/typography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const lineHeights = Object.freeze({
none: 1,
shortest: 1.1,
shorter: 1.25,
short: 1.375,
short: 1.385,
base: 1.5,
tall: 1.625,
taller: 2,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/clerk-js/src/ui.retheme/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
export { default as ArrowLeftIcon } from './arrow-left.svg';
export { default as ArrowRightIcon } from './arrow-right.svg';
export { default as ArrowRightButtonIcon } from './arrow-right-button.svg';
export { default as AuthApp } from './auth-app.svg';
export { default as Billing } from './billing.svg';
export { default as Caret } from './caret.svg';
Expand Down
56 changes: 44 additions & 12 deletions packages/clerk-js/src/ui.retheme/primitives/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';

import { Icon } from '../customizables';
import { ArrowRightButtonIcon } from '../icons';
import type { PrimitiveProps, StyleVariants } from '../styledSystem';
import { common, createCssVariables, createVariants } from '../styledSystem';
import { colors } from '../utils';
Expand All @@ -21,6 +23,8 @@ const { applyVariants, filterProps } = createVariants((theme, props: OwnProps) =
backgroundColor: 'unset',
color: 'currentColor',
borderRadius: theme.radii.$md,
position: 'relative',
isolation: 'isolate',
...common.centeredFlex('inline-flex'),
...common.disabled(theme),
transitionProperty: theme.transitionProperty.$common,
Expand All @@ -32,8 +36,8 @@ const { applyVariants, filterProps } = createVariants((theme, props: OwnProps) =
iconLg: { minHeight: theme.sizes.$14, width: theme.sizes.$14 },
xs: { minHeight: theme.sizes.$1x5, padding: `${theme.space.$1x5} ${theme.space.$1x5}` },
sm: {
minHeight: theme.sizes.$8,
padding: `${theme.space.$2} ${theme.space.$3x5}`,
minHeight: theme.sizes.$7,
padding: `${theme.space.$1x5} ${theme.space.$3x5}`,
},
md: {
minHeight: theme.sizes.$9,
Expand All @@ -43,11 +47,11 @@ const { applyVariants, filterProps } = createVariants((theme, props: OwnProps) =
},
colorScheme: {
primary: {
[vars.accentLightest]: colors.setAlpha(theme.colors.$primary400, 0.3),
[vars.accentLighter]: colors.setAlpha(theme.colors.$primary500, 0.3),
[vars.accent]: theme.colors.$primary500,
[vars.accentDark]: theme.colors.$primary600,
[vars.accentDarker]: theme.colors.$primary700,
[vars.accentLightest]: colors.setAlpha(theme.colors.$primary400, 0.3), // TODO: once we have the new color palette
[vars.accentLighter]: colors.setAlpha(theme.colors.$primary800, 0.3), // WIP reference: Updated to new color palette; previously `$primary500`
[vars.accent]: theme.colors.$primary800, // WIP reference: Updated to new color palette; previously `$primary500`
[vars.accentDark]: theme.colors.$primary600, // TODO: once we have the new color palette
[vars.accentDarker]: theme.colors.$primary700, // TODO: once we have the new color palette
},
danger: {
[vars.accentLightest]: colors.setAlpha(theme.colors.$danger400, 0.3),
Expand All @@ -69,9 +73,18 @@ const { applyVariants, filterProps } = createVariants((theme, props: OwnProps) =
solid: {
backgroundColor: vars.accent,
color: theme.colors.$colorTextOnPrimaryBackground,
'&:hover': { backgroundColor: vars.accentDark },
...common.buttonShadow(theme),
// '&:hover': { backgroundColor: vars.accentDark }, // TODO: once we have the new color palette
'&:focus': props.hoverAsFocus ? { backgroundColor: vars.accentDark } : undefined,
'&:active': { backgroundColor: vars.accentDarker },
// '&:active': { backgroundColor: vars.accentDarker }, // TODO: once we have the new color palette
':after': {
position: 'absolute',
content: '""',
borderRadius: 'inherit',
zIndex: -1,
inset: 0,
background: 'linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.00) 100%)',
Copy link
Member

@anagstef anagstef Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also move this literal value? And also use the color variables instead of hardcoded colors?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use colorPrimary somehow here, in order for this to be themable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, didn't understand that correctly. This property actually creates the shadow effect on the button, so no need to change anything

},
},
outline: {
border: theme.borders.$normal,
Expand Down Expand Up @@ -130,7 +143,7 @@ const { applyVariants, filterProps } = createVariants((theme, props: OwnProps) =
textVariant: 'buttonRegularRegular',
colorScheme: 'primary',
variant: 'solid',
size: 'md',
size: 'sm',
anagstef marked this conversation as resolved.
Show resolved Hide resolved
focusRing: true,
},
};
Expand All @@ -141,6 +154,7 @@ type OwnProps = PrimitiveProps<'button'> & {
isDisabled?: boolean;
isActive?: boolean;
hoverAsFocus?: boolean;
hasArrow?: boolean;
};

type ButtonProps = OwnProps & StyleVariants<typeof applyVariants>;
Expand All @@ -150,10 +164,10 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) =>
const {
isLoading,
isDisabled,

hoverAsFocus,
loadingText,
children,
hasArrow,
onClick: onClickProp,
...rest
} = filterProps(parsedProps);
Expand Down Expand Up @@ -193,7 +207,25 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) =>
{loadingText || <span style={{ opacity: 0 }}>{children}</span>}
</Flex>
)}
{!isLoading && children}

{!isLoading && (
<Flex
align='center'
gap={2}
>
{children}
{hasArrow && (
<Icon
icon={ArrowRightButtonIcon}
sx={t => ({
width: t.sizes.$2x5,
height: t.sizes.$2x5,
opacity: t.opacity.$inactive,
})}
/>
)}
</Flex>
)}
</button>
);
});
Expand Down
7 changes: 7 additions & 0 deletions packages/clerk-js/src/ui.retheme/styledSystem/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const textVariants = (t: InternalTheme) => {
const base = {
WebkitFontSmoothing: t.options.$fontSmoothing,
fontFamily: 'inherit',
letterSpacing: t.letterSpacings.$normal,
};

const smallRegular = {
Expand Down Expand Up @@ -84,6 +85,7 @@ const textVariants = (t: InternalTheme) => {
const buttonSmallRegular = {
...smallRegular,
fontFamily: t.fonts.$buttons,
lineHeight: t.lineHeights.$short,
};

const buttonRegularRegular = {
Expand Down Expand Up @@ -175,6 +177,10 @@ const focusRingInput = (t: InternalTheme, props?: any) => {
} as const;
};

const buttonShadow = (t: InternalTheme) => {
return { boxShadow: t.shadows.$buttonShadow.replace('{{color}}', t.colors.$primary800) };
};

const disabled = (t: InternalTheme) => {
return {
'&:disabled,&[data-disabled]': {
Expand Down Expand Up @@ -218,6 +224,7 @@ export const common = {
borderVariants,
focusRing,
focusRingInput,
buttonShadow,
disabled,
borderColor,
centeredFlex,
Expand Down
Loading