diff --git a/src/components/Button/Button.css b/src/components/Button/Button.css index a49ab434..2a7fbba0 100644 --- a/src/components/Button/Button.css +++ b/src/components/Button/Button.css @@ -1,13 +1,13 @@ .sbui-btn-container { - @apply inline-flex; + @apply inline-flex font-medium; } .sbui-btn { - @apply font-medium rounded; - @apply relative cursor-pointer inline-flex space-x-2 text-center border border-solid border-transparent transition ease-out duration-200; + @apply relative cursor-pointer inline-flex items-center space-x-2 text-center border border-solid border-transparent transition ease-out duration-200; + @apply rounded; font-family: inherit; + font-weight: inherit; text-shadow: 0 -1px 0 rgba(0,0,0,.12); - -webkit-box-shadow: 0 2px 0 rgba(0,0,0,.045); } .sbui-btn-container--shadow { @@ -86,8 +86,15 @@ } .sbui-btn-primary.sbui-btn--danger { - @apply bg-red-500 text-white + @apply bg-red-500 text-white; + @apply hover:bg-red-600 hover:border-red-600; } +.sbui-btn-default.sbui-btn--danger, .sbui-btn-secondary.sbui-btn--danger, .sbui-btn-outline.sbui-btn--danger, .sbui-btn-dashed.sbui-btn--danger, .sbui-btn-link.sbui-btn--danger, .sbui-btn-text.sbui-btn--danger { + @apply hover:bg-red-600 hover:text-white hover:border-red-600; +} + /* { + @apply hover:bg-red-600 hover:text-white hover:border-red-600; +} */ /* Animation for icon @@ -112,35 +119,3 @@ transform: rotate(360deg); } } - -/* - Puesdo classes -*/ - -.btn:focus { - @apply outline-none ring; -} - -/* .sbui-btn-primary:hover svg { - @apply text-gray-500; -} -.sbui-btn-secondary:hover svg { - @apply text-gray-100; -} -.sbui-btn-default:hover svg { - @apply text-gray-300; -} -.sbui-btn-outline:hover svg { - @apply text-white; -} -.sbui-btn-ghost:hover svg { - @apply bg-brand-300; -} */ - -.sbui-btn--with-icon { - /* @apply pl-10; */ -} - -.sbui-btn-icon-container { - @apply inset-y-0 flex items-center pointer-events-none; -} diff --git a/src/components/Button/Button.js b/src/components/Button/Button.js deleted file mode 100644 index 3957d0cc..00000000 --- a/src/components/Button/Button.js +++ /dev/null @@ -1,109 +0,0 @@ -import React from 'react' -import PropTypes from 'prop-types' -import './Button.css' -import { Transition, Icon } from '../../index' - -export const SIZES = ['tiny', 'small', 'medium', 'large', 'xlarge'] -export const VARIANTS = ['primary', 'default', 'secondary', 'outline', 'dashed', 'link', 'text'] - -const Button = ({ - block, - className, - children, - disabled = false, - onClick, - icon = undefined, - loading = false, - shadow = true, - size = 'medium', - style, - type = 'primary', - danger, - ...props -}) => { - // default classes - let classes = [] - let containerClasses = ['sbui-btn-container'] - - if (type !== 'ghost' && shadow) { - containerClasses.push('sbui-btn--shadow') - } - - if (block) { - containerClasses.push('sbui-btn--w-full') - classes.push('sbui-btn--w-full') - } - - if (icon) { - classes.push('sbui-btn--with-icon') - } - - if (danger ) { - classes.push('sbui-btn--danger') - } - - if (size) { - let sizeClasses = { - tiny: 'sbui-btn--tiny', - small: 'sbui-btn--small', - medium: 'sbui-btn--medium', - large: 'sbui-btn--large', - xlarge: 'sbui-btn--xlarge', - } - classes.push(sizeClasses[size]) - } - - classes.push(`sbui-btn-${type}`) - - return ( - - - - - - ) -} - -Button.propTypes = { - size: PropTypes.oneOf(SIZES), - type: PropTypes.oneOf(VARIANTS), - block: PropTypes.bool, - shadow: PropTypes.bool, - className: PropTypes.string, - loading: PropTypes.bool, - disabled: PropTypes.bool, - icon: PropTypes.string, - danger: PropTypes.bool -} - -export default Button diff --git a/src/components/Button/Button.stories.js b/src/components/Button/Button.stories.js deleted file mode 100644 index ef482ef5..00000000 --- a/src/components/Button/Button.stories.js +++ /dev/null @@ -1,42 +0,0 @@ -import React from 'react' - -import { Button } from '.' -import { Icon } from '../Icon' - -export default { - title: 'General/Button', - component: Button, -} - -export const Default = (args) => -export const withStyles = (args) => -export const withIcon = (args) => -export const withBlock = (args) => -export const withOnlyIcon = (args) => +export const withStyles = (args: any) => +export const withIcon = (args: any) => +export const withIconRight = (args: any) => +export const withBlock = (args: any) => +export const withOnlyIcon = (args: any) => + + + ) +} + +export default Button diff --git a/src/components/Button/index.js b/src/components/Button/index.tsx similarity index 100% rename from src/components/Button/index.js rename to src/components/Button/index.tsx diff --git a/src/components/Icon/Icon.tsx b/src/components/Icon/Icon.tsx index 01a2f950..12280a45 100644 --- a/src/components/Icon/Icon.tsx +++ b/src/components/Icon/Icon.tsx @@ -1,33 +1,67 @@ import React from 'react' import * as Icons from 'react-feather' +import { IconContext } from './IconContext' interface Props { className?: string - size?: number, - type?: string, - color?: string, - strokeWidth?: number, + size?: 'tiny' | 'small' | 'medium' | 'large' | 'xlarge' | number + type?: string + color?: string + strokeWidth?: number } -function Icon({ - className, - size = 21, - type, - color, - strokeWidth, - ...props -}: Props) { - // @ts-ignore - const FeatherIcon = Icons[type] +interface StringMap { + [key: string]: number +} +function Icon({ className, size, type, color, strokeWidth, ...props }: Props) { return ( - + + {({ contextSize }) => { + const defaultSizes: StringMap = { + tiny: 14, + small: 18, + medium: 20, + large: 20, + xlarge: 24, + } + + const defaultSize = defaultSizes['large'] + // @ts-ignore + const FeatherIcon = Icons[type] + + // const iconSize = typeof size === 'string' ? defaultSizes[contextSize] : 21 + let iconSize: any = 21 + + // use contextSize of parent (via context hook) if one exists + if (contextSize) { + iconSize = contextSize + ? typeof contextSize === 'string' + ? defaultSizes[contextSize] + : contextSize + : defaultSize + } + + // use size prop of this component if one exists + if (size) { + iconSize = size + ? typeof size === 'string' + ? defaultSizes[size] + : size + : defaultSize + } + + return ( + + ) + }} + ) } diff --git a/src/components/Icon/IconContext.tsx b/src/components/Icon/IconContext.tsx new file mode 100644 index 00000000..77d4cc25 --- /dev/null +++ b/src/components/Icon/IconContext.tsx @@ -0,0 +1,7 @@ +import { createContext } from 'react' + +// Make sure the shape of the default value passed to +// createContext matches the shape that the consumers expect! +export const IconContext = createContext({ + contextSize: '', +}) diff --git a/src/components/Space/Space.tsx b/src/components/Space/Space.tsx index ea527e2a..0005afe8 100644 --- a/src/components/Space/Space.tsx +++ b/src/components/Space/Space.tsx @@ -1,8 +1,7 @@ import React from 'react' import './Space.css' -function Space (props: any) { - const { direction, size, className, block, style, minus } = props +function Space ({direction, size = 2, className, block, style, minus, children}: any) { const classes = [] classes.push(direction === 'vertical' ? 'sbui-space-col' : 'sbui-space-row') @@ -16,7 +15,7 @@ function Space (props: any) { return (
- {props.children} + {children}
) }