ADDED: base styles for segmented buttons
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import React, { cloneElement, forwardRef, ReactElement } from 'react';
|
||||
import { SegmentedButtonProps } from './segmented-buttons.types';
|
||||
|
||||
export const SegmentedButtons = forwardRef<
|
||||
@@ -9,12 +9,21 @@ export const SegmentedButtons = forwardRef<
|
||||
throw 'You must build segmented button with 2 or more buttton';
|
||||
}
|
||||
|
||||
const buttons = children.map((button: ReactElement, index) => {
|
||||
const classes =
|
||||
`m3-button-segment ${button.props.className ?? ''}`.trimEnd();
|
||||
return cloneElement(button, {
|
||||
className: classes,
|
||||
key: index,
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`m3 m3-segmented-buttons ${props.className ?? ''}`.trimEnd()}
|
||||
ref={ref}
|
||||
>
|
||||
{children}
|
||||
{buttons}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user