-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(design): over length Radio should align to start
- Loading branch information
1 parent
667254f
commit 93698b5
Showing
6 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { useState } from 'react'; | ||
import { Radio, Space } from '@oceanbase/design'; | ||
import type { RadioChangeEvent } from '@oceanbase/design'; | ||
|
||
const App: React.FC = () => { | ||
const [value, setValue] = useState('long'); | ||
|
||
const onChange = (e: RadioChangeEvent) => { | ||
console.log('radio checked', e.target.value); | ||
setValue(e.target.value); | ||
}; | ||
|
||
return ( | ||
<Radio.Group onChange={onChange} value={value}> | ||
<Space direction="vertical"> | ||
<Radio value="long"> | ||
This is long long long long long long long long long long long long long long long long | ||
long long long long long long long long text | ||
</Radio> | ||
<Radio value="short">This is short text</Radio> | ||
</Space> | ||
</Radio.Group> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Radio as AntRadio } from 'antd'; | ||
import type { RadioProps as AntRadioProps, RadioRef } from 'antd/es/radio'; | ||
import classNames from 'classnames'; | ||
import React, { useContext } from 'react'; | ||
import ConfigProvider from '../config-provider'; | ||
import useStyle from './style'; | ||
|
||
export * from 'antd/es/radio'; | ||
|
||
const InternalRadio = React.forwardRef<RadioRef, AntRadioProps>( | ||
({ prefixCls: customizePrefixCls, className, ...restProps }, ref) => { | ||
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext); | ||
const prefixCls = getPrefixCls('radio', customizePrefixCls); | ||
const { wrapSSR } = useStyle(prefixCls); | ||
const radioCls = classNames(className); | ||
return wrapSSR( | ||
<AntRadio ref={ref} prefixCls={customizePrefixCls} className={radioCls} {...restProps} /> | ||
); | ||
} | ||
); | ||
|
||
const Radio = InternalRadio as typeof Radio; | ||
|
||
Radio.Button = AntRadio.Button; | ||
Radio.Group = AntRadio.Group; | ||
// @ts-ignore | ||
Radio.__ANT_RADIO = AntRadio.__ANT_RADIO; | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
Radio.displayName = AntRadio.displayName; | ||
} | ||
|
||
export default Radio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { CSSObject } from '@ant-design/cssinjs'; | ||
import type { FullToken, GenerateStyle } from 'antd/es/theme/internal'; | ||
import { genComponentStyleHook } from '../../_util/genComponentStyleHook'; | ||
|
||
export type RadioToken = FullToken<'Radio'>; | ||
|
||
export const genRadioStyle: GenerateStyle<RadioToken> = (token: RadioToken): CSSObject => { | ||
const { componentCls, radioSize, fontSize, fontSizeLG, lineHeight } = token; | ||
return { | ||
[`${componentCls}-wrapper`]: { | ||
[`${componentCls}`]: { | ||
alignSelf: 'auto', | ||
[`${componentCls}-inner`]: { | ||
marginBottom: -(fontSize * lineHeight - (radioSize || fontSizeLG)) / 2, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
export default (prefixCls: string) => { | ||
const useStyle = genComponentStyleHook('Radio', token => { | ||
return [genRadioStyle(token as RadioToken)]; | ||
}); | ||
return useStyle(prefixCls); | ||
}; |