mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-27 08:00:51 +01:00
Update layout components
This commit is contained in:
parent
84b8607b07
commit
0b6bb5c541
22
src/common/ButtonGroup.tsx
Normal file
22
src/common/ButtonGroup.tsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { FC, useMemo } from 'react';
|
||||||
|
import { Base, BaseProps } from './Base';
|
||||||
|
|
||||||
|
export interface ButtonGroupProps extends BaseProps<HTMLDivElement>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ButtonGroup: FC<ButtonGroupProps> = props =>
|
||||||
|
{
|
||||||
|
const { classNames = [], ...rest } = props;
|
||||||
|
|
||||||
|
const getClassNames = useMemo(() =>
|
||||||
|
{
|
||||||
|
const newClassNames: string[] = [ 'btn-group' ];
|
||||||
|
|
||||||
|
if(classNames.length) newClassNames.push(...classNames);
|
||||||
|
|
||||||
|
return newClassNames;
|
||||||
|
}, [ classNames ]);
|
||||||
|
|
||||||
|
return <Base classNames={ getClassNames } { ...rest } />;
|
||||||
|
}
|
@ -44,16 +44,11 @@ export const Flex: FC<FlexProps> = props =>
|
|||||||
|
|
||||||
if(gap) newClassNames.push('gap-' + gap);
|
if(gap) newClassNames.push('gap-' + gap);
|
||||||
|
|
||||||
if(center)
|
|
||||||
{
|
|
||||||
newClassNames.push('align-items-center', 'justify-content-center');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(alignItems) newClassNames.push('align-items-' + alignItems);
|
if(alignItems) newClassNames.push('align-items-' + alignItems);
|
||||||
|
|
||||||
if(justifyContent) newClassNames.push('justify-content-' + justifyContent);
|
if(justifyContent) newClassNames.push('justify-content-' + justifyContent);
|
||||||
}
|
|
||||||
|
if(!alignItems && !justifyContent && center) newClassNames.push('align-items-center', 'justify-content-center');
|
||||||
|
|
||||||
if(classNames.length) newClassNames.push(...classNames);
|
if(classNames.length) newClassNames.push(...classNames);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user