diff --git a/components/auto-complete/__tests__/__snapshots__/index.test.tsx.snap b/components/auto-complete/__tests__/__snapshots__/index.test.tsx.snap index b07b91691..690baa48e 100644 --- a/components/auto-complete/__tests__/__snapshots__/index.test.tsx.snap +++ b/components/auto-complete/__tests__/__snapshots__/index.test.tsx.snap @@ -10,5 +10,6 @@ exports[`AutoComplete should render correctly 1`] = ` initialValue="" options={Array []} size="medium" + type="default" /> `; diff --git a/components/auto-complete/__tests__/index.test.tsx b/components/auto-complete/__tests__/index.test.tsx index 1b20654e8..fcd376aaf 100644 --- a/components/auto-complete/__tests__/index.test.tsx +++ b/components/auto-complete/__tests__/index.test.tsx @@ -14,8 +14,8 @@ describe('AutoComplete', () => { it('should support sizes and status', () => { const wrapper = mount(
- - + +
, diff --git a/components/auto-complete/auto-complete.tsx b/components/auto-complete/auto-complete.tsx index e3bf55713..93d6e3486 100644 --- a/components/auto-complete/auto-complete.tsx +++ b/components/auto-complete/auto-complete.tsx @@ -31,7 +31,7 @@ export type AutoCompleteOptions = Array< interface Props { options: AutoCompleteOptions size?: NormalSizes - status?: NormalTypes + type?: NormalTypes initialValue?: string value?: string width?: string @@ -53,6 +53,7 @@ const defaultProps = { disabled: false, clearable: false, size: 'medium' as NormalSizes, + type: 'default' as NormalTypes, disableMatchWidth: false, disableFreeSolo: false, className: '', @@ -94,7 +95,7 @@ const AutoComplete = React.forwardRef< searching, children, size, - status, + type, value, width, clearable, @@ -209,7 +210,7 @@ const AutoComplete = React.forwardRef< toggleFocusHandler(true)} onBlur={() => toggleFocusHandler(false)} diff --git a/components/badge/badge.tsx b/components/badge/badge.tsx index 4528e690c..632ebea98 100644 --- a/components/badge/badge.tsx +++ b/components/badge/badge.tsx @@ -1,7 +1,7 @@ import React, { useMemo } from 'react' import useTheme from '../use-theme' import { NormalSizes, NormalTypes } from '../utils/prop-types' -import { GeistUIThemesPalette } from 'components/themes/presets' +import { GeistUIThemesPalette } from '../themes/presets' import BadgeAnchor from './badge-anchor' interface Props { diff --git a/components/button-group/button-group.tsx b/components/button-group/button-group.tsx index 31c134e55..ff72b9536 100644 --- a/components/button-group/button-group.tsx +++ b/components/button-group/button-group.tsx @@ -3,7 +3,7 @@ import useTheme from '../use-theme' import withDefaults from '../utils/with-defaults' import { NormalSizes, ButtonTypes } from '../utils/prop-types' import { ButtonGroupContext, ButtonGroupConfig } from './button-group-context' -import { GeistUIThemesPalette } from 'components/themes/presets' +import { GeistUIThemesPalette } from '../themes/presets' interface Props { disabled?: boolean diff --git a/components/button/utils.tsx b/components/button/utils.tsx index 511545693..78f18b8a4 100644 --- a/components/button/utils.tsx +++ b/components/button/utils.tsx @@ -1,8 +1,8 @@ import React, { ReactNode } from 'react' import { NormalSizes } from '../utils/prop-types' import ButtonIcon from './button-icon' -import { ButtonProps } from 'components/button/button' -import { ButtonGroupConfig } from 'components/button-group/button-group-context' +import { ButtonProps } from './button' +import { ButtonGroupConfig } from '../button-group/button-group-context' export const getButtonChildrenWithIcon = ( auto: boolean, diff --git a/components/checkbox/__tests__/__snapshots__/index.test.tsx.snap b/components/checkbox/__tests__/__snapshots__/index.test.tsx.snap index b3ce5234e..5a98d1336 100644 --- a/components/checkbox/__tests__/__snapshots__/index.test.tsx.snap +++ b/components/checkbox/__tests__/__snapshots__/index.test.tsx.snap @@ -1041,3 +1041,171 @@ exports[`Checkbox should work correctly with different sizes 1`] = ` } " `; + +exports[`Checkbox should work with different status 1`] = ` +"
" +`; diff --git a/components/checkbox/__tests__/index.test.tsx b/components/checkbox/__tests__/index.test.tsx index acd1f710b..3916d2c6e 100644 --- a/components/checkbox/__tests__/index.test.tsx +++ b/components/checkbox/__tests__/index.test.tsx @@ -23,6 +23,18 @@ describe('Checkbox', () => { expect(() => wrapper.unmount()).not.toThrow() }) + it('should work with different status', () => { + const wrapper = mount( +
+ + + + +
, + ) + expect(wrapper.html()).toMatchSnapshot() + }) + it('should work correctly with initial value', () => { let wrapper = mount(Sydney) let input = wrapper.find('input').getDOMNode() diff --git a/components/checkbox/checkbox.icon.tsx b/components/checkbox/checkbox.icon.tsx index 0ba4e1554..979eb8d76 100644 --- a/components/checkbox/checkbox.icon.tsx +++ b/components/checkbox/checkbox.icon.tsx @@ -4,16 +4,17 @@ import useTheme from '../use-theme' interface Props { disabled?: boolean checked?: boolean + fill?: string + bg?: string } -const CheckboxIcon: React.FC = ({ disabled, checked }) => { +const CheckboxIcon: React.FC = ({ fill, bg, disabled, checked }) => { const theme = useTheme() - const { fill, bg, stroke } = useMemo(() => { + const { propsFill, propsBg } = useMemo(() => { return { - fill: theme.palette.foreground, - bg: theme.palette.background, - stroke: theme.palette.accents_5, + propsFill: fill, + propsBg: bg, } }, [theme.palette]) @@ -23,15 +24,15 @@ const CheckboxIcon: React.FC = ({ disabled, checked }) => { - + ) : ( )} diff --git a/components/checkbox/checkbox.tsx b/components/checkbox/checkbox.tsx index 1deb70003..6d173c56b 100644 --- a/components/checkbox/checkbox.tsx +++ b/components/checkbox/checkbox.tsx @@ -3,7 +3,9 @@ import { useCheckbox } from './checkbox-context' import CheckboxGroup, { getCheckboxSize } from './checkbox-group' import CheckboxIcon from './checkbox.icon' import useWarning from '../utils/use-warning' -import { NormalSizes } from '../utils/prop-types' +import { NormalSizes, NormalTypes } from '../utils/prop-types' +import { getColors } from './styles' +import useTheme from '../use-theme' interface CheckboxEventTarget { checked: boolean @@ -19,6 +21,7 @@ export interface CheckboxEvent { interface Props { checked?: boolean disabled?: boolean + type?: NormalTypes initialChecked?: boolean onChange?: (e: CheckboxEvent) => void size?: NormalSizes @@ -28,6 +31,7 @@ interface Props { const defaultProps = { disabled: false, + type: 'default' as NormalTypes, initialChecked: false, size: 'small' as NormalSizes, className: '', @@ -45,9 +49,11 @@ const Checkbox: React.FC = ({ className, children, size, + type, value, ...props }) => { + const theme = useTheme() const [selfChecked, setSelfChecked] = useState(initialChecked) const { updateState, inGroup, disabledAll, values } = useCheckbox() const isDisabled = inGroup ? disabledAll || disabled : disabled @@ -67,6 +73,12 @@ const Checkbox: React.FC = ({ } const fontSize = useMemo(() => getCheckboxSize(size), [size]) + + const { fill, bg } = useMemo(() => getColors(theme.palette, type), [ + theme.palette, + type, + ]) + const changeHandle = useCallback( (ev: React.ChangeEvent) => { if (isDisabled) return @@ -95,7 +107,7 @@ const Checkbox: React.FC = ({ return (