Skip to content

Commit

Permalink
Merge pull request #91 from Synthetixio/feat/ui-improvment
Browse files Browse the repository at this point in the history
feat: improve Badge styles and Dialog
  • Loading branch information
fritzschoff authored Jun 10, 2022
2 parents 58dfc2c + 540b3af commit 4fc4fe6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
19 changes: 14 additions & 5 deletions src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import clsx from 'clsx';
import { HTMLAttributes, ReactNode } from 'react';

export type BadgeVariant = 'success';
export type BadgeVariant = 'success' | 'blue' | 'pink' | 'pink' | 'orange' | 'red' | 'yellow';

export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
variant?: BadgeVariant;
Expand All @@ -11,21 +11,30 @@ export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
}

const badgeColors = {
success: 'ui-border ui-border-green ui-bg-green ui-text-green ui-text-xs'
success: 'ui-border-green ui-bg-green ui-text-green',
blue: 'ui-border-blue ui-bg-blue ui-text-blue',
pink: 'ui-border-pink ui-bg-pink ui-text-pink',
orange: 'ui-border-orange ui-bg-orange ui-text-orange',
red: 'ui-border-red ui-bg-red ui-text-red',
yellow: 'ui-border-yellow ui-bg-yellow ui-text-yellow'
};

export const Badge: React.FC<BadgeProps> = ({
className,
defaultClass = 'ui-text-xs ui-font-semibold ui-px-2.5 ui-py-0.5',
defaultClass = 'ui-tg-caption-sm ui-font-semibold ui-px-2.5 ui-py-0.5',
variant = 'sucess',
children,
...props
}) => {
return (
<span
className={clsx(className, 'ui-rounded ui-inline-flex', badgeColors[variant as BadgeVariant])}
className={clsx(
className,
'ui-rounded ui-inline-flex ui-border',
badgeColors[variant as BadgeVariant]
)}
>
<span {...props} className={clsx(defaultClass, 'ui-darker-60 ui-rounded')}>
<span {...props} className={clsx(defaultClass, 'ui-darker-80 ui-rounded')}>
{children}
</span>
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Dialog: React.FC<DialogProps> = ({
<Card
ref={ref}
showBorder
rounded='ui-rounded-2xl'
rounded='md:ui-rounded-2xl'
wrapperClassName={clsx(
wrapperClass,
'ui-overflow-y-auto ui-relative ui-w-full ui-max-w-md ui-h-full ui-max-h-full md:ui-h-auto'
Expand Down
8 changes: 7 additions & 1 deletion src/components/TextField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import { InputHTMLAttributes, TextareaHTMLAttributes } from 'react';

export type InputSize = 'sm' | 'md';

export type TextFieldVariant = 'default' | 'black';

interface BaseProps {
label?: React.ReactNode;
error?: string | false;
onLabelClick?: () => void;
wrapperClassName?: string;
inputSize?: InputSize;
variant?: TextFieldVariant;
}

interface InputProps extends InputHTMLAttributes<HTMLInputElement>, BaseProps {
Expand All @@ -30,6 +33,7 @@ export const TextField: React.FC<TextFieldProps> = ({
onLabelClick,
wrapperClassName,
inputSize = 'md',
variant = 'default',
...props
}) => {
const hasError = !!error;
Expand All @@ -40,8 +44,10 @@ export const TextField: React.FC<TextFieldProps> = ({
'ui-h-14 ui-px-6': !multiline && inputSize === 'md',
'ui-h-10 ui-px-3': !multiline && inputSize === 'sm',
'ui-cursor-not-allowed': props.disabled,
'focus:ui-border-primary focus:dark:ui-border-primary active:dark:ui-border-primary ui-bg-gray-50 dark:ui-bg-dark-blue':
'focus:ui-border-primary focus:dark:ui-border-primary active:dark:ui-border-primary':
!props.disabled,
'ui-bg-gray-50 dark:ui-bg-dark-blue': variant === 'default' && !props.disabled,
'ui-bg-black': variant === 'black' && !props.disabled,
'ui-border-black-200 dark:ui-border-black-400': !hasError,
'ui-border-red-400 dark:ui-border-red-400 focus:ui-border-red-400 ui-text-red-400 dark:ui-text-red-400':
hasError
Expand Down
6 changes: 6 additions & 0 deletions src/styles/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@
line-height: 1rem; // 16px
font-weight: 600;
}

.ui-tg-caption-sm {
font-size: 0.6rem; // 9.6px
line-height: 0.8rem; // 12.8px
font-weight: normal;
}
}
3 changes: 3 additions & 0 deletions src/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ html {
.ui-darker-60 {
background-color: rgba(0, 0, 0, 0.6);
}
.ui-darker-70 {
background-color: rgba(0, 0, 0, 0.7);
}
.ui-darker-80 {
background-color: rgba(0, 0, 0, 0.8);
}
Expand Down

0 comments on commit 4fc4fe6

Please sign in to comment.