This PR was created by [GitStart](https://gitstart.com/) to address the requirements from this ticket: [TWNTY-7529](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-7529). --- ### Description - Migrated all button components to `twenty-ui` \ \ `Button`\ `ButtonGroup`\ `ColorPickerButton`\ `FloatingButton`\ `FloatingButtonGroup`\ `FloatingIconButton`\ `FloatingIconButtonGroup`\ `IconButton`\ `IconButtonGroup`\ `LightButton`\ `LightIconButton`\ `LightIconButtonGroup`\ `MainButton`\ \ Fixes twentyhq/private-issues#89 Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: Charles Bochet <charles@twenty.com>
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import styled from '@emotion/styled';
|
|
import React from 'react';
|
|
|
|
import { isDefined } from '@ui/utilities';
|
|
|
|
import { FloatingButtonPosition, FloatingButtonProps } from './FloatingButton';
|
|
|
|
const StyledFloatingButtonGroupContainer = styled.div`
|
|
backdrop-filter: blur(20px);
|
|
border-radius: ${({ theme }) => theme.border.radius.md};
|
|
box-shadow: ${({ theme }) =>
|
|
`0px 2px 4px 0px ${theme.background.transparent.light}, 0px 0px 4px 0px ${theme.background.transparent.medium}`};
|
|
display: inline-flex;
|
|
`;
|
|
|
|
export type FloatingButtonGroupProps = Pick<FloatingButtonProps, 'size'> & {
|
|
children: React.ReactElement[];
|
|
className?: string;
|
|
};
|
|
|
|
export const FloatingButtonGroup = ({
|
|
children,
|
|
size,
|
|
className,
|
|
}: FloatingButtonGroupProps) => (
|
|
<StyledFloatingButtonGroupContainer className={className}>
|
|
{React.Children.map(children, (child, index) => {
|
|
let position: FloatingButtonPosition;
|
|
|
|
if (index === 0) {
|
|
position = 'left';
|
|
} else if (index === children.length - 1) {
|
|
position = 'right';
|
|
} else {
|
|
position = 'middle';
|
|
}
|
|
|
|
const additionalProps: any = {
|
|
position,
|
|
size,
|
|
applyShadow: false,
|
|
applyBlur: false,
|
|
};
|
|
|
|
if (isDefined(size)) {
|
|
additionalProps.size = size;
|
|
}
|
|
|
|
return React.cloneElement(child, additionalProps);
|
|
})}
|
|
</StyledFloatingButtonGroupContainer>
|
|
);
|