* merge squashed
- A couple of CJS modules into ESM (config mostly)
- Vite complains about node.js modules: fixed `useIsMatchingLocation.ts`
> or use rollupOptions in vite.config.ts
> ref: f0e4f59d97/vite.config.js (L6)
- Adjust Storybook to work with Vite: use @storybook/test
- Use SWC for jest tranformations
- Remove unused deps:
- ts-jest: replaced with @swc/jest, typecheck by `tsc`
- babel plugins
- @svgr/plugin-jsx: not used
- @testing-library/user-event: handled by @storybook/test
- @typescript-eslint/utils: was not plugged in
- tsup, esbuild-plugin-svgr: will look into that later
- Install Vite required deps, and remove craco/webpack deps
- Adjust SVG to work with Vite as components
- Fixed `Step.tsx`: I dont know if one should be swaped for the other,
but there should be no slash
- Initial formating and linting:
- removed empty object params
- sorting imports, etc..
* prettier: fix pattern
* coverage: sb coverage report isnt working
* Add missing pieces
* `yarn lint --fix`
* fix: scripts permissions
* tsc: cut errors in half
* fix: remove `react-app-env.d.ts`
* tsc: all fixed, except `react-data-grid` types issue
* eslint: ignore env-config.js
* eslint: Align ci with config
* msw: bypass testing warnings
ref: https://stackoverflow.com/questions/68024935/msw-logging-warnings-for-unhandled-supertest-requests
* rebase: and fix things
* Adjust to current `graphql-codegen` no ESM support
* Remove vite plugin and use built-in methods
* rebase: and some fixes
* quick fix + `corepack use yarn@1.22.19`
* Fix build errors
---------
Co-authored-by: Charles Bochet <charles@twenty.com>
74 lines
2.2 KiB
TypeScript
74 lines
2.2 KiB
TypeScript
import { ReactNode, useState } from 'react';
|
|
import { useTheme } from '@emotion/react';
|
|
import styled from '@emotion/styled';
|
|
|
|
import { IconChevronDown, IconChevronUp } from '@/ui/display/icon';
|
|
|
|
import { TableBody } from './TableBody';
|
|
|
|
type TableSectionProps = {
|
|
children: ReactNode;
|
|
isInitiallyExpanded?: boolean;
|
|
title: string;
|
|
};
|
|
|
|
const StyledSectionHeader = styled.div<{ isExpanded: boolean }>`
|
|
align-items: center;
|
|
background-color: ${({ theme }) => theme.background.transparent.lighter};
|
|
border-bottom: 1px solid ${({ theme }) => theme.border.color.light};
|
|
color: ${({ theme }) => theme.font.color.light};
|
|
cursor: pointer;
|
|
display: flex;
|
|
font-size: ${({ theme }) => theme.font.size.xs};
|
|
font-weight: ${({ theme }) => theme.font.weight.semiBold};
|
|
height: ${({ theme }) => theme.spacing(6)};
|
|
justify-content: space-between;
|
|
padding: 0 ${({ theme }) => theme.spacing(2)};
|
|
text-align: left;
|
|
text-transform: uppercase;
|
|
`;
|
|
|
|
const StyledSection = styled.div<{ isExpanded: boolean }>`
|
|
max-height: ${({ isExpanded }) => (isExpanded ? '1000px' : 0)};
|
|
opacity: ${({ isExpanded }) => (isExpanded ? 1 : 0)};
|
|
overflow: hidden;
|
|
transition:
|
|
max-height ${({ theme }) => theme.animation.duration.normal}s,
|
|
opacity ${({ theme }) => theme.animation.duration.normal}s;
|
|
`;
|
|
|
|
const StyledSectionContent = styled(TableBody)`
|
|
border-bottom: 1px solid ${({ theme }) => theme.border.color.light};
|
|
`;
|
|
|
|
export const TableSection = ({
|
|
children,
|
|
isInitiallyExpanded = true,
|
|
title,
|
|
}: TableSectionProps) => {
|
|
const theme = useTheme();
|
|
const [isExpanded, setIsExpanded] = useState(isInitiallyExpanded);
|
|
|
|
const handleToggleSection = () =>
|
|
setIsExpanded((previousIsExpanded) => !previousIsExpanded);
|
|
|
|
return (
|
|
<>
|
|
<StyledSectionHeader
|
|
isExpanded={isExpanded}
|
|
onClick={handleToggleSection}
|
|
>
|
|
{title}
|
|
{isExpanded ? (
|
|
<IconChevronUp size={theme.icon.size.sm} />
|
|
) : (
|
|
<IconChevronDown size={theme.icon.size.sm} />
|
|
)}
|
|
</StyledSectionHeader>
|
|
<StyledSection isExpanded={isExpanded}>
|
|
<StyledSectionContent>{children}</StyledSectionContent>
|
|
</StyledSection>
|
|
</>
|
|
);
|
|
};
|