eda905f271
## Summary This PR improves Linaria/WYW pre-build speed and continues the migration of `twenty-ui` components away from runtime `ThemeContext` reads toward static CSS variables and theme constants. ### Linaria/WYW profiling plugin improvements (`twenty-shared`) - **Babel JIT warmup**: added a `buildStart` warmup step that triggers WYW's Babel JIT compilation before the real build starts, so the first real file doesn't pay the cold-start penalty - **`configResolved` hook**: detects dev vs prod mode and resolves the correct warmup file path relative to `config.root` - **Dev-only per-file logging**: slow file warnings are now gated behind `isDevMode`, keeping production/CI build output clean - **`closeBundle` summary**: moved the final top-slow-files report to `closeBundle` for accurate end-of-build reporting - **Removed noisy progress interval logging** in favor of the warmup log + final summary ### Migration from `ThemeContext` to static CSS variables / constants Across `twenty-ui`, replaced runtime `useTheme()` reads with: - `themeCssVariables` CSS custom properties (colors, spacing) - Hard-coded design-system constants (`ICON.size.md` → `16`, `ICON.stroke.sm` → `1.6`) so components no longer need a React context at render time — enabling Linaria static extraction **Components migrated:** - `Button`, `AnimatedButton`, `LightButton`, `LightIconButton`, `AnimatedLightIconButton`, `ButtonIcon`, `ButtonSoon` - `ProgressBar` (Framer Motion width animation → CSS `transition`) - `Info`, `HorizontalSeparator`, `LinkChip` - `MenuPicker`, `MenuItemLeftContent`, `MenuItemIconWithGripSwap`, `NavigationBarItem` - `JsonArrow`, `JsonNestedNode` - `ModalHeader` ### Other - Added `aria-valuenow` to `ProgressBar` for accessibility - `VisibilityHidden` component updated to inline accessibility styles
136 lines
3.4 KiB
TypeScript
136 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 { IconReload } from 'twenty-ui/display';
|
|
import { ICON_SIZES, 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;
|
|
width: 100vw;
|
|
padding: 12px;
|
|
`;
|
|
|
|
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;
|
|
width: 100%;
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 24px;
|
|
justify-content: center;
|
|
text-align: center;
|
|
`;
|
|
|
|
const StyledImageContainer = styled.div`
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
position: relative;
|
|
`;
|
|
|
|
const StyledBackgroundImage = styled.img`
|
|
max-height: 160px;
|
|
max-width: 160px;
|
|
`;
|
|
|
|
const StyledInnerImage = styled.img`
|
|
max-height: 130px;
|
|
position: absolute;
|
|
max-width: 130px;
|
|
`;
|
|
|
|
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};
|
|
color: ${themeCssVariables.grayScale.gray12};
|
|
border-radius: 8px;
|
|
cursor: pointer;
|
|
display: flex;
|
|
padding: 8px 16px;
|
|
padding: 8px;
|
|
`;
|
|
|
|
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) => {
|
|
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={ICON_SIZES.md} />
|
|
</StyledIconContainer>
|
|
{t`Reload`}
|
|
</StyledButton>
|
|
</StyledEmptyContainer>
|
|
</StyledPanel>
|
|
</StyledContainer>
|
|
);
|
|
};
|