Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 465712b

Browse files
authored
Merge pull request #15 from supabase/fix/styling-and-button-fixes
Fix/styling and button fixes
2 parents d5f2ae0 + 144aa17 commit 465712b

File tree

7 files changed

+78
-61
lines changed

7 files changed

+78
-61
lines changed

src/components/Button/Button.css

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
}
44

55
.sbui-btn {
6-
@apply relative cursor-pointer inline-flex space-x-2 text-center;
6+
@apply relative cursor-pointer inline-flex space-x-2 text-center border border-solid border-transparent transition ease-out duration-200;
77
}
88

99
.sbui-btn-container--shadow {
@@ -15,7 +15,7 @@
1515
}
1616

1717
.sbui-btn:disabled {
18-
@apply opacity-75 cursor-default;
18+
@apply opacity-75 cursor-not-allowed;
1919
pointer-events: none;
2020
}
2121

@@ -24,39 +24,57 @@
2424
*/
2525

2626
.sbui-btn--tiny {
27-
@apply inline-flex items-center px-2.5 py-1.5 border border-transparent text-xs font-medium rounded shadow-sm;
27+
@apply px-2.5 py-1.5 text-xs font-medium rounded;
2828
}
2929
.sbui-btn--small {
30-
@apply inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md;
30+
@apply px-3 py-2 text-sm leading-4 font-medium rounded-md;
3131
}
3232
.sbui-btn--medium {
33-
@apply inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm;
33+
@apply px-4 py-2 text-sm font-medium rounded-md;
3434
}
3535
.sbui-btn--large {
36-
@apply inline-flex items-center px-4 py-2 border border-transparent text-base font-medium rounded-md shadow-sm;
36+
@apply px-4 py-2 text-base font-medium rounded-md;
3737
}
3838
.sbui-btn--xlarge {
39-
@apply inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md shadow-sm;
39+
@apply px-6 py-3 text-base font-medium rounded-md;
4040
}
4141

4242
/*
4343
Button varients
4444
*/
4545
.sbui-btn-primary {
46-
@apply text-white hover:text-gray-500 bg-brand-700 hover:bg-brand-600;
47-
}
48-
.sbui-btn-secondary {
49-
@apply text-brand-800 text-brand-800 bg-brand-50 bg-opacity-75 hover:bg-brand-100;
46+
@apply text-white hover:text-gray-500 bg-brand-700 hover:bg-brand-600 dark:hover:bg-brand-800;
5047
}
5148
.sbui-btn-default {
52-
@apply text-gray-500 text-gray-500 bg-white border-gray-100 hover:text-gray-600 hover:bg-white hover:border-gray-200;
49+
@apply text-gray-500 bg-white border-gray-300 hover:text-gray-600 hover:bg-white hover:border-gray-200;
50+
@apply dark:border-dark-700 dark:bg-gray-600 dark:text-dark-200;
51+
}
52+
.sbui-btn-secondary {
53+
@apply text-gray-600 bg-gray-200 hover:text-gray-700 hover:bg-gray-300 dark:text-gray-300 dark:bg-gray-500 dark:hover:text-gray-200;
5354
}
5455
.sbui-btn-outline {
55-
@apply text-brand-700 bg-transparent border border-brand-700 border-solid text-brand-700 hover:bg-brand-700 hover:text-white;
56+
@apply border text-gray-500 bg-transparent border-gray-200 border-solid hover:bg-white hover:text-gray-600 hover:border-gray-600 dark:text-white dark:border-dark-400 dark:hover:text-dark-600 dark:hover:border-white;
57+
}
58+
.sbui-btn-dashed {
59+
@apply border text-gray-500 bg-transparent border-gray-200 border-dashed hover:text-gray-600 hover:border-gray-600;
60+
@apply dark:text-white dark:border-dark-400 dark:hover:text-white dark:hover:border-white;
5661
}
57-
.sbui-btn-ghost {
62+
.sbui-btn-link {
5863
@apply text-brand-700 bg-transparent text-brand-700 border-none hover:bg-brand-300 hover:bg-opacity-25;
5964
}
65+
.sbui-btn-text {
66+
@apply text-gray-400 bg-transparent border-none hover:bg-gray-200 hover:bg-opacity-25;
67+
@apply dark:text-dark-300 dark:hover:bg-dark-600;
68+
}
69+
70+
.sbui-btn--danger {
71+
@apply border-red-500 text-red-500;
72+
@apply dark:border-red-500 dark:text-red-500;
73+
}
74+
75+
.sbui-btn-primary.sbui-btn--danger {
76+
@apply bg-red-500 text-white
77+
}
6078

6179
/*
6280
Animation for icon
@@ -94,10 +112,10 @@
94112
@apply text-gray-500;
95113
}
96114
.sbui-btn-secondary:hover svg {
97-
@apply bg-brand-100;
115+
@apply text-gray-100;
98116
}
99117
.sbui-btn-default:hover svg {
100-
@apply text-gray-600;
118+
@apply text-gray-300;
101119
}
102120
.sbui-btn-outline:hover svg {
103121
@apply text-white;
@@ -107,9 +125,9 @@
107125
}
108126

109127
.sbui-btn--with-icon {
110-
@apply pl-10;
128+
/* @apply pl-10; */
111129
}
112130

