8f88605f32
* Fixed ActionBar paddings and added transition on button hover * Added recoil library for state management * Refactor table state with recoil : - Removed table internal states - Added refetchQueries to plug apollo store directly into tables - Added an action bar component that manages itself - Use recoil state and selector for row selection - Refactored Companies and People tables * Moved hook * Cleaned some files * Fix bug infinite re-compute table row selection --------- Co-authored-by: Charles Bochet <charles@twenty.com>
37 lines
1001 B
TypeScript
37 lines
1001 B
TypeScript
import styled from '@emotion/styled';
|
|
import React from 'react';
|
|
import { useRecoilValue } from 'recoil';
|
|
import { selectedRowIdsState } from '../../../modules/ui/tables/states/selectedRowIdsState';
|
|
|
|
type OwnProps = {
|
|
children: React.ReactNode | React.ReactNode[];
|
|
};
|
|
|
|
const StyledContainer = styled.div`
|
|
display: flex;
|
|
position: absolute;
|
|
z-index: 1;
|
|
height: 48px;
|
|
bottom: 38px;
|
|
background: ${(props) => props.theme.secondaryBackground};
|
|
align-items: center;
|
|
padding-left: ${(props) => props.theme.spacing(2)};
|
|
padding-right: ${(props) => props.theme.spacing(2)};
|
|
color: ${(props) => props.theme.red};
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
|
|
border-radius: 8px;
|
|
border: 1px solid ${(props) => props.theme.primaryBorder};
|
|
`;
|
|
|
|
export function EntityTableActionBar({ children }: OwnProps) {
|
|
const selectedRowIds = useRecoilValue(selectedRowIdsState);
|
|
|
|
if (selectedRowIds.length === 0) {
|
|
return <></>;
|
|
}
|
|
|
|
return <StyledContainer>{children}</StyledContainer>;
|
|
}
|