+ icon?: React.ReactNode
+ iconRight?: React.ReactNode
+ loading?: boolean
+ shadow?: boolean
+ size?: 'tiny' | 'small' | 'medium' | 'large' | 'xlarge'
+ style?: React.CSSProperties
+ type?:
+ | 'primary'
+ | 'default'
+ | 'secondary'
+ | 'outline'
+ | 'dashed'
+ | 'link'
+ | 'text'
+ danger: boolean
+ spaceSize: number
+}
+
+const Button = ({
+ block,
+ className,
+ children,
+ disabled = false,
+ onClick,
+ icon,
+ iconRight,
+ loading = false,
+ shadow = true,
+ size = 'medium',
+ style,
+ type = 'primary',
+ danger,
+ spaceSize,
+}: Props) => {
+ let classes = []
+ let containerClasses = ['sbui-btn-container']
+
+ if (block) {
+ containerClasses.push('sbui-btn--w-full')
+ classes.push('sbui-btn--w-full')
+ }
+
+ if (danger) {
+ classes.push('sbui-btn--danger')
+ }
+
+ if (shadow) {
+ classes.push('sbui-btn-container--shadow')
+ }
+
+ if (size) {
+ classes.push(`sbui-btn--${size}`)
+ }
+
+ classes.push(`sbui-btn-${type}`)
+
+ const showIcon = loading || icon
+
+ return (
+
+
+
+
+
+ )
+}
+
+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}
)
}