diff --git a/package.json b/package.json index 404a79bee..09ffb94a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pangolindex/components", - "version": "1.0.0", + "version": "1.0.3", "main": "lib/index.js", "module": "lib/index.esm.js", "engines": { diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index cb08f8bb0..3c4d9f01e 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -3,12 +3,22 @@ import { IconAfter, IconBefore, Root } from './styles'; import { ButtonProps } from './types'; const Button: React.FC = (props) => { - const { iconBefore, children, iconAfter, ...rest } = props; + const { iconBefore, children, iconAfter, loading, loadingText, ...rest } = props; return ( - {iconBefore && {iconBefore}} - {children} - {iconAfter && {iconAfter}} + {loading ? ( + loadingText ? ( + loadingText + ) : ( + 'Loading...' + ) + ) : ( + <> + {iconBefore && {iconBefore}} + {children} + {iconAfter && {iconAfter}} + + )} ); }; diff --git a/src/components/Button/styles.tsx b/src/components/Button/styles.tsx index 0ce6377f3..332a6eeb9 100644 --- a/src/components/Button/styles.tsx +++ b/src/components/Button/styles.tsx @@ -1,3 +1,4 @@ +import { lighten } from 'polished'; import styled, { css } from 'styled-components'; import { ButtonProps } from './types'; @@ -33,6 +34,23 @@ const Plain = (props: ButtonProps) => align-items: center; `; +const Disable = (props: ButtonProps) => + (props.isDisabled || props.loading) && + css` + background-color: ${({ theme }) => theme.bg4}; + color: ${({ theme }) => theme.text3}; + `; + +const Confirmed = (props: ButtonProps) => + props.variant === 'confirm' && + css` + background-color: ${({ theme }) => lighten(0.5, theme.green1)}; + color: ${({ theme }) => theme.green1}; + border: 1px solid ${({ theme }) => theme.green1}; + opacity: 50%; + cursor: auto; + `; + export const Root = styled.button` padding: ${(props) => (props?.padding ? props?.padding : '18px')}; width: ${({ width }) => (width ? width : '100%')}; @@ -48,17 +66,17 @@ export const Root = styled.button` justify-content: center; flex-wrap: nowrap; align-items: center; - cursor: pointer; + cursor: ${(props) => (props?.isDisabled ? 'auto' : 'pointer')}; + pointer-events: ${(props) => (props?.isDisabled ? 'none' : 'all')}; position: relative; z-index: 1; - &:disabled { - cursor: auto; - } ${Primary} ${Secondary} ${Outline} ${Plain} + ${Disable} + ${Confirmed} > * { user-select: none; diff --git a/src/components/Button/types.tsx b/src/components/Button/types.tsx index 0ef705e4c..b18e5c6e6 100644 --- a/src/components/Button/types.tsx +++ b/src/components/Button/types.tsx @@ -8,7 +8,7 @@ export type ButtonProps = { /** type of the button */ type?: 'button' | 'submit'; /** varient of the button */ - variant: 'primary' | 'secondary' | 'outline' | 'plain'; + variant: 'primary' | 'secondary' | 'outline' | 'plain' | 'confirm'; /** icon before the button text **/ iconBefore?: React.ReactNode | null; /** icon after the button text **/ @@ -26,6 +26,7 @@ export type ButtonProps = { loading?: boolean; /** loading icon **/ loadingIcon?: React.ReactNode; + loadingText?: string; padding?: string; borderRadius?: string; }; diff --git a/src/components/Checkbox/Checkbox.tsx b/src/components/Checkbox/Checkbox.tsx index 64c0efea5..8f1a92ddb 100644 --- a/src/components/Checkbox/Checkbox.tsx +++ b/src/components/Checkbox/Checkbox.tsx @@ -23,7 +23,7 @@ const Checkbox: React.FC = (props) => { - {Boolean(label) && } + {Boolean(label) && } ); }; diff --git a/src/components/Steps/Step.tsx b/src/components/Steps/Step.tsx index ccd58308d..5dc9fcad6 100644 --- a/src/components/Steps/Step.tsx +++ b/src/components/Steps/Step.tsx @@ -3,7 +3,7 @@ import { IconDot, StepCounter, StepItem, StepName } from './styles'; import { StepProps } from './types'; const Step: React.FC = (props) => { - const { active, completed, stepNumber, disabled, title, progressDot, stepIndex, onStepClick } = props; + const { active, completed, stepNumber, disabled, title, progressDot } = props; const renderIconNode = () => { let iconNode; @@ -21,12 +21,12 @@ const Step: React.FC = (props) => { return iconNode; }; - const onClick: React.MouseEventHandler = () => { - onStepClick && onStepClick(stepIndex || 0); - }; + // const onClick: React.MouseEventHandler = () => { + // onStepClick && onStepClick(stepIndex || 0); + // }; return ( - + {renderIconNode()} {active && {title}} diff --git a/src/components/Steps/styles.tsx b/src/components/Steps/styles.tsx index f9ac4f0ef..6e663891a 100644 --- a/src/components/Steps/styles.tsx +++ b/src/components/Steps/styles.tsx @@ -28,9 +28,9 @@ export const StepItem = styled.div<{ &:before { position: absolute; content: ''; - border-bottom: 2px solid #717171; + border-bottom: ${({ theme }) => `2px solid ${theme.bg5}`}; width: 100%; - top: ${({ progressDot }) => (progressDot ? '20px' : '15px')}; + top: ${({ progressDot }) => (progressDot ? '21px' : '15px')}; left: -50%; z-index: 2; } @@ -38,9 +38,9 @@ export const StepItem = styled.div<{ position: absolute; content: ''; border-bottom: 2px solid; - border-bottom-color: ${({ completed }) => (completed ? '#fff' : '#717171')}; + border-bottom-color: ${({ completed, theme }) => (completed ? theme.primary1 : theme.bg5)}; width: 100%; - top: ${({ progressDot }) => (progressDot ? '20px' : '15px')}; + top: ${({ progressDot }) => (progressDot ? '21px' : '15px')}; left: 50%; z-index: ${({ completed }) => (completed ? 3 : 2)}; } @@ -61,8 +61,8 @@ export const StepCounter = styled.div<{ completed?: boolean; active?: boolean }> width: 30px; height: 30px; border-radius: 50%; - background: ${({ completed, active }) => (completed || active ? '#fff' : '#717171')}; - color: ${({ completed, active }) => (completed || active ? '#111111' : '#fff')}; + background: ${({ completed, active, theme }) => (completed || active ? theme.primary1 : theme.bg5)}; + color: ${({ completed, active, theme }) => (completed || active ? theme.text6 : theme.white)}; margin-bottom: 6px; `; @@ -71,19 +71,18 @@ export const StepName = styled('div')` display: flex; justify-content: space-between; margin-bottom: 20px; - color: #fff; + color: ${({ theme }) => theme.text4}; `; export const IconDot = styled.div<{ completed?: boolean; active?: boolean }>` -position: relative; -z-index: 5; -display: flex; -justify-content: center; -align-items: center; -width: 10px; -height: 10px; -border-radius: 50%; -background: ${({ completed, active }) => (completed || active ? '#fff' : '#717171')}; -margin-top: 17px; -} + position: relative; + z-index: 5; + display: flex; + justify-content: center; + align-items: center; + width: 10px; + height: 10px; + border-radius: 50%; + background: ${({ completed, active, theme }) => (completed || active ? theme.primary1 : theme.bg5)}; + margin-top: 17px; `; diff --git a/src/components/Steps/types.tsx b/src/components/Steps/types.tsx index c409fb400..70e4e008d 100644 --- a/src/components/Steps/types.tsx +++ b/src/components/Steps/types.tsx @@ -9,7 +9,7 @@ export interface StepsProps { } export interface StepProps { - onStepClick?: (index: number) => void; + // onStepClick?: (index: number) => void; disabled?: boolean; title?: React.ReactNode; completed?: boolean; diff --git a/src/components/TextInput/TextInput.tsx b/src/components/TextInput/TextInput.tsx index 15f833967..9f93f0ce6 100644 --- a/src/components/TextInput/TextInput.tsx +++ b/src/components/TextInput/TextInput.tsx @@ -5,17 +5,42 @@ import { AddonAfter, AddonBefore, ErrorText, InputWrapper, StyledInput } from '. import { TextInputProps } from './types'; const TextInput: React.FC = (props) => { - const { label, addonLabel, addonAfter, addonBefore, error, showErrorMessage = true, ...rest } = props; + const { + label, + addonLabel, + addonAfter, + addonBefore, + error, + showErrorMessage = true, + onChange, + isNumeric, + ...rest + } = props; + + const inputRegex = new RegExp(`^\\d+\\.?\\d*$`); return ( - - {label && {label}} + + {label && {label}} {addonLabel && addonLabel} {addonBefore && {addonBefore}} - + { + const value = e.target.value; + + if (isNumeric && !!value) { + if (inputRegex.test(value)) { + onChange && onChange(value); + } + } else { + onChange && onChange(value); + } + }} + /> {addonAfter && {addonAfter}} {showErrorMessage && {error}} diff --git a/src/components/TextInput/styles.tsx b/src/components/TextInput/styles.tsx index a402fcb90..0dcf0651f 100644 --- a/src/components/TextInput/styles.tsx +++ b/src/components/TextInput/styles.tsx @@ -11,15 +11,18 @@ export const InputWrapper = styled(Box)` display: flex; position: relative; box-sizing: border-box; - background-color: ${({ theme }) => theme.bg3}; - color: ${({ theme }) => theme.text1}; + background-color: ${({ theme }) => theme.bg6}; + color: ${({ theme }) => theme.text4}; `; export const StyledInput = styled.input` flex: 1; border: 1px solid transparent; - background-color: ${({ theme }) => theme.bg3}; - color: ${({ theme }) => theme.text1}; + font-size: ${(props) => (props?.fontSize ? `${props?.fontSize}px` : '18px')}; + background-color: ${({ theme }) => theme.bg6}; + color: ${({ theme }) => theme.text4}; outline: none; + width: 100%; + padding: 0; `; export const AddonAfter = styled(Box)` position: relative; diff --git a/src/components/TextInput/types.tsx b/src/components/TextInput/types.tsx index eecee066c..2eaea273e 100644 --- a/src/components/TextInput/types.tsx +++ b/src/components/TextInput/types.tsx @@ -17,4 +17,6 @@ export type TextInputProps = Omit, 'accept' | label?: string; addonLabel?: React.ReactNode | null; id?: string; + fontSize?: number; + isNumeric?: boolean; }; diff --git a/src/theme/index.tsx b/src/theme/index.tsx index 447dd5f47..17a0c93bf 100644 --- a/src/theme/index.tsx +++ b/src/theme/index.tsx @@ -35,6 +35,7 @@ export const defaultColors: Colors = { text3: '#888D9B', text4: '#C3C5CB', text5: '#EDEEF2', + text6: '#111111', // backgrounds / greys bg1: '#FFFFFF', @@ -42,6 +43,8 @@ export const defaultColors: Colors = { bg3: '#EDEEF2', bg4: '#CED0D9', bg5: '#888D9B', + bg6: '#1C1C1C', + bg7: '#2C2D33', //specialty colors modalBG: 'rgba(0,0,0,0.3)', diff --git a/src/theme/styled.ts b/src/theme/styled.ts index 70625d7a6..2d4fc7ef0 100644 --- a/src/theme/styled.ts +++ b/src/theme/styled.ts @@ -12,6 +12,7 @@ export interface Colors { text3: Color; text4: Color; text5: Color; + text6: Color; // backgrounds / greys bg1: Color; @@ -19,6 +20,8 @@ export interface Colors { bg3: Color; bg4: Color; bg5: Color; + bg6: Color; + bg7: Color; modalBG: Color; advancedBG: Color;