113131
.sbui-btn-icon-container {
114-
@apply absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none;
132+
@apply inset-y-0 flex items-center pointer-events-none;
115133
}

src/components/Button/Button.js

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import './Button.css'
44
import { Transition, Icon } from '../../index'
55

66
export const SIZES = ['tiny', 'small', 'medium', 'large', 'xlarge']
7-
export const VARIANTS = ['primary', 'default', 'secondary', 'outline', 'ghost']
7+
export const VARIANTS = ['primary', 'default', 'secondary', 'outline', 'dashed', 'link', 'text']
88

99
const Button = ({
1010
block,
@@ -18,6 +18,7 @@ const Button = ({
1818
size = 'medium',
1919
style,
2020
type = 'primary',
21+
danger,
2122
...props
2223
}) => {
2324
// default classes
@@ -29,13 +30,18 @@ const Button = ({
2930
}
3031

3132
if (block) {
33+
containerClasses.push('sbui-btn--w-full')
3234
classes.push('sbui-btn--w-full')
3335
}
3436

3537
if (icon) {
3638
classes.push('sbui-btn--with-icon')
3739
}
3840

41+
if (danger ) {
42+
classes.push('sbui-btn--danger')
43+
}
44+
3945
if (size) {
4046
let sizeClasses = {
4147
tiny: 'sbui-btn--tiny',
@@ -47,27 +53,11 @@ const Button = ({
4753
classes.push(sizeClasses[size])
4854
}
4955

50-
let textColor = {
51-
primary: 'text-white hover:text-gray-500',
52-
secondary: 'text-brand-800',
53-
default: 'text-gray-500',
54-
outline: 'text-brand-500',
55-
ghost: 'text-brand-500',
56-
}
57-
58-
let variantClasses = {
59-
primary: 'sbui-btn-primary',
60-
secondary: 'sbui-btn-secondary',
61-
default: 'sbui-btn-default',
62-
outline: 'sbui-btn-outline',
63-
ghost: 'sbui-btn-ghost',
64-
}
65-
66-
classes.push(variantClasses[type])
56+
classes.push(`sbui-btn-${type}`)
6757

6858
return (
6959
<React.Fragment>
70-
<span className={containerClasses}>
60+
<span className={containerClasses.join(' ')}>
7161
<button
7262
{...props}
7363
className={`sbui-btn ${classes.join(' ')} ${classes.join(
@@ -79,30 +69,25 @@ const Button = ({
7969
type="button"
8070
>
8171
<Transition
82-
show={loading ? true : false}
72+
show={loading || icon ? true : false}
8373
enter="ease-out duration-300"
8474
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
8575
enterTo="opacity-100 translate-y-0 sm:scale-100"
8676
leave="ease-in duration-200"
8777
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
8878
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
8979
>
90-
<Icon
91-
size={16}
92-
className={
93-
'sbui-btn--icon-stroke ' +
94-
textColor[type] +
95-
' sbui-btn--anim--spin'
96-
}
97-
type={'Loader'}
98-
/>
80+
{loading ? (
81+
<Icon
82+
size={21}
83+
className={'sbui-btn--anim--spin'}
84+
type={'Loader'}
85+
/>
86+
) : icon ? (
87+
<div className="sbui-btn-icon-container">{icon}</div>
88+
) : null}
9989
</Transition>
100-
101-
{icon && !loading && (
102-
<div className="sbui-btn-icon-container">{icon}</div>
103-
)}
104-
105-
<span>{children}</span>
90+
{children && <span>{children}</span>}
10691
</button>
10792
</span>
10893
</React.Fragment>
@@ -118,6 +103,7 @@ Button.propTypes = {
118103
loading: PropTypes.bool,
119104
disabled: PropTypes.bool,
120105
icon: PropTypes.string,
106+
danger: PropTypes.bool
121107
}
122108

123109
export default Button

src/components/Button/Button.stories.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ export const Default = (args) => <Button {...args}>Button text</Button>
1212
export const withStyles = (args) => <Button {...args}>Button text</Button>
1313
export const withIcon = (args) => <Button {...args}>Button text</Button>
1414
export const withBlock = (args) => <Button {...args}>Button text</Button>
15+
export const withOnlyIcon = (args) => <Button {...args}/>
16+
export const withOnlyLoading = (args) => <Button {...args}/>
1517

16-
const icon = <Icon stroke={'#666666'} className={''} type={"Package"}/>
18+
const icon = <Icon className={''} type={"Package"}/>
1719

1820
withIcon.args = {
1921
type: 'primary',
@@ -29,4 +31,12 @@ withStyles.args = {
2931
withBlock.args = {
3032
type: 'primary',
3133
block: true
34+
}
35+
36+
withOnlyIcon.args = {
37+
icon: icon
38+
}
39+
40+
withOnlyLoading.args = {
41+
loading: true
3242
}

src/components/Checkbox/Checkbox.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
2727
}
2828

29-
[type='checkbox']:checked,
30-
[type='radio']:checked {
29+
[type='checkbox']:checked {
30+
@apply dark:bg-brand-700;
3131
border-color: transparent;
3232
background-color: currentColor;
3333
background-size: 100% 100%;
@@ -37,7 +37,7 @@
3737

3838
.sbui-checkbox {
3939
/* @apply m-0 focus:ring-brand-500 h-4 text-brand-600 border border-solid border-gray-300 dark:border-gray-400 dark:bg-transparent rounded; */
40-
@apply focus:ring-brand-500 h-4 w-4 text-brand-700 border border-solid border-gray-300 rounded;
40+
@apply m-0 focus:ring-brand-500 h-4 w-4 text-brand-700 border border-solid border-gray-300 rounded dark:border-dark-400 dark:bg-transparent dark:text-white ;
4141
margin-top: 2px;
4242
}
4343

src/components/Icon/Icon.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface Props {
1212

1313
function Icon({
1414
className,
15-
size,
15+
size = 21,
1616
type,
1717
color,
1818
strokeWidth,
@@ -24,7 +24,7 @@ function Icon({
2424

2525
return (
2626
<FeatherIcon
27-
stroke={stroke ? stroke : color}
27+
stroke={stroke ? stroke : color ? color : 'currentColor'}
2828
className={`${className}`}
2929
strokeWidth={strokeWidth}
3030
size={size}

src/components/Typography/Link.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
a.sbui-typography {
2-
@apply text-sm text-brand-700 dark:text-brand-700;
2+
@apply text-sm text-brand-700 dark:text-brand-700 cursor-pointer;
33
}

src/components/Typography/Link.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { HandlerFunction } from '@storybook/addon-actions'
12
import React from 'react'
23
import './Link.css'
34

@@ -7,14 +8,15 @@ interface Props {
78
href?: string
89
className?: string
910
style?: React.CSSProperties
11+
onClick?: HandlerFunction
1012
}
1113

1214
function Link({
1315
children,
1416
target = '_blank',
1517
href,
1618
className,
17-
19+
onClick,
1820
style,
1921
}: Props) {
2022
let classes = ['sbui-typography sbui-typography-link']
@@ -24,6 +26,7 @@ function Link({
2426

2527
return (
2628
<a
29+
onClick={onClick}
2730
className={classes.join(' ')}
2831
href={href}
2932
target={target}

0 commit comments

Comments
 (0)