From 11389365d32776c0f2ddf23fb6a0d185dbf480d2 Mon Sep 17 00:00:00 2001 From: ChiFeng <34206801+ga021396@users.noreply.github.com> Date: Fri, 8 Mar 2019 14:05:53 +0800 Subject: [PATCH] Checkbox fix props (#452) * add props can change size & icon size * fix checkbox props * save yarnlock * remove props size * let line-height === checkbox size * update snap --- packages/form/src/checkbox/CheckIcon.tsx | 37 +++++++++++-------- packages/form/src/checkbox/Checkbox.tsx | 12 ++---- .../__snapshots__/Checkbox.spec.tsx.snap | 9 +++-- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/packages/form/src/checkbox/CheckIcon.tsx b/packages/form/src/checkbox/CheckIcon.tsx index 3481508b2..a799af773 100644 --- a/packages/form/src/checkbox/CheckIcon.tsx +++ b/packages/form/src/checkbox/CheckIcon.tsx @@ -1,24 +1,29 @@ import React from 'react'; +import { defaultTheme } from '@vital-ui/react-theme'; +import { ThemeConsumer } from 'styled-components'; type Props = { fontSize?: number | string; color?: string; - size?: string; }; -export const CheckIcon = ({ size, fontSize, ...props }: Props) => ( - - - +export const CheckIcon = ({ fontSize, ...props }: Props) => ( + + {(theme = defaultTheme) => ( + + + + )} + ); diff --git a/packages/form/src/checkbox/Checkbox.tsx b/packages/form/src/checkbox/Checkbox.tsx index d0cf972fa..70643f3f8 100644 --- a/packages/form/src/checkbox/Checkbox.tsx +++ b/packages/form/src/checkbox/Checkbox.tsx @@ -15,6 +15,7 @@ const Root = styled.label` font-size: 15px; cursor: pointer; margin-right: 5px; + line-height: ${({ theme }) => theme.checkbox.size}; display: inline-block; &:hover { > span:first-child { @@ -53,8 +54,8 @@ const CheckWrapper = styled('span')` checked ? theme.checkbox.checkedBg : round - ? theme.checkbox.roundBg - : theme.checkbox.bg}; + ? theme.checkbox.roundBg + : theme.checkbox.bg}; transition: ${({ theme }) => theme.defaultTransition}; margin: -2px 0.6em 0 0; vertical-align: middle; @@ -195,12 +196,7 @@ export class Checkbox extends React.Component { round={contextRound || round} > - {contextIcon || - icon || ( - - )} + {contextIcon || icon || }