Files
twenty/packages/twenty-front/src/modules/error-handler/components/AppRootErrorFallback.tsx
T
Raphaël Bosi 8034c7725f Reorganize twenty-ui into best-practice component domains and per-component folders (#21745)
Reorganizes `twenty-ui`'s component organization to follow how the best
UI libraries (MUI, Mantine, Base UI, Polaris) structure their source,
now that the package has stabilized.

**Taxonomy** — dissolves the meaningless `components/` junk-drawer and
the 107-file `display/` mega-category. New domains/subpaths:
`data-display`, `typography`, `icon`, `surfaces`; `feedback` and
`layout` absorb the rest (banners/callout/info + placeholders →
feedback; modal/card → surfaces; motion + separators → layout).

**Per-component layout** — every component is now
`<domain>/<ComponentName>/<ComponentName>.tsx` with colocated
styles/stories/types, `internal/` for private helpers and `parts/` for
re-exported compound sub-parts. The redundant inner `/components/` is
gone. `icon` and `json-visualizer` are kept as cohesive subsystems.

**Also:** adds a tree-shakeable root barrel (`import { Button } from
'twenty-ui'`), the generator now owns `individual-entry.ts`, and a real
barrel-leak bug is fixed (private `internals/` parts were leaking into
the public API).

Consumer imports (~1.2k files) and the `twenty-sdk` UI aggregator were
updated by codemod. The change is **export-neutral** except 16
intentionally-removed private internals symbols (all verified
unconsumed). Gates green: typecheck, lint, build, size-limit, storybook.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/21745?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
2026-06-18 10:31:29 +02:00

139 lines
3.4 KiB
TypeScript

import { type AppErrorDisplayProps } from '@/error-handler/types/AppErrorDisplayProps';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { useContext } from 'react';
import { IconReload } from 'twenty-ui/icon';
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
type AppRootErrorFallbackProps = AppErrorDisplayProps;
const StyledContainer = styled.div`
background: ${themeCssVariables.background.noisy};
box-sizing: border-box;
display: flex;
height: 100vh;
padding: 12px;
width: 100vw;
`;
const StyledPanel = styled.div`
background: ${themeCssVariables.grayScale.gray1};
border: 1px solid ${themeCssVariables.grayScale.gray5};
border-radius: 8px;
height: 100%;
overflow-x: auto;
overflow-y: hidden;
width: 100%;
`;
const StyledEmptyContainer = styled.div`
align-items: center;
display: flex;
flex-direction: column;
gap: 24px;
height: 100%;
justify-content: center;
text-align: center;
width: 100%;
`;
const StyledImageContainer = styled.div`
align-items: center;
display: flex;
justify-content: center;
position: relative;
`;
const StyledBackgroundImage = styled.img`
max-height: 160px;
max-width: 160px;
`;
const StyledInnerImage = styled.img`
max-height: 130px;
max-width: 130px;
position: absolute;
`;
const StyledEmptyTextContainer = styled.div`
align-items: center;
display: flex;
flex-direction: column;
gap: 8px;
justify-content: center;
text-align: center;
width: 100%;
`;
const StyledEmptyTitle = styled.div`
color: ${themeCssVariables.grayScale.gray12};
font-size: 1.23rem;
font-weight: 600;
`;
const StyledEmptySubTitle = styled.div`
color: ${themeCssVariables.grayScale.gray11};
font-size: 0.92rem;
font-weight: 400;
line-height: 1.5;
max-height: 2.8em;
overflow: hidden;
width: 50%;
`;
const StyledButton = styled.button`
align-items: center;
background: ${themeCssVariables.grayScale.gray1};
border: 1px solid ${themeCssVariables.grayScale.gray5};
border-radius: 8px;
color: ${themeCssVariables.grayScale.gray12};
cursor: pointer;
display: flex;
padding: 8px;
padding: 8px 16px;
`;
const StyledIconContainer = styled.span`
color: ${themeCssVariables.grayScale.gray12};
display: inline-flex;
margin-right: 8px;
`;
export const AppRootErrorFallback = ({
resetErrorBoundary,
title = t`Sorry, something went wrong`,
}: AppRootErrorFallbackProps) => {
const { theme } = useContext(ThemeContext);
return (
<StyledContainer>
<StyledPanel>
<StyledEmptyContainer>
<StyledImageContainer>
<StyledBackgroundImage
src="/images/placeholders/background/error_index_bg.png"
alt={t`Background`}
/>
<StyledInnerImage
src="/images/placeholders/moving-image/error_index.png"
alt={t`Error illustration`}
/>
</StyledImageContainer>
<StyledEmptyTextContainer>
<StyledEmptyTitle>{title}</StyledEmptyTitle>
<StyledEmptySubTitle>
{t`Please refresh the page.`}
</StyledEmptySubTitle>
</StyledEmptyTextContainer>
<StyledButton onClick={resetErrorBoundary}>
<StyledIconContainer>
<IconReload size={theme.icon.size.md} />
</StyledIconContainer>
{t`Reload`}
</StyledButton>
</StyledEmptyContainer>
</StyledPanel>
</StyledContainer>
);
};