Skip to content

Commit

Permalink
fix(@air/zephyr): allow baseStyles in specific areas
Browse files Browse the repository at this point in the history
  • Loading branch information
andyhqtran committed Jan 26, 2022
1 parent 2f7f3ea commit c109b5e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/zephyr/src/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type BoxStylingProps = {

/**
* Used to apply predefined styles.
* TODO: Define merging behavior for tx and __baseStyles.
*/
variant?: string | string[];
};
Expand All @@ -31,6 +32,8 @@ export type BoxProps<TDefaultElement extends As = 'div'> = PropsWithAs<

const inlineStyles = ({ tx, theme }: any) => css({ ...tx })(theme);

const baseStyles = (props: any) => css(props.__baseStyles)(props.theme);

const variants = ({
theme,
__themeKey = 'variants',
Expand All @@ -48,6 +51,7 @@ export const Box = styled('div')<BoxStylingProps>(
margin: 0,
boxSizing: 'border-box',
},
baseStyles,
variants,
inlineStyles,
compose(color, space),
Expand Down
5 changes: 2 additions & 3 deletions packages/zephyr/src/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ export const Button = forwardRefWithAs<NonSemanticButtonProps, 'button'>(
ref: _ref, // eslint-disable-line @typescript-eslint/no-unused-vars
children,
className,
tx,
...restOfProps
}: ButtonProps,
ref: Ref<HTMLButtonElement>,
Expand Down Expand Up @@ -280,7 +279,8 @@ export const Button = forwardRefWithAs<NonSemanticButtonProps, 'button'>(
type={type}
variant={variant}
className={classNames({ 'is-loading': isLoading }, className)}
tx={{
// @ts-ignore - Allowing it here
__baseStyles={{
appearance: 'none',
outline: 'none',
display: 'inline-flex',
Expand Down Expand Up @@ -313,7 +313,6 @@ export const Button = forwardRefWithAs<NonSemanticButtonProps, 'button'>(
'&.is-loading': {
cursor: 'progress',
},
...tx,
}}
{...restOfProps}
ref={ref}
Expand Down
13 changes: 10 additions & 3 deletions packages/zephyr/src/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ export interface TextProps extends PropsWithAs<'div', NonSemanticTextProps> {}
export const Text = forwardRefWithAs<NonSemanticTextProps, 'div'>(
(
{
ref: _ref, // eslint-disable-line @typescript-eslint/no-unused-vars
tx,
variant = 'text-ui-16',
ref: _ref, // eslint-disable-line @typescript-eslint/no-unused-vars
...restOfProps
}: TextProps,
ref: Ref<HTMLDivElement>,
) => {
return <Box variant={variant} ref={ref} {...restOfProps} tx={{ color: 'pigeon700', ...tx }} />;
return (
<Box
variant={variant}
ref={ref}
{...restOfProps}
// @ts-ignore - Allowing it here
__baseStyles={{ color: 'pigeon700' }}
/>
);
},
);

Expand Down

0 comments on commit c109b5e

Please sign in to comment.