Skip to content

The open alternative to Salesforce, designed for AI.

Migrate twenty ui to linaria (#18307)

Charles Bochet1db2a409612d
diff --git a/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx b/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx
index 12e136f1df8..0ead5fe577f 100644
--- a/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx
+++ b/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx
@@ -24,7 +24,7 @@ const StyledTaskBody = styled.div`
max-width: calc(80% - ${({ theme }) => theme.spacing(2)});
text-overflow: ellipsis;
overflow: hidden;
- padding-bottom: ${({ theme }) => theme.spacing(0.25)};
+ padding-bottom: 1px;
`;
const StyledTaskTitle = styled.div<{
@@ -33,7 +33,7 @@ const StyledTaskTitle = styled.div<{
color: ${({ theme }) => theme.font.color.primary};
font-weight: ${({ theme }) => theme.font.weight.medium};
padding: 0 ${({ theme }) => theme.spacing(2)};
- padding-bottom: ${({ theme }) => theme.spacing(0.25)};
+ padding-bottom: 1px;
text-decoration: ${({ completed }) => (completed ? 'line-through' : 'none')};
white-space: nowrap;
overflow: hidden;
diff --git a/packages/twenty-front/src/modules/ai/components/AIChatMessage.tsx b/packages/twenty-front/src/modules/ai/components/AIChatMessage.tsx
index c8838011d9e..374d680cbec 100644
--- a/packages/twenty-front/src/modules/ai/components/AIChatMessage.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AIChatMessage.tsx
@@ -49,7 +49,7 @@ const StyledMessageText = styled.div<{ isUser?: boolean }>`
word-wrap: break-word;
max-width: 100%;
line-height: 1.4;
- padding: ${({ theme }) => `${theme.spacing(0.25)} ${theme.spacing(0.75)}`};
+ padding: 1px 3px;
border-radius: ${({ theme }) => theme.border.radius.sm};
background: ${({ theme }) => theme.background.tertiary};
}
diff --git a/packages/twenty-front/src/modules/ai/components/AIChatThreadGroup.tsx b/packages/twenty-front/src/modules/ai/components/AIChatThreadGroup.tsx
index 83a5549f631..f7b91f0a604 100644
--- a/packages/twenty-front/src/modules/ai/components/AIChatThreadGroup.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AIChatThreadGroup.tsx
@@ -31,10 +31,10 @@ const StyledThreadItem = styled.div<{ isSelected?: boolean }>`
margin-bottom: ${({ theme }) => theme.spacing(1)};
border-left: 3px solid transparent;
cursor: pointer;
- padding: ${({ theme }) => theme.spacing(1, 0.25)};
- right: ${({ theme }) => theme.spacing(0.75)};
+ padding: ${({ theme }) => theme.spacing(1)} 1px;
+ right: 3px;
position: relative;
- width: calc(100% + ${({ theme }) => theme.spacing(0.25)});
+ width: calc(100% + 1px);
&:hover {
background: ${({ theme }) => theme.background.transparent.light};
diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AIChatAssistantMessageRenderer.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AIChatAssistantMessageRenderer.test.tsx
index f175ad5aaff..ba2200ed68a 100644
--- a/packages/twenty-front/src/modules/ai/components/__tests__/AIChatAssistantMessageRenderer.test.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__tests__/AIChatAssistantMessageRenderer.test.tsx
@@ -1,9 +1,6 @@
+import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
import { render, screen } from '@testing-library/react';
-import {
- THEME_LIGHT,
- ThemeContextProvider,
- ThemeProvider,
-} from 'twenty-ui/theme';
+import { THEME_LIGHT, ThemeContextProvider } from 'twenty-ui/theme';
import { type ExtendedUIMessagePart } from 'twenty-shared/ai';
import { AIChatAssistantMessageRenderer } from '@/ai/components/AIChatAssistantMessageRenderer';
@@ -46,14 +43,14 @@ jest.mock('@/ai/components/CodeExecutionDisplay', () => ({
const renderAssistantRenderer = (messageParts: ExtendedUIMessagePart[]) => {
return render(
- <ThemeProvider theme={THEME_LIGHT}>
+ <EmotionThemeProvider theme={THEME_LIGHT}>
<ThemeContextProvider theme={THEME_LIGHT}>
<AIChatAssistantMessageRenderer
messageParts={messageParts}
isLastMessageStreaming={false}
/>
</ThemeContextProvider>
- </ThemeProvider>,
+ </EmotionThemeProvider>,
);
};
diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/ThinkingStepsDisplay.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/ThinkingStepsDisplay.test.tsx
index 49e4740cb8e..9a355ab6dab 100644
--- a/packages/twenty-front/src/modules/ai/components/__tests__/ThinkingStepsDisplay.test.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__tests__/ThinkingStepsDisplay.test.tsx
@@ -1,10 +1,7 @@
+import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import {
- THEME_LIGHT,
- ThemeContextProvider,
- ThemeProvider,
-} from 'twenty-ui/theme';
+import { THEME_LIGHT, ThemeContextProvider } from 'twenty-ui/theme';
import { ThinkingStepsDisplay } from '@/ai/components/ThinkingStepsDisplay';
import { type ThinkingStepPart } from '@/ai/utils/thinkingStepPart';
@@ -84,7 +81,7 @@ const renderThinkingStepsDisplay = ({
hasAssistantTextResponseStarted?: boolean;
}) => {
return render(
- <ThemeProvider theme={THEME_LIGHT}>
+ <EmotionThemeProvider theme={THEME_LIGHT}>
<ThemeContextProvider theme={THEME_LIGHT}>
<ThinkingStepsDisplay
parts={parts}
@@ -92,7 +89,7 @@ const renderThinkingStepsDisplay = ({
hasAssistantTextResponseStarted={hasAssistantTextResponseStarted}
/>
</ThemeContextProvider>
- </ThemeProvider>,
+ </EmotionThemeProvider>,
);
};
diff --git a/packages/twenty-front/src/modules/file/components/FileIcon.tsx b/packages/twenty-front/src/modules/file/components/FileIcon.tsx
index b485c03d25e..ee2e224d6b1 100644
--- a/packages/twenty-front/src/modules/file/components/FileIcon.tsx
+++ b/packages/twenty-front/src/modules/file/components/FileIcon.tsx
@@ -18,8 +18,7 @@ const StyledIconContainer = styled.div<{
flex-shrink: 0;
height: ${({ size }) => (size === 'small' ? '14px' : 'auto')};
justify-content: center;
- padding: ${({ theme, size }) =>
- size === 'small' ? '0' : theme.spacing(1.25)};
+ padding: ${({ size }) => (size === 'small' ? '0' : '5px')};
width: ${({ size }) => (size === 'small' ? '14px' : 'auto')};
`;
diff --git a/packages/twenty-front/src/modules/navigation-menu-item/components/ObjectIconWithViewOverlay.tsx b/packages/twenty-front/src/modules/navigation-menu-item/components/ObjectIconWithViewOverlay.tsx
index 8a8bec1bf81..07346a02a45 100644
--- a/packages/twenty-front/src/modules/navigation-menu-item/components/ObjectIconWithViewOverlay.tsx
+++ b/packages/twenty-front/src/modules/navigation-menu-item/components/ObjectIconWithViewOverlay.tsx
@@ -38,11 +38,11 @@ const StyledViewOverlay = styled.div<{ $backgroundColor: string }>`
border-radius: 4px;
bottom: -7px;
display: flex;
- height: ${({ theme }) => theme.spacing(3.5)};
+ height: 14px;
justify-content: center;
position: absolute;
right: -7px;
- width: ${({ theme }) => theme.spacing(3.5)};
+ width: 14px;
`;
export type ObjectIconWithViewOverlayProps = {
@@ -69,14 +69,14 @@ export const ObjectIconWithViewOverlay = ({
$borderColor={objectStyle.borderColor}
>
<ObjectIcon
- size={theme.spacing(3.5)}
+ size="14px"
stroke={theme.icon.stroke.md}
color={objectStyle.iconColor}
/>
</StyledObjectIconWrapper>
<StyledViewOverlay $backgroundColor={theme.grayScale.gray4}>
<ViewIcon
- size={theme.spacing(2.5)}
+ size="10px"
stroke={theme.icon.stroke.lg}
color={theme.grayScale.gray10}
/>
diff --git a/packages/twenty-front/src/modules/navigation-menu-item/utils/parseThemeColor.ts b/packages/twenty-front/src/modules/navigation-menu-item/utils/parseThemeColor.ts
index 30e6783e160..7a407a80a97 100644
--- a/packages/twenty-front/src/modules/navigation-menu-item/utils/parseThemeColor.ts
+++ b/packages/twenty-front/src/modules/navigation-menu-item/utils/parseThemeColor.ts
@@ -1,4 +1,5 @@
-import { themeColorSchema, type ThemeColor } from 'twenty-ui/theme';
+import { type ThemeColor } from 'twenty-ui/theme';
+import { themeColorSchema } from 'twenty-ui/utilities';
import { DEFAULT_NAV_ITEM_ICON_COLOR } from '@/navigation-menu-item/constants/NavigationMenuItemDefaultIconColor.constant';
diff --git a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx
index 16c63477cb1..84f8e454aee 100644
--- a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx
@@ -37,7 +37,7 @@ const StyledTabsPill = styled.div`
border: 1px solid ${({ theme }) => theme.border.color.medium};
background: ${({ theme }) => theme.background.secondary};
border-radius: ${({ theme }) => theme.border.radius.pill};
- padding: ${({ theme }) => theme.spacing(0.75)};
+ padding: 3px;
height: ${({ theme }) => theme.spacing(7)};
display: flex;
width: ${({ theme }) => theme.spacing(18)};
@@ -85,7 +85,7 @@ const StyledNewChatButtonWrapper = styled.div<{ isExpanded: boolean }>`
isExpanded ? theme.spacing(7) : theme.spacing(6)};
justify-content: center;
padding: ${({ theme, isExpanded }) =>
- isExpanded ? theme.spacing(0.75) : theme.spacing(0.5)};
+ isExpanded ? '3px' : theme.spacing(0.5)};
width: ${({ theme, isExpanded }) =>
isExpanded ? theme.spacing(25.75) : theme.spacing(6)};
transition:
diff --git a/packages/twenty-front/src/modules/object-metadata/validation-schemas/fieldMetadataItemSchema.ts b/packages/twenty-front/src/modules/object-metadata/validation-schemas/fieldMetadataItemSchema.ts
index 1eccdd1c53b..37f1b665e55 100644
--- a/packages/twenty-front/src/modules/object-metadata/validation-schemas/fieldMetadataItemSchema.ts
+++ b/packages/twenty-front/src/modules/object-metadata/validation-schemas/fieldMetadataItemSchema.ts
@@ -1,7 +1,7 @@
import { z } from 'zod';
import { metadataLabelSchema } from '@/object-metadata/validation-schemas/metadataLabelSchema';
-import { themeColorSchema } from 'twenty-ui/theme';
+import { themeColorSchema } from 'twenty-ui/utilities';
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
import { camelCaseStringSchema } from '~/utils/validation-schemas/camelCaseStringSchema';
diff --git a/packages/twenty-front/src/modules/object-metadata/validation-schemas/selectOptionsSchema.ts b/packages/twenty-front/src/modules/object-metadata/validation-schemas/selectOptionsSchema.ts
index f334b727d6f..edea9463396 100644
--- a/packages/twenty-front/src/modules/object-metadata/validation-schemas/selectOptionsSchema.ts
+++ b/packages/twenty-front/src/modules/object-metadata/validation-schemas/selectOptionsSchema.ts
@@ -1,6 +1,6 @@
import { z } from 'zod';
-import { themeColorSchema } from 'twenty-ui/theme';
+import { themeColorSchema } from 'twenty-ui/utilities';
import { computeOptionValueFromLabel } from '~/pages/settings/data-model/utils/computeOptionValueFromLabel';
const selectOptionSchema = z
diff --git a/packages/twenty-front/src/modules/object-record/record-card/components/RecordCardBodyContainer.tsx b/packages/twenty-front/src/modules/object-record/record-card/components/RecordCardBodyContainer.tsx
index 24900ba5d11..573c2661ac7 100644
--- a/packages/twenty-front/src/modules/object-record/record-card/components/RecordCardBodyContainer.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-card/components/RecordCardBodyContainer.tsx
@@ -5,7 +5,7 @@ const StyledCardBodyContainer = styled.div`
flex-direction: column;
gap: ${({ theme }) => theme.spacing(0.5)};
padding-bottom: ${({ theme }) => theme.spacing(2)};
- padding-left: ${({ theme }) => theme.spacing(2.5)};
+ padding-left: 10px;
padding-right: ${({ theme }) => theme.spacing(2)};
span {
align-items: center;
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellBaseContainer.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellBaseContainer.tsx
index 0ab91883da7..6a689392770 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellBaseContainer.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellBaseContainer.tsx
@@ -4,7 +4,6 @@ import { useContext, type ReactNode } from 'react';
import { FieldContext } from '@/object-record/record-field/ui/contexts/FieldContext';
import { isFieldIdentifierDisplay } from '@/object-record/record-field/ui/meta-types/display/utils/isFieldIdentifierDisplay';
import { RECORD_CHIP_CLICK_OUTSIDE_ID } from '@/object-record/record-table/constants/RecordChipClickOutsideId';
-import { RECORD_TABLE_ROW_HEIGHT } from '@/object-record/record-table/constants/RecordTableRowHeight';
import { RecordTableCellContext } from '@/object-record/record-table/contexts/RecordTableCellContext';
import { useOpenRecordTableCellFromCell } from '@/object-record/record-table/record-table-cell/hooks/useOpenRecordTableCellFromCell';
import { ThemeContext } from 'twenty-ui/theme';
@@ -21,7 +20,7 @@ const StyledBaseContainer = styled.div<{
box-sizing: border-box;
cursor: ${({ isReadOnly }) => (isReadOnly ? 'default' : 'pointer')};
display: flex;
- height: ${RECORD_TABLE_ROW_HEIGHT}px;
+ height: 32px;
user-select: none;
position: relative;
diff --git a/packages/twenty-front/src/modules/object-record/record-table/virtualization/components/RecordTableRowVirtualizedContainer.tsx b/packages/twenty-front/src/modules/object-record/record-table/virtualization/components/RecordTableRowVirtualizedContainer.tsx
index 57fbc26a6b6..f9d968578b7 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/virtualization/components/RecordTableRowVirtualizedContainer.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/virtualization/components/RecordTableRowVirtualizedContainer.tsx
@@ -14,7 +14,7 @@ import { isDefined } from 'twenty-shared/utils';
const StyledVirtualizedRowContainer = styled.div<{
pixelsFromTop: number;
}>`
- height: ${RECORD_TABLE_ROW_HEIGHT + 1};
+ height: 33px;
position: absolute;
top: ${({ pixelsFromTop }) => pixelsFromTop}px;
`;
diff --git a/packages/twenty-front/src/modules/object-record/record-table/virtualization/components/RecordTableRowVirtualizedDebugRowHelper.tsx b/packages/twenty-front/src/modules/object-record/record-table/virtualization/components/RecordTableRowVirtualizedDebugRowHelper.tsx
index 863501ba49d..16bddf45e09 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/virtualization/components/RecordTableRowVirtualizedDebugRowHelper.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/virtualization/components/RecordTableRowVirtualizedDebugRowHelper.tsx
@@ -16,7 +16,7 @@ import { isDefined } from 'twenty-shared/utils';
const StyledDebugRow = styled.div`
position: absolute;
left: 250px;
- top: ${({ theme }) => theme.spacing(1.25)};
+ top: 5px;
z-index: 20;
color: ${({ theme }) => theme.font.color.primary};
background-color: ${({ theme }) => theme.color.gray3};
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminWorkerMetricsGraph.tsx b/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminWorkerMetricsGraph.tsx
index 6b9438df344..a4f0bb1d51d 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminWorkerMetricsGraph.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminWorkerMetricsGraph.tsx
@@ -16,7 +16,7 @@ const StyledGraphContainer = styled.div`
height: 240px;
border: 1px solid ${({ theme }) => theme.border.color.medium};
margin-bottom: ${({ theme }) => theme.spacing(4)};
- padding-top: ${({ theme }) => theme.spacing(2.5)};
+ padding-top: 10px;
width: 100%;
`;
diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/select/components/SettingsDataModelFieldSelectForm.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/select/components/SettingsDataModelFieldSelectForm.tsx
index 2f2516413b0..319f4905762 100644
--- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/select/components/SettingsDataModelFieldSelectForm.tsx
+++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/select/components/SettingsDataModelFieldSelectForm.tsx
@@ -68,7 +68,7 @@ type SettingsDataModelFieldSelectFormProps = {
};
const StyledContainer = styled(CardContent)`
- padding-bottom: ${({ theme }) => theme.spacing(3.5)};
+ padding-bottom: 14px;
`;
const StyledOptionsLabel = styled.div<{
diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/select/components/SettingsDataModelFieldSelectFormOptionRow.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/select/components/SettingsDataModelFieldSelectFormOptionRow.tsx
index 5effa596a31..201c9be3110 100644
--- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/select/components/SettingsDataModelFieldSelectFormOptionRow.tsx
+++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/select/components/SettingsDataModelFieldSelectFormOptionRow.tsx
@@ -79,8 +79,8 @@ const StyledColorSample = styled(ColorSample)`
margin-top: ${({ theme }) => theme.spacing(1)};
margin-bottom: ${({ theme }) => theme.spacing(1)};
- margin-right: ${({ theme }) => theme.spacing(3.5)};
- margin-left: ${({ theme }) => theme.spacing(3.5)};
+ margin-right: 14px;
+ margin-left: 14px;
`;
const StyledOptionInput = styled(SettingsTextInput)`Chip
@@ -92,7 +92,7 @@ const StyledOptionInput = styled(SettingsTextInput)`Chip
`;
const StyledIconGripVertical = styled(IconGripVertical)`
- margin-right: ${({ theme }) => theme.spacing(0.75)};
+ margin-right: 3px;
`;
const StyledLightIconButton = styled(LightIconButton)`
diff --git a/packages/twenty-front/src/modules/spreadsheet-import/components/StepNavigationButton.tsx b/packages/twenty-front/src/modules/spreadsheet-import/components/StepNavigationButton.tsx
index c24ffd30a47..9f77dc3ed21 100644
--- a/packages/twenty-front/src/modules/spreadsheet-import/components/StepNavigationButton.tsx
+++ b/packages/twenty-front/src/modules/spreadsheet-import/components/StepNavigationButton.tsx
@@ -9,7 +9,7 @@ import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
const StyledFooter = styled(Modal.Footer)`
border-top: 1px solid ${({ theme }) => theme.border.color.medium};
box-shadow: ${({ theme }) => theme.boxShadow.strong};
- gap: ${({ theme }) => theme.spacing(2.5)};
+ gap: 10px;
justify-content: space-between;
padding: ${({ theme }) => theme.spacing(4)};
height: auto;
diff --git a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/MatchColumnsStep/components/UnmatchColumnBanner.tsx b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/MatchColumnsStep/components/UnmatchColumnBanner.tsx
index fc81306021a..0a1f5555293 100644
--- a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/MatchColumnsStep/components/UnmatchColumnBanner.tsx
+++ b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/MatchColumnsStep/components/UnmatchColumnBanner.tsx
@@ -10,7 +10,7 @@ const StyledBanner = styled(Banner, {
background: ${({ allMatched, theme }) =>
allMatched ? theme.accent.secondary : theme.background.transparent.light};
border-radius: ${({ theme }) => theme.spacing(2)};
- padding: ${({ theme }) => theme.spacing(2) + ' ' + theme.spacing(2.5)};
+ padding: ${({ theme }) => theme.spacing(2) + ' 10px'};
`;
const StyledText = styled('div', {
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/BooleanDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/BooleanDisplay.tsx
index a9eb0b30ee5..ee2851d6ecb 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/BooleanDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/BooleanDisplay.tsx
@@ -3,11 +3,10 @@ import { t } from '@lingui/core/macro';
import { IconCheck, IconX } from 'twenty-ui/display';
import { THEME_COMMON } from 'twenty-ui/theme';
-const spacing = THEME_COMMON.spacingMultiplicator * 1;
const iconSizeSm = THEME_COMMON.icon.size.sm;
const StyledBooleanFieldValue = styled.div`
- margin-left: ${spacing}px;
+ margin-left: 4px;
`;
type BooleanDisplayProps = {
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx
index a7616997fb7..856d582721a 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx
@@ -5,7 +5,6 @@ import { ExpandableList } from '@/ui/layout/expandable-list/components/Expandabl
import { styled } from '@linaria/react';
import { isDefined } from 'twenty-shared/utils';
import { RoundedLink } from 'twenty-ui/navigation';
-import { THEME_COMMON } from 'twenty-ui/theme';
type EmailsDisplayProps = {
value?: FieldEmailsValue;
@@ -13,12 +12,10 @@ type EmailsDisplayProps = {
onEmailClick?: (email: string, event: React.MouseEvent<HTMLElement>) => void;
};
-const themeSpacing = THEME_COMMON.spacingMultiplicator;
-
const StyledContainer = styled.div`
align-items: center;
display: flex;
- gap: ${themeSpacing * 1}px;
+ gap: 4px;
justify-content: flex-start;
max-width: 100%;
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx
index fe7568e173a..ee3a9f79afc 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx
@@ -2,14 +2,11 @@ import { type FieldMultiSelectValue } from '@/object-record/record-field/ui/type
import { styled } from '@linaria/react';
import { Tag } from 'twenty-ui/components';
import { type SelectOption } from 'twenty-ui/input';
-import { THEME_COMMON } from 'twenty-ui/theme';
-
-const spacing1 = THEME_COMMON.spacing(1);
const StyledContainer = styled.div`
align-items: center;
display: flex;
- gap: ${spacing1};
+ gap: 4px;
justify-content: flex-start;
max-width: 100%;
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx
index a6b484c2448..4148cdb4694 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx
@@ -8,7 +8,6 @@ import { styled } from '@linaria/react';
import { parsePhoneNumber } from 'libphonenumber-js';
import { isDefined } from 'twenty-shared/utils';
import { RoundedLink } from 'twenty-ui/navigation';
-import { THEME_COMMON } from 'twenty-ui/theme';
import { logError } from '~/utils/logError';
type PhonesDisplayProps = {
@@ -20,12 +19,10 @@ type PhonesDisplayProps = {
) => void;
};
-const themeSpacing = THEME_COMMON.spacingMultiplicator;
-
const StyledContainer = styled.div`
align-items: center;
display: flex;
- gap: ${themeSpacing * 1}px;
+ gap: 4px;
justify-content: flex-start;
max-width: 100%;
diff --git a/packages/twenty-front/src/modules/ui/input/components/InputErrorHelper.tsx b/packages/twenty-front/src/modules/ui/input/components/InputErrorHelper.tsx
index 5f3d4690920..85eddd811ba 100644
--- a/packages/twenty-front/src/modules/ui/input/components/InputErrorHelper.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/InputErrorHelper.tsx
@@ -5,7 +5,7 @@ const StyledInputErrorHelper = styled.div`
color: ${({ theme }) => theme.color.red};
font-size: ${({ theme }) => theme.font.size.xs};
position: absolute;
- margin-top: ${({ theme }) => theme.spacing(0.25)};
+ margin-top: 1px;
`;
export const InputErrorHelper = ({
diff --git a/packages/twenty-front/src/modules/ui/input/components/TextInput.tsx b/packages/twenty-front/src/modules/ui/input/components/TextInput.tsx
index 351a0b291e4..dbe65ed8277 100644
--- a/packages/twenty-front/src/modules/ui/input/components/TextInput.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/TextInput.tsx
@@ -409,7 +409,7 @@ const StyledAutogrowWrapper = styled(AutogrowWrapper)<{
: sizeVariant === 'md'
? '28px'
: '32px'};
- padding: 0 ${({ theme }) => theme.spacing(1.25)};
+ padding: 0 5px;
`;
const TextInputWithAutoGrowWrapper = forwardRef<
diff --git a/packages/twenty-front/src/modules/workflow/workflow-trigger/components/WorkflowEditTriggerManual.tsx b/packages/twenty-front/src/modules/workflow/workflow-trigger/components/WorkflowEditTriggerManual.tsx
index 51c4a027ede..645fcc92eff 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-trigger/components/WorkflowEditTriggerManual.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-trigger/components/WorkflowEditTriggerManual.tsx
@@ -40,7 +40,7 @@ const StyledLabel = styled.span`
const StyledDescription = styled.span`
color: ${({ theme }) => theme.font.color.light};
font-size: ${({ theme }) => theme.font.size.sm};
- margin-top: ${({ theme }) => theme.spacing(0.25)};
+ margin-top: 1px;
`;
const StyledIconPickerContainer = styled.div`
diff --git a/packages/twenty-front/vite.config.ts b/packages/twenty-front/vite.config.ts
index 38ab9e49d00..d63368cabb0 100644
--- a/packages/twenty-front/vite.config.ts
+++ b/packages/twenty-front/vite.config.ts
@@ -111,32 +111,14 @@ export default defineConfig(({ command, mode }) => {
{
...wyw({
include: [
- '**/CurrencyDisplay.tsx',
+ '**/twenty-ui/src/**/*.{ts,tsx}',
'**/EllipsisDisplay.tsx',
- '**/ContactLink.tsx',
'**/BooleanDisplay.tsx',
- '**/LinksDisplay.tsx',
- '**/RoundedLink.tsx',
- '**/OverflowingTextWithTooltip.tsx',
- '**/Chip.tsx',
- '**/Tag.tsx',
- '**/MultiSelectFieldDisplay.tsx',
'**/RatingInput.tsx',
- '**/RecordTableCellContainer.tsx',
'**/RecordTableCellDisplayContainer.tsx',
- '**/Avatar.tsx',
- '**/RecordTableBodyDroppable.tsx',
'**/RecordTableCellBaseContainer.tsx',
- '**/RecordTableCellTd.tsx',
'**/RecordTableCellStyleWrapper.tsx',
- '**/RecordTableHeaderDragDropColumn.tsx',
- '**/ActorDisplay.tsx',
- '**/BooleanDisplay.tsx',
- '**/CurrencyDisplay.tsx',
'**/TextDisplay.tsx',
- '**/EllipsisDisplay.tsx',
- '**/AvatarChip.tsx',
- '**/URLDisplay.tsx',
'**/EmailsDisplay.tsx',
'**/PhonesDisplay.tsx',
'**/MultiSelectDisplay.tsx',
diff --git a/packages/twenty-shared/src/utils/index.ts b/packages/twenty-shared/src/utils/index.ts
index 4b818c259e6..3cf64935a17 100644
--- a/packages/twenty-shared/src/utils/index.ts
+++ b/packages/twenty-shared/src/utils/index.ts
@@ -147,6 +147,7 @@ export { safeParseRelativeDateFilterJSONStringified } from './safeParseRelativeD
export { getGenericOperationName } from './sentry/getGenericOperationName';
export { getHumanReadableNameFromCode } from './sentry/getHumanReadableNameFromCode';
export { appendCopySuffix } from './strings/appendCopySuffix';
+export { camelToKebab } from './strings/camelToKebab';
export { camelToSnakeCase } from './strings/camelToSnakeCase';
export { capitalize } from './strings/capitalize';
export { pascalCase } from './strings/pascalCase';
diff --git a/packages/twenty-shared/src/utils/strings/camelToKebab.ts b/packages/twenty-shared/src/utils/strings/camelToKebab.ts
new file mode 100644
index 00000000000..5df757f3541
--- /dev/null
+++ b/packages/twenty-shared/src/utils/strings/camelToKebab.ts
@@ -0,0 +1,2 @@
+export const camelToKebab = (str: string): string =>
+ str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
diff --git a/packages/twenty-ui/.storybook/preview.tsx b/packages/twenty-ui/.storybook/preview.tsx
index bf19bc3b925..ce885f37912 100644
--- a/packages/twenty-ui/.storybook/preview.tsx
+++ b/packages/twenty-ui/.storybook/preview.tsx
@@ -1,4 +1,3 @@
-import { ThemeProvider } from '@emotion/react';
import { type Preview } from '@storybook/react-vite';
import { THEME_LIGHT, ThemeContextProvider } from '@ui/theme';
@@ -6,20 +5,12 @@ const preview: Preview = {
tags: ['autodocs'],
decorators: [
(Story) => {
- // const mode = useDarkMode() ? 'Dark' : 'Light';
-
const theme = THEME_LIGHT;
- /* useEffect(() => {
- document.documentElement.className = mode === 'Dark' ? 'dark' : 'light';
- }, [mode]);*/
-
return (
- <ThemeProvider theme={theme}>
- <ThemeContextProvider theme={theme}>
- <Story />
- </ThemeContextProvider>
- </ThemeProvider>
+ <ThemeContextProvider theme={theme}>
+ <Story />
+ </ThemeContextProvider>
);
},
],
diff --git a/packages/twenty-ui/package.json b/packages/twenty-ui/package.json
index 8b4e893d9fd..c090bb9df3c 100644
--- a/packages/twenty-ui/package.json
+++ b/packages/twenty-ui/package.json
@@ -12,7 +12,6 @@
"@babel/preset-env": "^7.26.9",
"@babel/preset-react": "^7.26.3",
"@prettier/sync": "^0.5.2",
- "@swc/plugin-emotion": "14.6.0",
"@types/babel__preset-env": "^7",
"@types/react": "^18.2.39",
"@types/react-dom": "^18.2.15",
@@ -26,9 +25,6 @@
"vite-plugin-svgr": "^4.3.0"
},
"dependencies": {
- "@emotion/is-prop-valid": "^1.3.0",
- "@emotion/react": "^11.11.1",
- "@emotion/styled": "^11.11.0",
"@linaria/react": "^6.2.1",
"@monaco-editor/react": "^4.7.0",
"@sniptt/guards": "^0.2.0",
diff --git a/packages/twenty-ui/src/accessibility/components/VisibilityHidden.tsx b/packages/twenty-ui/src/accessibility/components/VisibilityHidden.tsx
index 44f00440e25..0aae6f4a3fb 100644
--- a/packages/twenty-ui/src/accessibility/components/VisibilityHidden.tsx
+++ b/packages/twenty-ui/src/accessibility/components/VisibilityHidden.tsx
@@ -1,4 +1,4 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { VISIBILITY_HIDDEN } from '@ui/accessibility/utils/visibility-hidden';
const StyledSpan = styled.span`
diff --git a/packages/twenty-ui/src/accessibility/components/VisibilityHiddenInput.tsx b/packages/twenty-ui/src/accessibility/components/VisibilityHiddenInput.tsx
index 9d57d504798..52b6876ea98 100644
--- a/packages/twenty-ui/src/accessibility/components/VisibilityHiddenInput.tsx
+++ b/packages/twenty-ui/src/accessibility/components/VisibilityHiddenInput.tsx
@@ -1,4 +1,4 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { VISIBILITY_HIDDEN } from '@ui/accessibility/utils/visibility-hidden';
// eslint-disable-next-line twenty/styled-components-prefixed-with-styled
diff --git a/packages/twenty-ui/src/accessibility/utils/visibility-hidden.ts b/packages/twenty-ui/src/accessibility/utils/visibility-hidden.ts
index c00ebfe9060..0ee9b33dda7 100644
--- a/packages/twenty-ui/src/accessibility/utils/visibility-hidden.ts
+++ b/packages/twenty-ui/src/accessibility/utils/visibility-hidden.ts
@@ -1,6 +1,4 @@
-import { css } from '@emotion/react';
-
-export const VISIBILITY_HIDDEN = css`
+export const VISIBILITY_HIDDEN = `
position: absolute;
width: 1px;
height: 1px;
diff --git a/packages/twenty-ui/src/components/Pill/Pill.tsx b/packages/twenty-ui/src/components/Pill/Pill.tsx
index d014e1d521f..069ee0af95e 100644
--- a/packages/twenty-ui/src/components/Pill/Pill.tsx
+++ b/packages/twenty-ui/src/components/Pill/Pill.tsx
@@ -1,5 +1,6 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
+import { themeCssVariables } from '@ui/theme';
type PillProps = {
className?: string;
@@ -9,18 +10,18 @@ type PillProps = {
const StyledPill = styled.span`
align-items: center;
- background: ${({ theme }) => theme.background.transparent.light};
- border-radius: ${({ theme }) => theme.border.radius.pill};
- color: ${({ theme }) => theme.font.color.light};
+ background: ${themeCssVariables.background.transparent.light};
+ border-radius: ${themeCssVariables.border.radius.pill};
+ color: ${themeCssVariables.font.color.light};
display: inline-flex;
- font-size: ${({ theme }) => theme.font.size.xs};
+ font-size: ${themeCssVariables.font.size.xs};
font-style: normal;
- font-weight: ${({ theme }) => theme.font.weight.medium};
- gap: ${({ theme }) => theme.spacing(1)};
- height: ${({ theme }) => theme.spacing(4)};
+ font-weight: ${themeCssVariables.font.weight.medium};
+ gap: ${themeCssVariables.spacing[1]};
+ height: ${themeCssVariables.spacing[4]};
justify-content: flex-end;
- line-height: ${({ theme }) => theme.text.lineHeight.lg};
- padding: ${({ theme }) => `0 ${theme.spacing(2)}`};
+ line-height: ${themeCssVariables.text.lineHeight.lg};
+ padding: 0 ${themeCssVariables.spacing[2]};
`;
export const Pill = ({ className, label, Icon }: PillProps) => {
diff --git a/packages/twenty-ui/src/components/avatar-chip/AvatarChip.tsx b/packages/twenty-ui/src/components/avatar-chip/AvatarChip.tsx
index 8905e7a3dd6..70c26942d57 100644
--- a/packages/twenty-ui/src/components/avatar-chip/AvatarChip.tsx
+++ b/packages/twenty-ui/src/components/avatar-chip/AvatarChip.tsx
@@ -1,9 +1,10 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { Avatar } from '@ui/display/avatar/components/Avatar';
import { type AvatarType } from '@ui/display/avatar/types/AvatarType';
import { type IconComponent } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
import { type Nullable } from '@ui/utilities';
+import { useContext } from 'react';
import { isDefined } from 'twenty-shared/utils';
const StyledIconWithBackgroundContainer = styled.div<{
@@ -21,13 +22,15 @@ const StyledIconWithBackgroundContainer = styled.div<{
const StyledAvatarChipWrapper = styled.div<{
isClickable: boolean;
divider: AvatarChipProps['divider'];
- theme: any;
}>`
- ${({ divider, theme }) => {
- const borderStyle = (side: 'left' | 'right') =>
- `border-${side}: 1px solid ${theme.border.color.light};`;
- return divider ? borderStyle(divider) : '';
- }}
+ border-left: ${({ divider }) =>
+ divider === 'left'
+ ? `1px solid ${themeCssVariables.border.color.light}`
+ : 'none'};
+ border-right: ${({ divider }) =>
+ divider === 'right'
+ ? `1px solid ${themeCssVariables.border.color.light}`
+ : 'none'};
cursor: ${({ isClickable }) => (isClickable ? 'pointer' : 'inherit')};
display: flex;
@@ -58,7 +61,7 @@ export const AvatarChip = ({
onClick,
divider,
}: AvatarChipProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
if (!isDefined(Icon)) {
return (
<Avatar
@@ -79,7 +82,6 @@ export const AvatarChip = ({
<StyledAvatarChipWrapper
isClickable={isClickable}
divider={divider}
- theme={theme}
onClick={onClick}
>
<StyledIconWithBackgroundContainer
@@ -101,7 +103,6 @@ export const AvatarChip = ({
<StyledAvatarChipWrapper
isClickable={isClickable}
divider={divider}
- theme={theme}
onClick={onClick}
>
<Icon
diff --git a/packages/twenty-ui/src/components/avatar-chip/MultipleAvatarChip.tsx b/packages/twenty-ui/src/components/avatar-chip/MultipleAvatarChip.tsx
index 382834bc149..eb9be95dedb 100644
--- a/packages/twenty-ui/src/components/avatar-chip/MultipleAvatarChip.tsx
+++ b/packages/twenty-ui/src/components/avatar-chip/MultipleAvatarChip.tsx
@@ -1,9 +1,10 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { isNonEmptyString } from '@sniptt/guards';
import { Fragment } from 'react/jsx-runtime';
import { isDefined } from 'twenty-shared/utils';
import { Chip, ChipVariant } from '@ui/components/chip/Chip';
+import { themeCssVariables } from '@ui/theme';
const StyledIconsContainer = styled.div`
align-items: center;
@@ -12,7 +13,7 @@ const StyledIconsContainer = styled.div`
const StyledChipContainer = styled.div`
display: inline-flex;
- font-size: ${({ theme }) => theme.font.size.sm};
+ font-size: ${themeCssVariables.font.size.sm};
`;
export type MultipleAvatarChipProps = {
diff --git a/packages/twenty-ui/src/components/chip/Chip.tsx b/packages/twenty-ui/src/components/chip/Chip.tsx
index eb4beb38b73..a3db2024b01 100644
--- a/packages/twenty-ui/src/components/chip/Chip.tsx
+++ b/packages/twenty-ui/src/components/chip/Chip.tsx
@@ -1,8 +1,8 @@
-import { type Theme, withTheme } from '@emotion/react';
import { styled } from '@linaria/react';
import { type ReactNode } from 'react';
import { OverflowingTextWithTooltip } from '@ui/display/tooltip/OverflowingTextWithTooltip';
+import { themeCssVariables } from '@ui/theme';
export enum ChipSize {
Large = 'large',
@@ -38,28 +38,28 @@ export type ChipProps = {
emptyLabel?: string;
};
-const StyledDiv = withTheme(styled.div<{ theme: Theme }>`
- color: ${({ theme }) => theme.font.color.tertiary};
-`);
+const StyledDiv = styled.div`
+ color: ${themeCssVariables.font.color.tertiary};
+`;
-const StyledContainer = withTheme(styled.div<
+const StyledContainer = styled.div<
Pick<
ChipProps,
'accent' | 'clickable' | 'disabled' | 'maxWidth' | 'size' | 'variant'
- > & { theme: Theme }
+ >
>`
- --chip-horizontal-padding: ${({ theme }) => theme.spacing(1)};
- --chip-vertical-padding: ${({ theme }) => theme.spacing(1)};
+ --chip-horizontal-padding: ${themeCssVariables.spacing[1]};
+ --chip-vertical-padding: ${themeCssVariables.spacing[1]};
text-decoration: none;
align-items: center;
- color: ${({ theme, accent, disabled }) =>
+ color: ${({ accent, disabled }) =>
disabled
- ? theme.font.color.light
+ ? themeCssVariables.font.color.light
: accent === ChipAccent.TextPrimary
- ? theme.font.color.primary
- : theme.font.color.secondary};
+ ? themeCssVariables.font.color.primary
+ : themeCssVariables.font.color.secondary};
cursor: ${({ clickable, disabled, variant }) =>
variant === ChipVariant.Transparent
@@ -72,9 +72,11 @@ const StyledContainer = withTheme(styled.div<
display: inline-flex;
justify-content: flex-start;
- gap: ${({ theme }) => theme.spacing(1)};
- height: ${({ theme, size }) =>
- size === ChipSize.Large ? theme.spacing(4) : theme.spacing(3)};
+ gap: ${themeCssVariables.spacing[1]};
+ height: ${({ size }) =>
+ size === ChipSize.Large
+ ? themeCssVariables.spacing[4]
+ : themeCssVariables.spacing[3]};
max-width: ${({ maxWidth }) =>
maxWidth
? `calc(${maxWidth}px - 2 * var(--chip-horizontal-padding))`
@@ -83,51 +85,52 @@ const StyledContainer = withTheme(styled.div<
padding: var(--chip-vertical-padding) var(--chip-horizontal-padding);
user-select: none;
- font-weight: ${({ theme, accent }) =>
- accent === ChipAccent.TextSecondary ? theme.font.weight.medium : 'inherit'};
+ font-weight: ${({ accent }) =>
+ accent === ChipAccent.TextSecondary
+ ? themeCssVariables.font.weight.medium
+ : 'inherit'};
&:hover {
- background-color: ${({ theme, variant, disabled }) =>
+ background-color: ${({ variant, disabled }) =>
variant === ChipVariant.Regular && !disabled
- ? theme.background.transparent.light
+ ? themeCssVariables.background.transparent.light
: variant === ChipVariant.Highlighted
- ? theme.background.transparent.medium
+ ? themeCssVariables.background.transparent.medium
: variant === ChipVariant.Static
- ? theme.background.transparent.light
+ ? themeCssVariables.background.transparent.light
: 'inherit'};
}
&:active {
- background-color: ${({ theme, disabled, variant }) =>
+ background-color: ${({ disabled, variant }) =>
variant === ChipVariant.Regular && !disabled
- ? theme.background.transparent.medium
+ ? themeCssVariables.background.transparent.medium
: variant === ChipVariant.Highlighted
- ? theme.background.transparent.strong
+ ? themeCssVariables.background.transparent.strong
: variant === ChipVariant.Static
- ? theme.background.transparent.light
+ ? themeCssVariables.background.transparent.light
: 'inherit'};
}
- background-color: ${({ theme, variant }) =>
+ background-color: ${({ variant }) =>
variant === ChipVariant.Highlighted || variant === ChipVariant.Static
- ? theme.background.transparent.light
+ ? themeCssVariables.background.transparent.light
: 'inherit'};
border: none;
- border-radius: ${({ theme }) => theme.border.radius.sm};
+ border-radius: ${themeCssVariables.border.radius.sm};
& > svg {
flex-shrink: 0;
}
- padding-left: ${({ theme, variant }) =>
+ padding-left: ${({ variant }) =>
variant === ChipVariant.Transparent
- ? theme.spacing(0)
+ ? themeCssVariables.spacing[0]
: 'var(--chip-horizontal-padding)'};
-`);
+`;
-// TODO: refactor this
const renderRightComponent = (
rightComponent: (() => ReactNode) | ReactNode | null,
) => {
diff --git a/packages/twenty-ui/src/components/chip/__stories__/LinkChip.stories.tsx b/packages/twenty-ui/src/components/chip/__stories__/LinkChip.stories.tsx
new file mode 100644
index 00000000000..646d05475fe
--- /dev/null
+++ b/packages/twenty-ui/src/components/chip/__stories__/LinkChip.stories.tsx
@@ -0,0 +1,32 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { ComponentDecorator } from '@ui/testing';
+import { MemoryRouter } from 'react-router-dom';
+
+import { ChipAccent, ChipSize, ChipVariant } from '../Chip';
+import { LinkChip } from '../LinkChip';
+
+const meta: Meta<typeof LinkChip> = {
+ title: 'UI/Display/Chip/LinkChip',
+ component: LinkChip,
+ decorators: [
+ (Story) => (
+ <MemoryRouter>
+ <Story />
+ </MemoryRouter>
+ ),
+ ComponentDecorator,
+ ],
+};
+
+export default meta;
+type Story = StoryObj<typeof LinkChip>;
+
+export const Default: Story = {
+ args: {
+ label: 'Link Chip',
+ to: '/example',
+ size: ChipSize.Small,
+ variant: ChipVariant.Regular,
+ accent: ChipAccent.TextPrimary,
+ },
+};
diff --git a/packages/twenty-ui/src/components/tag/Tag.tsx b/packages/twenty-ui/src/components/tag/Tag.tsx
index c6d1584c8fe..634815c5748 100644
--- a/packages/twenty-ui/src/components/tag/Tag.tsx
+++ b/packages/twenty-ui/src/components/tag/Tag.tsx
@@ -1,24 +1,12 @@
import { styled } from '@linaria/react';
import { useContext } from 'react';
-// TODO prastoin We should forbid barrel import within the twenty-ui package
import { type IconComponent } from '@ui/display/icon/types/IconComponent';
import { OverflowingTextWithTooltip } from '@ui/display/tooltip/OverflowingTextWithTooltip';
-import {
- BORDER_COMMON,
- THEME_COMMON,
- type ThemeColor,
- ThemeContext,
- type ThemeType,
-} from '@ui/theme';
+import { type ThemeColor, ThemeContext, themeCssVariables } from '@ui/theme';
import { isDefined } from 'twenty-shared/utils';
-const spacing5 = THEME_COMMON.spacing(5);
-const spacing2 = THEME_COMMON.spacing(2);
-const spacing1 = THEME_COMMON.spacing(1);
-
const StyledTag = styled.h3<{
- theme: ThemeType;
color: TagColor;
weight: TagWeight;
variant: TagVariant;
@@ -26,43 +14,35 @@ const StyledTag = styled.h3<{
preventPadding?: boolean;
}>`
align-items: center;
- background: ${({ color, theme }) => {
- if (color === 'transparent') {
- return 'transparent';
- } else {
- const themeColor = theme.tag.background[color];
-
- if (!isDefined(themeColor)) {
- // eslint-disable-next-line no-console
- console.warn(`Tag color ${color} is not defined in the theme`);
- return theme.tag.background.gray;
- } else {
- return themeColor;
- }
- }
- }};
- border-radius: ${BORDER_COMMON.radius.sm};
- color: ${({ color, theme }) =>
+ background: ${({ color }) =>
+ color === 'transparent'
+ ? 'transparent'
+ : (themeCssVariables.tag.background[color] ??
+ themeCssVariables.tag.background.gray)};
+ border-radius: ${themeCssVariables.border.radius.sm};
+ color: ${({ color }) =>
color === 'transparent'
- ? theme.font.color.secondary
- : theme.tag.text[color]};
+ ? themeCssVariables.font.color.secondary
+ : (themeCssVariables.tag.text[color] ??
+ themeCssVariables.font.color.secondary)};
display: inline-flex;
- font-size: ${({ theme }) => theme.font.size.md};
+ font-size: ${themeCssVariables.font.size.md};
font-style: normal;
- font-weight: ${({ theme, weight }) =>
+ font-weight: ${({ weight }) =>
weight === 'regular'
- ? theme.font.weight.regular
- : theme.font.weight.medium};
- height: ${spacing5};
+ ? themeCssVariables.font.weight.regular
+ : themeCssVariables.font.weight.medium};
+ height: ${themeCssVariables.spacing[5]};
margin: 0;
overflow: hidden;
- padding: ${({ preventPadding }) => (preventPadding ? '0' : `0 ${spacing2}`)};
- border: ${({ variant, theme }) =>
+ padding: ${({ preventPadding }) =>
+ preventPadding ? '0' : `0 ${themeCssVariables.spacing[2]}`};
+ border: ${({ variant }) =>
variant === 'outline' || variant === 'border'
- ? `1px ${variant === 'border' ? 'solid' : 'dashed'} ${theme.border.color.strong}`
+ ? `1px ${variant === 'border' ? 'solid' : 'dashed'} ${themeCssVariables.border.color.strong}`
: 'none'};
- gap: ${spacing1};
+ gap: ${themeCssVariables.spacing[1]};
min-width: ${({ preventShrink }) => (preventShrink ? 'fit-content' : 'none')};
`;
@@ -98,7 +78,6 @@ type TagProps = {
preventPadding?: boolean;
};
-// TODO: Find a way to have ellipsis and shrinkable tag in tag list while keeping good perf for table cells
export const Tag = ({
className,
color,
@@ -114,7 +93,6 @@ export const Tag = ({
return (
<StyledTag
- theme={theme}
className={className}
color={color}
onClick={onClick}
diff --git a/packages/twenty-ui/src/display/avatar/components/AvatarGroup.tsx b/packages/twenty-ui/src/display/avatar/components/AvatarGroup.tsx
index fe9a9929d0a..d0c220949fe 100644
--- a/packages/twenty-ui/src/display/avatar/components/AvatarGroup.tsx
+++ b/packages/twenty-ui/src/display/avatar/components/AvatarGroup.tsx
@@ -1,4 +1,4 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type ReactNode } from 'react';
export type AvatarGroupProps = {
diff --git a/packages/twenty-ui/src/display/banner/components/Banner.tsx b/packages/twenty-ui/src/display/banner/components/Banner.tsx
index ae1b8d78088..0a394a157f1 100644
--- a/packages/twenty-ui/src/display/banner/components/Banner.tsx
+++ b/packages/twenty-ui/src/display/banner/components/Banner.tsx
@@ -1,21 +1,24 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
const StyledBanner = styled.div<{ variant?: BannerVariant }>`
align-items: center;
backdrop-filter: blur(5px);
- background: ${({ theme, variant }) =>
- variant === 'danger' ? theme.color.red : theme.color.blue};
+ background: ${({ variant }) =>
+ variant === 'danger'
+ ? themeCssVariables.color.red
+ : themeCssVariables.color.blue};
display: flex;
- gap: ${({ theme }) => theme.spacing(3)};
+ gap: ${themeCssVariables.spacing[3]};
height: 40px;
justify-content: center;
- padding: ${({ theme }) => theme.spacing(2) + ' ' + theme.spacing(3)};
+ padding: ${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[3]};
width: 100%;
- color: ${({ theme }) => theme.font.color.inverted};
+ color: ${themeCssVariables.font.color.inverted};
font-family: Inter;
- font-size: ${({ theme }) => theme.font.size.md};
+ font-size: ${themeCssVariables.font.size.md};
font-style: normal;
- font-weight: ${({ theme }) => theme.font.weight.medium};
+ font-weight: ${themeCssVariables.font.weight.medium};
line-height: 150%;
box-sizing: border-box;
`;
@@ -32,8 +35,10 @@ export const Banner = ({
variant = 'default',
className,
children,
-}: BannerProps) => (
- <StyledBanner variant={variant} className={className}>
- {children}
- </StyledBanner>
-);
+}: BannerProps) => {
+ return (
+ <StyledBanner variant={variant} className={className}>
+ {children}
+ </StyledBanner>
+ );
+};
diff --git a/packages/twenty-ui/src/display/banner/components/SidePanelInformationBanner.tsx b/packages/twenty-ui/src/display/banner/components/SidePanelInformationBanner.tsx
index 2f2c3241e69..cecd05f0ab5 100644
--- a/packages/twenty-ui/src/display/banner/components/SidePanelInformationBanner.tsx
+++ b/packages/twenty-ui/src/display/banner/components/SidePanelInformationBanner.tsx
@@ -1,5 +1,6 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { isDefined } from 'twenty-shared/utils';
+import { themeCssVariables } from '@ui/theme';
import {
IconAlertTriangle,
IconInfoCircle,
@@ -8,18 +9,18 @@ import { AppTooltip } from '../../tooltip/AppTooltip';
const StyledBanner = styled.div`
align-items: center;
- background-color: ${({ theme }) => theme.accent.secondary};
- border-radius: ${({ theme }) => theme.border.radius.md};
+ background-color: ${themeCssVariables.accent.secondary};
+ border-radius: ${themeCssVariables.border.radius.md};
box-sizing: border-box;
display: flex;
- gap: ${({ theme }) => theme.spacing(2)};
- padding: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
+ padding: ${themeCssVariables.spacing[2]};
width: 100%;
`;
const StyledIconContainer = styled.div`
align-items: center;
- color: ${({ theme }) => theme.color.blue};
+ color: ${themeCssVariables.color.blue};
display: flex;
flex-shrink: 0;
height: 16px;
@@ -28,12 +29,12 @@ const StyledIconContainer = styled.div`
`;
const StyledMessage = styled.p`
- color: ${({ theme }) => theme.color.blue};
+ color: ${themeCssVariables.color.blue};
flex-grow: 1;
- font-family: ${({ theme }) => theme.font.family};
- font-size: ${({ theme }) => theme.font.size.sm};
+ font-family: ${themeCssVariables.font.family};
+ font-size: ${themeCssVariables.font.size.sm};
font-style: normal;
- font-weight: ${({ theme }) => theme.font.weight.medium};
+ font-weight: ${themeCssVariables.font.weight.medium};
line-height: 1.4;
margin: 0;
min-width: 0;
diff --git a/packages/twenty-ui/src/display/callout/Callout.tsx b/packages/twenty-ui/src/display/callout/Callout.tsx
index 50bac0e9f81..5f816cc330c 100644
--- a/packages/twenty-ui/src/display/callout/Callout.tsx
+++ b/packages/twenty-ui/src/display/callout/Callout.tsx
@@ -1,9 +1,10 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { IconHelp, IconX } from '@ui/display/icon/components/TablerIcons';
import { type IconComponent } from '@ui/display/icon/types/IconComponent';
import { LightButton, LightIconButton } from '@ui/input';
import { useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
+import { themeCssVariables } from '@ui/theme';
export type CalloutVariant =
| 'info'
@@ -12,38 +13,40 @@ export type CalloutVariant =
| 'neutral'
| 'success';
-const StyledCalloutContainer = styled.div<{ variant: CalloutVariant }>`
+const StyledCalloutContainer = styled.div<{
+ variant: CalloutVariant;
+}>`
align-items: flex-start;
- background-color: ${({ theme, variant }) =>
+ background-color: ${({ variant }) =>
variant === 'info'
- ? theme.accent.accent1
+ ? themeCssVariables.accent.accent1
: variant === 'warning'
- ? theme.color.orange1
+ ? themeCssVariables.color.orange1
: variant === 'success'
- ? theme.color.turquoise1
+ ? themeCssVariables.color.turquoise1
: variant === 'error'
- ? theme.color.red1
- : theme.color.gray1};
+ ? themeCssVariables.color.red1
+ : themeCssVariables.color.gray1};
border: 1px solid
- ${({ theme, variant }) =>
+ ${({ variant }) =>
variant === 'info'
- ? theme.accent.accent6
+ ? themeCssVariables.accent.accent6
: variant === 'warning'
- ? theme.color.orange6
+ ? themeCssVariables.color.orange6
: variant === 'success'
- ? theme.color.turquoise6
+ ? themeCssVariables.color.turquoise6
: variant === 'error'
- ? theme.color.red6
- : theme.color.gray6};
- border-radius: ${({ theme }) => theme.border.radius.md};
+ ? themeCssVariables.color.red6
+ : themeCssVariables.color.gray6};
+ border-radius: ${themeCssVariables.border.radius.md};
box-sizing: border-box;
display: flex;
flex-direction: column;
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
max-width: 512px;
overflow: hidden;
- padding: ${({ theme }) =>
- `${theme.spacing(3)} ${theme.spacing(3)} ${theme.spacing(2)}`};
+ padding: ${themeCssVariables.spacing[3]} ${themeCssVariables.spacing[3]}
+ ${themeCssVariables.spacing[2]};
width: 100%;
`;
@@ -52,56 +55,60 @@ const StyledHeader = styled.div`
align-self: stretch;
display: flex;
flex-direction: row;
- gap: ${({ theme }) => theme.spacing(2)};
- min-height: ${({ theme }) => theme.spacing(6)};
+ gap: ${themeCssVariables.spacing[2]};
+ min-height: ${themeCssVariables.spacing[6]};
`;
-const StyledIconContainer = styled.div<{ variant: CalloutVariant }>`
+const StyledIconContainer = styled.div<{
+ variant: CalloutVariant;
+}>`
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
- height: ${({ theme }) => theme.spacing(4)};
- width: ${({ theme }) => theme.spacing(4)};
- color: ${({ theme, variant }) =>
+ height: ${themeCssVariables.spacing[4]};
+ width: ${themeCssVariables.spacing[4]};
+ color: ${({ variant }) =>
variant === 'info'
- ? theme.accent.accent9
+ ? themeCssVariables.accent.accent9
: variant === 'warning'
- ? theme.color.orange9
+ ? themeCssVariables.color.orange9
: variant === 'success'
- ? theme.color.turquoise9
+ ? themeCssVariables.color.turquoise9
: variant === 'error'
- ? theme.color.red9
- : theme.color.gray9};
+ ? themeCssVariables.color.red9
+ : themeCssVariables.color.gray9};
`;
const StyledTitle = styled.div`
flex: 1;
- color: ${({ theme }) => theme.font.color.primary};
- font-family: ${({ theme }) => theme.font.family};
- font-size: ${({ theme }) => theme.font.size.md};
- font-weight: ${({ theme }) => theme.font.weight.medium};
+ color: ${themeCssVariables.font.color.primary};
+ font-family: ${themeCssVariables.font.family};
+ font-size: ${themeCssVariables.font.size.md};
+ font-weight: ${themeCssVariables.font.weight.medium};
line-height: 1.4;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
-const StyledDescriptionWrapper = styled.div<{ hasAction: boolean }>`
+const StyledDescriptionWrapper = styled.div<{
+ hasAction: boolean;
+}>`
align-items: center;
display: flex;
align-self: stretch;
- padding-bottom: ${({ hasAction, theme }) =>
- hasAction ? 0 : theme.spacing(2)};
- padding-left: ${({ theme }) => theme.spacing(6)};
+ padding-bottom: ${({ hasAction }) =>
+ hasAction ? 0 : themeCssVariables.spacing[2]};
+ padding-left: ${themeCssVariables.spacing[6]};
`;
const StyledDescription = styled.div`
flex: 1;
- color: ${({ theme }) => theme.font.color.tertiary};
- font-family: ${({ theme }) => theme.font.family};
- font-size: ${({ theme }) => theme.font.size.sm};
- font-weight: ${({ theme }) => theme.font.weight.regular};
+ color: ${themeCssVariables.font.color.tertiary};
+ font-family: ${themeCssVariables.font.family};
+ font-size: ${themeCssVariables.font.size.sm};
+ font-weight: ${themeCssVariables.font.weight.regular};
line-height: 1.4;
`;
diff --git a/packages/twenty-ui/src/display/checkmark/components/AnimatedCheckmark.tsx b/packages/twenty-ui/src/display/checkmark/components/AnimatedCheckmark.tsx
index 0fe806bb9f1..72011e93bdc 100644
--- a/packages/twenty-ui/src/display/checkmark/components/AnimatedCheckmark.tsx
+++ b/packages/twenty-ui/src/display/checkmark/components/AnimatedCheckmark.tsx
@@ -1,5 +1,6 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { motion } from 'framer-motion';
+import { ThemeContext } from '@ui/theme';
export type AnimatedCheckmarkProps = React.ComponentProps<
typeof motion.path
@@ -16,7 +17,7 @@ export const AnimatedCheckmark = ({
duration = 0.5,
size = 28,
}: AnimatedCheckmarkProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<svg
xmlns="http://www.w3.org/2000/svg"
diff --git a/packages/twenty-ui/src/display/checkmark/components/Checkmark.tsx b/packages/twenty-ui/src/display/checkmark/components/Checkmark.tsx
index 1de6aba0ff8..f2c51ea31ca 100644
--- a/packages/twenty-ui/src/display/checkmark/components/Checkmark.tsx
+++ b/packages/twenty-ui/src/display/checkmark/components/Checkmark.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
-import React from 'react';
+import React, { useContext } from 'react';
+
+import { styled } from '@linaria/react';
import { IconCheck } from '@ui/display/icon/components/TablerIcons';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
const StyledContainer = styled.div`
align-items: center;
- background-color: ${({ theme }) => theme.color.blue};
+ background-color: ${themeCssVariables.color.blue};
border-radius: 50%;
display: flex;
height: 20px;
@@ -19,7 +20,7 @@ export type CheckmarkProps = React.ComponentPropsWithoutRef<'div'> & {
};
export const Checkmark = ({ className }: CheckmarkProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledContainer className={className}>
diff --git a/packages/twenty-ui/src/display/color/components/ColorSample.tsx b/packages/twenty-ui/src/display/color/components/ColorSample.tsx
index 9ec4eb063f7..1c9b048224e 100644
--- a/packages/twenty-ui/src/display/color/components/ColorSample.tsx
+++ b/packages/twenty-ui/src/display/color/components/ColorSample.tsx
@@ -1,56 +1,63 @@
-import { css } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
-import { type ThemeColor, type ThemeType } from '@ui/theme';
+import { type ThemeColor, themeCssVariables } from '@ui/theme';
import { isDefined } from 'twenty-shared/utils';
export type ColorSampleVariant = 'default' | 'pipeline';
-export type ColorSampleProps = {
+type StyledColorSampleProps = {
colorName: ThemeColor;
color?: string;
variant?: ColorSampleVariant;
};
-const getColor = (theme: ThemeType, colorName: ThemeColor, color?: string) => {
+export type ColorSampleProps = StyledColorSampleProps;
+
+const getColor = (colorName: ThemeColor, color?: string) => {
if (isDefined(color)) {
return color;
}
- return theme.tag.background[colorName];
+ return themeCssVariables.tag.background[colorName];
};
-const getBorderColor = (theme: ThemeType, colorName: ThemeColor) => {
- return theme.tag.text[colorName];
+const getBorderColor = (colorName: ThemeColor) => {
+ return themeCssVariables.tag.text[colorName];
};
-const StyledColorSample = styled.div<ColorSampleProps>`
- background-color: ${({ theme, colorName, color }) =>
- getColor(theme, colorName, color)};
- border: 1px solid
- ${({ theme, colorName }) => getBorderColor(theme, colorName)};
+const StyledColorSample = styled.div<StyledColorSampleProps>`
+ background-color: ${({ colorName, color }) => getColor(colorName, color)};
+ border: ${({ variant, colorName }) =>
+ variant === 'pipeline' ? '0' : `1px solid ${getBorderColor(colorName)}`};
border-radius: 60px;
- height: ${({ theme }) => theme.spacing(4)};
- width: ${({ theme }) => theme.spacing(3)};
-
- ${({ colorName, color, theme, variant }) => {
- if (variant === 'pipeline')
- return css`
- align-items: center;
- border: 0;
- display: flex;
- justify-content: center;
-
- &:after {
- background-color: ${getColor(theme, colorName, color)};
- border-radius: ${theme.border.radius.rounded};
- content: '';
- display: block;
- height: ${theme.spacing(1)};
- width: ${theme.spacing(1)};
- }
- `;
- }}
+ height: ${themeCssVariables.spacing[4]};
+ width: ${themeCssVariables.spacing[3]};
+ align-items: ${({ variant }) =>
+ variant === 'pipeline' ? 'center' : 'initial'};
+ display: ${({ variant }) => (variant === 'pipeline' ? 'flex' : 'block')};
+ justify-content: ${({ variant }) =>
+ variant === 'pipeline' ? 'center' : 'initial'};
+
+ &:after {
+ background-color: ${({ colorName, color, variant }) =>
+ variant === 'pipeline' ? getColor(colorName, color) : 'transparent'};
+ border-radius: ${({ variant }) =>
+ variant === 'pipeline' ? themeCssVariables.border.radius.rounded : '0'};
+ content: ${({ variant }) => (variant === 'pipeline' ? "''" : 'none')};
+ display: ${({ variant }) => (variant === 'pipeline' ? 'block' : 'none')};
+ height: ${({ variant }) =>
+ variant === 'pipeline' ? themeCssVariables.spacing[1] : '0'};
+ width: ${({ variant }) =>
+ variant === 'pipeline' ? themeCssVariables.spacing[1] : '0'};
+ }
`;
-export { StyledColorSample as ColorSample };
+export const ColorSample = ({
+ colorName,
+ color,
+ variant,
+}: ColorSampleProps) => {
+ return (
+ <StyledColorSample colorName={colorName} color={color} variant={variant} />
+ );
+};
diff --git a/packages/twenty-ui/src/display/color/components/__stories__/ColorSample.stories.tsx b/packages/twenty-ui/src/display/color/components/__stories__/ColorSample.stories.tsx
index 5917cd61504..deab220b24c 100644
--- a/packages/twenty-ui/src/display/color/components/__stories__/ColorSample.stories.tsx
+++ b/packages/twenty-ui/src/display/color/components/__stories__/ColorSample.stories.tsx
@@ -9,10 +9,6 @@ const meta: Meta<typeof ColorSample> = {
component: ColorSample,
decorators: [ComponentDecorator],
args: { colorName: 'green' },
- argTypes: {
- as: { control: false },
- theme: { control: false },
- },
};
export default meta;
diff --git a/packages/twenty-ui/src/display/command-block/components/CommandBlock.tsx b/packages/twenty-ui/src/display/command-block/components/CommandBlock.tsx
index 9c2d2c3bf5c..f51b71b69e7 100644
--- a/packages/twenty-ui/src/display/command-block/components/CommandBlock.tsx
+++ b/packages/twenty-ui/src/display/command-block/components/CommandBlock.tsx
@@ -1,18 +1,19 @@
-import styled from '@emotion/styled';
-import type { ReactElement } from 'react';
+import { type ReactElement } from 'react';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
const StyledContainer = styled.div`
- border-radius: ${({ theme }) => theme.border.radius.sm};
- border: 1px solid ${({ theme }) => theme.border.color.medium};
- background: ${({ theme }) => theme.background.transparent.secondary};
+ border-radius: ${themeCssVariables.border.radius.sm};
+ border: 1px solid ${themeCssVariables.border.color.medium};
+ background: ${themeCssVariables.background.transparent.secondary};
display: flex;
justify-content: space-between;
- padding: ${({ theme }) => theme.spacing(3)};
- gap: ${({ theme }) => theme.spacing(3)};
+ padding: ${themeCssVariables.spacing[3]};
+ gap: ${themeCssVariables.spacing[3]};
`;
const StyledCommandContain = styled.div`
- font-family: ${({ theme }) => theme.code.font.family};
+ font-family: ${themeCssVariables.code.font.family};
`;
const StyledButtonContainer = styled.div`
@@ -22,11 +23,11 @@ const StyledButtonContainer = styled.div`
const StyledLineContainer = styled.div``;
const StyledLineStartSpan = styled.span`
- color: ${({ theme }) => theme.code.text.orange};
+ color: ${themeCssVariables.code.text.orange};
`;
const StyledLineSpan = styled.span`
- color: ${({ theme }) => theme.code.text.green};
+ color: ${themeCssVariables.code.text.green};
`;
type CommandBlockProps = {
diff --git a/packages/twenty-ui/src/display/icon/components/IconAddressBook.tsx b/packages/twenty-ui/src/display/icon/components/IconAddressBook.tsx
index 35f5daae211..a4b54e30606 100644
--- a/packages/twenty-ui/src/display/icon/components/IconAddressBook.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconAddressBook.tsx
@@ -1,6 +1,7 @@
import IconAddressBookRaw from '@assets/icons/address-book.svg?react';
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconAddressBookProps = Pick<
IconComponentProps,
@@ -8,7 +9,7 @@ type IconAddressBookProps = Pick<
>;
export const IconAddressBook = (props: IconAddressBookProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? 24;
const stroke = props.stroke ?? theme.icon.stroke.md;
diff --git a/packages/twenty-ui/src/display/icon/components/IconBrandAnthropic.tsx b/packages/twenty-ui/src/display/icon/components/IconBrandAnthropic.tsx
index e9e23f27e43..a953287ea32 100644
--- a/packages/twenty-ui/src/display/icon/components/IconBrandAnthropic.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconBrandAnthropic.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconAnthropicRaw from '@assets/icons/anthropic.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconBrandAnthropicProps = Pick<IconComponentProps, 'size' | 'color'>;
export const IconBrandAnthropic = (props: IconBrandAnthropicProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
diff --git a/packages/twenty-ui/src/display/icon/components/IconBrandGroq.tsx b/packages/twenty-ui/src/display/icon/components/IconBrandGroq.tsx
index 97c41c0f775..5c059c4d480 100644
--- a/packages/twenty-ui/src/display/icon/components/IconBrandGroq.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconBrandGroq.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconBrandGroqRaw from '@assets/icons/groq.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconBrandGroqProps = Pick<IconComponentProps, 'size' | 'color'>;
export const IconBrandGroq = (props: IconBrandGroqProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
diff --git a/packages/twenty-ui/src/display/icon/components/IconBrandMistral.tsx b/packages/twenty-ui/src/display/icon/components/IconBrandMistral.tsx
index 1a1e4244e2c..0f15d51287e 100644
--- a/packages/twenty-ui/src/display/icon/components/IconBrandMistral.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconBrandMistral.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconBrandMistralRaw from '@assets/icons/mistral.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconBrandMistralProps = Pick<IconComponentProps, 'size' | 'color'>;
export const IconBrandMistral = (props: IconBrandMistralProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
diff --git a/packages/twenty-ui/src/display/icon/components/IconBrandXai.tsx b/packages/twenty-ui/src/display/icon/components/IconBrandXai.tsx
index 8daa89b2658..283ade6ca18 100644
--- a/packages/twenty-ui/src/display/icon/components/IconBrandXai.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconBrandXai.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconBrandXaiRaw from '@assets/icons/xai.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconBrandXaiProps = Pick<IconComponentProps, 'size' | 'color'>;
export const IconBrandXai = (props: IconBrandXaiProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
diff --git a/packages/twenty-ui/src/display/icon/components/IconChartBarHorizontal.tsx b/packages/twenty-ui/src/display/icon/components/IconChartBarHorizontal.tsx
index 7d61c2b5aba..32e293c185b 100644
--- a/packages/twenty-ui/src/display/icon/components/IconChartBarHorizontal.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconChartBarHorizontal.tsx
@@ -1,8 +1,10 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { useContext } from 'react';
+
+import { styled } from '@linaria/react';
import { IconChartBar } from '@ui/display/icon/components/TablerIcons';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
const StyledRotatedIconWrapper = styled.div`
display: inline-flex;
@@ -15,7 +17,7 @@ type IconChartBarHorizontalProps = Pick<
>;
export const IconChartBarHorizontal = (props: IconChartBarHorizontalProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.md;
const stroke = props.stroke ?? theme.icon.stroke.sm;
diff --git a/packages/twenty-ui/src/display/icon/components/IconGmail.tsx b/packages/twenty-ui/src/display/icon/components/IconGmail.tsx
index 2361be516a0..b42c619324d 100644
--- a/packages/twenty-ui/src/display/icon/components/IconGmail.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconGmail.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconGmailRaw from '@assets/icons/gmail.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconGmailProps = Pick<IconComponentProps, 'size'>;
export const IconGmail = (props: IconGmailProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return <IconGmailRaw height={size} width={size} />;
diff --git a/packages/twenty-ui/src/display/icon/components/IconGoogle.tsx b/packages/twenty-ui/src/display/icon/components/IconGoogle.tsx
index 18f0cf030d2..cf8b30176da 100644
--- a/packages/twenty-ui/src/display/icon/components/IconGoogle.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconGoogle.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconGoogleRaw from '@assets/icons/google.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconGoogleProps = Pick<IconComponentProps, 'size'>;
export const IconGoogle = (props: IconGoogleProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return <IconGoogleRaw height={size} width={size} />;
diff --git a/packages/twenty-ui/src/display/icon/components/IconGoogleCalendar.tsx b/packages/twenty-ui/src/display/icon/components/IconGoogleCalendar.tsx
index f5af378e9ac..70a8e200b83 100644
--- a/packages/twenty-ui/src/display/icon/components/IconGoogleCalendar.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconGoogleCalendar.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconGoogleCalendarRaw from '@assets/icons/google-calendar.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconGoogleCalendarProps = Pick<IconComponentProps, 'size'>;
export const IconGoogleCalendar = (props: IconGoogleCalendarProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return <IconGoogleCalendarRaw height={size} width={size} />;
diff --git a/packages/twenty-ui/src/display/icon/components/IconLock.tsx b/packages/twenty-ui/src/display/icon/components/IconLock.tsx
index e083b20b653..f8e8563d094 100644
--- a/packages/twenty-ui/src/display/icon/components/IconLock.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconLock.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconLockRaw from '@assets/icons/lock.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconLockCustomProps = Pick<IconComponentProps, 'size'>;
export const IconLockCustom = (props: IconLockCustomProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return <IconLockRaw height={size} width={size} />;
diff --git a/packages/twenty-ui/src/display/icon/components/IconMicrosoft.tsx b/packages/twenty-ui/src/display/icon/components/IconMicrosoft.tsx
index f32ee63183b..7d4d92a40ed 100644
--- a/packages/twenty-ui/src/display/icon/components/IconMicrosoft.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconMicrosoft.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconMicrosoftRaw from '@assets/icons/microsoft.svg?react';
+import { ThemeContext } from '@ui/theme';
interface IconMicrosoftProps {
size?: number | string;
}
export const IconMicrosoft = (props: IconMicrosoftProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return <IconMicrosoftRaw height={size} width={size} />;
diff --git a/packages/twenty-ui/src/display/icon/components/IconMicrosoftCalendar.tsx b/packages/twenty-ui/src/display/icon/components/IconMicrosoftCalendar.tsx
index d65d5800c5a..60d0e656c8f 100644
--- a/packages/twenty-ui/src/display/icon/components/IconMicrosoftCalendar.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconMicrosoftCalendar.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconMicrosoftCalendarRaw from '@assets/icons/microsoft-calendar.svg?react';
+import { ThemeContext } from '@ui/theme';
interface IconMicrosoftCalendarProps {
size?: number | string;
}
export const IconMicrosoftCalendar = (props: IconMicrosoftCalendarProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return <IconMicrosoftCalendarRaw height={size} width={size} />;
diff --git a/packages/twenty-ui/src/display/icon/components/IconMicrosoftOutlook.tsx b/packages/twenty-ui/src/display/icon/components/IconMicrosoftOutlook.tsx
index fbdf9bee508..aaaa48ab0c7 100644
--- a/packages/twenty-ui/src/display/icon/components/IconMicrosoftOutlook.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconMicrosoftOutlook.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconMicrosoftOutlookRaw from '@assets/icons/microsoft-outlook.svg?react';
+import { ThemeContext } from '@ui/theme';
interface IconMicrosoftOutlookProps {
size?: number | string;
}
export const IconMicrosoftOutlook = (props: IconMicrosoftOutlookProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return <IconMicrosoftOutlookRaw height={size} width={size} />;
diff --git a/packages/twenty-ui/src/display/icon/components/IconRelationManyToOne.tsx b/packages/twenty-ui/src/display/icon/components/IconRelationManyToOne.tsx
index 0bd21c4cbdf..808305a748b 100644
--- a/packages/twenty-ui/src/display/icon/components/IconRelationManyToOne.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconRelationManyToOne.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconRelationManyToOneRaw from '@assets/icons/many-to-one.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconRelationManyToOneProps = Pick<IconComponentProps, 'size' | 'stroke'>;
export const IconRelationManyToOne = (props: IconRelationManyToOneProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? 24;
const stroke = props.stroke ?? theme.icon.stroke.md;
diff --git a/packages/twenty-ui/src/display/icon/components/IconTrashXOff.tsx b/packages/twenty-ui/src/display/icon/components/IconTrashXOff.tsx
index 2363506647a..b5f5dbe50a6 100644
--- a/packages/twenty-ui/src/display/icon/components/IconTrashXOff.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconTrashXOff.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconTrashXOffRaw from '@assets/icons/trash-x-off.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconTrashXOffProps = Pick<IconComponentProps, 'size' | 'stroke'>;
export const IconTrashXOff = (props: IconTrashXOffProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
const stroke = props.stroke ?? theme.icon.stroke.md;
diff --git a/packages/twenty-ui/src/display/icon/components/IconTwentyStar.tsx b/packages/twenty-ui/src/display/icon/components/IconTwentyStar.tsx
index d11b2d449c5..b763b5b684f 100644
--- a/packages/twenty-ui/src/display/icon/components/IconTwentyStar.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IconTwentyStar.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import IconTwentyStarRaw from '@assets/icons/twenty-star.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IconTwentyStarProps = Pick<IconComponentProps, 'size' | 'stroke'>;
export const IconTwentyStar = (props: IconTwentyStarProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? 24;
const stroke = props.stroke ?? theme.icon.stroke.md;
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconArray.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconArray.tsx
index 17dc958f22c..9c8d1d1bf93 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconArray.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconArray.tsx
@@ -1,11 +1,12 @@
import IllustrationIconArrayRaw from '@assets/icons/illustration-array.svg?react';
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconArrayProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconArray = (props: IllustrationIconArrayProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconCalendarEvent.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconCalendarEvent.tsx
index 150987cf843..14e91b5f134 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconCalendarEvent.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconCalendarEvent.tsx
@@ -1,13 +1,14 @@
import IllustrationIconCalendarEventRaw from '@assets/icons/illustration-calendar-event.svg?react';
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconCalendarEventProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconCalendarEvent = (
props: IllustrationIconCalendarEventProps,
) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconCalendarTime.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconCalendarTime.tsx
index 5b736a25b46..f9c6edf5af2 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconCalendarTime.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconCalendarTime.tsx
@@ -1,14 +1,15 @@
import IllustrationIconCalendarTimeRaw from '@assets/icons/illustration-calendar-time.svg?react';
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconCalendarTimeProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconCalendarTime = (
props: IllustrationIconCalendarTimeProps,
) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconCurrency.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconCurrency.tsx
index c0c8631c00f..19253394914 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconCurrency.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconCurrency.tsx
@@ -1,15 +1,16 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconCurrencyRaw from '@assets/icons/illustration-currency.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconCurrencyProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconCurrency = (
props: IllustrationIconCurrencyProps,
) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconFile.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconFile.tsx
index bf9a31266ed..f2b880b2e91 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconFile.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconFile.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconFileRaw from '@assets/icons/illustration-file.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconFileProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconFile = (props: IllustrationIconFileProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconJson.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconJson.tsx
index 28c97c90026..bf147d2b137 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconJson.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconJson.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconJsonRaw from '@assets/icons/illustration-json.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconJsonProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconJson = (props: IllustrationIconJsonProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconLink.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconLink.tsx
index 1abdf9e613d..799cd3d8dfe 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconLink.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconLink.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconLinkRaw from '@assets/icons/illustration-link.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconLinkProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconLink = (props: IllustrationIconLinkProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconMail.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconMail.tsx
index 4312b8847b9..8925466e958 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconMail.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconMail.tsx
@@ -1,12 +1,13 @@
import IllustrationIconMailRaw from '@assets/icons/illustration-mail.svg?react';
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconMailProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconMail = (props: IllustrationIconMailProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconManyToMany.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconManyToMany.tsx
index 05c29db3575..e1ce8101d38 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconManyToMany.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconManyToMany.tsx
@@ -1,14 +1,15 @@
import IllustrationIconManyToManyRaw from '@assets/icons/illustration-many-to-many.svg?react';
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconManyToManyProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconManyToMany = (
props: IllustrationIconManyToManyProps,
) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconMap.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconMap.tsx
index 01d409d8459..3c1018ca495 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconMap.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconMap.tsx
@@ -1,12 +1,13 @@
import IllustrationIconMapRaw from '@assets/icons/illustration-map.svg?react';
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconMapProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconMap = (props: IllustrationIconMapProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconNumbers.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconNumbers.tsx
index c762a79dfee..19bd1ebbd03 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconNumbers.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconNumbers.tsx
@@ -1,14 +1,15 @@
import IllustrationIconNumbersRaw from '@assets/icons/illustration-numbers.svg?react';
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconNumbersProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconNumbers = (
props: IllustrationIconNumbersProps,
) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconOneToMany.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconOneToMany.tsx
index 2edbe6b0ea5..c4e4f9204ed 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconOneToMany.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconOneToMany.tsx
@@ -1,15 +1,16 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconOneToManyRaw from '@assets/icons/illustration-one-to-many.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconOneToManyProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconOneToMany = (
props: IllustrationIconOneToManyProps,
) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconOneToOne.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconOneToOne.tsx
index 8050d8d4158..88d810a7da1 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconOneToOne.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconOneToOne.tsx
@@ -1,15 +1,16 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconOneToOneRaw from '@assets/icons/illustration-one-to-one.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconOneToOneProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconOneToOne = (
props: IllustrationIconOneToOneProps,
) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconPhone.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconPhone.tsx
index 23ce1650fad..84845786da3 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconPhone.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconPhone.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconPhoneRaw from '@assets/icons/illustration-phone.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconPhoneProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconPhone = (props: IllustrationIconPhoneProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconSetting.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconSetting.tsx
index b3816971830..30acb88824c 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconSetting.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconSetting.tsx
@@ -1,15 +1,16 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconSettingRaw from '@assets/icons/illustration-setting.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconSettingProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconSetting = (
props: IllustrationIconSettingProps,
) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconStar.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconStar.tsx
index b2e4012fdaf..f610a32c0fb 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconStar.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconStar.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconStarRaw from '@assets/icons/illustration-star.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconStarProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconStar = (props: IllustrationIconStarProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconTag.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconTag.tsx
index 637c87471ee..b2a85b29d62 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconTag.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconTag.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconTagRaw from '@assets/icons/illustration-tag.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconTagProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconTag = (props: IllustrationIconTagProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconTags.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconTags.tsx
index 6e64c7e5122..59e9f7ba260 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconTags.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconTags.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconTagsRaw from '@assets/icons/illustration-tags.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconTagsProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconTags = (props: IllustrationIconTagsProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconText.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconText.tsx
index 9edcf16423f..bff5af5b3ee 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconText.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconText.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconTextRaw from '@assets/icons/illustration-text.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconTextProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconText = (props: IllustrationIconTextProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconToggle.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconToggle.tsx
index fd503168aee..fd0e9109da7 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconToggle.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconToggle.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconToggleRaw from '@assets/icons/illustration-toggle.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconToggleProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconToggle = (props: IllustrationIconToggleProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconUid.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconUid.tsx
index d13161d8cd4..ce3465195f0 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconUid.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconUid.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconUidRaw from '@assets/icons/illustration-uid.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconUidProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconUid = (props: IllustrationIconUidProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconUser.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconUser.tsx
index 6286bf25ecf..d155b0144a7 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconUser.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconUser.tsx
@@ -1,13 +1,14 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IllustrationIconWrapper } from '@ui/display/icon/components/IllustrationIconWrapper';
import IllustrationIconUserRaw from '@assets/icons/illustration-user.svg?react';
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext } from '@ui/theme';
type IllustrationIconUserProps = Pick<IconComponentProps, 'size'>;
export const IllustrationIconUser = (props: IllustrationIconUserProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const size = props.size ?? theme.icon.size.lg;
return (
<IllustrationIconWrapper>
diff --git a/packages/twenty-ui/src/display/icon/components/IllustrationIconWrapper.tsx b/packages/twenty-ui/src/display/icon/components/IllustrationIconWrapper.tsx
index 4e583a31200..fdff3d204ac 100644
--- a/packages/twenty-ui/src/display/icon/components/IllustrationIconWrapper.tsx
+++ b/packages/twenty-ui/src/display/icon/components/IllustrationIconWrapper.tsx
@@ -1,11 +1,11 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
-const StyledRectangleIllustrationIcon = styled('div')`
- background-color: ${({ theme }) => theme.background.primary};
- border: 0.75px solid ${({ theme }) => theme.border.color.medium};
- border-radius: ${({ theme }) => theme.border.radius.sm};
+// eslint-disable-next-line twenty/styled-components-prefixed-with-styled
+export const IllustrationIconWrapper = styled.div`
+ background-color: ${themeCssVariables.background.primary};
+ border: 0.75px solid ${themeCssVariables.border.color.medium};
+ border-radius: ${themeCssVariables.border.radius.sm};
display: flex;
justify-content: center;
`;
-
-export const IllustrationIconWrapper = StyledRectangleIllustrationIcon;
diff --git a/packages/twenty-ui/src/display/info/components/Info.tsx b/packages/twenty-ui/src/display/info/components/Info.tsx
index 878f0e523e2..afb4ae5d35a 100644
--- a/packages/twenty-ui/src/display/info/components/Info.tsx
+++ b/packages/twenty-ui/src/display/info/components/Info.tsx
@@ -1,9 +1,9 @@
-import { css, useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { IconInfoCircle } from '@ui/display/icon/components/TablerIcons';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
import { Button } from '@ui/input/button/components/Button/Button';
-import React from 'react';
+import React, { useContext } from 'react';
import { Link } from 'react-router-dom';
export type InfoAccent = 'blue' | 'danger';
@@ -18,7 +18,7 @@ export type InfoProps = {
const StyledTextContainer = styled.div`
align-items: center;
display: flex;
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
`;
const StyledIconInfoCircle = styled(IconInfoCircle)`
@@ -27,27 +27,33 @@ const StyledIconInfoCircle = styled(IconInfoCircle)`
const StyledInfo = styled.div<Pick<InfoProps, 'accent'>>`
align-items: center;
- border-radius: ${({ theme }) => theme.border.radius.md};
+ border-radius: ${themeCssVariables.border.radius.md};
display: flex;
- font-weight: ${({ theme }) => theme.font.weight.medium};
+ font-weight: ${themeCssVariables.font.weight.medium};
justify-content: space-between;
max-width: 512px;
- gap: ${({ theme }) => theme.spacing(2)};
- padding: ${({ theme }) => theme.spacing(2)};
- ${({ theme, accent }) => {
+ gap: ${themeCssVariables.spacing[2]};
+ padding: ${themeCssVariables.spacing[2]};
+ background: ${({ accent }) => {
switch (accent) {
case 'blue':
- return css`
- background: ${theme.color.blue5};
- color: ${theme.color.blue10};
- `;
+ return themeCssVariables.color.blue5;
case 'danger':
- return css`
- background: ${theme.color.red3};
- color: ${theme.color.red};
- `;
+ return themeCssVariables.color.red3;
+ default:
+ return 'transparent';
}
- }}
+ }};
+ color: ${({ accent }) => {
+ switch (accent) {
+ case 'blue':
+ return themeCssVariables.color.blue10;
+ case 'danger':
+ return themeCssVariables.color.red;
+ default:
+ return 'inherit';
+ }
+ }};
`;
const StyledLink = styled(Link)`
@@ -61,7 +67,7 @@ export const Info = ({
onClick,
to,
}: InfoProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledInfo accent={accent}>
<StyledTextContainer>
diff --git a/packages/twenty-ui/src/display/status/components/Status.tsx b/packages/twenty-ui/src/display/status/components/Status.tsx
index 29fea6579b0..99b4d1043b2 100644
--- a/packages/twenty-ui/src/display/status/components/Status.tsx
+++ b/packages/twenty-ui/src/display/status/components/Status.tsx
@@ -1,5 +1,9 @@
-import styled from '@emotion/styled';
-import { MAIN_COLOR_NAMES, type ThemeColor } from '@ui/theme';
+import { styled } from '@linaria/react';
+import {
+ MAIN_COLOR_NAMES,
+ themeCssVariables,
+ type ThemeColor,
+} from '@ui/theme';
import { Loader } from '@ui/feedback/loader/components/Loader';
@@ -14,30 +18,32 @@ const StyledStatus = styled.h3<{
isLoaderVisible: boolean;
}>`
align-items: center;
- background: ${({ color, theme }) => theme.tag.background[color]};
- border-radius: ${({ theme }) => theme.border.radius.pill};
- color: ${({ color, theme }) => theme.tag.text[color]};
+ background: ${({ color }) => themeCssVariables.tag.background[color]};
+ border-radius: ${themeCssVariables.border.radius.pill};
+ color: ${({ color }) => themeCssVariables.tag.text[color]};
display: inline-flex;
- font-size: ${({ theme }) => theme.font.size.md};
+ font-size: ${themeCssVariables.font.size.md};
font-style: normal;
- font-weight: ${({ theme, weight }) => theme.font.weight[weight]};
- gap: ${({ theme }) => theme.spacing(1)};
- height: ${({ theme }) => theme.spacing(5)};
+ font-weight: ${({ weight }) => themeCssVariables.font.weight[weight]};
+ gap: ${themeCssVariables.spacing[1]};
+ height: ${themeCssVariables.spacing[5]};
margin: 0;
overflow: hidden;
padding: 0
- ${({ theme, isLoaderVisible }) =>
- isLoaderVisible ? theme.spacing(1) : theme.spacing(2)}
- 0 ${({ theme }) => theme.spacing(2)};
+ ${({ isLoaderVisible }) =>
+ isLoaderVisible
+ ? themeCssVariables.spacing[1]
+ : themeCssVariables.spacing[2]}
+ 0 ${themeCssVariables.spacing[2]};
&:before {
- background-color: ${({ color, theme }) => theme.tag.text[color]};
- border-radius: ${({ theme }) => theme.border.radius.rounded};
+ background-color: ${({ color }) => themeCssVariables.tag.text[color]};
+ border-radius: ${themeCssVariables.border.radius.rounded};
content: '';
display: block;
flex-shrink: 0;
- height: ${({ theme }) => theme.spacing(1)};
- width: ${({ theme }) => theme.spacing(1)};
+ height: ${themeCssVariables.spacing[1]};
+ width: ${themeCssVariables.spacing[1]};
}
`;
@@ -63,15 +69,17 @@ export const Status = ({
text,
onClick,
weight = 'regular',
-}: StatusProps) => (
- <StyledStatus
- className={className}
- color={parseThemeColor(color)}
- onClick={onClick}
- weight={weight}
- isLoaderVisible={isLoaderVisible}
- >
- <StyledContent>{text}</StyledContent>
- {isLoaderVisible ? <Loader color={color} /> : null}
- </StyledStatus>
-);
+}: StatusProps) => {
+ return (
+ <StyledStatus
+ className={className}
+ color={parseThemeColor(color)}
+ onClick={onClick}
+ weight={weight}
+ isLoaderVisible={isLoaderVisible}
+ >
+ <StyledContent>{text}</StyledContent>
+ {isLoaderVisible ? <Loader color={color} /> : null}
+ </StyledStatus>
+ );
+};
diff --git a/packages/twenty-ui/src/display/text/components/HorizontalSeparator.tsx b/packages/twenty-ui/src/display/text/components/HorizontalSeparator.tsx
index beb96067c62..ce5a86979b1 100644
--- a/packages/twenty-ui/src/display/text/components/HorizontalSeparator.tsx
+++ b/packages/twenty-ui/src/display/text/components/HorizontalSeparator.tsx
@@ -1,6 +1,10 @@
-import styled from '@emotion/styled';
-import { type JSX } from 'react';
+import { styled } from '@linaria/react';
+import { type JSX, useContext } from 'react';
import { Label } from '@ui/display';
+import { THEME_COMMON, ThemeContext } from '@ui/theme';
+
+const spacing3 = THEME_COMMON.spacing(3);
+const spacing2 = THEME_COMMON.spacing(2);
type HorizontalSeparatorProps = {
visible?: boolean;
@@ -8,31 +12,39 @@ type HorizontalSeparatorProps = {
noMargin?: boolean;
color?: string;
};
-const StyledSeparator = styled.div<HorizontalSeparatorProps>`
- background-color: ${({ theme, color }) => color ?? theme.border.color.medium};
- height: ${({ visible }) => (visible ? '1px' : 0)};
+
+const StyledSeparator = styled.div<{
+ visible: boolean;
+ noMargin: boolean;
+ backgroundColor: string;
+}>`
+ background-color: ${({ backgroundColor }) => backgroundColor};
+ height: ${({ visible }) => (visible ? '1px' : '0')};
flex-shrink: 0;
- margin-bottom: ${({ theme, noMargin }) => (noMargin ? 0 : theme.spacing(3))};
- margin-top: ${({ theme, noMargin }) => (noMargin ? 0 : theme.spacing(3))};
+ margin-bottom: ${({ noMargin }) => (noMargin ? '0' : spacing3)};
+ margin-top: ${({ noMargin }) => (noMargin ? '0' : spacing3)};
width: 100%;
`;
const StyledSeparatorContainer = styled.div<{ noMargin: boolean }>`
align-items: center;
display: flex;
- margin-bottom: ${({ theme, noMargin }) => (noMargin ? 0 : theme.spacing(3))};
- margin-top: ${({ theme, noMargin }) => (noMargin ? 0 : theme.spacing(3))};
+ margin-bottom: ${({ noMargin }) => (noMargin ? '0' : spacing3)};
+ margin-top: ${({ noMargin }) => (noMargin ? '0' : spacing3)};
width: 100%;
`;
-const StyledLine = styled.div<HorizontalSeparatorProps>`
- background-color: ${({ theme }) => theme.border.color.medium};
- height: ${({ visible }) => (visible ? '1px' : 0)};
+const StyledLine = styled.div<{
+ visible: boolean;
+ backgroundColor: string;
+}>`
+ background-color: ${({ backgroundColor }) => backgroundColor};
+ height: ${({ visible }) => (visible ? '1px' : '0')};
flex-grow: 1;
`;
const StyledText = styled.span`
- margin: 0 ${({ theme }) => theme.spacing(2)};
+ margin: 0 ${spacing2};
`;
export const HorizontalSeparator = ({
@@ -40,18 +52,27 @@ export const HorizontalSeparator = ({
text = '',
noMargin = false,
color,
-}: HorizontalSeparatorProps): JSX.Element => (
- <>
- {text ? (
- <StyledSeparatorContainer noMargin={noMargin}>
- <StyledLine visible={visible} />
- <Label>
- <StyledText>{text}</StyledText>
- </Label>
- <StyledLine visible={visible} />
- </StyledSeparatorContainer>
- ) : (
- <StyledSeparator visible={visible} noMargin={noMargin} color={color} />
- )}
- </>
-);
+}: HorizontalSeparatorProps): JSX.Element => {
+ const { theme } = useContext(ThemeContext);
+ const borderColor = color ?? theme.border.color.medium;
+
+ return (
+ <>
+ {text ? (
+ <StyledSeparatorContainer noMargin={noMargin}>
+ <StyledLine visible={visible} backgroundColor={borderColor} />
+ <Label>
+ <StyledText>{text}</StyledText>
+ </Label>
+ <StyledLine visible={visible} backgroundColor={borderColor} />
+ </StyledSeparatorContainer>
+ ) : (
+ <StyledSeparator
+ visible={visible}
+ noMargin={noMargin}
+ backgroundColor={borderColor}
+ />
+ )}
+ </>
+ );
+};
diff --git a/packages/twenty-ui/src/display/text/components/SeparatorLineText.tsx b/packages/twenty-ui/src/display/text/components/SeparatorLineText.tsx
index e5b2c35a340..88f87a6ab18 100644
--- a/packages/twenty-ui/src/display/text/components/SeparatorLineText.tsx
+++ b/packages/twenty-ui/src/display/text/components/SeparatorLineText.tsx
@@ -1,27 +1,27 @@
-import React from 'react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
const StyledContainer = styled.div`
display: flex;
align-items: center;
width: 100%;
- font-size: ${({ theme }) => theme.font.size.md};
- font-weight: ${({ theme }) => theme.font.weight.semiBold};
- color: ${({ theme }) => theme.font.color.extraLight};
+ font-size: ${themeCssVariables.font.size.md};
+ font-weight: ${themeCssVariables.font.weight.semiBold};
+ color: ${themeCssVariables.font.color.extraLight};
&:before,
&:after {
content: '';
height: 1px;
flex-grow: 1;
- background: ${({ theme }) => theme.background.transparent.light};
+ background: ${themeCssVariables.background.transparent.light};
}
&:before {
- margin: 0 ${({ theme }) => theme.spacing(4)} 0 0;
+ margin: 0 ${themeCssVariables.spacing[4]} 0 0;
}
&:after {
- margin: 0 0 0 ${({ theme }) => theme.spacing(4)};
+ margin: 0 0 0 ${themeCssVariables.spacing[4]};
}
`;
diff --git a/packages/twenty-ui/src/display/tooltip/AppTooltip.tsx b/packages/twenty-ui/src/display/tooltip/AppTooltip.tsx
index 4950821e7f2..b2354fe9dd6 100644
--- a/packages/twenty-ui/src/display/tooltip/AppTooltip.tsx
+++ b/packages/twenty-ui/src/display/tooltip/AppTooltip.tsx
@@ -1,5 +1,6 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type PlacesType, type PositionStrategy, Tooltip } from 'react-tooltip';
+import { themeCssVariables } from '@ui/theme';
export enum TooltipPosition {
Top = 'top',
@@ -16,24 +17,24 @@ export enum TooltipDelay {
}
const StyledAppTooltip = styled(Tooltip)<{ width?: string }>`
- backdrop-filter: ${({ theme }) => theme.blur.strong};
- background-color: ${({ theme }) => theme.color.transparent.gray11};
- border-radius: ${({ theme }) => theme.border.radius.sm};
+ backdrop-filter: ${themeCssVariables.blur.strong};
+ background-color: ${themeCssVariables.color.transparent.gray11};
+ border-radius: ${themeCssVariables.border.radius.sm};
- box-shadow: ${({ theme }) => theme.boxShadow.light};
- color: ${({ theme }) => theme.grayScale.gray1};
+ box-shadow: ${themeCssVariables.boxShadow.light};
+ color: ${themeCssVariables.grayScale.gray1};
- font-size: ${({ theme }) => theme.font.size.sm};
- font-weight: ${({ theme }) => theme.font.weight.regular};
+ font-size: ${themeCssVariables.font.size.sm};
+ font-weight: ${themeCssVariables.font.weight.regular};
max-width: ${({ width }) => width || '40%'};
overflow: visible;
- padding: ${({ theme }) => theme.spacing(2)};
+ padding: ${themeCssVariables.spacing[2]};
word-break: break-word;
- z-index: ${({ theme }) => theme.lastLayerZIndex};
+ z-index: ${themeCssVariables.lastLayerZIndex};
`;
export type AppTooltipProps = {
diff --git a/packages/twenty-ui/src/display/typography/components/H1Title.tsx b/packages/twenty-ui/src/display/typography/components/H1Title.tsx
index 8175a644bf9..7e11ab0d44a 100644
--- a/packages/twenty-ui/src/display/typography/components/H1Title.tsx
+++ b/packages/twenty-ui/src/display/typography/components/H1Title.tsx
@@ -1,5 +1,6 @@
import { type ReactNode } from 'react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
type H1TitleProps = {
title: ReactNode;
@@ -16,12 +17,12 @@ export enum H1TitleFontColor {
const StyledTitle = styled.h2<{
fontColor: H1TitleFontColor;
}>`
- color: ${({ theme, fontColor }) => theme.font.color[fontColor]};
- font-size: ${({ theme }) => theme.font.size.lg};
- font-weight: ${({ theme }) => theme.font.weight.semiBold};
- line-height: ${({ theme }) => theme.text.lineHeight.md};
+ color: ${({ fontColor }) => themeCssVariables.font.color[fontColor]};
+ font-size: ${themeCssVariables.font.size.lg};
+ font-weight: ${themeCssVariables.font.weight.semiBold};
+ line-height: ${themeCssVariables.text.lineHeight.md};
margin: 0;
- margin-bottom: ${({ theme }) => theme.spacing(4)};
+ margin-bottom: ${themeCssVariables.spacing[4]};
`;
export const H1Title = ({
diff --git a/packages/twenty-ui/src/display/typography/components/H2Title.tsx b/packages/twenty-ui/src/display/typography/components/H2Title.tsx
index 022a967e591..d71823a981e 100644
--- a/packages/twenty-ui/src/display/typography/components/H2Title.tsx
+++ b/packages/twenty-ui/src/display/typography/components/H2Title.tsx
@@ -1,5 +1,6 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { OverflowingTextWithTooltip } from '@ui/display/tooltip/OverflowingTextWithTooltip';
+import { themeCssVariables } from '@ui/theme';
type H2TitleProps = {
title: string;
@@ -11,7 +12,7 @@ type H2TitleProps = {
const StyledContainer = styled.div`
display: flex;
flex-direction: column;
- margin-bottom: ${({ theme }) => theme.spacing(4)};
+ margin-bottom: ${themeCssVariables.spacing[4]};
`;
const StyledTitleContainer = styled.div`
@@ -21,18 +22,18 @@ const StyledTitleContainer = styled.div`
`;
const StyledTitle = styled.h2`
- color: ${({ theme }) => theme.font.color.primary};
- font-size: ${({ theme }) => theme.font.size.md};
- font-weight: ${({ theme }) => theme.font.weight.semiBold};
+ color: ${themeCssVariables.font.color.primary};
+ font-size: ${themeCssVariables.font.size.md};
+ font-weight: ${themeCssVariables.font.weight.semiBold};
margin: 0;
`;
const StyledDescription = styled.h3`
- color: ${({ theme }) => theme.font.color.tertiary};
- font-size: ${({ theme }) => theme.font.size.md};
- font-weight: ${({ theme }) => theme.font.weight.regular};
+ color: ${themeCssVariables.font.color.tertiary};
+ font-size: ${themeCssVariables.font.size.md};
+ font-weight: ${themeCssVariables.font.weight.regular};
margin: 0;
- margin-top: ${({ theme }) => theme.spacing(2)};
+ margin-top: ${themeCssVariables.spacing[2]};
`;
export const H2Title = ({
@@ -40,20 +41,22 @@ export const H2Title = ({
description,
adornment,
className,
-}: H2TitleProps) => (
- <StyledContainer className={className}>
- <StyledTitleContainer>
- <StyledTitle>{title}</StyledTitle>
- {adornment}
- </StyledTitleContainer>
- {description && (
- <StyledDescription>
- <OverflowingTextWithTooltip
- text={description}
- displayedMaxRows={5}
- isTooltipMultiline={true}
- />
- </StyledDescription>
- )}
- </StyledContainer>
-);
+}: H2TitleProps) => {
+ return (
+ <StyledContainer className={className}>
+ <StyledTitleContainer>
+ <StyledTitle>{title}</StyledTitle>
+ {adornment}
+ </StyledTitleContainer>
+ {description && (
+ <StyledDescription>
+ <OverflowingTextWithTooltip
+ text={description}
+ displayedMaxRows={5}
+ isTooltipMultiline={true}
+ />
+ </StyledDescription>
+ )}
+ </StyledContainer>
+ );
+};
diff --git a/packages/twenty-ui/src/display/typography/components/H3Title.tsx b/packages/twenty-ui/src/display/typography/components/H3Title.tsx
index 630a41fcd45..8af5341dea9 100644
--- a/packages/twenty-ui/src/display/typography/components/H3Title.tsx
+++ b/packages/twenty-ui/src/display/typography/components/H3Title.tsx
@@ -1,6 +1,7 @@
-import styled from '@emotion/styled';
-import { OverflowingTextWithTooltip } from '@ui/display/tooltip/OverflowingTextWithTooltip';
import { type ReactNode } from 'react';
+import { styled } from '@linaria/react';
+import { OverflowingTextWithTooltip } from '@ui/display/tooltip/OverflowingTextWithTooltip';
+import { themeCssVariables } from '@ui/theme';
type H3TitleProps = {
title: ReactNode;
@@ -14,18 +15,18 @@ const StyledContainer = styled.div`
`;
const StyledH3Title = styled.h3`
- color: ${({ theme }) => theme.font.color.primary};
- font-size: ${({ theme }) => theme.font.size.lg};
- font-weight: ${({ theme }) => theme.font.weight.semiBold};
+ color: ${themeCssVariables.font.color.primary};
+ font-size: ${themeCssVariables.font.size.lg};
+ font-weight: ${themeCssVariables.font.weight.semiBold};
margin: 0;
`;
const StyledDescription = styled.h4`
- color: ${({ theme }) => theme.font.color.tertiary};
- font-size: ${({ theme }) => theme.font.size.md};
- font-weight: ${({ theme }) => theme.font.weight.regular};
+ color: ${themeCssVariables.font.color.tertiary};
+ font-size: ${themeCssVariables.font.size.md};
+ font-weight: ${themeCssVariables.font.weight.regular};
margin: 0;
- margin-top: ${({ theme }) => theme.spacing(2)};
+ margin-top: ${themeCssVariables.spacing[2]};
`;
export const H3Title = ({ title, description, className }: H3TitleProps) => {
diff --git a/packages/twenty-ui/src/display/typography/components/Label.tsx b/packages/twenty-ui/src/display/typography/components/Label.tsx
index 61a4e66d8fb..f5ef78788a1 100644
--- a/packages/twenty-ui/src/display/typography/components/Label.tsx
+++ b/packages/twenty-ui/src/display/typography/components/Label.tsx
@@ -1,9 +1,10 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
export type LabelVariant = 'default' | 'small';
const StyledLabel = styled.div<{ variant?: LabelVariant }>`
- color: ${({ theme }) => theme.font.color.light};
+ color: ${themeCssVariables.font.color.light};
font-size: ${({ variant = 'default' }) => {
switch (variant) {
case 'default':
@@ -12,7 +13,19 @@ const StyledLabel = styled.div<{ variant?: LabelVariant }>`
return '9px';
}
}};
- font-weight: ${({ theme }) => theme.font.weight.semiBold};
+ font-weight: ${themeCssVariables.font.weight.semiBold};
`;
-export { StyledLabel as Label };
+type LabelProps = {
+ variant?: LabelVariant;
+ children?: React.ReactNode;
+ className?: string;
+};
+
+export const Label = ({ variant, children, className }: LabelProps) => {
+ return (
+ <StyledLabel variant={variant} className={className}>
+ {children}
+ </StyledLabel>
+ );
+};
diff --git a/packages/twenty-ui/src/display/typography/components/StyledText.tsx b/packages/twenty-ui/src/display/typography/components/StyledText.tsx
index e6165b91bd6..57c00004639 100644
--- a/packages/twenty-ui/src/display/typography/components/StyledText.tsx
+++ b/packages/twenty-ui/src/display/typography/components/StyledText.tsx
@@ -1,5 +1,6 @@
import { type ReactElement, type ReactNode } from 'react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
type StyledTextProps = {
PrefixComponent?: ReactElement;
@@ -8,8 +9,8 @@ type StyledTextProps = {
};
export const StyledTextContent = styled.div`
- font-size: ${({ theme }) => theme.font.size.sm};
- font-weight: ${({ theme }) => theme.font.weight.regular};
+ font-size: ${themeCssVariables.font.size.sm};
+ font-weight: ${themeCssVariables.font.weight.regular};
overflow: hidden;
padding-left: 0;
@@ -20,8 +21,8 @@ export const StyledTextContent = styled.div`
export const StyledTextWrapper = styled.div<{
color?: string;
}>`
- --horizontal-padding: ${({ theme }) => theme.spacing(1)};
- --vertical-padding: ${({ theme }) => theme.spacing(2)};
+ --horizontal-padding: ${themeCssVariables.spacing[1]};
+ --vertical-padding: ${themeCssVariables.spacing[2]};
cursor: initial;
@@ -29,13 +30,13 @@ export const StyledTextWrapper = styled.div<{
flex-direction: row;
- font-size: ${({ theme }) => theme.font.size.sm};
+ font-size: ${themeCssVariables.font.size.sm};
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
padding: var(--vertical-padding) 0;
- color: ${({ theme, color }) => color ?? theme.font.color.primary};
+ color: ${({ color }) => color ?? themeCssVariables.font.color.primary};
`;
export const StyledText = ({
diff --git a/packages/twenty-ui/src/emotion.d.ts b/packages/twenty-ui/src/emotion.d.ts
deleted file mode 100644
index 844111ace3f..00000000000
--- a/packages/twenty-ui/src/emotion.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { type ThemeType } from './theme';
-
-declare module '@emotion/react' {
- export interface Theme extends ThemeType {}
-}
diff --git a/packages/twenty-ui/src/feedback/loader/components/Loader.tsx b/packages/twenty-ui/src/feedback/loader/components/Loader.tsx
index 6ebba29bc13..e16ce9733cb 100644
--- a/packages/twenty-ui/src/feedback/loader/components/Loader.tsx
+++ b/packages/twenty-ui/src/feedback/loader/components/Loader.tsx
@@ -1,5 +1,5 @@
-import styled from '@emotion/styled';
-import { type ThemeColor } from '@ui/theme';
+import { styled } from '@linaria/react';
+import { type ThemeColor, themeCssVariables } from '@ui/theme';
import { motion } from 'framer-motion';
const StyledLoaderContainer = styled.div<{
@@ -9,48 +9,52 @@ const StyledLoaderContainer = styled.div<{
justify-content: center;
align-items: center;
display: flex;
- gap: ${({ theme }) => theme.spacing(2)};
- width: ${({ theme }) => theme.spacing(6)};
- height: ${({ theme }) => theme.spacing(3)};
- border-radius: ${({ theme }) => theme.border.radius.pill};
+ gap: ${themeCssVariables.spacing[2]};
+ width: ${themeCssVariables.spacing[6]};
+ height: ${themeCssVariables.spacing[3]};
+ border-radius: ${themeCssVariables.border.radius.pill};
border: 1px solid
- ${({ color, theme }) =>
+ ${({ color }) =>
color
- ? theme.tag.text[color]
- : `var(--tw-button-color, ${theme.font.color.tertiary})`};
+ ? themeCssVariables.tag.text[color]
+ : `var(--tw-button-color, ${themeCssVariables.font.color.tertiary})`};
overflow: hidden;
`;
-const StyledLoader = styled(motion.div)<{
+const StyledLoaderBase = styled.div<{
color?: ThemeColor;
}>`
- background-color: ${({ color, theme }) =>
+ background-color: ${({ color }) =>
color
- ? theme.tag.text[color]
- : `var(--tw-button-color, ${theme.font.color.tertiary})`};
- border-radius: ${({ theme }) => theme.border.radius.pill};
+ ? themeCssVariables.tag.text[color]
+ : `var(--tw-button-color, ${themeCssVariables.font.color.tertiary})`};
+ border-radius: ${themeCssVariables.border.radius.pill};
height: 8px;
width: 8px;
`;
+const StyledLoader = motion.create(StyledLoaderBase);
+
type LoaderProps = {
color?: ThemeColor;
};
-export const Loader = ({ color }: LoaderProps) => (
- <StyledLoaderContainer color={color}>
- <StyledLoader
- color={color}
- animate={{
- x: [-16, 0, 16],
- width: [8, 12, 8],
- height: [8, 2, 8],
- }}
- transition={{
- duration: 0.8,
- times: [0, 0.15, 0.3],
- repeat: Infinity,
- }}
- />
- </StyledLoaderContainer>
-);
+export const Loader = ({ color }: LoaderProps) => {
+ return (
+ <StyledLoaderContainer color={color}>
+ <StyledLoader
+ color={color}
+ animate={{
+ x: [-16, 0, 16],
+ width: [8, 12, 8],
+ height: [8, 2, 8],
+ }}
+ transition={{
+ duration: 0.8,
+ times: [0, 0.15, 0.3],
+ repeat: Infinity,
+ }}
+ />
+ </StyledLoaderContainer>
+ );
+};
diff --git a/packages/twenty-ui/src/feedback/progress-bar/components/ProgressBar.tsx b/packages/twenty-ui/src/feedback/progress-bar/components/ProgressBar.tsx
index bd81d2c108c..b93438cb462 100644
--- a/packages/twenty-ui/src/feedback/progress-bar/components/ProgressBar.tsx
+++ b/packages/twenty-ui/src/feedback/progress-bar/components/ProgressBar.tsx
@@ -1,4 +1,5 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
import { motion } from 'framer-motion';
import { useState } from 'react';
@@ -17,25 +18,27 @@ export type StyledBarProps = {
};
const StyledBar = styled.div<StyledBarProps>`
- height: ${({ theme }) => theme.spacing(2)};
- background-color: ${({ backgroundColor }) => backgroundColor};
- border-radius: ${({ withBorderRadius, theme }) =>
- withBorderRadius ? theme.border.radius.xxl : '0'};
+ height: ${themeCssVariables.spacing[2]};
+ background-color: ${({ backgroundColor }) => backgroundColor ?? ''};
+ border-radius: ${({ withBorderRadius }) =>
+ withBorderRadius ? themeCssVariables.border.radius.xxl : '0'};
overflow: hidden;
width: 100%;
`;
-const StyledBarFilling = styled(motion.div)<{
+const StyledBarFillingBase = styled.div<{
barColor?: string;
withBorderRadius?: boolean;
}>`
- background-color: ${({ barColor, theme }) =>
- barColor ?? theme.font.color.primary};
+ background-color: ${({ barColor }) =>
+ barColor ?? themeCssVariables.font.color.primary};
height: 100%;
- border-radius: ${({ withBorderRadius, theme }) =>
- withBorderRadius ? theme.border.radius.md : '0'};
+ border-radius: ${({ withBorderRadius }) =>
+ withBorderRadius ? themeCssVariables.border.radius.md : '0'};
`;
+const StyledBarFilling = motion.create(StyledBarFillingBase);
+
export const ProgressBar = ({
value,
className,
diff --git a/packages/twenty-ui/src/input/button/components/AnimatedButton.tsx b/packages/twenty-ui/src/input/button/components/AnimatedButton.tsx
index 0dc7d105998..5b5e55ec476 100644
--- a/packages/twenty-ui/src/input/button/components/AnimatedButton.tsx
+++ b/packages/twenty-ui/src/input/button/components/AnimatedButton.tsx
@@ -1,13 +1,15 @@
-import { css, useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { useIsMobile } from '@ui/utilities';
import { getOsShortcutSeparator } from '@ui/utilities/device/getOsShortcutSeparator';
import { type MotionProps, motion } from 'framer-motion';
+import React, { useContext, useMemo } from 'react';
import { Link } from 'react-router-dom';
import { Pill } from '@ui/components/Pill/Pill';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
import {
type ButtonAccent,
+ type ButtonPosition,
type ButtonProps,
type ButtonSize,
type ButtonVariant,
@@ -19,16 +21,294 @@ export type AnimatedButtonProps = ButtonProps &
soonLabel?: string;
};
+type AnimatedButtonDynamicStyles = {
+ background: string;
+ borderColor: string;
+ borderWidthOverride: string;
+ boxShadow: string;
+ color: string;
+ hoverBackground: string;
+ activeBackground: string;
+};
+
+const computeAnimatedButtonDynamicStyles = (
+ variant: ButtonVariant,
+ inverted: boolean,
+ accent: ButtonAccent,
+ disabled: boolean,
+ focus: boolean,
+ position: ButtonPosition,
+): AnimatedButtonDynamicStyles => {
+ const result: AnimatedButtonDynamicStyles = {
+ background: 'transparent',
+ borderColor: 'transparent',
+ borderWidthOverride: '',
+ boxShadow: 'none',
+ color: themeCssVariables.font.color.secondary,
+ hoverBackground: 'transparent',
+ activeBackground: 'transparent',
+ };
+
+ switch (variant) {
+ case 'primary':
+ switch (accent) {
+ case 'default':
+ result.background = !inverted
+ ? themeCssVariables.background.secondary
+ : themeCssVariables.background.primary;
+ result.borderColor = !inverted
+ ? !disabled && focus
+ ? themeCssVariables.color.blue
+ : themeCssVariables.background.transparent.light
+ : themeCssVariables.background.transparent.light;
+ result.borderWidthOverride = '1px 1px 1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.accent.tertiary
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? !disabled
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.extraLight
+ : themeCssVariables.font.color.secondary;
+ if (!disabled) {
+ result.hoverBackground = !inverted
+ ? themeCssVariables.background.tertiary
+ : themeCssVariables.background.secondary;
+ result.activeBackground = !inverted
+ ? themeCssVariables.background.quaternary
+ : themeCssVariables.background.tertiary;
+ } else {
+ result.hoverBackground = result.background;
+ result.activeBackground = result.background;
+ }
+ break;
+ case 'blue':
+ result.background = !inverted
+ ? themeCssVariables.color.blue
+ : themeCssVariables.background.primary;
+ result.borderColor = !inverted
+ ? focus
+ ? themeCssVariables.color.blue
+ : themeCssVariables.background.transparent.light
+ : themeCssVariables.background.transparent.light;
+ result.borderWidthOverride = '1px 1px 1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.accent.tertiary
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? themeCssVariables.grayScale.gray1
+ : themeCssVariables.color.blue;
+ if (!disabled) {
+ result.hoverBackground = !inverted
+ ? themeCssVariables.color.blue10
+ : themeCssVariables.background.secondary;
+ result.activeBackground = !inverted
+ ? themeCssVariables.color.blue12
+ : themeCssVariables.background.tertiary;
+ } else {
+ result.hoverBackground = result.background;
+ result.activeBackground = result.background;
+ }
+ break;
+ case 'danger':
+ result.background = !inverted
+ ? themeCssVariables.color.red
+ : themeCssVariables.background.primary;
+ result.borderColor = !inverted
+ ? focus
+ ? themeCssVariables.color.red
+ : themeCssVariables.background.transparent.light
+ : themeCssVariables.background.transparent.light;
+ result.borderWidthOverride = '1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.color.red3
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? themeCssVariables.background.primary
+ : themeCssVariables.color.red;
+ if (!disabled) {
+ result.hoverBackground = !inverted
+ ? themeCssVariables.color.red8
+ : themeCssVariables.background.secondary;
+ result.activeBackground = !inverted
+ ? themeCssVariables.color.red10
+ : themeCssVariables.background.tertiary;
+ } else {
+ result.hoverBackground = result.background;
+ result.activeBackground = result.background;
+ }
+ break;
+ }
+ break;
+ case 'secondary':
+ case 'tertiary':
+ switch (accent) {
+ case 'default':
+ result.background = 'transparent';
+ result.borderColor = !inverted
+ ? variant === 'secondary'
+ ? !disabled && focus
+ ? themeCssVariables.color.blue
+ : themeCssVariables.background.transparent.medium
+ : focus
+ ? themeCssVariables.color.blue
+ : 'transparent'
+ : variant === 'secondary'
+ ? focus || disabled
+ ? themeCssVariables.grayScale.gray1
+ : themeCssVariables.background.transparent.primary
+ : focus
+ ? themeCssVariables.grayScale.gray1
+ : 'transparent';
+ result.borderWidthOverride = '1px 1px 1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.accent.tertiary
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? !disabled
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.extraLight
+ : themeCssVariables.font.color.inverted;
+ result.hoverBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.background.transparent.light
+ : 'transparent'
+ : themeCssVariables.background.transparent.light;
+ result.activeBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.background.transparent.light
+ : 'transparent'
+ : themeCssVariables.background.transparent.medium;
+ break;
+ case 'blue':
+ result.background = 'transparent';
+ result.borderColor = !inverted
+ ? variant === 'secondary'
+ ? focus
+ ? themeCssVariables.color.blue
+ : themeCssVariables.accent.primary
+ : focus
+ ? themeCssVariables.color.blue
+ : 'transparent'
+ : variant === 'secondary'
+ ? focus || disabled
+ ? themeCssVariables.grayScale.gray1
+ : themeCssVariables.background.transparent.primary
+ : focus
+ ? themeCssVariables.grayScale.gray1
+ : 'transparent';
+ result.borderWidthOverride = '1px 1px 1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.accent.tertiary
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? !disabled
+ ? themeCssVariables.color.blue
+ : themeCssVariables.accent.accent4060
+ : themeCssVariables.font.color.inverted;
+ result.hoverBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.accent.tertiary
+ : 'transparent'
+ : themeCssVariables.background.transparent.light;
+ result.activeBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.accent.secondary
+ : 'transparent'
+ : themeCssVariables.background.transparent.medium;
+ break;
+ case 'danger':
+ result.background = 'transparent';
+ result.borderColor = !inverted
+ ? variant === 'secondary'
+ ? focus
+ ? themeCssVariables.color.red
+ : themeCssVariables.border.color.danger
+ : focus
+ ? themeCssVariables.color.red
+ : 'transparent'
+ : variant === 'secondary'
+ ? focus || disabled
+ ? themeCssVariables.grayScale.gray1
+ : themeCssVariables.background.transparent.primary
+ : focus
+ ? themeCssVariables.grayScale.gray1
+ : 'transparent';
+ result.borderWidthOverride = '1px 1px 1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.color.red3
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? themeCssVariables.font.color.danger
+ : themeCssVariables.font.color.inverted;
+ result.hoverBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.background.danger
+ : 'transparent'
+ : themeCssVariables.background.transparent.light;
+ result.activeBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.background.danger
+ : 'transparent'
+ : themeCssVariables.background.transparent.medium;
+ break;
+ }
+ break;
+ }
+
+ if (result.borderWidthOverride !== '' && position !== 'standalone') {
+ switch (position) {
+ case 'left':
+ result.borderWidthOverride = '1px 0px 1px 1px';
+ break;
+ case 'middle':
+ result.borderWidthOverride = '1px 0px 1px 0px';
+ break;
+ case 'right':
+ result.borderWidthOverride = '1px 1px 1px 0px';
+ break;
+ }
+ }
+
+ return result;
+};
+
const StyledButton = styled.button<
Pick<
ButtonProps,
| 'fullWidth'
- | 'variant'
- | 'inverted'
| 'size'
| 'position'
- | 'accent'
- | 'focus'
| 'justify'
| 'to'
| 'target'
@@ -37,292 +317,44 @@ const StyledButton = styled.button<
>
>`
align-items: center;
- ${({ theme, variant, inverted, accent, disabled, focus }) => {
- switch (variant) {
- case 'primary':
- switch (accent) {
- case 'default':
- return css`
- background: ${!inverted
- ? theme.background.secondary
- : theme.background.primary};
- border-color: ${!inverted
- ? !disabled && focus
- ? theme.color.blue
- : theme.background.transparent.light
- : theme.background.transparent.light};
- border-width: 1px 1px 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.accent.tertiary
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted
- ? !disabled
- ? theme.font.color.secondary
- : theme.font.color.extraLight
- : theme.font.color.secondary};
- &:hover {
- background: ${!inverted
- ? theme.background.tertiary
- : theme.background.secondary};
- }
- &:active {
- background: ${!inverted
- ? theme.background.quaternary
- : theme.background.tertiary};
- }
- `;
- case 'blue':
- return css`
- background: ${!inverted
- ? theme.color.blue
- : theme.background.primary};
- border-color: ${!inverted
- ? focus
- ? theme.color.blue
- : theme.background.transparent.light
- : theme.background.transparent.light};
- border-width: 1px 1px 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.accent.tertiary
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted ? theme.grayScale.gray1 : theme.color.blue};
- ${disabled
- ? ''
- : css`
- &:hover {
- background: ${!inverted
- ? theme.color.blue10
- : theme.background.secondary};
- }
- &:active {
- background: ${!inverted
- ? theme.color.blue12
- : theme.background.tertiary};
- }
- `}
- `;
- case 'danger':
- return css`
- background: ${!inverted
- ? theme.color.red
- : theme.background.primary};
- border-color: ${!inverted
- ? focus
- ? theme.color.red
- : theme.background.transparent.light
- : theme.background.transparent.light};
- border-width: 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.color.red3
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted ? theme.background.primary : theme.color.red};
- ${disabled
- ? ''
- : css`
- &:hover {
- background: ${!inverted
- ? theme.color.red8
- : theme.background.secondary};
- }
- &:active {
- background: ${!inverted
- ? theme.color.red10
- : theme.background.tertiary};
- }
- `}
- `;
- }
- break;
- case 'secondary':
- case 'tertiary':
- switch (accent) {
- case 'default':
- return css`
- background: transparent;
- border-color: ${!inverted
- ? variant === 'secondary'
- ? !disabled && focus
- ? theme.color.blue
- : theme.background.transparent.medium
- : focus
- ? theme.color.blue
- : 'transparent'
- : variant === 'secondary'
- ? focus || disabled
- ? theme.grayScale.gray1
- : theme.background.transparent.primary
- : focus
- ? theme.grayScale.gray1
- : 'transparent'};
- border-width: 1px 1px 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.accent.tertiary
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted
- ? !disabled
- ? theme.font.color.secondary
- : theme.font.color.extraLight
- : theme.font.color.inverted};
- &:hover {
- background: ${!inverted
- ? !disabled
- ? theme.background.transparent.light
- : 'transparent'
- : theme.background.transparent.light};
- }
- &:active {
- background: ${!inverted
- ? !disabled
- ? theme.background.transparent.light
- : 'transparent'
- : theme.background.transparent.medium};
- }
- `;
- case 'blue':
- return css`
- background: transparent;
- border-color: ${!inverted
- ? variant === 'secondary'
- ? focus
- ? theme.color.blue
- : theme.accent.primary
- : focus
- ? theme.color.blue
- : 'transparent'
- : variant === 'secondary'
- ? focus || disabled
- ? theme.grayScale.gray1
- : theme.background.transparent.primary
- : focus
- ? theme.grayScale.gray1
- : 'transparent'};
- border-width: 1px 1px 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.accent.tertiary
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted
- ? !disabled
- ? theme.color.blue
- : theme.accent.accent4060
- : theme.font.color.inverted};
- &:hover {
- background: ${!inverted
- ? !disabled
- ? theme.accent.tertiary
- : 'transparent'
- : theme.background.transparent.light};
- }
- &:active {
- background: ${!inverted
- ? !disabled
- ? theme.accent.secondary
- : 'transparent'
- : theme.background.transparent.medium};
- }
- `;
- case 'danger':
- return css`
- background: transparent;
- border-color: ${!inverted
- ? variant === 'secondary'
- ? focus
- ? theme.color.red
- : theme.border.color.danger
- : focus
- ? theme.color.red
- : 'transparent'
- : variant === 'secondary'
- ? focus || disabled
- ? theme.grayScale.gray1
- : theme.background.transparent.primary
- : focus
- ? theme.grayScale.gray1
- : 'transparent'};
- border-width: 1px 1px 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.color.red3
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted
- ? theme.font.color.danger
- : theme.font.color.inverted};
- &:hover {
- background: ${!inverted
- ? !disabled
- ? theme.background.danger
- : 'transparent'
- : theme.background.transparent.light};
- }
- &:active {
- background: ${!inverted
- ? !disabled
- ? theme.background.danger
- : 'transparent'
- : theme.background.transparent.medium};
- }
- `;
- }
- }
- }}
+ background: var(--abtn-bg);
+ border-color: var(--abtn-border-color);
+ border-width: var(--abtn-border-width);
+ box-shadow: var(--abtn-box-shadow);
+ color: var(--abtn-color);
+
+ &:hover {
+ background: var(--abtn-hover-bg);
+ }
+ &:active {
+ background: var(--abtn-active-bg);
+ }
text-decoration: none;
- border-radius: ${({ position, theme }) => {
+ border-radius: ${({ position }) => {
switch (position) {
case 'left':
- return `${theme.border.radius.sm} 0px 0px ${theme.border.radius.sm}`;
+ return `${themeCssVariables.border.radius.sm} 0px 0px ${themeCssVariables.border.radius.sm}`;
case 'right':
- return `0px ${theme.border.radius.sm} ${theme.border.radius.sm} 0px`;
+ return `0px ${themeCssVariables.border.radius.sm} ${themeCssVariables.border.radius.sm} 0px`;
case 'middle':
return '0px';
case 'standalone':
- return theme.border.radius.sm;
+ return themeCssVariables.border.radius.sm;
}
+ return '';
}};
border-style: solid;
- border-width: ${({ variant, position }) => {
- switch (variant) {
- case 'primary':
- case 'secondary':
- return position === 'middle' ? '1px 0px' : '1px';
- case 'tertiary':
- return '0';
- }
- }};
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
display: flex;
flex-direction: row;
- font-family: ${({ theme }) => theme.font.family};
+ font-family: ${themeCssVariables.font.family};
font-weight: 500;
- font-size: ${({ theme }) => theme.font.size.md};
- gap: ${({ theme }) => theme.spacing(1)};
+ font-size: ${themeCssVariables.font.size.md};
+ gap: ${themeCssVariables.spacing[1]};
height: ${({ size }) => (size === 'small' ? '24px' : '32px')};
- justify-content: ${({ justify }) => justify};
- padding: ${({ theme }) => {
- return `0 ${theme.spacing(2)}`;
- }};
+ justify-content: ${({ justify }) => justify ?? ''};
+ padding: 0 ${themeCssVariables.spacing[2]};
transition: background 0.1s ease;
@@ -343,18 +375,20 @@ const StyledSeparator = styled.div<{
buttonSize: ButtonSize;
accent: ButtonAccent;
}>`
- background: ${({ theme, accent }) => {
+ background: ${({ accent }) => {
switch (accent) {
case 'blue':
- return theme.border.color.blue;
+ return themeCssVariables.border.color.blue;
case 'danger':
- return theme.border.color.danger;
+ return themeCssVariables.border.color.danger;
default:
- return theme.font.color.light;
+ return themeCssVariables.font.color.light;
}
}};
- height: ${({ theme, buttonSize }) =>
- theme.spacing(buttonSize === 'small' ? 2 : 4)};
+ height: ${({ buttonSize }) =>
+ buttonSize === 'small'
+ ? themeCssVariables.spacing[2]
+ : themeCssVariables.spacing[4]};
margin: 0;
width: 1px;
`;
@@ -363,19 +397,19 @@ const StyledShortcutLabel = styled.div<{
variant: ButtonVariant;
accent: ButtonAccent;
}>`
- color: ${({ theme, variant, accent }) => {
+ color: ${({ variant, accent }) => {
switch (accent) {
case 'blue':
- return theme.border.color.blue;
+ return themeCssVariables.border.color.blue;
case 'danger':
return variant === 'primary'
- ? theme.border.color.danger
- : theme.color.red8;
+ ? themeCssVariables.border.color.danger
+ : themeCssVariables.color.red8;
default:
- return theme.font.color.light;
+ return themeCssVariables.font.color.light;
}
}};
- font-weight: ${({ theme }) => theme.font.weight.medium};
+ font-weight: ${themeCssVariables.font.weight.medium};
`;
const StyledIconContainer = styled(motion.div)`
@@ -411,8 +445,29 @@ export const AnimatedButton = ({
dataGloballyPreventClickOutside,
soonLabel = 'Soon',
}: AnimatedButtonProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const isMobile = useIsMobile();
+ const isDisabled = soon || disabled;
+
+ const dynamicStyles = useMemo(() => {
+ const s = computeAnimatedButtonDynamicStyles(
+ variant,
+ inverted,
+ accent,
+ isDisabled,
+ focus,
+ position,
+ );
+ return {
+ '--abtn-bg': s.background,
+ '--abtn-border-color': s.borderColor,
+ '--abtn-border-width': s.borderWidthOverride || undefined,
+ '--abtn-box-shadow': s.boxShadow,
+ '--abtn-color': s.color,
+ '--abtn-hover-bg': s.hoverBackground,
+ '--abtn-active-bg': s.activeBackground,
+ } as React.CSSProperties;
+ }, [variant, inverted, accent, isDisabled, focus, position]);
const ButtonComponent = to ? Link : 'button';
@@ -420,15 +475,12 @@ export const AnimatedButton = ({
<StyledButton
as={ButtonComponent}
fullWidth={fullWidth}
- variant={variant}
- inverted={inverted}
size={size}
position={position}
- disabled={soon || disabled}
- focus={focus}
+ disabled={isDisabled}
justify={justify}
- accent={accent}
className={className}
+ style={dynamicStyles}
onClick={onClick}
to={to}
target={target}
diff --git a/packages/twenty-ui/src/input/button/components/AnimatedLightIconButton.tsx b/packages/twenty-ui/src/input/button/components/AnimatedLightIconButton.tsx
index d2231bf5c87..c4f53328eb4 100644
--- a/packages/twenty-ui/src/input/button/components/AnimatedLightIconButton.tsx
+++ b/packages/twenty-ui/src/input/button/components/AnimatedLightIconButton.tsx
@@ -1,12 +1,12 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
import {
type LightIconButtonAccent,
type LightIconButtonSize,
} from '@ui/input/button/components/LightIconButton';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
import { motion, type MotionProps } from 'framer-motion';
-import { type ComponentProps, type MouseEvent } from 'react';
+import { type ComponentProps, type MouseEvent, useContext } from 'react';
export type AnimatedLightIconButtonProps = {
className?: string;
@@ -29,37 +29,38 @@ const StyledButton = styled.button<
background: transparent;
border: none;
- border: ${({ disabled, theme, focus }) =>
- !disabled && focus ? `1px solid ${theme.color.blue}` : 'none'};
- border-radius: ${({ theme }) => theme.border.radius.sm};
- box-shadow: ${({ disabled, theme, focus }) =>
- !disabled && focus ? `0 0 0 3px ${theme.color.blue3}` : 'none'};
- color: ${({ theme, accent, active, disabled, focus }) => {
+ border: ${({ disabled, focus }) =>
+ !disabled && focus ? `1px solid ${themeCssVariables.color.blue}` : 'none'};
+ border-radius: ${themeCssVariables.border.radius.sm};
+ box-shadow: ${({ disabled, focus }) =>
+ !disabled && focus ? `0 0 0 3px ${themeCssVariables.color.blue3}` : 'none'};
+ color: ${({ accent, active, disabled, focus }) => {
switch (accent) {
case 'secondary':
return active || focus
- ? theme.color.blue
+ ? themeCssVariables.color.blue
: !disabled
- ? theme.font.color.secondary
- : theme.font.color.extraLight;
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.extraLight;
case 'tertiary':
return active || focus
- ? theme.color.blue
+ ? themeCssVariables.color.blue
: !disabled
- ? theme.font.color.tertiary
- : theme.font.color.extraLight;
+ ? themeCssVariables.font.color.tertiary
+ : themeCssVariables.font.color.extraLight;
}
+ return '';
}};
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
display: flex;
flex-direction: row;
- font-family: ${({ theme }) => theme.font.family};
- font-weight: ${({ theme }) => theme.font.weight.regular};
- gap: ${({ theme }) => theme.spacing(1)};
+ font-family: ${themeCssVariables.font.family};
+ font-weight: ${themeCssVariables.font.weight.regular};
+ gap: ${themeCssVariables.spacing[1]};
height: ${({ size }) => (size === 'small' ? '24px' : '32px')};
justify-content: center;
- padding: ${({ theme }) => theme.spacing(1)};
+ padding: ${themeCssVariables.spacing[1]};
transition: background 0.1s ease;
white-space: nowrap;
@@ -67,8 +68,10 @@ const StyledButton = styled.button<
min-width: ${({ size }) => (size === 'small' ? '24px' : '32px')};
&:hover {
- background: ${({ theme, disabled }) =>
- !disabled ? theme.background.transparent.light : 'transparent'};
+ background: ${({ disabled }) =>
+ !disabled
+ ? themeCssVariables.background.transparent.light
+ : 'transparent'};
}
&:focus {
@@ -76,8 +79,10 @@ const StyledButton = styled.button<
}
&:active {
- background: ${({ theme, disabled }) =>
- !disabled ? theme.background.transparent.medium : 'transparent'};
+ background: ${({ disabled }) =>
+ !disabled
+ ? themeCssVariables.background.transparent.medium
+ : 'transparent'};
}
`;
@@ -102,7 +107,7 @@ export const AnimatedLightIconButton = ({
onClick,
title,
}: AnimatedLightIconButtonProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledButton
diff --git a/packages/twenty-ui/src/input/button/components/Button/Button.tsx b/packages/twenty-ui/src/input/button/components/Button/Button.tsx
index 925945f7b59..93f65040f44 100644
--- a/packages/twenty-ui/src/input/button/components/Button/Button.tsx
+++ b/packages/twenty-ui/src/input/button/components/Button/Button.tsx
@@ -1,14 +1,12 @@
-import isPropValid from '@emotion/is-prop-valid';
-import { css } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display/icon/types/IconComponent';
import { ButtonHotkeys } from '@ui/input/button/components/Button/internal/ButtonHotKeys';
import { ButtonIcon } from '@ui/input/button/components/Button/internal/ButtonIcon';
import { ButtonSoon } from '@ui/input/button/components/Button/internal/ButtonSoon';
-import { GRAY_SCALE_LIGHT } from '@ui/theme';
+import { GRAY_SCALE_LIGHT, themeCssVariables } from '@ui/theme';
import { useIsMobile } from '@ui/utilities';
import { type ClickOutsideAttributes } from '@ui/utilities/types/ClickOutsideAttributes';
-import React, { useState } from 'react';
+import React, { useMemo, useState } from 'react';
import { Link } from 'react-router-dom';
import { isDefined } from 'twenty-shared/utils';
import { ButtonText } from './internal/ButtonText';
@@ -42,18 +40,295 @@ export type ButtonProps = {
} & Pick<React.ComponentProps<'button'>, 'type'> &
ClickOutsideAttributes;
-const StyledButton = styled('button', {
- shouldForwardProp: (prop) =>
- !['fullWidth'].includes(prop) && isPropValid(prop),
-})<
+type ButtonDynamicStyles = {
+ background: string;
+ borderColor: string;
+ borderWidthOverride: string;
+ boxShadow: string;
+ color: string;
+ hoverBackground: string;
+ activeBackground: string;
+};
+
+const computeButtonDynamicStyles = (
+ variant: ButtonVariant,
+ accent: ButtonAccent,
+ inverted: boolean,
+ disabled: boolean,
+ focus: boolean,
+ position: ButtonPosition,
+): ButtonDynamicStyles => {
+ const result: ButtonDynamicStyles = {
+ background: 'transparent',
+ borderColor: 'transparent',
+ borderWidthOverride: '',
+ boxShadow: 'none',
+ color: themeCssVariables.font.color.secondary,
+ hoverBackground: 'transparent',
+ activeBackground: 'transparent',
+ };
+
+ switch (variant) {
+ case 'primary':
+ switch (accent) {
+ case 'default':
+ result.background = !inverted
+ ? themeCssVariables.background.secondary
+ : themeCssVariables.background.primary;
+ result.borderColor = !inverted
+ ? !disabled && focus
+ ? themeCssVariables.color.blue
+ : themeCssVariables.background.transparent.light
+ : themeCssVariables.background.transparent.light;
+ result.borderWidthOverride = '1px 1px 1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.accent.tertiary
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? !disabled
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.extraLight
+ : themeCssVariables.font.color.secondary;
+ if (!disabled) {
+ result.hoverBackground = !inverted
+ ? themeCssVariables.background.tertiary
+ : themeCssVariables.background.secondary;
+ result.activeBackground = !inverted
+ ? themeCssVariables.background.quaternary
+ : themeCssVariables.background.tertiary;
+ } else {
+ result.hoverBackground = result.background;
+ result.activeBackground = result.background;
+ }
+ break;
+ case 'blue':
+ result.background = !inverted
+ ? disabled
+ ? themeCssVariables.accent.accent4060
+ : themeCssVariables.color.blue
+ : themeCssVariables.background.primary;
+ result.borderColor = !inverted
+ ? focus
+ ? themeCssVariables.color.blue
+ : themeCssVariables.background.transparent.light
+ : themeCssVariables.background.transparent.light;
+ result.borderWidthOverride = '1px 1px 1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.accent.tertiary
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? GRAY_SCALE_LIGHT.gray1
+ : themeCssVariables.color.blue;
+ if (!disabled) {
+ result.hoverBackground = !inverted
+ ? themeCssVariables.color.blue10
+ : themeCssVariables.background.secondary;
+ result.activeBackground = !inverted
+ ? themeCssVariables.color.blue12
+ : themeCssVariables.background.tertiary;
+ } else {
+ result.hoverBackground = result.background;
+ result.activeBackground = result.background;
+ }
+ break;
+ case 'danger':
+ result.background = !inverted
+ ? themeCssVariables.color.red
+ : themeCssVariables.background.primary;
+ result.borderColor = !inverted
+ ? focus
+ ? themeCssVariables.color.red
+ : themeCssVariables.background.transparent.light
+ : themeCssVariables.background.transparent.light;
+ result.borderWidthOverride = '1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.color.red3
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? themeCssVariables.background.primary
+ : themeCssVariables.color.red;
+ if (!disabled) {
+ result.hoverBackground = !inverted
+ ? themeCssVariables.color.red8
+ : themeCssVariables.background.secondary;
+ result.activeBackground = !inverted
+ ? themeCssVariables.color.red10
+ : themeCssVariables.background.tertiary;
+ } else {
+ result.hoverBackground = result.background;
+ result.activeBackground = result.background;
+ }
+ break;
+ }
+ break;
+ case 'secondary':
+ case 'tertiary':
+ switch (accent) {
+ case 'default':
+ result.borderColor = !inverted
+ ? variant === 'secondary'
+ ? !disabled && focus
+ ? themeCssVariables.color.blue
+ : themeCssVariables.background.transparent.medium
+ : focus
+ ? themeCssVariables.color.blue
+ : 'transparent'
+ : variant === 'secondary'
+ ? focus || disabled
+ ? GRAY_SCALE_LIGHT.gray1
+ : themeCssVariables.background.transparent.primary
+ : focus
+ ? GRAY_SCALE_LIGHT.gray1
+ : 'transparent';
+ result.borderWidthOverride = '1px 1px 1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.accent.tertiary
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? !disabled
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.extraLight
+ : themeCssVariables.font.color.inverted;
+ result.hoverBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.background.transparent.light
+ : 'transparent'
+ : themeCssVariables.background.transparent.light;
+ result.activeBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.background.transparent.light
+ : 'transparent'
+ : themeCssVariables.background.transparent.medium;
+ break;
+ case 'blue':
+ result.borderColor = !inverted
+ ? variant === 'secondary'
+ ? focus
+ ? themeCssVariables.color.blue
+ : themeCssVariables.accent.primary
+ : focus
+ ? themeCssVariables.color.blue
+ : 'transparent'
+ : variant === 'secondary'
+ ? focus || disabled
+ ? GRAY_SCALE_LIGHT.gray1
+ : themeCssVariables.background.transparent.primary
+ : focus
+ ? GRAY_SCALE_LIGHT.gray1
+ : 'transparent';
+ result.borderWidthOverride = '1px 1px 1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.accent.tertiary
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? !disabled
+ ? themeCssVariables.color.blue
+ : themeCssVariables.accent.accent4060
+ : themeCssVariables.font.color.inverted;
+ result.hoverBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.accent.tertiary
+ : 'transparent'
+ : themeCssVariables.background.transparent.light;
+ result.activeBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.accent.secondary
+ : 'transparent'
+ : themeCssVariables.background.transparent.medium;
+ break;
+ case 'danger':
+ result.borderColor = !inverted
+ ? variant === 'secondary'
+ ? focus
+ ? themeCssVariables.color.red
+ : themeCssVariables.border.color.danger
+ : focus
+ ? themeCssVariables.color.red
+ : 'transparent'
+ : variant === 'secondary'
+ ? focus || disabled
+ ? GRAY_SCALE_LIGHT.gray1
+ : themeCssVariables.background.transparent.primary
+ : focus
+ ? GRAY_SCALE_LIGHT.gray1
+ : 'transparent';
+ result.borderWidthOverride = '1px 1px 1px 1px';
+ result.boxShadow =
+ !disabled && focus
+ ? `0 0 0 3px ${
+ !inverted
+ ? themeCssVariables.color.red3
+ : themeCssVariables.background.transparent.medium
+ }`
+ : 'none';
+ result.color = !inverted
+ ? !disabled
+ ? themeCssVariables.font.color.danger
+ : themeCssVariables.color.red5
+ : themeCssVariables.font.color.inverted;
+ result.hoverBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.background.danger
+ : 'transparent'
+ : themeCssVariables.background.transparent.light;
+ result.activeBackground = !inverted
+ ? !disabled
+ ? themeCssVariables.background.danger
+ : 'transparent'
+ : themeCssVariables.background.transparent.medium;
+ break;
+ }
+ break;
+ }
+
+ if (result.borderWidthOverride !== '' && position !== 'standalone') {
+ switch (position) {
+ case 'left':
+ result.borderWidthOverride = '1px 0px 1px 1px';
+ break;
+ case 'middle':
+ result.borderWidthOverride = '1px 0px 1px 0px';
+ break;
+ case 'right':
+ result.borderWidthOverride = '1px 1px 1px 0px';
+ break;
+ }
+ }
+
+ return result;
+};
+
+const StyledButton = styled.button<
Pick<
ButtonProps,
| 'fullWidth'
- | 'variant'
- | 'inverted'
| 'size'
| 'position'
- | 'accent'
| 'focus'
| 'justify'
| 'to'
@@ -62,300 +337,37 @@ const StyledButton = styled('button', {
> & { hasIcon: boolean }
>`
align-items: center;
- ${({ theme, variant, inverted, accent, disabled, focus }) => {
- switch (variant) {
- case 'primary':
- switch (accent) {
- case 'default':
- return css`
- background: ${!inverted
- ? theme.background.secondary
- : theme.background.primary};
- border-color: ${!inverted
- ? !disabled && focus
- ? theme.color.blue
- : theme.background.transparent.light
- : theme.background.transparent.light};
- border-width: 1px 1px 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.accent.tertiary
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted
- ? !disabled
- ? theme.font.color.secondary
- : theme.font.color.extraLight
- : theme.font.color.secondary};
- ${disabled
- ? ''
- : css`
- &:hover {
- background: ${!inverted
- ? theme.background.tertiary
- : theme.background.secondary};
- }
- &:active {
- background: ${!inverted
- ? theme.background.quaternary
- : theme.background.tertiary};
- }
- `}
- `;
- case 'blue':
- return css`
- background: ${!inverted
- ? disabled
- ? theme.accent.accent4060
- : theme.color.blue
- : theme.background.primary};
- border-color: ${!inverted
- ? focus
- ? theme.color.blue
- : theme.background.transparent.light
- : theme.background.transparent.light};
- border-width: 1px 1px 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.accent.tertiary
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted ? GRAY_SCALE_LIGHT.gray1 : theme.color.blue};
- ${disabled
- ? ''
- : css`
- &:hover {
- background: ${!inverted
- ? theme.color.blue10
- : theme.background.secondary};
- }
- &:active {
- background: ${!inverted
- ? theme.color.blue12
- : theme.background.tertiary};
- }
- `}
- `;
- case 'danger':
- return css`
- background: ${!inverted
- ? theme.color.red
- : theme.background.primary};
- border-color: ${!inverted
- ? focus
- ? theme.color.red
- : theme.background.transparent.light
- : theme.background.transparent.light};
- border-width: 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.color.red3
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted ? theme.background.primary : theme.color.red};
- ${disabled
- ? ''
- : css`
- &:hover {
- background: ${!inverted
- ? theme.color.red8
- : theme.background.secondary};
- }
- &:active {
- background: ${!inverted
- ? theme.color.red10
- : theme.background.tertiary};
- }
- `}
- `;
- }
- break;
- case 'secondary':
- case 'tertiary':
- switch (accent) {
- case 'default':
- return css`
- background: transparent;
- border-color: ${!inverted
- ? variant === 'secondary'
- ? !disabled && focus
- ? theme.color.blue
- : theme.background.transparent.medium
- : focus
- ? theme.color.blue
- : 'transparent'
- : variant === 'secondary'
- ? focus || disabled
- ? GRAY_SCALE_LIGHT.gray1
- : theme.background.transparent.primary
- : focus
- ? GRAY_SCALE_LIGHT.gray1
- : 'transparent'};
- border-width: 1px 1px 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.accent.tertiary
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted
- ? !disabled
- ? theme.font.color.secondary
- : theme.font.color.extraLight
- : theme.font.color.inverted};
- &:hover {
- background: ${!inverted
- ? !disabled
- ? theme.background.transparent.light
- : 'transparent'
- : theme.background.transparent.light};
- }
- &:active {
- background: ${!inverted
- ? !disabled
- ? theme.background.transparent.light
- : 'transparent'
- : theme.background.transparent.medium};
- }
- `;
- case 'blue':
- return css`
- background: transparent;
- border-color: ${!inverted
- ? variant === 'secondary'
- ? focus
- ? theme.color.blue
- : theme.accent.primary
- : focus
- ? theme.color.blue
- : 'transparent'
- : variant === 'secondary'
- ? focus || disabled
- ? GRAY_SCALE_LIGHT.gray1
- : theme.background.transparent.primary
- : focus
- ? GRAY_SCALE_LIGHT.gray1
- : 'transparent'};
- border-width: 1px 1px 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.accent.tertiary
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted
- ? !disabled
- ? theme.color.blue
- : theme.accent.accent4060
- : theme.font.color.inverted};
- &:hover {
- background: ${!inverted
- ? !disabled
- ? theme.accent.tertiary
- : 'transparent'
- : theme.background.transparent.light};
- }
- &:active {
- background: ${!inverted
- ? !disabled
- ? theme.accent.secondary
- : 'transparent'
- : theme.background.transparent.medium};
- }
- `;
- case 'danger':
- return css`
- background: transparent;
- border-color: ${!inverted
- ? variant === 'secondary'
- ? focus
- ? theme.color.red
- : theme.border.color.danger
- : focus
- ? theme.color.red
- : 'transparent'
- : variant === 'secondary'
- ? focus || disabled
- ? GRAY_SCALE_LIGHT.gray1
- : theme.background.transparent.primary
- : focus
- ? GRAY_SCALE_LIGHT.gray1
- : 'transparent'};
- border-width: 1px 1px 1px 1px !important;
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? theme.color.red3
- : theme.background.transparent.medium
- }`
- : 'none'};
- color: ${!inverted
- ? !disabled
- ? theme.font.color.danger
- : theme.color.red5
- : theme.font.color.inverted};
- &:hover {
- background: ${!inverted
- ? !disabled
- ? theme.background.danger
- : 'transparent'
- : theme.background.transparent.light};
- }
- &:active {
- background: ${!inverted
- ? !disabled
- ? theme.background.danger
- : 'transparent'
- : theme.background.transparent.medium};
- }
- `;
- }
- }
- }}
+ background: var(--btn-bg);
+ border-color: var(--btn-border-color);
+ border-width: var(--btn-border-width);
+ box-shadow: var(--btn-box-shadow);
+ color: var(--btn-color);
text-decoration: none;
- border-radius: ${({ position, theme }) => {
+ border-radius: ${({ position }) => {
switch (position) {
case 'left':
- return `${theme.border.radius.sm} 0px 0px ${theme.border.radius.sm}`;
+ return `${themeCssVariables.border.radius.sm} 0px 0px ${themeCssVariables.border.radius.sm}`;
case 'right':
- return `0px ${theme.border.radius.sm} ${theme.border.radius.sm} 0px`;
+ return `0px ${themeCssVariables.border.radius.sm} ${themeCssVariables.border.radius.sm} 0px`;
case 'middle':
return '0px';
case 'standalone':
- return theme.border.radius.sm;
+ return themeCssVariables.border.radius.sm;
}
+ return '';
}};
border-style: solid;
- border-width: ${({ variant, position }) => {
- switch (variant) {
- case 'primary':
- case 'secondary':
- return position === 'middle' ? '1px 0px' : '1px';
- case 'tertiary':
- return '0';
- }
- }};
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
display: flex;
flex-direction: row;
- font-family: ${({ theme }) => theme.font.family};
+ font-family: ${themeCssVariables.font.family};
font-weight: 500;
- font-size: ${({ theme }) => theme.font.size.md};
- gap: ${({ theme }) => theme.spacing(1)};
+ font-size: ${themeCssVariables.font.size.md};
+ gap: ${themeCssVariables.spacing[1]};
height: ${({ size }) => (size === 'small' ? '24px' : '32px')};
- justify-content: ${({ justify }) => justify};
- padding: ${({ theme }) => {
- return `0 ${theme.spacing(2)} 0 ${theme.spacing(2)}`;
- }};
+ justify-content: ${({ justify }) => justify ?? ''};
+ padding: 0 ${themeCssVariables.spacing[2]} 0 ${themeCssVariables.spacing[2]};
box-sizing: border-box;
transition: background 0.1s ease;
@@ -364,67 +376,78 @@ const StyledButton = styled('button', {
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
+ &:hover {
+ background: var(--btn-hover-bg);
+ }
+ &:active {
+ background: var(--btn-active-bg);
+ }
+
&:focus {
outline: none;
}
`;
const StyledButtonWrapper = styled.div<
- Pick<
- ButtonProps,
- 'isLoading' | 'variant' | 'accent' | 'inverted' | 'disabled' | 'fullWidth'
- >
+ Pick<ButtonProps, 'isLoading' | 'fullWidth'>
>`
- ${({ theme, variant, accent, inverted, disabled }) => css`
- --tw-button-color: ${(() => {
- switch (variant) {
- case 'primary':
- switch (accent) {
- case 'default':
- return !inverted
- ? !disabled
- ? theme.font.color.secondary
- : theme.font.color.extraLight
- : theme.font.color.secondary;
- case 'blue':
- return !inverted ? GRAY_SCALE_LIGHT.gray1 : theme.color.blue;
- case 'danger':
- return !inverted ? theme.background.primary : theme.color.red;
- }
- break;
- case 'secondary':
- case 'tertiary':
- switch (accent) {
- case 'default':
- return !inverted
- ? !disabled
- ? theme.font.color.secondary
- : theme.font.color.extraLight
- : theme.font.color.inverted;
- case 'blue':
- return !inverted
- ? !disabled
- ? theme.color.blue
- : theme.accent.accent4060
- : theme.font.color.inverted;
- case 'danger':
- return !inverted
- ? theme.font.color.danger
- : theme.font.color.inverted;
- }
- break;
- }
- return theme.font.color.secondary; // Valeur par défaut
- })()};
- `}
-
- max-width: ${({ isLoading, theme }) =>
- isLoading ? `calc(100% - ${theme.spacing(8)})` : 'none'};
+ max-width: ${({ isLoading }) =>
+ isLoading ? `calc(100% - ${themeCssVariables.spacing[8]})` : 'none'};
position: relative;
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
`;
+const computeButtonWrapperColor = (
+ variant: ButtonVariant,
+ accent: ButtonAccent,
+ inverted: boolean,
+ disabled: boolean,
+): string => {
+ switch (variant) {
+ case 'primary':
+ switch (accent) {
+ case 'default':
+ return !inverted
+ ? !disabled
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.extraLight
+ : themeCssVariables.font.color.secondary;
+ case 'blue':
+ return !inverted
+ ? GRAY_SCALE_LIGHT.gray1
+ : themeCssVariables.color.blue;
+ case 'danger':
+ return !inverted
+ ? themeCssVariables.background.primary
+ : themeCssVariables.color.red;
+ }
+ break;
+ case 'secondary':
+ case 'tertiary':
+ switch (accent) {
+ case 'default':
+ return !inverted
+ ? !disabled
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.extraLight
+ : themeCssVariables.font.color.inverted;
+ case 'blue':
+ return !inverted
+ ? !disabled
+ ? themeCssVariables.color.blue
+ : themeCssVariables.accent.accent4060
+ : themeCssVariables.font.color.inverted;
+ case 'danger':
+ return !inverted
+ ? themeCssVariables.font.color.danger
+ : themeCssVariables.font.color.inverted;
+ }
+ break;
+ }
+ return themeCssVariables.font.color.secondary;
+};
+
export const Button = ({
className,
Icon,
@@ -453,25 +476,47 @@ export const Button = ({
const isMobile = useIsMobile();
const [isFocused, setIsFocused] = useState(propFocus);
+ const isDisabled = soon || disabled;
+
+ const dynamicStyles = useMemo(() => {
+ const s = computeButtonDynamicStyles(
+ variant,
+ accent,
+ inverted,
+ isDisabled,
+ isFocused,
+ position,
+ );
+ return {
+ '--btn-bg': s.background,
+ '--btn-border-color': s.borderColor,
+ '--btn-border-width': s.borderWidthOverride || undefined,
+ '--btn-box-shadow': s.boxShadow,
+ '--btn-color': s.color,
+ '--btn-hover-bg': s.hoverBackground,
+ '--btn-active-bg': s.activeBackground,
+ '--tw-button-color': computeButtonWrapperColor(
+ variant,
+ accent,
+ inverted,
+ isDisabled,
+ ),
+ } as React.CSSProperties;
+ }, [variant, accent, inverted, isDisabled, isFocused, position]);
+
return (
<StyledButtonWrapper
isLoading={!!isLoading}
- variant={variant}
- accent={accent}
- inverted={inverted}
- disabled={soon || disabled}
fullWidth={fullWidth}
+ style={dynamicStyles}
>
<StyledButton
fullWidth={fullWidth}
- variant={variant}
- inverted={inverted}
position={position}
- disabled={soon || disabled}
+ disabled={isDisabled}
hasIcon={!!Icon}
focus={isFocused}
justify={justify}
- accent={accent}
className={className}
onClick={onClick}
to={to}
@@ -486,6 +531,7 @@ export const Button = ({
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
size={size}
+ style={dynamicStyles}
>
{(isLoading || Icon) && (
<ButtonIcon Icon={Icon} isLoading={!!isLoading} />
diff --git a/packages/twenty-ui/src/input/button/components/Button/internal/ButtonHotKeys.tsx b/packages/twenty-ui/src/input/button/components/Button/internal/ButtonHotKeys.tsx
index 396f2736302..a0dd63949f6 100644
--- a/packages/twenty-ui/src/input/button/components/Button/internal/ButtonHotKeys.tsx
+++ b/packages/twenty-ui/src/input/button/components/Button/internal/ButtonHotKeys.tsx
@@ -1,27 +1,31 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+
import {
type ButtonAccent,
type ButtonSize,
type ButtonVariant,
} from '@ui/input';
+import { themeCssVariables } from '@ui/theme';
import { getOsShortcutSeparator } from '@ui/utilities';
const StyledSeparator = styled.div<{
buttonSize: ButtonSize;
accent: ButtonAccent;
}>`
- background: ${({ theme, accent }) => {
+ background: ${({ accent }) => {
switch (accent) {
case 'blue':
- return theme.buttons.secondaryTextColor;
+ return themeCssVariables.buttons.secondaryTextColor;
case 'danger':
- return theme.border.color.danger;
+ return themeCssVariables.border.color.danger;
default:
- return theme.font.color.light;
+ return themeCssVariables.font.color.light;
}
}};
- height: ${({ theme, buttonSize }) =>
- theme.spacing(buttonSize === 'small' ? 2 : 4)};
+ height: ${({ buttonSize }) =>
+ buttonSize === 'small'
+ ? themeCssVariables.spacing[2]
+ : themeCssVariables.spacing[4]};
margin: 0;
width: 1px;
`;
@@ -30,19 +34,19 @@ const StyledShortcutLabel = styled.div<{
variant: ButtonVariant;
accent: ButtonAccent;
}>`
- color: ${({ theme, variant, accent }) => {
+ color: ${({ variant, accent }) => {
switch (accent) {
case 'blue':
- return theme.buttons.secondaryTextColor;
+ return themeCssVariables.buttons.secondaryTextColor;
case 'danger':
return variant === 'primary'
- ? theme.border.color.danger
- : theme.color.red8;
+ ? themeCssVariables.border.color.danger
+ : themeCssVariables.color.red8;
default:
- return theme.font.color.light;
+ return themeCssVariables.font.color.light;
}
}};
- font-weight: ${({ theme }) => theme.font.weight.medium};
+ font-weight: ${themeCssVariables.font.weight.medium};
`;
export const ButtonHotkeys = ({
@@ -55,11 +59,13 @@ export const ButtonHotkeys = ({
accent: ButtonAccent;
variant: ButtonVariant;
hotkeys: string[];
-}) => (
- <>
- <StyledSeparator buttonSize={size} accent={accent} />
- <StyledShortcutLabel variant={variant} accent={accent}>
- {hotkeys.join(getOsShortcutSeparator())}
- </StyledShortcutLabel>
- </>
-);
+}) => {
+ return (
+ <>
+ <StyledSeparator buttonSize={size} accent={accent} />
+ <StyledShortcutLabel variant={variant} accent={accent}>
+ {hotkeys.join(getOsShortcutSeparator())}
+ </StyledShortcutLabel>
+ </>
+ );
+};
diff --git a/packages/twenty-ui/src/input/button/components/Button/internal/ButtonIcon.tsx b/packages/twenty-ui/src/input/button/components/Button/internal/ButtonIcon.tsx
index af412262f30..347d6e78ffe 100644
--- a/packages/twenty-ui/src/input/button/components/Button/internal/ButtonIcon.tsx
+++ b/packages/twenty-ui/src/input/button/components/Button/internal/ButtonIcon.tsx
@@ -1,15 +1,16 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
import { Loader } from '@ui/feedback';
import { baseTransitionTiming } from '@ui/input/button/components/Button/constant';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
+import { useContext } from 'react';
const StyledIcon = styled.div<{
isLoading: boolean;
}>`
align-items: center;
display: flex;
- height: calc(100% - ${({ theme }) => theme.spacing(4)});
+ height: calc(100% - ${themeCssVariables.spacing[4]});
color: var(--tw-button-color);
opacity: ${({ isLoading }) => (isLoading ? 0 : 1)};
@@ -26,13 +27,13 @@ const StyledIconWrapper = styled.div`
`;
const StyledLoader = styled.div`
- left: ${({ theme }) => theme.spacing(2)};
+ left: ${themeCssVariables.spacing[2]};
opacity: 1;
position: absolute;
transition: opacity ${baseTransitionTiming / 2}ms ease;
transition-delay: ${baseTransitionTiming / 2}ms;
- width: ${({ theme }) => theme.spacing(6)};
+ width: ${themeCssVariables.spacing[6]};
`;
export const ButtonIcon = ({
@@ -42,7 +43,7 @@ export const ButtonIcon = ({
Icon?: IconComponent;
isLoading?: boolean;
}) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledIconWrapper>
{isLoading && (
diff --git a/packages/twenty-ui/src/input/button/components/Button/internal/ButtonSoon.tsx b/packages/twenty-ui/src/input/button/components/Button/internal/ButtonSoon.tsx
index e9f435af58e..b8c2c46bf6f 100644
--- a/packages/twenty-ui/src/input/button/components/Button/internal/ButtonSoon.tsx
+++ b/packages/twenty-ui/src/input/button/components/Button/internal/ButtonSoon.tsx
@@ -1,4 +1,4 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { Pill } from '@ui/components';
const StyledSoonPill = styled(Pill)`
diff --git a/packages/twenty-ui/src/input/button/components/Button/internal/ButtonText.tsx b/packages/twenty-ui/src/input/button/components/Button/internal/ButtonText.tsx
index ab014a03e72..52b139ab597 100644
--- a/packages/twenty-ui/src/input/button/components/Button/internal/ButtonText.tsx
+++ b/packages/twenty-ui/src/input/button/components/Button/internal/ButtonText.tsx
@@ -1,10 +1,14 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+
import { baseTransitionTiming } from '@ui/input/button/components/Button/constant';
+import { themeCssVariables } from '@ui/theme';
const StyledEllipsis = styled.div<{ isLoading?: boolean }>`
right: 0;
- clip-path: ${({ theme, isLoading }) =>
- isLoading ? `inset(0 0 0 0)` : `inset(0 0 0 ${theme.spacing(6)})`};
+ clip-path: ${({ isLoading }) =>
+ isLoading
+ ? `inset(0 0 0 0)`
+ : `inset(0 0 0 ${themeCssVariables.spacing[6]})`};
overflow: hidden;
position: absolute;
@@ -19,17 +23,20 @@ const StyledTextWrapper = styled.div`
position: relative;
`;
-const StyledText = styled.div<{ isLoading?: boolean; hasIcon: boolean }>`
- clip-path: ${({ isLoading, theme, hasIcon }) =>
+const StyledText = styled.div<{
+ isLoading?: boolean;
+ hasIcon: boolean;
+}>`
+ clip-path: ${({ isLoading, hasIcon }) =>
isLoading
- ? ` inset(0 ${!hasIcon ? theme.spacing(12) : theme.spacing(6)} 0 0)`
+ ? ` inset(0 ${!hasIcon ? themeCssVariables.spacing[12] : themeCssVariables.spacing[6]} 0 0)`
: ' inset(0 0 0 0)'};
overflow: hidden;
- transform: ${({ theme, isLoading, hasIcon }) =>
+ transform: ${({ isLoading, hasIcon }) =>
isLoading
- ? `translateX(${!hasIcon ? theme.spacing(7) : theme.spacing(3)})`
+ ? `translateX(${!hasIcon ? themeCssVariables.spacing[7] : themeCssVariables.spacing[3]})`
: 'none'};
transition:
@@ -49,11 +56,13 @@ export const ButtonText = ({
isLoading?: boolean;
hasIcon: boolean;
title?: string;
-}) => (
- <StyledTextWrapper>
- <StyledText isLoading={isLoading} hasIcon={hasIcon}>
- {title}
- </StyledText>
- <StyledEllipsis isLoading={isLoading}>...</StyledEllipsis>
- </StyledTextWrapper>
-);
+}) => {
+ return (
+ <StyledTextWrapper>
+ <StyledText isLoading={isLoading} hasIcon={hasIcon}>
+ {title}
+ </StyledText>
+ <StyledEllipsis isLoading={isLoading}>...</StyledEllipsis>
+ </StyledTextWrapper>
+ );
+};
diff --git a/packages/twenty-ui/src/input/button/components/ButtonGroup.tsx b/packages/twenty-ui/src/input/button/components/ButtonGroup.tsx
index 922900b2791..278eb8f6b05 100644
--- a/packages/twenty-ui/src/input/button/components/ButtonGroup.tsx
+++ b/packages/twenty-ui/src/input/button/components/ButtonGroup.tsx
@@ -1,11 +1,12 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import React, { type ReactNode } from 'react';
import { type ButtonPosition, type ButtonProps } from './Button/Button';
+import { themeCssVariables } from '@ui/theme';
import { isDefined } from 'twenty-shared/utils';
const StyledButtonGroupContainer = styled.div`
- border-radius: ${({ theme }) => theme.border.radius.md};
+ border-radius: ${themeCssVariables.border.radius.md};
display: flex;
`;
@@ -22,36 +23,38 @@ export const ButtonGroup = ({
variant,
size,
accent,
-}: ButtonGroupProps) => (
- <StyledButtonGroupContainer className={className}>
- {React.Children.map(children, (child, index) => {
- if (!React.isValidElement(child)) return null;
-
- let position: ButtonPosition;
-
- if (index === 0) {
- position = 'left';
- } else if (index === children.length - 1) {
- position = 'right';
- } else {
- position = 'middle';
- }
-
- const additionalProps: any = { position, variant, accent, size };
-
- if (isDefined(variant)) {
- additionalProps.variant = variant;
- }
-
- if (isDefined(accent)) {
- additionalProps.variant = variant;
- }
-
- if (isDefined(size)) {
- additionalProps.size = size;
- }
-
- return React.cloneElement(child, additionalProps);
- })}
- </StyledButtonGroupContainer>
-);
+}: ButtonGroupProps) => {
+ return (
+ <StyledButtonGroupContainer className={className}>
+ {React.Children.map(children, (child, index) => {
+ if (!React.isValidElement(child)) return null;
+
+ let position: ButtonPosition;
+
+ if (index === 0) {
+ position = 'left';
+ } else if (index === children.length - 1) {
+ position = 'right';
+ } else {
+ position = 'middle';
+ }
+
+ const additionalProps: any = { position, variant, accent, size };
+
+ if (isDefined(variant)) {
+ additionalProps.variant = variant;
+ }
+
+ if (isDefined(accent)) {
+ additionalProps.accent = accent;
+ }
+
+ if (isDefined(size)) {
+ additionalProps.size = size;
+ }
+
+ return React.cloneElement(child, additionalProps);
+ })}
+ </StyledButtonGroupContainer>
+ );
+};
diff --git a/packages/twenty-ui/src/input/button/components/ColorPickerButton.tsx b/packages/twenty-ui/src/input/button/components/ColorPickerButton.tsx
index d9c97a766af..9fa25a714e2 100644
--- a/packages/twenty-ui/src/input/button/components/ColorPickerButton.tsx
+++ b/packages/twenty-ui/src/input/button/components/ColorPickerButton.tsx
@@ -1,6 +1,6 @@
-import { css } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { ColorSample, type ColorSampleProps } from '@ui/display';
+import { themeCssVariables } from '@ui/theme';
import {
LightIconButton,
type LightIconButtonProps,
@@ -11,30 +11,36 @@ type ColorPickerButtonProps = Pick<ColorSampleProps, 'colorName'> &
isSelected?: boolean;
};
-const StyledButton = styled(LightIconButton)<{
+const StyledButtonWrapper = styled.div<{
isSelected?: boolean;
}>`
- ${({ isSelected, theme }) =>
- isSelected
- ? css`
- background-color: ${theme.background.transparent.medium};
+ button {
+ ${({ isSelected }) =>
+ isSelected
+ ? `background-color: ${themeCssVariables.background.transparent.medium};`
+ : ''}
+ }
- &:hover {
- background-color: ${theme.background.transparent.medium};
- }
- `
- : ''}
+ button:hover {
+ ${({ isSelected }) =>
+ isSelected
+ ? `background-color: ${themeCssVariables.background.transparent.medium};`
+ : ''}
+ }
`;
export const ColorPickerButton = ({
colorName,
isSelected,
onClick,
-}: ColorPickerButtonProps) => (
- <StyledButton
- size="medium"
- isSelected={isSelected}
- Icon={() => <ColorSample colorName={colorName} />}
- onClick={onClick}
- />
-);
+}: ColorPickerButtonProps) => {
+ return (
+ <StyledButtonWrapper isSelected={isSelected}>
+ <LightIconButton
+ size="medium"
+ Icon={() => <ColorSample colorName={colorName} />}
+ onClick={onClick}
+ />
+ </StyledButtonWrapper>
+ );
+};
diff --git a/packages/twenty-ui/src/input/button/components/FloatingButton.tsx b/packages/twenty-ui/src/input/button/components/FloatingButton.tsx
index 5056a40480c..2a7e57123d2 100644
--- a/packages/twenty-ui/src/input/button/components/FloatingButton.tsx
+++ b/packages/twenty-ui/src/input/button/components/FloatingButton.tsx
@@ -1,7 +1,7 @@
-import isPropValid from '@emotion/is-prop-valid';
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
+import { useContext } from 'react';
import { Link } from 'react-router-dom';
export type FloatingButtonSize = 'small' | 'medium';
@@ -20,11 +20,7 @@ export type FloatingButtonProps = {
to?: string;
};
-const StyledButton = styled('button', {
- shouldForwardProp: (prop) =>
- !['applyBlur', 'applyShadow', 'focus', 'position', 'size'].includes(prop) &&
- isPropValid(prop),
-})<
+const StyledButton = styled.button<
Pick<
FloatingButtonProps,
| 'size'
@@ -38,62 +34,65 @@ const StyledButton = styled('button', {
>`
align-items: center;
backdrop-filter: ${({ applyBlur }) => (applyBlur ? 'blur(20px)' : 'none')};
- background: ${({ theme }) => theme.background.primary};
+ background: ${themeCssVariables.background.primary};
- border: ${({ focus, theme }) =>
- focus ? `1px solid ${theme.color.blue}` : 'none'};
- border-radius: ${({ position, theme }) => {
+ border: ${({ focus }) =>
+ focus ? `1px solid ${themeCssVariables.color.blue}` : 'none'};
+ border-radius: ${({ position }) => {
switch (position) {
case 'left':
- return `${theme.border.radius.sm} 0px 0px ${theme.border.radius.sm}`;
+ return `${themeCssVariables.border.radius.sm} 0px 0px ${themeCssVariables.border.radius.sm}`;
case 'right':
- return `0px ${theme.border.radius.sm} ${theme.border.radius.sm} 0px`;
+ return `0px ${themeCssVariables.border.radius.sm} ${themeCssVariables.border.radius.sm} 0px`;
case 'middle':
return '0px';
case 'standalone':
- return theme.border.radius.sm;
+ return themeCssVariables.border.radius.sm;
}
+ return '';
}};
- box-shadow: ${({ theme, applyShadow, focus }) =>
+ box-shadow: ${({ applyShadow, focus }) =>
applyShadow
? `0px 2px 4px 0px ${
- theme.background.transparent.light
- }, 0px 0px 4px 0px ${theme.background.transparent.medium}${
- focus ? `,0 0 0 3px ${theme.color.blue3}` : ''
+ themeCssVariables.background.transparent.light
+ }, 0px 0px 4px 0px ${themeCssVariables.background.transparent.medium}${
+ focus ? `,0 0 0 3px ${themeCssVariables.color.blue3}` : ''
}`
: focus
- ? `0 0 0 3px ${theme.color.blue3}`
+ ? `0 0 0 3px ${themeCssVariables.color.blue3}`
: 'none'};
- color: ${({ theme, disabled, focus }) => {
+ color: ${({ disabled, focus }) => {
return !disabled
? focus
- ? theme.color.blue
- : theme.font.color.secondary
- : theme.font.color.extraLight;
+ ? themeCssVariables.color.blue
+ : themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.extraLight;
}};
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
display: flex;
flex-direction: row;
- font-family: ${({ theme }) => theme.font.family};
- font-weight: ${({ theme }) => theme.font.weight.regular};
- gap: ${({ theme }) => theme.spacing(1)};
+ font-family: ${themeCssVariables.font.family};
+ font-weight: ${themeCssVariables.font.weight.regular};
+ gap: ${themeCssVariables.spacing[1]};
height: ${({ size }) => (size === 'small' ? '24px' : '32px')};
- padding: ${({ theme }) => {
- return `0 ${theme.spacing(2)}`;
- }};
+ padding: 0 ${themeCssVariables.spacing[2]};
transition: background 0.1s ease;
white-space: nowrap;
&:hover {
- background: ${({ theme, disabled }) =>
- !disabled ? theme.background.transparent.lighter : 'transparent'};
+ background: ${({ disabled }) =>
+ !disabled
+ ? themeCssVariables.background.transparent.lighter
+ : 'transparent'};
}
&:active {
- background: ${({ theme, disabled }) =>
- !disabled ? theme.background.transparent.medium : 'transparent'};
+ background: ${({ disabled }) =>
+ !disabled
+ ? themeCssVariables.background.transparent.medium
+ : 'transparent'};
}
&:focus {
@@ -114,7 +113,7 @@ export const FloatingButton = ({
focus = false,
to,
}: FloatingButtonProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledButton
disabled={disabled}
diff --git a/packages/twenty-ui/src/input/button/components/FloatingButtonGroup.tsx b/packages/twenty-ui/src/input/button/components/FloatingButtonGroup.tsx
index 86933d94402..0dd37245ee1 100644
--- a/packages/twenty-ui/src/input/button/components/FloatingButtonGroup.tsx
+++ b/packages/twenty-ui/src/input/button/components/FloatingButtonGroup.tsx
@@ -1,17 +1,19 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import React from 'react';
import {
type FloatingButtonPosition,
type FloatingButtonProps,
} from './FloatingButton';
+import { themeCssVariables } from '@ui/theme';
import { isDefined } from 'twenty-shared/utils';
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}`};
+ border-radius: ${themeCssVariables.border.radius.md};
+ box-shadow:
+ 0px 2px 4px 0px ${themeCssVariables.background.transparent.light},
+ 0px 0px 4px 0px ${themeCssVariables.background.transparent.medium};
display: inline-flex;
`;
@@ -24,31 +26,33 @@ 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>
-);
+}: FloatingButtonGroupProps) => {
+ return (
+ <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>
+ );
+};
diff --git a/packages/twenty-ui/src/input/button/components/FloatingIconButton.tsx b/packages/twenty-ui/src/input/button/components/FloatingIconButton.tsx
index 662ec3ba77c..2e711dec303 100644
--- a/packages/twenty-ui/src/input/button/components/FloatingIconButton.tsx
+++ b/packages/twenty-ui/src/input/button/components/FloatingIconButton.tsx
@@ -1,7 +1,7 @@
-import { css, useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
-import React from 'react';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
+import React, { useContext } from 'react';
export type FloatingIconButtonSize = 'small' | 'medium';
export type FloatingIconButtonPosition =
@@ -22,92 +22,81 @@ export type FloatingIconButtonProps = {
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
isActive?: boolean;
};
-const shouldForwardProp = (prop: string) =>
- ![
- 'applyBlur',
- 'applyShadow',
- 'isActive',
- 'focus',
- 'position',
- 'size',
- ].includes(prop);
-
-const StyledButton = styled('button', { shouldForwardProp })<
+const StyledButton = styled.button<
Pick<
FloatingIconButtonProps,
'size' | 'position' | 'applyShadow' | 'applyBlur' | 'focus' | 'isActive'
>
>`
align-items: center;
- backdrop-filter: ${({ theme, applyBlur }) =>
- applyBlur ? theme.blur.medium : 'none'};
- background: ${({ theme, isActive }) =>
- isActive ? theme.background.transparent.medium : theme.background.primary};
- border: ${({ focus, theme }) =>
+ backdrop-filter: ${({ applyBlur }) =>
+ applyBlur ? themeCssVariables.blur.medium : 'none'};
+ background: ${({ isActive }) =>
+ isActive
+ ? themeCssVariables.background.transparent.medium
+ : themeCssVariables.background.primary};
+ border: ${({ focus }) =>
focus
- ? `1px solid ${theme.color.blue}`
- : `1px solid ${theme.border.color.strong}`};
- border-radius: ${({ position, theme }) => {
+ ? `1px solid ${themeCssVariables.color.blue}`
+ : `1px solid ${themeCssVariables.border.color.strong}`};
+ border-radius: ${({ position }) => {
switch (position) {
case 'left':
- return `${theme.border.radius.sm} 0px 0px ${theme.border.radius.sm}`;
+ return `${themeCssVariables.border.radius.sm} 0px 0px ${themeCssVariables.border.radius.sm}`;
case 'right':
- return `0px ${theme.border.radius.sm} ${theme.border.radius.sm} 0px`;
+ return `0px ${themeCssVariables.border.radius.sm} ${themeCssVariables.border.radius.sm} 0px`;
case 'middle':
return '0px';
case 'standalone':
- return theme.border.radius.sm;
+ return themeCssVariables.border.radius.sm;
}
+ return '';
}};
- box-shadow: ${({ theme, applyShadow, focus }) =>
+ box-shadow: ${({ applyShadow, focus }) =>
applyShadow
- ? theme.boxShadow.light
+ ? themeCssVariables.boxShadow.light
: focus
- ? `0 0 0 3px ${theme.color.blue3}`
+ ? `0 0 0 3px ${themeCssVariables.color.blue3}`
: 'none'};
box-sizing: border-box;
- color: ${({ theme, disabled, focus }) => {
+ color: ${({ disabled, focus }) => {
return !disabled
? focus
- ? theme.color.blue
- : theme.font.color.tertiary
- : theme.font.color.extraLight;
+ ? themeCssVariables.color.blue
+ : themeCssVariables.font.color.tertiary
+ : themeCssVariables.font.color.extraLight;
}};
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
display: flex;
flex-direction: row;
- font-family: ${({ theme }) => theme.font.family};
- font-weight: ${({ theme }) => theme.font.weight.regular};
- gap: ${({ theme }) => theme.spacing(1)};
+ font-family: ${themeCssVariables.font.family};
+ font-weight: ${themeCssVariables.font.weight.regular};
+ gap: ${themeCssVariables.spacing[1]};
justify-content: center;
padding: 0;
position: relative;
- transition: background ${({ theme }) => theme.animation.duration.instant}s
- ease;
+ transition: background
+ calc(${themeCssVariables.animation.duration.instant} * 1s) ease;
white-space: nowrap;
- ${({ position, size }) => {
- const sizeInPx =
- (size === 'small' ? 24 : 32) - (position === 'standalone' ? 0 : 4);
-
- return `
- height: ${sizeInPx}px;
- width: ${sizeInPx}px;
- `;
- }}
+ height: ${({ position, size }) =>
+ (size === 'small' ? 24 : 32) - (position === 'standalone' ? 0 : 4)}px;
+ width: ${({ position, size }) =>
+ (size === 'small' ? 24 : 32) - (position === 'standalone' ? 0 : 4)}px;
- ${({ theme, disabled }) =>
- !disabled &&
- css`
- &:hover {
- background: ${theme.background.transparent.lighter};
- }
- `}
+ &:hover {
+ background: ${({ disabled }) =>
+ !disabled
+ ? themeCssVariables.background.transparent.lighter
+ : 'transparent'};
+ }
&:active {
- background: ${({ theme, disabled }) =>
- !disabled ? theme.background.transparent.medium : 'transparent'};
+ background: ${({ disabled }) =>
+ !disabled
+ ? themeCssVariables.background.transparent.medium
+ : 'transparent'};
}
&:focus {
@@ -127,7 +116,7 @@ export const FloatingIconButton = ({
onClick,
isActive,
}: FloatingIconButtonProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledButton
disabled={disabled}
diff --git a/packages/twenty-ui/src/input/button/components/FloatingIconButtonGroup.tsx b/packages/twenty-ui/src/input/button/components/FloatingIconButtonGroup.tsx
index 26c45aecfe9..edbee251bc4 100644
--- a/packages/twenty-ui/src/input/button/components/FloatingIconButtonGroup.tsx
+++ b/packages/twenty-ui/src/input/button/components/FloatingIconButtonGroup.tsx
@@ -1,4 +1,4 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
import { type MouseEvent } from 'react';
@@ -7,13 +7,15 @@ import {
type FloatingIconButtonPosition,
type FloatingIconButtonProps,
} from './FloatingIconButton';
+import { themeCssVariables } from '@ui/theme';
const StyledFloatingIconButtonGroupContainer = styled.div`
backdrop-filter: blur(20px);
- background-color: ${({ theme }) => theme.background.primary};
- border-radius: ${({ theme }) => theme.border.radius.sm};
- box-shadow: ${({ theme }) =>
- `0px 2px 4px 0px ${theme.background.transparent.light}, 0px 0px 4px 0px ${theme.background.transparent.medium}`};
+ background-color: ${themeCssVariables.background.primary};
+ border-radius: ${themeCssVariables.border.radius.sm};
+ box-shadow:
+ 0px 2px 4px 0px ${themeCssVariables.background.transparent.light},
+ 0px 0px 4px 0px ${themeCssVariables.background.transparent.medium};
display: inline-flex;
gap: 2px;
padding: 2px;
@@ -34,30 +36,32 @@ export const FloatingIconButtonGroup = ({
iconButtons,
size,
className,
-}: FloatingIconButtonGroupProps) => (
- <StyledFloatingIconButtonGroupContainer className={className}>
- {iconButtons.map(({ Icon, onClick, isActive }, index) => {
- const position: FloatingIconButtonPosition =
- iconButtons.length === 1
- ? 'standalone'
- : index === 0
- ? 'left'
- : index === iconButtons.length - 1
- ? 'right'
- : 'middle';
+}: FloatingIconButtonGroupProps) => {
+ return (
+ <StyledFloatingIconButtonGroupContainer className={className}>
+ {iconButtons.map(({ Icon, onClick, isActive }, index) => {
+ const position: FloatingIconButtonPosition =
+ iconButtons.length === 1
+ ? 'standalone'
+ : index === 0
+ ? 'left'
+ : index === iconButtons.length - 1
+ ? 'right'
+ : 'middle';
- return (
- <FloatingIconButton
- key={`floating-icon-button-${index}`}
- applyBlur={false}
- applyShadow={false}
- Icon={Icon}
- onClick={onClick}
- position={position}
- size={size}
- isActive={isActive}
- />
- );
- })}
- </StyledFloatingIconButtonGroupContainer>
-);
+ return (
+ <FloatingIconButton
+ key={`floating-icon-button-${index}`}
+ applyBlur={false}
+ applyShadow={false}
+ Icon={Icon}
+ onClick={onClick}
+ position={position}
+ size={size}
+ isActive={isActive}
+ />
+ );
+ })}
+ </StyledFloatingIconButtonGroupContainer>
+ );
+};
diff --git a/packages/twenty-ui/src/input/button/components/IconButton.tsx b/packages/twenty-ui/src/input/button/components/IconButton.tsx
index 6afea934288..a404673d978 100644
--- a/packages/twenty-ui/src/input/button/components/IconButton.tsx
+++ b/packages/twenty-ui/src/input/button/components/IconButton.tsx
@@ -1,8 +1,7 @@
-import { css, useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
-import { GRAY_SCALE_LIGHT } from '@ui/theme';
-import React from 'react';
+import { GRAY_SCALE_LIGHT, ThemeContext, themeCssVariables } from '@ui/theme';
+import React, { useContext, useMemo } from 'react';
export type IconButtonSize = 'medium' | 'small';
export type IconButtonPosition = 'standalone' | 'left' | 'middle' | 'right';
@@ -24,6 +23,192 @@ export type IconButtonProps = {
to?: string;
};
+type IconButtonDynamicStyles = {
+ background: string;
+ borderColor: string;
+ borderWidthOverride?: string;
+ boxShadow: string;
+ color: string;
+ opacity: number;
+ hoverBackground: string;
+ activeBackground: string;
+};
+
+const computeIconButtonDynamicStyles = (
+ variant: IconButtonVariant,
+ accent: IconButtonAccent,
+ disabled: boolean,
+ focus: boolean,
+): IconButtonDynamicStyles => {
+ const focusOverride = !disabled && focus;
+
+ switch (variant) {
+ case 'primary':
+ switch (accent) {
+ case 'default':
+ return {
+ background: themeCssVariables.background.secondary,
+ borderColor: focus
+ ? themeCssVariables.color.blue
+ : themeCssVariables.background.transparent.light,
+ borderWidthOverride: focusOverride ? '1px 1px' : undefined,
+ boxShadow: focusOverride
+ ? `0 0 0 3px ${themeCssVariables.accent.tertiary}`
+ : 'none',
+ color: !disabled
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.extraLight,
+ opacity: 1,
+ hoverBackground: !disabled
+ ? themeCssVariables.background.tertiary
+ : themeCssVariables.background.secondary,
+ activeBackground: !disabled
+ ? themeCssVariables.background.quaternary
+ : themeCssVariables.background.secondary,
+ };
+ case 'blue':
+ return {
+ background: themeCssVariables.color.blue,
+ borderColor: !disabled
+ ? focus
+ ? themeCssVariables.color.blue
+ : themeCssVariables.background.transparent.light
+ : 'transparent',
+ borderWidthOverride: focusOverride ? '1px 1px' : undefined,
+ boxShadow: focusOverride
+ ? `0 0 0 3px ${themeCssVariables.accent.tertiary}`
+ : 'none',
+ color: GRAY_SCALE_LIGHT.gray1,
+ opacity: disabled ? 0.24 : 1,
+ hoverBackground: disabled
+ ? themeCssVariables.color.blue
+ : themeCssVariables.color.blue10,
+ activeBackground: disabled
+ ? themeCssVariables.color.blue
+ : themeCssVariables.color.blue12,
+ };
+ case 'danger':
+ return {
+ background: themeCssVariables.color.red,
+ borderColor: !disabled
+ ? focus
+ ? themeCssVariables.color.red
+ : themeCssVariables.background.transparent.light
+ : 'transparent',
+ borderWidthOverride: focusOverride ? '1px 1px' : undefined,
+ boxShadow: focusOverride
+ ? `0 0 0 3px ${themeCssVariables.color.red3}`
+ : 'none',
+ color: GRAY_SCALE_LIGHT.gray1,
+ opacity: disabled ? 0.24 : 1,
+ hoverBackground: disabled
+ ? themeCssVariables.color.red
+ : themeCssVariables.color.red10,
+ activeBackground: disabled
+ ? themeCssVariables.color.red
+ : themeCssVariables.color.red10,
+ };
+ }
+ break;
+ case 'secondary':
+ case 'tertiary':
+ switch (accent) {
+ case 'default':
+ return {
+ background: focus
+ ? themeCssVariables.background.transparent.primary
+ : 'transparent',
+ borderColor:
+ variant === 'secondary'
+ ? focusOverride
+ ? themeCssVariables.color.blue
+ : themeCssVariables.background.transparent.medium
+ : focus
+ ? themeCssVariables.color.blue
+ : 'transparent',
+ borderWidthOverride: focusOverride ? '1px 1px' : undefined,
+ boxShadow: focusOverride
+ ? `0 0 0 3px ${themeCssVariables.accent.tertiary}`
+ : 'none',
+ color: disabled
+ ? themeCssVariables.font.color.extraLight
+ : variant === 'secondary'
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.tertiary,
+ opacity: 1,
+ hoverBackground: !disabled
+ ? themeCssVariables.background.transparent.light
+ : 'transparent',
+ activeBackground: !disabled
+ ? themeCssVariables.background.transparent.light
+ : 'transparent',
+ };
+ case 'blue':
+ return {
+ background: focus
+ ? themeCssVariables.background.transparent.primary
+ : 'transparent',
+ borderColor:
+ variant === 'secondary'
+ ? !disabled
+ ? themeCssVariables.color.blue
+ : themeCssVariables.color.blue5
+ : focus
+ ? themeCssVariables.color.blue
+ : 'transparent',
+ borderWidthOverride: focusOverride ? '1px 1px' : undefined,
+ boxShadow: focusOverride
+ ? `0 0 0 3px ${themeCssVariables.accent.tertiary}`
+ : 'none',
+ color: !disabled
+ ? themeCssVariables.color.blue
+ : themeCssVariables.accent.accent4060,
+ opacity: 1,
+ hoverBackground: !disabled
+ ? themeCssVariables.accent.tertiary
+ : 'transparent',
+ activeBackground: !disabled
+ ? themeCssVariables.accent.secondary
+ : 'transparent',
+ };
+ case 'danger':
+ return {
+ background: 'transparent',
+ borderColor:
+ variant === 'secondary'
+ ? themeCssVariables.border.color.danger
+ : focus
+ ? themeCssVariables.color.red
+ : 'transparent',
+ borderWidthOverride: focusOverride ? '1px 1px' : undefined,
+ boxShadow: focusOverride
+ ? `0 0 0 3px ${themeCssVariables.color.red3}`
+ : 'none',
+ color: !disabled
+ ? themeCssVariables.font.color.danger
+ : themeCssVariables.color.red5,
+ opacity: 1,
+ hoverBackground: !disabled
+ ? themeCssVariables.background.danger
+ : 'transparent',
+ activeBackground: !disabled
+ ? themeCssVariables.background.danger
+ : 'transparent',
+ };
+ }
+ }
+
+ return {
+ background: 'transparent',
+ borderColor: 'transparent',
+ boxShadow: 'none',
+ color: themeCssVariables.font.color.secondary,
+ opacity: 1,
+ hoverBackground: 'transparent',
+ activeBackground: 'transparent',
+ };
+};
+
const StyledButton = styled.button<
Pick<
IconButtonProps,
@@ -31,206 +216,52 @@ const StyledButton = styled.button<
>
>`
align-items: center;
- ${({ theme, variant, accent, disabled, focus }) => {
- switch (variant) {
- case 'primary':
- switch (accent) {
- case 'default':
- return css`
- background: ${theme.background.secondary};
- border-color: ${focus
- ? theme.color.blue
- : theme.background.transparent.light};
- border-width: ${!disabled && focus ? '1px 1px !important' : 0};
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${theme.accent.tertiary}`
- : 'none'};
- color: ${!disabled
- ? theme.font.color.secondary
- : theme.font.color.extraLight};
- &:hover {
- background: ${!disabled
- ? theme.background.tertiary
- : theme.background.secondary};
- }
- &:active {
- background: ${!disabled
- ? theme.background.quaternary
- : theme.background.secondary};
- }
- `;
- case 'blue':
- return css`
- background: ${theme.color.blue};
- border-color: ${!disabled
- ? focus
- ? theme.color.blue
- : theme.background.transparent.light
- : 'transparent'};
- border-width: ${!disabled && focus ? '1px 1px !important' : 0};
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${theme.accent.tertiary}`
- : 'none'};
- color: ${GRAY_SCALE_LIGHT.gray1};
- opacity: ${disabled ? 0.24 : 1};
-
- ${disabled
- ? ''
- : css`
- &:hover {
- background: ${theme.color.blue10};
- }
- &:active {
- background: ${theme.color.blue12};
- }
- `}
- `;
- case 'danger':
- return css`
- background: ${theme.color.red};
- border-color: ${!disabled
- ? focus
- ? theme.color.red
- : theme.background.transparent.light
- : 'transparent'};
- border-width: ${!disabled && focus ? '1px 1px !important' : 0};
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${theme.color.red3}`
- : 'none'};
- color: ${GRAY_SCALE_LIGHT.gray1};
- opacity: ${disabled ? 0.24 : 1};
-
- ${disabled
- ? ''
- : css`
- &:hover,
- &:active {
- background: ${theme.color.red10};
- }
- `}
- `;
- }
- break;
- case 'secondary':
- case 'tertiary':
- switch (accent) {
- case 'default':
- return css`
- background: ${focus
- ? theme.background.transparent.primary
- : 'transparent'};
- border-color: ${variant === 'secondary'
- ? !disabled && focus
- ? theme.color.blue
- : theme.background.transparent.medium
- : focus
- ? theme.color.blue
- : 'transparent'};
- border-width: ${!disabled && focus ? '1px 1px !important' : 0};
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${theme.accent.tertiary}`
- : 'none'};
- color: ${disabled
- ? theme.font.color.extraLight
- : variant === 'secondary'
- ? theme.font.color.secondary
- : theme.font.color.tertiary};
- &:hover {
- background: ${!disabled
- ? theme.background.transparent.light
- : 'transparent'};
- }
- &:active {
- background: ${!disabled
- ? theme.background.transparent.light
- : 'transparent'};
- }
- `;
- case 'blue':
- return css`
- background: ${focus
- ? theme.background.transparent.primary
- : 'transparent'};
- border-color: ${variant === 'secondary'
- ? !disabled
- ? theme.color.blue
- : theme.color.blue5
- : focus
- ? theme.color.blue
- : 'transparent'};
- border-width: ${!disabled && focus ? '1px 1px !important' : 0};
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${theme.accent.tertiary}`
- : 'none'};
- color: ${!disabled ? theme.color.blue : theme.accent.accent4060};
- &:hover {
- background: ${!disabled
- ? theme.accent.tertiary
- : 'transparent'};
- }
- &:active {
- background: ${!disabled
- ? theme.accent.secondary
- : 'transparent'};
- }
- `;
- case 'danger':
- return css`
- background: transparent;
- border-color: ${variant === 'secondary'
- ? theme.border.color.danger
- : focus
- ? theme.color.red
- : 'transparent'};
- border-width: ${!disabled && focus ? '1px 1px !important' : 0};
- box-shadow: ${!disabled && focus
- ? `0 0 0 3px ${theme.color.red3}`
- : 'none'};
- color: ${!disabled ? theme.font.color.danger : theme.color.red5};
- &:hover {
- background: ${!disabled
- ? theme.background.danger
- : 'transparent'};
- }
- &:active {
- background: ${!disabled
- ? theme.background.danger
- : 'transparent'};
- }
- `;
- }
- }
- }}
+ background: var(--ibtn-bg);
+ border-color: var(--ibtn-border-color);
+ box-shadow: var(--ibtn-box-shadow);
+ color: var(--ibtn-color);
+ opacity: var(--ibtn-opacity, 1);
+ &:hover {
+ background: var(--ibtn-hover-bg);
+ }
+ &:active {
+ background: var(--ibtn-active-bg);
+ }
- border-radius: ${({ position, theme }) => {
+ border-radius: ${({ position }) => {
switch (position) {
case 'left':
- return `${theme.border.radius.sm} 0px 0px ${theme.border.radius.sm}`;
+ return `${themeCssVariables.border.radius.sm} 0px 0px ${themeCssVariables.border.radius.sm}`;
case 'right':
- return `0px ${theme.border.radius.sm} ${theme.border.radius.sm} 0px`;
+ return `0px ${themeCssVariables.border.radius.sm} ${themeCssVariables.border.radius.sm} 0px`;
case 'middle':
return '0px';
case 'standalone':
- return theme.border.radius.sm;
+ return themeCssVariables.border.radius.sm;
}
+ return '';
}};
border-style: solid;
- border-width: ${({ variant, position }) => {
- switch (variant) {
- case 'primary':
- case 'secondary':
- return position === 'middle' ? '1px 0px' : '1px';
- case 'tertiary':
- return '0';
- }
- }};
+ border-width: var(
+ --ibtn-border-width,
+ ${({ variant, position }) => {
+ switch (variant) {
+ case 'primary':
+ case 'secondary':
+ return position === 'middle' ? '1px 0px' : '1px';
+ case 'tertiary':
+ return '0';
+ }
+ return '';
+ }}
+ );
box-sizing: border-box;
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
display: flex;
flex-direction: row;
- font-family: ${({ theme }) => theme.font.family};
+ font-family: ${themeCssVariables.font.family};
font-weight: 500;
- gap: ${({ theme }) => theme.spacing(1)};
+ gap: ${themeCssVariables.spacing[1]};
height: ${({ size }) => (size === 'small' ? '24px' : '32px')};
justify-content: center;
padding: 0;
@@ -259,7 +290,26 @@ export const IconButton = ({
onClick,
to,
}: IconButtonProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
+ const dynamicStyles = useMemo(() => {
+ const styles = computeIconButtonDynamicStyles(
+ variant,
+ accent,
+ disabled,
+ focus,
+ );
+ return {
+ '--ibtn-bg': styles.background,
+ '--ibtn-border-color': styles.borderColor,
+ '--ibtn-border-width': styles.borderWidthOverride || undefined,
+ '--ibtn-box-shadow': styles.boxShadow,
+ '--ibtn-color': styles.color,
+ '--ibtn-opacity': styles.opacity,
+ '--ibtn-hover-bg': styles.hoverBackground,
+ '--ibtn-active-bg': styles.activeBackground,
+ } as React.CSSProperties;
+ }, [variant, accent, disabled, focus]);
+
return (
<StyledButton
data-testid={dataTestId}
@@ -273,6 +323,7 @@ export const IconButton = ({
onClick={onClick}
aria-label={ariaLabel}
to={to}
+ style={dynamicStyles}
>
{Icon && <Icon size={theme.icon.size.md} />}
</StyledButton>
diff --git a/packages/twenty-ui/src/input/button/components/IconButtonGroup.tsx b/packages/twenty-ui/src/input/button/components/IconButtonGroup.tsx
index 12ffe7767ff..65ad4e429ac 100644
--- a/packages/twenty-ui/src/input/button/components/IconButtonGroup.tsx
+++ b/packages/twenty-ui/src/input/button/components/IconButtonGroup.tsx
@@ -1,8 +1,9 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
import { type MouseEvent } from 'react';
import { InsideButton } from '@ui/input/button/components/InsideButton';
+import { themeCssVariables } from '@ui/theme';
export type IconButtonGroupProps = {
disabled?: boolean;
@@ -18,16 +19,16 @@ const StyledIconButtonGroupContainer = styled.div<
>`
display: inline-flex;
align-items: flex-start;
- background-color: ${({ disabled, theme }) =>
- disabled ? 'inherit' : theme.background.transparent.lighter};
- border-radius: ${({ theme }) => theme.border.radius.sm};
- border: 1px solid ${({ theme }) => theme.border.color.strong};
+ background-color: ${({ disabled }) =>
+ disabled ? 'inherit' : themeCssVariables.background.transparent.lighter};
+ border-radius: ${themeCssVariables.border.radius.sm};
+ border: 1px solid ${themeCssVariables.border.color.strong};
gap: 2px;
padding: 2px;
backdrop-filter: blur(20px);
&:hover {
- box-shadow: ${({ theme }) => theme.boxShadow.light};
+ box-shadow: ${themeCssVariables.boxShadow.light};
}
`;
@@ -35,17 +36,19 @@ export const IconButtonGroup = ({
iconButtons,
disabled,
className,
-}: IconButtonGroupProps) => (
- <StyledIconButtonGroupContainer className={className} disabled={disabled}>
- {iconButtons.map(({ Icon, onClick }, index) => {
- return (
- <InsideButton
- key={index}
- Icon={Icon}
- onClick={onClick}
- disabled={disabled}
- />
- );
- })}
- </StyledIconButtonGroupContainer>
-);
+}: IconButtonGroupProps) => {
+ return (
+ <StyledIconButtonGroupContainer className={className} disabled={disabled}>
+ {iconButtons.map(({ Icon, onClick }, index) => {
+ return (
+ <InsideButton
+ key={index}
+ Icon={Icon}
+ onClick={onClick}
+ disabled={disabled}
+ />
+ );
+ })}
+ </StyledIconButtonGroupContainer>
+ );
+};
diff --git a/packages/twenty-ui/src/input/button/components/InsideButton.tsx b/packages/twenty-ui/src/input/button/components/InsideButton.tsx
index 5dbba51dd2a..ba3c34fb3c2 100644
--- a/packages/twenty-ui/src/input/button/components/InsideButton.tsx
+++ b/packages/twenty-ui/src/input/button/components/InsideButton.tsx
@@ -1,7 +1,7 @@
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
-import styled from '@emotion/styled';
-import React from 'react';
-import { useTheme } from '@emotion/react';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
+import React, { useContext } from 'react';
export type InsideButtonProps = {
className?: string;
@@ -14,8 +14,8 @@ const StyledButton = styled.button`
align-items: center;
border: none;
background-color: transparent;
- border-radius: ${({ theme }) => theme.border.radius.xs};
- color: ${({ theme }) => theme.font.color.tertiary};
+ border-radius: ${themeCssVariables.border.radius.xs};
+ color: ${themeCssVariables.font.color.tertiary};
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
display: flex;
flex-direction: row;
@@ -27,7 +27,7 @@ const StyledButton = styled.button`
transition: background-color 0.1s ease;
&:hover {
- background-color: ${({ theme }) => theme.background.transparent.light};
+ background-color: ${themeCssVariables.background.transparent.light};
}
`;
@@ -37,7 +37,7 @@ export const InsideButton = ({
onClick,
disabled = false,
}: InsideButtonProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledButton className={className} onClick={onClick} disabled={disabled}>
diff --git a/packages/twenty-ui/src/input/button/components/LightButton.tsx b/packages/twenty-ui/src/input/button/components/LightButton.tsx
index 6fbe252096e..7d8caa603c5 100644
--- a/packages/twenty-ui/src/input/button/components/LightButton.tsx
+++ b/packages/twenty-ui/src/input/button/components/LightButton.tsx
@@ -1,7 +1,7 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
-import { type MouseEvent } from 'react';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
+import { type MouseEvent, useContext } from 'react';
export type LightButtonAccent = 'secondary' | 'tertiary';
@@ -22,47 +22,48 @@ const StyledButton = styled.button<
>`
align-items: center;
background: transparent;
- border: ${({ theme, focus }) =>
- focus ? `1px solid ${theme.color.blue}` : 'none'};
+ border: ${({ focus }) =>
+ focus ? `1px solid ${themeCssVariables.color.blue}` : 'none'};
- border-radius: ${({ theme }) => theme.border.radius.sm};
- box-shadow: ${({ theme, focus }) =>
- focus ? `0 0 0 3px ${theme.color.blue3}` : 'none'};
- color: ${({ theme, accent, active, disabled, focus }) => {
+ border-radius: ${themeCssVariables.border.radius.sm};
+ box-shadow: ${({ focus }) =>
+ focus ? `0 0 0 3px ${themeCssVariables.color.blue3}` : 'none'};
+ color: ${({ accent, active, disabled, focus }) => {
switch (accent) {
case 'secondary':
return active || focus
- ? theme.color.blue
+ ? themeCssVariables.color.blue
: !disabled
- ? theme.font.color.secondary
- : theme.font.color.extraLight;
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.extraLight;
case 'tertiary':
return active || focus
- ? theme.color.blue
+ ? themeCssVariables.color.blue
: !disabled
- ? theme.font.color.tertiary
- : theme.font.color.extraLight;
+ ? themeCssVariables.font.color.tertiary
+ : themeCssVariables.font.color.extraLight;
}
+ return '';
}};
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
display: flex;
flex-direction: row;
- font-family: ${({ theme }) => theme.font.family};
- font-weight: ${({ theme }) => theme.font.weight.regular};
- gap: ${({ theme }) => theme.spacing(1)};
+ font-family: ${themeCssVariables.font.family};
+ font-weight: ${themeCssVariables.font.weight.regular};
+ gap: ${themeCssVariables.spacing[1]};
height: 24px;
- padding: ${({ theme }) => {
- return `0 ${theme.spacing(2)}`;
- }};
+ padding: 0 ${themeCssVariables.spacing[2]};
transition: background 0.1s ease;
white-space: nowrap;
&:hover {
- background: ${({ theme, disabled }) =>
- !disabled ? theme.background.transparent.light : 'transparent'};
+ background: ${({ disabled }) =>
+ !disabled
+ ? themeCssVariables.background.transparent.light
+ : 'transparent'};
}
&:focus {
@@ -70,8 +71,10 @@ const StyledButton = styled.button<
}
&:active {
- background: ${({ theme, disabled }) =>
- !disabled ? theme.background.transparent.medium : 'transparent'};
+ background: ${({ disabled }) =>
+ !disabled
+ ? themeCssVariables.background.transparent.medium
+ : 'transparent'};
}
`;
@@ -86,7 +89,7 @@ export const LightButton = ({
type = 'button',
onClick,
}: LightButtonProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledButton
diff --git a/packages/twenty-ui/src/input/button/components/LightIconButton.tsx b/packages/twenty-ui/src/input/button/components/LightIconButton.tsx
index a336a793c49..04d0487e2e7 100644
--- a/packages/twenty-ui/src/input/button/components/LightIconButton.tsx
+++ b/packages/twenty-ui/src/input/button/components/LightIconButton.tsx
@@ -1,7 +1,7 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
-import { type ComponentProps, type MouseEvent } from 'react';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
+import { type ComponentProps, type MouseEvent, useContext } from 'react';
export type LightIconButtonAccent = 'secondary' | 'tertiary';
export type LightIconButtonSize = 'small' | 'medium';
@@ -26,49 +26,58 @@ const StyledButton = styled.button<
background: transparent;
border: none;
- border: ${({ disabled, theme, focus }) =>
- !disabled && focus ? `1px solid ${theme.color.blue}` : 'none'};
- border-radius: ${({ theme }) => theme.border.radius.sm};
- box-shadow: ${({ disabled, theme, focus }) =>
- !disabled && focus ? `0 0 0 3px ${theme.color.blue3}` : 'none'};
- color: ${({ theme, accent, active, disabled, focus }) => {
+ border: ${({ disabled, focus }) =>
+ !disabled && focus ? `1px solid ${themeCssVariables.color.blue}` : 'none'};
+ border-radius: ${themeCssVariables.border.radius.sm};
+ box-shadow: ${({ disabled, focus }) =>
+ !disabled && focus ? `0 0 0 3px ${themeCssVariables.color.blue3}` : 'none'};
+ color: ${({ accent, active, disabled, focus }) => {
switch (accent) {
case 'secondary':
return active || focus
- ? theme.color.blue
+ ? themeCssVariables.color.blue
: !disabled
- ? theme.font.color.secondary
- : theme.font.color.extraLight;
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.extraLight;
case 'tertiary':
return active || focus
- ? theme.color.blue
+ ? themeCssVariables.color.blue
: !disabled
- ? theme.font.color.tertiary
- : theme.font.color.extraLight;
+ ? themeCssVariables.font.color.tertiary
+ : themeCssVariables.font.color.extraLight;
}
+ return '';
}};
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
display: flex;
flex-direction: row;
- font-family: ${({ theme }) => theme.font.family};
- font-weight: ${({ theme }) => theme.font.weight.regular};
- gap: ${({ theme }) => theme.spacing(1)};
- height: ${({ size, theme }) =>
- size === 'small' ? theme.spacing(6) : theme.spacing(8)};
+ font-family: ${themeCssVariables.font.family};
+ font-weight: ${themeCssVariables.font.weight.regular};
+ gap: ${themeCssVariables.spacing[1]};
+ height: ${({ size }) =>
+ size === 'small'
+ ? themeCssVariables.spacing[6]
+ : themeCssVariables.spacing[8]};
justify-content: center;
- padding: ${({ theme }) => theme.spacing(1)};
+ padding: ${themeCssVariables.spacing[1]};
transition: background 0.1s ease;
white-space: nowrap;
- width: ${({ size, theme }) =>
- size === 'small' ? theme.spacing(6) : theme.spacing(8)};
- min-width: ${({ size, theme }) =>
- size === 'small' ? theme.spacing(6) : theme.spacing(8)};
+ width: ${({ size }) =>
+ size === 'small'
+ ? themeCssVariables.spacing[6]
+ : themeCssVariables.spacing[8]};
+ min-width: ${({ size }) =>
+ size === 'small'
+ ? themeCssVariables.spacing[6]
+ : themeCssVariables.spacing[8]};
&:hover {
- background: ${({ theme, disabled }) =>
- !disabled ? theme.background.transparent.light : 'transparent'};
+ background: ${({ disabled }) =>
+ !disabled
+ ? themeCssVariables.background.transparent.light
+ : 'transparent'};
}
&:focus {
@@ -76,8 +85,10 @@ const StyledButton = styled.button<
}
&:active {
- background: ${({ theme, disabled }) =>
- !disabled ? theme.background.transparent.medium : 'transparent'};
+ background: ${({ disabled }) =>
+ !disabled
+ ? themeCssVariables.background.transparent.medium
+ : 'transparent'};
}
`;
@@ -94,7 +105,7 @@ export const LightIconButton = ({
onClick,
title,
}: LightIconButtonProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledButton
diff --git a/packages/twenty-ui/src/input/button/components/LightIconButtonGroup.tsx b/packages/twenty-ui/src/input/button/components/LightIconButtonGroup.tsx
index d25dd94bbb4..e3e742eb670 100644
--- a/packages/twenty-ui/src/input/button/components/LightIconButtonGroup.tsx
+++ b/packages/twenty-ui/src/input/button/components/LightIconButtonGroup.tsx
@@ -1,4 +1,4 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
import {
type FunctionComponent,
diff --git a/packages/twenty-ui/src/input/button/components/MainButton.tsx b/packages/twenty-ui/src/input/button/components/MainButton.tsx
index d415d2bd3e2..408b6ebc96e 100644
--- a/packages/twenty-ui/src/input/button/components/MainButton.tsx
+++ b/packages/twenty-ui/src/input/button/components/MainButton.tsx
@@ -1,7 +1,7 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
-import React, { type FunctionComponent } from 'react';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
+import React, { type FunctionComponent, useContext } from 'react';
export type MainButtonVariant = 'primary' | 'secondary';
@@ -17,89 +17,76 @@ const StyledButton = styled.button<
Pick<Props, 'fullWidth' | 'width' | 'variant'>
>`
align-items: center;
- background: ${({ theme, variant, disabled }) => {
+ background: ${({ variant, disabled }) => {
if (disabled === true) {
- return theme.background.secondary;
+ return themeCssVariables.background.secondary;
}
switch (variant) {
case 'primary':
- return theme.background.primaryInverted;
+ return themeCssVariables.background.primaryInverted;
case 'secondary':
- return theme.background.primary;
+ return themeCssVariables.background.primary;
default:
- return theme.background.primary;
+ return themeCssVariables.background.primary;
}
}};
border: 1px solid;
- border-color: ${({ theme, disabled, variant }) => {
+ border-color: ${({ disabled, variant }) => {
if (disabled === true) {
- return theme.background.transparent.lighter;
+ return themeCssVariables.background.transparent.lighter;
}
switch (variant) {
case 'primary':
- return theme.background.transparent.strong;
+ return themeCssVariables.background.transparent.strong;
case 'secondary':
- return theme.border.color.medium;
+ return themeCssVariables.border.color.medium;
default:
- return theme.background.primary;
+ return themeCssVariables.background.primary;
}
}};
- border-radius: ${({ theme }) => theme.border.radius.md};
- ${({ theme, disabled }) => {
+ border-radius: ${themeCssVariables.border.radius.md};
+ box-shadow: ${({ disabled }) =>
+ disabled ? 'none' : themeCssVariables.boxShadow.light};
+ color: ${({ variant, disabled }) => {
if (disabled === true) {
- return '';
- }
-
- return `box-shadow: ${theme.boxShadow.light};`;
- }}
- color: ${({ theme, variant, disabled }) => {
- if (disabled === true) {
- return theme.font.color.light;
+ return themeCssVariables.font.color.light;
}
switch (variant) {
case 'primary':
- return theme.font.color.inverted;
+ return themeCssVariables.font.color.inverted;
case 'secondary':
- return theme.font.color.primary;
+ return themeCssVariables.font.color.primary;
default:
- return theme.font.color.primary;
+ return themeCssVariables.font.color.primary;
}
}};
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
display: flex;
flex-direction: row;
- font-family: ${({ theme }) => theme.font.family};
- font-weight: ${({ theme }) => theme.font.weight.semiBold};
- gap: ${({ theme }) => theme.spacing(2)};
+ font-family: ${themeCssVariables.font.family};
+ font-weight: ${themeCssVariables.font.weight.semiBold};
+ gap: ${themeCssVariables.spacing[2]};
justify-content: center;
outline: none;
- padding: ${({ theme }) => theme.spacing(2)} ${({ theme }) => theme.spacing(3)};
- max-height: ${({ theme }) => theme.spacing(8)};
+ padding: ${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[3]};
+ max-height: ${themeCssVariables.spacing[8]};
width: ${({ fullWidth, width }) =>
fullWidth ? '100%' : width ? `${width}px` : 'auto'};
- ${({ theme, variant, disabled }) => {
- switch (variant) {
- case 'secondary':
- return `
- &:hover {
- background: ${theme.background.tertiary};
- }
- `;
- default:
- return `
- &:hover {
- background: ${
- !disabled
- ? theme.background.primaryInvertedHover
- : theme.background.secondary
- };};
- }
- `;
- }
- }};
+ &:hover {
+ background: ${({ variant, disabled }) => {
+ switch (variant) {
+ case 'secondary':
+ return themeCssVariables.background.tertiary;
+ default:
+ return !disabled
+ ? themeCssVariables.background.primaryInvertedHover
+ : themeCssVariables.background.secondary;
+ }
+ }};
+ }
`;
type MainButtonProps = Props & {
@@ -117,7 +104,7 @@ export const MainButton = ({
disabled,
className,
}: MainButtonProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledButton
className={className}
diff --git a/packages/twenty-ui/src/input/button/components/RoundedIconButton.tsx b/packages/twenty-ui/src/input/button/components/RoundedIconButton.tsx
index 161b165abec..f913a6a869b 100644
--- a/packages/twenty-ui/src/input/button/components/RoundedIconButton.tsx
+++ b/packages/twenty-ui/src/input/button/components/RoundedIconButton.tsx
@@ -1,15 +1,18 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
+import { useContext } from 'react';
export type RoundedIconButtonSize = 'small' | 'medium';
-const StyledIconButton = styled.button<{ size: RoundedIconButtonSize }>`
+const StyledIconButton = styled.button<{
+ size: RoundedIconButtonSize;
+}>`
align-items: center;
- background: ${({ theme }) => theme.color.blue};
+ background: ${themeCssVariables.color.blue};
border: none;
border-radius: 50%;
- color: ${({ theme }) => theme.font.color.inverted};
+ color: ${themeCssVariables.font.color.inverted};
cursor: pointer;
display: flex;
height: ${({ size }) => (size === 'small' ? '20px' : '24px')};
@@ -21,8 +24,8 @@ const StyledIconButton = styled.button<{ size: RoundedIconButtonSize }>`
background 0.1s ease-in-out;
&:disabled {
- background: ${({ theme }) => theme.background.quaternary};
- color: ${({ theme }) => theme.font.color.tertiary};
+ background: ${themeCssVariables.background.quaternary};
+ color: ${themeCssVariables.font.color.tertiary};
cursor: default;
}
width: ${({ size }) => (size === 'small' ? '20px' : '24px')};
@@ -40,7 +43,7 @@ export const RoundedIconButton = ({
className,
size = 'small',
}: RoundedIconButtonProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledIconButton
diff --git a/packages/twenty-ui/src/input/button/components/TabButton/internals/components/StyledTabBase.tsx b/packages/twenty-ui/src/input/button/components/TabButton/internals/components/StyledTabBase.tsx
index 27911d932c2..7602e0dd003 100644
--- a/packages/twenty-ui/src/input/button/components/TabButton/internals/components/StyledTabBase.tsx
+++ b/packages/twenty-ui/src/input/button/components/TabButton/internals/components/StyledTabBase.tsx
@@ -1,27 +1,25 @@
-import isPropValid from '@emotion/is-prop-valid';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
-export const StyledTabButton = styled('button', {
- shouldForwardProp: (prop) => isPropValid(prop) && prop !== 'active',
-})<{
+export const StyledTabButton = styled.button<{
active?: boolean;
disabled?: boolean;
to?: string;
}>`
all: unset;
align-items: center;
- color: ${({ theme, active, disabled }) =>
+ color: ${({ active, disabled }) =>
active
- ? theme.font.color.primary
+ ? themeCssVariables.font.color.primary
: disabled
- ? theme.font.color.light
- : theme.font.color.secondary};
+ ? themeCssVariables.font.color.light
+ : themeCssVariables.font.color.secondary};
cursor: pointer;
background-color: transparent;
border: none;
font-family: inherit;
display: flex;
- gap: ${({ theme }) => theme.spacing(1)};
+ gap: ${themeCssVariables.spacing[1]};
justify-content: center;
pointer-events: ${({ disabled }) => (disabled ? 'none' : '')};
text-decoration: none;
@@ -33,8 +31,8 @@ export const StyledTabButton = styled('button', {
left: 0;
right: 0;
height: 1px;
- background-color: ${({ theme, active }) =>
- active ? theme.border.color.inverted : 'transparent'};
+ background-color: ${({ active }) =>
+ active ? themeCssVariables.border.color.inverted : 'transparent'};
z-index: 1;
}
`;
@@ -44,16 +42,16 @@ export const StyledTabContainer = styled.div<{
disabled?: boolean;
}>`
align-items: center;
- color: ${({ theme, active, disabled }) =>
+ color: ${({ active, disabled }) =>
active
- ? theme.font.color.primary
+ ? themeCssVariables.font.color.primary
: disabled
- ? theme.font.color.light
- : theme.font.color.secondary};
+ ? themeCssVariables.font.color.light
+ : themeCssVariables.font.color.secondary};
cursor: pointer;
background-color: transparent;
display: flex;
- gap: ${({ theme }) => theme.spacing(1)};
+ gap: ${themeCssVariables.spacing[1]};
justify-content: center;
text-decoration: none;
position: relative;
@@ -65,8 +63,8 @@ export const StyledTabContainer = styled.div<{
left: 0;
right: 0;
height: 1px;
- background-color: ${({ theme, active }) =>
- active ? theme.border.color.inverted : 'transparent'};
+ background-color: ${({ active }) =>
+ active ? themeCssVariables.border.color.inverted : 'transparent'};
z-index: 1;
}
`;
@@ -75,19 +73,19 @@ export const StyledTabHover = styled.span<{
contentSize?: 'sm' | 'md';
}>`
display: flex;
- gap: ${({ theme }) => theme.spacing(1)};
- padding: ${({ theme, contentSize }) =>
+ gap: ${themeCssVariables.spacing[1]};
+ padding: ${({ contentSize }) =>
contentSize === 'sm'
- ? `${theme.spacing(1)} ${theme.spacing(2)}`
- : `${theme.spacing(2)} ${theme.spacing(2)}`};
- font-weight: ${({ theme }) => theme.font.weight.medium};
+ ? `${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]}`
+ : `${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[2]}`};
+ font-weight: ${themeCssVariables.font.weight.medium};
width: 100%;
white-space: nowrap;
- border-radius: ${({ theme }) => theme.border.radius.sm};
+ border-radius: ${themeCssVariables.border.radius.sm};
&:hover {
- background: ${({ theme }) => theme.background.tertiary};
+ background: ${themeCssVariables.background.tertiary};
}
&:active {
- background: ${({ theme }) => theme.background.quaternary};
+ background: ${themeCssVariables.background.quaternary};
}
`;
diff --git a/packages/twenty-ui/src/input/button/components/__stories__/TabButton.stories.tsx b/packages/twenty-ui/src/input/button/components/__stories__/TabButton.stories.tsx
index a2d29fee879..b45e97fd33a 100644
--- a/packages/twenty-ui/src/input/button/components/__stories__/TabButton.stories.tsx
+++ b/packages/twenty-ui/src/input/button/components/__stories__/TabButton.stories.tsx
@@ -1,4 +1,5 @@
-import styled from '@emotion/styled';
+/* eslint-disable react/jsx-props-no-spreading */
+import { styled } from '@linaria/react';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import {
IconCheckbox,
@@ -15,11 +16,12 @@ import {
ComponentWithRouterDecorator,
JotaiRootDecorator,
} from '@ui/testing';
+import { type ReactNode } from 'react';
+import { themeCssVariables } from '@ui/theme';
-// Mimic the TabList container styling for proper positioning
const StyledTabContainer = styled.div`
display: flex;
- gap: ${({ theme }) => theme.spacing(1)};
+ gap: ${themeCssVariables.spacing[1]};
height: 40px;
user-select: none;
position: relative;
@@ -32,10 +34,14 @@ const StyledTabContainer = styled.div`
left: 0;
right: 0;
height: 1px;
- background-color: ${({ theme }) => theme.border.color.light};
+ background-color: ${themeCssVariables.border.color.light};
}
`;
+const TabContainer = ({ children }: { children?: ReactNode }) => {
+ return <StyledTabContainer>{children}</StyledTabContainer>;
+};
+
const meta: Meta<typeof TabButton> = {
title: 'UI/Input/Button/TabButton',
component: TabButton,
@@ -67,22 +73,9 @@ export const Default: Story = {
LeftIcon: IconSettings,
},
render: (args) => (
- <StyledTabContainer>
- <TabButton
- id={args.id}
- title={args.title}
- LeftIcon={args.LeftIcon}
- RightIcon={args.RightIcon}
- active={args.active}
- disabled={args.disabled}
- pill={args.pill}
- to={args.to}
- logo={args.logo}
- onClick={args.onClick}
- className={args.className}
- contentSize={args.contentSize}
- />
- </StyledTabContainer>
+ <TabContainer>
+ <TabButton {...args} />
+ </TabContainer>
),
};
@@ -93,22 +86,9 @@ export const Active: Story = {
active: true,
},
render: (args) => (
- <StyledTabContainer>
- <TabButton
- id={args.id}
- title={args.title}
- LeftIcon={args.LeftIcon}
- RightIcon={args.RightIcon}
- active={args.active}
- disabled={args.disabled}
- pill={args.pill}
- to={args.to}
- logo={args.logo}
- onClick={args.onClick}
- className={args.className}
- contentSize={args.contentSize}
- />
- </StyledTabContainer>
+ <TabContainer>
+ <TabButton {...args} />
+ </TabContainer>
),
};
@@ -119,22 +99,9 @@ export const Disabled: Story = {
disabled: true,
},
render: (args) => (
- <StyledTabContainer>
- <TabButton
- id={args.id}
- title={args.title}
- LeftIcon={args.LeftIcon}
- RightIcon={args.RightIcon}
- active={args.active}
- disabled={args.disabled}
- pill={args.pill}
- to={args.to}
- logo={args.logo}
- onClick={args.onClick}
- className={args.className}
- contentSize={args.contentSize}
- />
- </StyledTabContainer>
+ <TabContainer>
+ <TabButton {...args} />
+ </TabContainer>
),
};
@@ -144,22 +111,9 @@ export const WithLogo: Story = {
logo: 'https://picsum.photos/192/192',
},
render: (args) => (
- <StyledTabContainer>
- <TabButton
- id={args.id}
- title={args.title}
- LeftIcon={args.LeftIcon}
- RightIcon={args.RightIcon}
- active={args.active}
- disabled={args.disabled}
- pill={args.pill}
- to={args.to}
- logo={args.logo}
- onClick={args.onClick}
- className={args.className}
- contentSize={args.contentSize}
- />
- </StyledTabContainer>
+ <TabContainer>
+ <TabButton {...args} />
+ </TabContainer>
),
};
@@ -170,22 +124,9 @@ export const WithStringPill: Story = {
pill: '12',
},
render: (args) => (
- <StyledTabContainer>
- <TabButton
- id={args.id}
- title={args.title}
- LeftIcon={args.LeftIcon}
- RightIcon={args.RightIcon}
- active={args.active}
- disabled={args.disabled}
- pill={args.pill}
- to={args.to}
- logo={args.logo}
- onClick={args.onClick}
- className={args.className}
- contentSize={args.contentSize}
- />
- </StyledTabContainer>
+ <TabContainer>
+ <TabButton {...args} />
+ </TabContainer>
),
};
@@ -196,22 +137,9 @@ export const WithBothIcons: Story = {
RightIcon: IconChevronDown,
},
render: (args) => (
- <StyledTabContainer>
- <TabButton
- id={args.id}
- title={args.title}
- LeftIcon={args.LeftIcon}
- RightIcon={args.RightIcon}
- active={args.active}
- disabled={args.disabled}
- pill={args.pill}
- to={args.to}
- logo={args.logo}
- onClick={args.onClick}
- className={args.className}
- contentSize={args.contentSize}
- />
- </StyledTabContainer>
+ <TabContainer>
+ <TabButton {...args} />
+ </TabContainer>
),
};
@@ -222,22 +150,9 @@ export const AsLink: Story = {
to: '/profile',
},
render: (args) => (
- <StyledTabContainer>
- <TabButton
- id={args.id}
- title={args.title}
- LeftIcon={args.LeftIcon}
- RightIcon={args.RightIcon}
- active={args.active}
- disabled={args.disabled}
- pill={args.pill}
- to={args.to}
- logo={args.logo}
- onClick={args.onClick}
- className={args.className}
- contentSize={args.contentSize}
- />
- </StyledTabContainer>
+ <TabContainer>
+ <TabButton {...args} />
+ </TabContainer>
),
};
@@ -248,22 +163,9 @@ export const SmallContent: Story = {
contentSize: 'sm',
},
render: (args) => (
- <StyledTabContainer>
- <TabButton
- id={args.id}
- title={args.title}
- LeftIcon={args.LeftIcon}
- RightIcon={args.RightIcon}
- active={args.active}
- disabled={args.disabled}
- pill={args.pill}
- to={args.to}
- logo={args.logo}
- onClick={args.onClick}
- className={args.className}
- contentSize={args.contentSize}
- />
- </StyledTabContainer>
+ <TabContainer>
+ <TabButton {...args} />
+ </TabContainer>
),
};
@@ -274,22 +176,9 @@ export const MediumContent: Story = {
contentSize: 'md',
},
render: (args) => (
- <StyledTabContainer>
- <TabButton
- id={args.id}
- title={args.title}
- LeftIcon={args.LeftIcon}
- RightIcon={args.RightIcon}
- active={args.active}
- disabled={args.disabled}
- pill={args.pill}
- to={args.to}
- logo={args.logo}
- onClick={args.onClick}
- className={args.className}
- contentSize={args.contentSize}
- />
- </StyledTabContainer>
+ <TabContainer>
+ <TabButton {...args} />
+ </TabContainer>
),
};
@@ -305,22 +194,9 @@ export const Catalog: CatalogStory<Story, typeof TabButton> = {
to: { control: false },
},
render: (args) => (
- <StyledTabContainer>
- <TabButton
- id={args.id}
- title={args.title}
- LeftIcon={args.LeftIcon}
- RightIcon={args.RightIcon}
- active={args.active}
- disabled={args.disabled}
- pill={args.pill}
- to={args.to}
- logo={args.logo}
- onClick={args.onClick}
- className={args.className}
- contentSize={args.contentSize}
- />
- </StyledTabContainer>
+ <TabContainer>
+ <TabButton {...args} />
+ </TabContainer>
),
parameters: {
pseudo: { hover: ['.hover'], active: ['.active'] },
diff --git a/packages/twenty-ui/src/input/code-editor/components/CodeEditor.tsx b/packages/twenty-ui/src/input/code-editor/components/CodeEditor.tsx
index 803b6ff6f0c..35bfd31acdd 100644
--- a/packages/twenty-ui/src/input/code-editor/components/CodeEditor.tsx
+++ b/packages/twenty-ui/src/input/code-editor/components/CodeEditor.tsx
@@ -1,11 +1,11 @@
-import { css, useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import Editor, { type EditorProps, type Monaco } from '@monaco-editor/react';
import { Loader } from '@ui/feedback/loader/components/Loader';
import { BASE_CODE_EDITOR_THEME_ID } from '@ui/input/code-editor/constants/BaseCodeEditorThemeId';
import { getBaseCodeEditorTheme } from '@ui/input/code-editor/theme/utils/getBaseCodeEditorTheme';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
import { type editor } from 'monaco-editor';
-import { type KeyboardEvent, useState } from 'react';
+import { type KeyboardEvent, useContext, useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
type CodeEditorVariant = 'default' | 'with-header' | 'borderless';
@@ -30,72 +30,78 @@ const StyledEditorLoader = styled.div<{
height: ${({ height }) =>
typeof height === 'number' ? `${height}px` : height};
justify-content: center;
- border: 1px solid ${({ theme }) => theme.border.color.medium};
- background-color: ${({ theme }) => theme.background.transparent.lighter};
- ${({ variant, theme }) => {
+ border: ${({ variant }) =>
+ variant === 'borderless'
+ ? 'none'
+ : `1px solid ${themeCssVariables.border.color.medium}`};
+ border-top: ${({ variant }) => {
+ if (variant === 'default')
+ return `1px solid ${themeCssVariables.border.color.medium}`;
+ return 'none';
+ }};
+ border-radius: ${({ variant }) => {
switch (variant) {
case 'default':
- return css`
- border-radius: ${theme.border.radius.sm};
- `;
- case 'borderless':
- return css`
- border: none;
- `;
+ return themeCssVariables.border.radius.sm;
case 'with-header':
- return css`
- border-radius: 0 0 ${theme.border.radius.sm} ${theme.border.radius.sm};
- border-top: none;
- `;
+ return `0 0 ${themeCssVariables.border.radius.sm} ${themeCssVariables.border.radius.sm}`;
+ default:
+ return '0';
}
- }}
+ }};
+ background-color: ${themeCssVariables.background.transparent.lighter};
`;
const StyledCodeEditorContainer = styled.div`
display: contents;
`;
-const StyledEditor = styled(Editor)<{
+const StyledEditorWrapper = styled.div<{
variant: CodeEditorVariant;
transparentBackground?: boolean;
}>`
+ display: contents;
+
.monaco-editor {
outline-width: 0;
- ${({ theme, transparentBackground }) =>
- !transparentBackground &&
- css`
- background-color: ${theme.background.secondary};
- `}
-
- ${({ variant, theme }) =>
- variant !== 'borderless' &&
- css`
- border-radius: ${theme.border.radius.sm};
- `}
+ background-color: ${({ transparentBackground }) =>
+ !transparentBackground
+ ? themeCssVariables.background.secondary
+ : 'transparent'};
+
+ border-radius: ${({ variant }) =>
+ variant !== 'borderless' ? themeCssVariables.border.radius.sm : '0'};
}
.overflow-guard {
box-sizing: border-box;
- ${({ variant, theme }) => {
+ border: ${({ variant }) => {
switch (variant) {
- case 'default': {
- return css`
- border: 1px solid ${theme.border.color.medium};
- border-radius: ${theme.border.radius.sm};
- `;
- }
- case 'with-header': {
- return css`
- border: 1px solid ${theme.border.color.medium};
- border-radius: 0 0 ${theme.border.radius.sm}
- ${theme.border.radius.sm};
- border-top: none;
- `;
- }
+ case 'default':
+ case 'with-header':
+ return `1px solid ${themeCssVariables.border.color.medium}`;
+ default:
+ return 'none';
}
- }}
+ }};
+ border-radius: ${({ variant }) => {
+ switch (variant) {
+ case 'default':
+ return themeCssVariables.border.radius.sm;
+ case 'with-header':
+ return `0 0 ${themeCssVariables.border.radius.sm} ${themeCssVariables.border.radius.sm}`;
+ default:
+ return '0';
+ }
+ }};
+ border-top: ${({ variant }) => {
+ if (variant === 'with-header') return 'none';
+ if (variant === 'default')
+ return `1px solid ${themeCssVariables.border.color.medium}`;
+ return 'none';
+ }};
}
`;
@@ -112,7 +118,7 @@ export const CodeEditor = ({
isLoading = false,
options,
}: CodeEditorProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const [monaco, setMonaco] = useState<Monaco | undefined>(undefined);
const [editor, setEditor] = useState<
editor.IStandaloneCodeEditor | undefined
@@ -151,58 +157,61 @@ export const CodeEditor = ({
value={value ?? ''}
readOnly
/>
- <StyledEditor
- height={height}
+ <StyledEditorWrapper
variant={variant}
- value={value}
- language={language}
- loading=""
transparentBackground={transparentBackground}
- onMount={(editor, monaco) => {
- setMonaco(monaco);
- setEditor(editor);
-
- monaco.editor.defineTheme(
- BASE_CODE_EDITOR_THEME_ID,
- getBaseCodeEditorTheme({
- theme,
- }),
- );
- monaco.editor.setTheme(BASE_CODE_EDITOR_THEME_ID);
-
- editor.onDidFocusEditorWidget(() => {
- setIsEditorFocused(true);
- });
- editor.onDidBlurEditorWidget(() => {
- setIsEditorFocused(false);
- });
-
- onMount?.(editor, monaco);
- setModelMarkers(editor, monaco);
- }}
- onChange={(value) => {
- if (isDefined(value)) {
- onChange?.(value);
+ >
+ <Editor
+ height={height}
+ value={value}
+ language={language}
+ loading=""
+ onMount={(editor, monaco) => {
+ setMonaco(monaco);
+ setEditor(editor);
+
+ monaco.editor.defineTheme(
+ BASE_CODE_EDITOR_THEME_ID,
+ getBaseCodeEditorTheme({
+ theme,
+ }),
+ );
+ monaco.editor.setTheme(BASE_CODE_EDITOR_THEME_ID);
+
+ editor.onDidFocusEditorWidget(() => {
+ setIsEditorFocused(true);
+ });
+ editor.onDidBlurEditorWidget(() => {
+ setIsEditorFocused(false);
+ });
+
+ onMount?.(editor, monaco);
setModelMarkers(editor, monaco);
- }
- }}
- onValidate={(markers) => {
- onValidate?.(markers);
- }}
- options={{
- formatOnPaste: true,
- formatOnType: true,
- overviewRulerLanes: 0,
- scrollbar: {
- vertical: 'hidden',
- horizontal: 'hidden',
- },
- minimap: {
- enabled: false,
- },
- ...options,
- }}
- />
+ }}
+ onChange={(value) => {
+ if (isDefined(value)) {
+ onChange?.(value);
+ setModelMarkers(editor, monaco);
+ }
+ }}
+ onValidate={(markers) => {
+ onValidate?.(markers);
+ }}
+ options={{
+ formatOnPaste: true,
+ formatOnType: true,
+ overviewRulerLanes: 0,
+ scrollbar: {
+ vertical: 'hidden',
+ horizontal: 'hidden',
+ },
+ minimap: {
+ enabled: false,
+ },
+ ...options,
+ }}
+ />
+ </StyledEditorWrapper>
</StyledCodeEditorContainer>
);
};
diff --git a/packages/twenty-ui/src/input/code-editor/components/CodeEditorHeader.tsx b/packages/twenty-ui/src/input/code-editor/components/CodeEditorHeader.tsx
index 0ac5904784d..d1212e0f947 100644
--- a/packages/twenty-ui/src/input/code-editor/components/CodeEditorHeader.tsx
+++ b/packages/twenty-ui/src/input/code-editor/components/CodeEditorHeader.tsx
@@ -1,23 +1,25 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+
+import { themeCssVariables } from '@ui/theme';
const StyledEditorHeader = styled.div`
align-items: center;
- background-color: ${({ theme }) => theme.background.transparent.lighter};
- color: ${({ theme }) => theme.font.color.tertiary};
- font-weight: ${({ theme }) => theme.font.weight.medium};
+ background-color: ${themeCssVariables.background.transparent.lighter};
+ color: ${themeCssVariables.font.color.tertiary};
+ font-weight: ${themeCssVariables.font.weight.medium};
display: flex;
- height: ${({ theme }) => theme.spacing(10)};
- padding: ${({ theme }) => `0 ${theme.spacing(2)}`};
- border: 1px solid ${({ theme }) => theme.border.color.medium};
- border-top-left-radius: ${({ theme }) => theme.border.radius.sm};
- border-top-right-radius: ${({ theme }) => theme.border.radius.sm};
+ height: ${themeCssVariables.spacing[10]};
+ padding: 0 ${themeCssVariables.spacing[2]};
+ border: 1px solid ${themeCssVariables.border.color.medium};
+ border-top-left-radius: ${themeCssVariables.border.radius.sm};
+ border-top-right-radius: ${themeCssVariables.border.radius.sm};
justify-content: space-between;
`;
const StyledElementContainer = styled.div`
align-content: flex-end;
display: flex;
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
`;
export type CoreEditorHeaderProps = {
diff --git a/packages/twenty-ui/src/input/color-scheme/components/ColorSchemeCard.tsx b/packages/twenty-ui/src/input/color-scheme/components/ColorSchemeCard.tsx
index ac55d9f18b3..67cde275d35 100644
--- a/packages/twenty-ui/src/input/color-scheme/components/ColorSchemeCard.tsx
+++ b/packages/twenty-ui/src/input/color-scheme/components/ColorSchemeCard.tsx
@@ -1,7 +1,11 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { Checkmark } from '@ui/display/checkmark/components/Checkmark';
import { type ColorScheme } from '@ui/input/types/ColorScheme';
-import { GRAY_SCALE_DARK, GRAY_SCALE_LIGHT } from '@ui/theme';
+import {
+ GRAY_SCALE_DARK,
+ GRAY_SCALE_LIGHT,
+ themeCssVariables,
+} from '@ui/theme';
import {
AnimatePresence,
type AnimationControls,
@@ -32,19 +36,19 @@ const StyledColorSchemeBackground = styled.div<
return `1px solid ${GRAY_SCALE_LIGHT.gray5};`;
}
}};
- border-radius: ${({ theme }) => theme.border.radius.md};
+ border-radius: ${themeCssVariables.border.radius.md};
box-sizing: border-box;
cursor: pointer;
display: flex;
height: 80px;
justify-content: flex-end;
overflow: hidden;
- padding-left: ${({ theme }) => theme.spacing(6)};
- padding-top: ${({ theme }) => theme.spacing(6)};
+ padding-left: ${themeCssVariables.spacing[6]};
+ padding-top: ${themeCssVariables.spacing[6]};
width: 160px;
`;
-const StyledColorSchemeContent = styled(motion.div)<
+const StyledColorSchemeContentBase = styled.div<
Pick<ColorSchemeCardProps, 'variant'>
>`
background: ${({ variant }) => {
@@ -54,6 +58,7 @@ const StyledColorSchemeContent = styled(motion.div)<
case 'Light':
return GRAY_SCALE_LIGHT.gray1;
}
+ return '';
}};
border-left: ${({ variant }) => {
@@ -65,7 +70,7 @@ const StyledColorSchemeContent = styled(motion.div)<
return `1px solid ${GRAY_SCALE_LIGHT.gray5};`;
}
}};
- border-radius: ${({ theme }) => theme.border.radius.md} 0px 0px 0px;
+ border-radius: ${themeCssVariables.border.radius.md} 0px 0px 0px;
border-top: ${({ variant }) => {
switch (variant) {
case 'Dark':
@@ -89,10 +94,12 @@ const StyledColorSchemeContent = styled(motion.div)<
flex: 1;
font-size: 20px;
height: 56px;
- padding-left: ${({ theme }) => theme.spacing(2)};
- padding-top: ${({ theme }) => theme.spacing(2)};
+ padding-left: ${themeCssVariables.spacing[2]};
+ padding-top: ${themeCssVariables.spacing[2]};
`;
+const StyledColorSchemeContent = motion.create(StyledColorSchemeContentBase);
+
export type ColorSchemeSegmentProps = {
variant: ColorScheme;
controls: AnimationControls;
@@ -107,16 +114,18 @@ const ColorSchemeSegment = ({
onClick,
onMouseEnter,
onMouseLeave,
-}: ColorSchemeSegmentProps) => (
- <StyledColorSchemeBackground
- className={className}
- {...{ variant, style, onClick, onMouseEnter, onMouseLeave }}
- >
- <StyledColorSchemeContent animate={controls} variant={variant}>
- Aa
- </StyledColorSchemeContent>
- </StyledColorSchemeBackground>
-);
+}: ColorSchemeSegmentProps) => {
+ return (
+ <StyledColorSchemeBackground
+ className={className}
+ {...{ variant, style, onClick, onMouseEnter, onMouseLeave }}
+ >
+ <StyledColorSchemeContent animate={controls} variant={variant}>
+ Aa
+ </StyledColorSchemeContent>
+ </StyledColorSchemeBackground>
+ );
+};
const StyledContainer = styled.div`
position: relative;
@@ -124,7 +133,7 @@ const StyledContainer = styled.div`
`;
const StyledMixedColorSchemeSegment = styled.div`
- border-radius: ${({ theme }) => theme.border.radius.md};
+ border-radius: ${themeCssVariables.border.radius.md};
cursor: pointer;
display: flex;
height: 80px;
@@ -133,13 +142,15 @@ const StyledMixedColorSchemeSegment = styled.div`
width: 160px;
`;
-const StyledCheckmarkContainer = styled(motion.div)`
+const StyledCheckmarkContainerBase = styled.div`
bottom: 0px;
- padding: ${({ theme }) => theme.spacing(2)};
+ padding: ${themeCssVariables.spacing[2]};
position: absolute;
right: 0px;
`;
+const StyledCheckmarkContainer = motion.create(StyledCheckmarkContainerBase);
+
export type ColorSchemeCardProps = {
variant: ColorScheme;
selected?: boolean;
diff --git a/packages/twenty-ui/src/input/color-scheme/components/ColorSchemePicker.tsx b/packages/twenty-ui/src/input/color-scheme/components/ColorSchemePicker.tsx
index 1346bf3b491..76e21fe20d7 100644
--- a/packages/twenty-ui/src/input/color-scheme/components/ColorSchemePicker.tsx
+++ b/packages/twenty-ui/src/input/color-scheme/components/ColorSchemePicker.tsx
@@ -1,14 +1,14 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type ColorScheme } from '@ui/input/types/ColorScheme';
-import { MOBILE_VIEWPORT } from '@ui/theme';
+import { MOBILE_VIEWPORT, themeCssVariables } from '@ui/theme';
import { ColorSchemeCard } from './ColorSchemeCard';
const StyledContainer = styled.div`
display: flex;
flex-direction: row;
> * + * {
- margin-left: ${({ theme }) => theme.spacing(4)};
+ margin-left: ${themeCssVariables.spacing[4]};
}
@media (max-width: ${MOBILE_VIEWPORT}px) {
overflow: scroll;
@@ -21,10 +21,10 @@ const StyledCardContainer = styled.div`
`;
const StyledLabel = styled.span`
- color: ${({ theme }) => theme.font.color.secondary};
- font-size: ${({ theme }) => theme.font.size.xs};
- font-weight: ${({ theme }) => theme.font.weight.medium};
- margin-top: ${({ theme }) => theme.spacing(2)};
+ color: ${themeCssVariables.font.color.secondary};
+ font-size: ${themeCssVariables.font.size.xs};
+ font-weight: ${themeCssVariables.font.weight.medium};
+ margin-top: ${themeCssVariables.spacing[2]};
`;
export type ColorSchemePickerProps = {
@@ -43,31 +43,33 @@ export const ColorSchemePicker = ({
lightLabel,
darkLabel,
systemLabel,
-}: ColorSchemePickerProps) => (
- <StyledContainer className={className}>
- <StyledCardContainer>
- <ColorSchemeCard
- onClick={() => onChange('Light')}
- variant="Light"
- selected={value === 'Light'}
- />
- <StyledLabel>{lightLabel}</StyledLabel>
- </StyledCardContainer>
- <StyledCardContainer>
- <ColorSchemeCard
- onClick={() => onChange('Dark')}
- variant="Dark"
- selected={value === 'Dark'}
- />
- <StyledLabel>{darkLabel}</StyledLabel>
- </StyledCardContainer>
- <StyledCardContainer>
- <ColorSchemeCard
- onClick={() => onChange('System')}
- variant="System"
- selected={value === 'System'}
- />
- <StyledLabel>{systemLabel}</StyledLabel>
- </StyledCardContainer>
- </StyledContainer>
-);
+}: ColorSchemePickerProps) => {
+ return (
+ <StyledContainer className={className}>
+ <StyledCardContainer>
+ <ColorSchemeCard
+ onClick={() => onChange('Light')}
+ variant="Light"
+ selected={value === 'Light'}
+ />
+ <StyledLabel>{lightLabel}</StyledLabel>
+ </StyledCardContainer>
+ <StyledCardContainer>
+ <ColorSchemeCard
+ onClick={() => onChange('Dark')}
+ variant="Dark"
+ selected={value === 'Dark'}
+ />
+ <StyledLabel>{darkLabel}</StyledLabel>
+ </StyledCardContainer>
+ <StyledCardContainer>
+ <ColorSchemeCard
+ onClick={() => onChange('System')}
+ variant="System"
+ selected={value === 'System'}
+ />
+ <StyledLabel>{systemLabel}</StyledLabel>
+ </StyledCardContainer>
+ </StyledContainer>
+ );
+};
diff --git a/packages/twenty-ui/src/input/color-scheme/components/__stories__/ColorSchemeCard.stories.tsx b/packages/twenty-ui/src/input/color-scheme/components/__stories__/ColorSchemeCard.stories.tsx
index 74d534c00ed..70aa1264abf 100644
--- a/packages/twenty-ui/src/input/color-scheme/components/__stories__/ColorSchemeCard.stories.tsx
+++ b/packages/twenty-ui/src/input/color-scheme/components/__stories__/ColorSchemeCard.stories.tsx
@@ -1,10 +1,12 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { ComponentDecorator } from '@ui/testing';
+import { useContext } from 'react';
+import { ThemeContext, type ThemeType } from '@ui/theme';
import { ColorSchemeCard } from '../ColorSchemeCard';
-const StyledContainer = styled.div`
+const StyledContainer = styled.div<{ theme: ThemeType }>`
display: flex;
flex-direction: row;
> * + * {
@@ -16,11 +18,15 @@ const meta: Meta<typeof ColorSchemeCard> = {
title: 'UI/Input/ColorScheme/ColorSchemeCard',
component: ColorSchemeCard,
decorators: [
- (Story) => (
- <StyledContainer>
- <Story />
- </StyledContainer>
- ),
+ (Story) => {
+ const { theme } = useContext(ThemeContext);
+
+ return (
+ <StyledContainer theme={theme}>
+ <Story />
+ </StyledContainer>
+ );
+ },
ComponentDecorator,
],
argTypes: {
diff --git a/packages/twenty-ui/src/input/components/CardPicker.tsx b/packages/twenty-ui/src/input/components/CardPicker.tsx
index b5565371b20..6e77868ef83 100644
--- a/packages/twenty-ui/src/input/components/CardPicker.tsx
+++ b/packages/twenty-ui/src/input/components/CardPicker.tsx
@@ -1,26 +1,27 @@
import React from 'react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
import { Radio } from './Radio';
const StyledSubscriptionCardContainer = styled.button`
- background-color: ${({ theme }) => theme.background.secondary};
- border: 1px solid ${({ theme }) => theme.border.color.medium};
- border-radius: ${({ theme }) => theme.border.radius.md};
+ background-color: ${themeCssVariables.background.secondary};
+ border: 1px solid ${themeCssVariables.border.color.medium};
+ border-radius: ${themeCssVariables.border.radius.md};
display: flex;
- padding: ${({ theme }) => theme.spacing(4)} ${({ theme }) => theme.spacing(3)};
+ padding: ${themeCssVariables.spacing[4]} ${themeCssVariables.spacing[3]};
position: relative;
width: 100%;
:hover {
cursor: pointer;
- background: ${({ theme }) => theme.background.tertiary};
+ background: ${themeCssVariables.background.tertiary};
}
`;
const StyledRadioContainer = styled.div`
position: absolute;
- right: ${({ theme }) => theme.spacing(2)};
- top: ${({ theme }) => theme.spacing(2)};
+ right: ${themeCssVariables.spacing[2]};
+ top: ${themeCssVariables.spacing[2]};
`;
type CardPickerProps = {
diff --git a/packages/twenty-ui/src/input/components/Checkbox.tsx b/packages/twenty-ui/src/input/components/Checkbox.tsx
index 106876a18bf..9d17519680c 100644
--- a/packages/twenty-ui/src/input/components/Checkbox.tsx
+++ b/packages/twenty-ui/src/input/components/Checkbox.tsx
@@ -1,6 +1,7 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { IconCheck, IconMinus } from '@ui/display/icon/components/TablerIcons';
+import { themeCssVariables } from '@ui/theme';
import * as React from 'react';
export enum CheckboxVariant {
@@ -49,133 +50,140 @@ type InputProps = {
disabled?: boolean;
};
-const StyledInputContainer = styled.div<InputProps>`
- --size: ${({ checkboxSize, hoverable }) => {
+const StyledCheckboxContainer = styled.div<InputProps>`
+ --checkbox-outer-size: ${({ checkboxSize, hoverable }) => {
if (hoverable === true) {
return checkboxSize === CheckboxSize.Large ? '32px' : '24px';
} else {
return checkboxSize === CheckboxSize.Large ? '20px' : '14px';
}
}};
- align-items: center;
- border-radius: ${({ theme, shape }) =>
+ --checkbox-label-size: ${({ checkboxSize }) =>
+ checkboxSize === CheckboxSize.Large ? '18px' : '12px'};
+ --checkbox-icon-size: ${({ checkboxSize }) =>
+ checkboxSize === CheckboxSize.Large ? '20px' : '14px'};
+ --checkbox-bg: ${({ indeterminate, isChecked, disabled, accent }) => {
+ if (!(indeterminate || isChecked)) return 'transparent';
+ return disabled === true
+ ? accent === CheckboxAccent.Blue
+ ? themeCssVariables.color.blue7
+ : themeCssVariables.color.orange7
+ : accent === CheckboxAccent.Blue
+ ? themeCssVariables.color.blue
+ : themeCssVariables.color.orange;
+ }};
+ --checkbox-border-color: ${({
+ indeterminate,
+ isChecked,
+ variant,
+ disabled,
+ accent,
+ }) => {
+ switch (true) {
+ case indeterminate || isChecked:
+ return disabled === true
+ ? accent === CheckboxAccent.Blue
+ ? themeCssVariables.color.blue7
+ : themeCssVariables.color.orange7
+ : accent === CheckboxAccent.Blue
+ ? themeCssVariables.color.blue
+ : themeCssVariables.color.orange;
+ case disabled === true:
+ return themeCssVariables.border.color.strong;
+ case variant === CheckboxVariant.Primary:
+ return themeCssVariables.border.color.inverted;
+ case variant === CheckboxVariant.Tertiary:
+ return themeCssVariables.border.color.medium;
+ default:
+ return themeCssVariables.border.color.secondaryInverted;
+ }
+ }};
+ --checkbox-border-radius: ${({ shape }) =>
shape === CheckboxShape.Rounded
- ? theme.border.radius.rounded
- : theme.border.radius.md};
+ ? themeCssVariables.border.radius.rounded
+ : themeCssVariables.border.radius.sm};
+ --checkbox-border-width: ${({ variant, checkboxSize }) =>
+ checkboxSize === CheckboxSize.Large || variant === CheckboxVariant.Tertiary
+ ? '1.43px'
+ : '1px'};
+ --checkbox-cursor: ${({ disabled }) =>
+ disabled === true ? 'not-allowed' : 'pointer'};
+ --checkbox-stroke: ${themeCssVariables.font.color.inverted};
- cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
+ align-items: center;
+ border-radius: ${({ shape }) =>
+ shape === CheckboxShape.Rounded
+ ? themeCssVariables.border.radius.rounded
+ : themeCssVariables.border.radius.md};
+ cursor: var(--checkbox-cursor);
display: flex;
- padding: ${({ theme, checkboxSize, hoverable }) => {
+ padding: ${({ checkboxSize, hoverable }) => {
if (hoverable === true) {
- return checkboxSize === CheckboxSize.Large
- ? theme.spacing(1.5)
- : theme.spacing(1.25);
+ return checkboxSize === CheckboxSize.Large ? '6px' : '5px';
} else {
- return 0;
+ return '0';
}
}};
position: relative;
- ${({ hoverable, isChecked, theme, indeterminate, disabled, accent }) => {
- if (!hoverable || disabled === true) return '';
- return `&:hover{
- background-color: ${
- indeterminate || isChecked
- ? accent === CheckboxAccent.Blue
- ? theme.background.transparent.blue
- : theme.background.transparent.orange
- : theme.background.transparent.light
- };
- }}
- }`;
- }}
-`;
-
-const StyledInput = styled.input<InputProps>`
- cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
- margin: 0;
- opacity: 0;
- position: absolute;
- z-index: 10;
- & + label {
- --size: ${({ checkboxSize }) =>
- checkboxSize === CheckboxSize.Large ? '18px' : '12px'};
- cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
- height: calc(var(--size) + 2px);
- padding: 0;
- position: relative;
- width: calc(var(--size) + 2px);
- }
- & + label:before {
- --size: ${({ checkboxSize }) =>
- checkboxSize === CheckboxSize.Large ? '18px' : '12px'};
- background: ${({ theme, indeterminate, isChecked, disabled, accent }) => {
- if (!(indeterminate || isChecked)) return 'transparent';
- return disabled
- ? accent === CheckboxAccent.Blue
- ? theme.color.blue7
- : theme.color.orange7
- : accent === CheckboxAccent.Blue
- ? theme.color.blue
- : theme.color.orange;
- }};
- border-color: ${({
- theme,
- indeterminate,
+ &:hover {
+ background-color: ${({
+ hoverable,
isChecked,
- variant,
+ indeterminate,
disabled,
accent,
}) => {
- switch (true) {
- case indeterminate || isChecked:
- return disabled
- ? accent === CheckboxAccent.Blue
- ? theme.color.blue7
- : theme.color.orange7
- : accent === CheckboxAccent.Blue
- ? theme.color.blue
- : theme.color.orange;
- case disabled:
- return theme.border.color.strong;
- case variant === CheckboxVariant.Primary:
- return theme.border.color.inverted;
- case variant === CheckboxVariant.Tertiary:
- return theme.border.color.medium;
- default:
- return theme.border.color.secondaryInverted;
+ if (hoverable !== true || disabled === true) return 'transparent';
+ if (indeterminate === true || isChecked === true) {
+ return accent === CheckboxAccent.Blue
+ ? themeCssVariables.background.transparent.blue
+ : themeCssVariables.background.transparent.orange;
}
+ return themeCssVariables.background.transparent.light;
}};
- border-radius: ${({ theme, shape }) =>
- shape === CheckboxShape.Rounded
- ? theme.border.radius.rounded
- : theme.border.radius.sm};
+ }
+
+ input + label {
+ cursor: var(--checkbox-cursor);
+ height: calc(var(--checkbox-label-size) + 2px);
+ padding: 0;
+ position: relative;
+ width: calc(var(--checkbox-label-size) + 2px);
+ }
+
+ input + label:before {
+ background: var(--checkbox-bg);
+ border-color: var(--checkbox-border-color);
+ border-radius: var(--checkbox-border-radius);
border-style: solid;
- border-width: ${({ variant, checkboxSize }) =>
- checkboxSize === CheckboxSize.Large ||
- variant === CheckboxVariant.Tertiary
- ? '1.43px'
- : '1px'};
+ border-width: var(--checkbox-border-width);
content: '';
- cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
+ cursor: var(--checkbox-cursor);
display: inline-block;
- height: var(--size);
- width: var(--size);
+ height: var(--checkbox-label-size);
+ width: var(--checkbox-label-size);
}
- & + label > svg {
+ input + label > svg {
--padding: 0px;
- --size: ${({ checkboxSize }) =>
- checkboxSize === CheckboxSize.Large ? '20px' : '14px'};
- height: var(--size);
+ height: var(--checkbox-icon-size);
left: var(--padding);
position: absolute;
- stroke: ${({ theme }) => theme.font.color.inverted};
+ stroke: var(--checkbox-stroke);
top: var(--padding);
- width: var(--size);
+ width: var(--checkbox-icon-size);
}
`;
+const StyledCheckboxInput = styled.input`
+ cursor: ${({ disabled }) => (disabled === true ? 'not-allowed' : 'pointer')};
+ margin: 0;
+ opacity: 0;
+ position: absolute;
+ z-index: 10;
+`;
+
export const Checkbox = ({
checked,
onChange,
@@ -205,7 +213,7 @@ export const Checkbox = ({
const checkboxId = React.useId();
return (
- <StyledInputContainer
+ <StyledCheckboxContainer
checkboxSize={size}
variant={variant}
shape={shape}
@@ -216,21 +224,15 @@ export const Checkbox = ({
disabled={disabled}
accent={accent}
>
- <StyledInput
+ <StyledCheckboxInput
autoComplete="off"
type="checkbox"
id={checkboxId}
name="styled-checkbox"
data-testid="input-checkbox"
checked={isInternalChecked}
- indeterminate={indeterminate}
- variant={variant}
- checkboxSize={size}
- shape={shape}
- isChecked={isInternalChecked}
onChange={handleChange}
disabled={disabled}
- accent={accent}
/>
<label htmlFor={checkboxId}>
{indeterminate ? (
@@ -241,6 +243,6 @@ export const Checkbox = ({
<></>
)}
</label>
- </StyledInputContainer>
+ </StyledCheckboxContainer>
);
};
diff --git a/packages/twenty-ui/src/input/components/Radio.tsx b/packages/twenty-ui/src/input/components/Radio.tsx
index 7f3e003ff35..8b338acba44 100644
--- a/packages/twenty-ui/src/input/components/Radio.tsx
+++ b/packages/twenty-ui/src/input/components/Radio.tsx
@@ -1,6 +1,8 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { motion } from 'framer-motion';
import * as React from 'react';
+
+import { themeCssVariables } from '@ui/theme';
import { RadioGroup } from './RadioGroup';
export enum RadioSize {
@@ -30,12 +32,12 @@ type RadioInputProps = {
'radio-size'?: RadioSize;
};
-const StyledRadioInput = styled(motion.input)<RadioInputProps>`
+const StyledRadioInputBase = styled.input<RadioInputProps>`
-webkit-appearance: none;
appearance: none;
background-color: transparent;
- border: 1px solid ${({ theme }) => theme.font.color.secondary};
- border-radius: ${({ theme }) => theme.border.radius.rounded};
+ border: 1px solid ${themeCssVariables.font.color.secondary};
+ border-radius: ${themeCssVariables.border.radius.rounded};
height: ${({ 'radio-size': radioSize }) =>
radioSize === RadioSize.Large ? '18px' : '16px'};
margin: 0;
@@ -45,25 +47,26 @@ const StyledRadioInput = styled(motion.input)<RadioInputProps>`
radioSize === RadioSize.Large ? '18px' : '16px'};
:hover {
- background-color: ${({ theme, checked }) => {
+ background-color: ${({ checked }) => {
if (!checked) {
- return theme.background.tertiary;
+ return themeCssVariables.background.tertiary;
}
+ return '';
}};
outline: 4px solid
- ${({ theme, checked }) => {
+ ${({ checked }) => {
if (!checked) {
- return theme.background.tertiary;
+ return themeCssVariables.background.tertiary;
}
- return theme.color.transparent.blue2;
+ return themeCssVariables.color.transparent.blue2;
}};
}
&:checked {
- background-color: ${({ theme }) => theme.color.blue};
+ background-color: ${themeCssVariables.color.blue};
border: none;
&::after {
- background-color: ${({ theme }) => theme.grayScale.gray1};
+ background-color: ${themeCssVariables.grayScale.gray1};
border-radius: 50%;
content: '';
height: ${({ 'radio-size': radioSize }) =>
@@ -83,20 +86,26 @@ const StyledRadioInput = styled(motion.input)<RadioInputProps>`
}
`;
+const StyledRadioInput = motion.create(StyledRadioInputBase);
+
type LabelProps = {
disabled?: boolean;
labelPosition?: LabelPosition;
};
const StyledLabel = styled.label<LabelProps>`
- color: ${({ theme }) => theme.font.color.primary};
+ color: ${themeCssVariables.font.color.primary};
cursor: pointer;
- font-size: ${({ theme }) => theme.font.size.sm};
- font-weight: ${({ theme }) => theme.font.weight.regular};
- margin-left: ${({ theme, labelPosition }) =>
- labelPosition === LabelPosition.Right ? theme.spacing(2) : '0px'};
- margin-right: ${({ theme, labelPosition }) =>
- labelPosition === LabelPosition.Left ? theme.spacing(2) : '0px'};
+ font-size: ${themeCssVariables.font.size.sm};
+ font-weight: ${themeCssVariables.font.weight.regular};
+ margin-left: ${({ labelPosition }) =>
+ labelPosition === LabelPosition.Right
+ ? themeCssVariables.spacing[2]
+ : '0px'};
+ margin-right: ${({ labelPosition }) =>
+ labelPosition === LabelPosition.Left
+ ? themeCssVariables.spacing[2]
+ : '0px'};
opacity: ${({ disabled }) => (disabled ? 0.32 : 1)};
`;
diff --git a/packages/twenty-ui/src/input/components/RadioGroup.tsx b/packages/twenty-ui/src/input/components/RadioGroup.tsx
index c8f2aede5d0..6fc7806d0d2 100644
--- a/packages/twenty-ui/src/input/components/RadioGroup.tsx
+++ b/packages/twenty-ui/src/input/components/RadioGroup.tsx
@@ -1,7 +1,7 @@
import React from 'react';
-import { useTheme } from '@emotion/react';
import { type RadioProps } from './Radio';
+import { themeCssVariables } from '@ui/theme';
type RadioGroupProps = React.PropsWithChildren & {
value?: string;
@@ -15,8 +15,6 @@ export const RadioGroup = ({
onValueChange,
children,
}: RadioGroupProps) => {
- const theme = useTheme();
-
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
onChange?.(event);
onValueChange?.(event.target.value);
@@ -27,7 +25,7 @@ export const RadioGroup = ({
{React.Children.map(children, (child) => {
if (React.isValidElement<RadioProps>(child)) {
return React.cloneElement(child, {
- style: { marginBottom: theme.spacing(2) },
+ style: { marginBottom: themeCssVariables.spacing[2] },
checked: child.props.value === value,
onChange: handleChange,
});
diff --git a/packages/twenty-ui/src/input/components/SearchInput.tsx b/packages/twenty-ui/src/input/components/SearchInput.tsx
index 7329286be65..d2373d31f5f 100644
--- a/packages/twenty-ui/src/input/components/SearchInput.tsx
+++ b/packages/twenty-ui/src/input/components/SearchInput.tsx
@@ -1,8 +1,8 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { IconFilter, IconSearch } from '@ui/display';
import { IconButton } from '@ui/input/button/components/IconButton';
-import { type ChangeEvent, type ReactNode, useState } from 'react';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
+import { type ChangeEvent, type ReactNode, useContext, useState } from 'react';
export type SearchInputProps = {
value: string;
@@ -17,31 +17,35 @@ export type SearchInputProps = {
const StyledWrapper = styled.div`
align-items: center;
display: flex;
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
width: 100%;
`;
const StyledInputContainer = styled.div`
align-items: center;
- background-color: ${({ theme }) => theme.background.transparent.lighter};
- border: 1px solid ${({ theme }) => theme.border.color.medium};
- border-radius: ${({ theme }) => theme.border.radius.sm};
+ background-color: ${themeCssVariables.background.transparent.lighter};
+ border: 1px solid ${themeCssVariables.border.color.medium};
+ border-radius: ${themeCssVariables.border.radius.sm};
box-sizing: border-box;
display: flex;
flex: 1;
- gap: ${({ theme }) => theme.spacing(1)};
+ gap: ${themeCssVariables.spacing[1]};
height: 32px;
- padding: 0 ${({ theme }) => theme.spacing(2)};
+ padding: 0 ${themeCssVariables.spacing[2]};
&:focus-within {
- border-color: ${({ theme }) => theme.color.blue};
+ border-color: ${themeCssVariables.color.blue};
}
`;
-const StyledIconContainer = styled.div<{ isFocused: boolean }>`
+const StyledIconContainer = styled.div<{
+ isFocused: boolean;
+}>`
align-items: center;
- color: ${({ theme, isFocused }) =>
- isFocused ? theme.font.color.secondary : theme.font.color.light};
+ color: ${({ isFocused }) =>
+ isFocused
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.light};
display: flex;
justify-content: center;
`;
@@ -49,21 +53,21 @@ const StyledIconContainer = styled.div<{ isFocused: boolean }>`
const StyledInput = styled.input`
background: transparent;
border: none;
- color: ${({ theme }) => theme.font.color.primary};
+ color: ${themeCssVariables.font.color.primary};
flex: 1;
- font-family: ${({ theme }) => theme.font.family};
- font-size: ${({ theme }) => theme.font.size.md};
- font-weight: ${({ theme }) => theme.font.weight.regular};
+ font-family: ${themeCssVariables.font.family};
+ font-size: ${themeCssVariables.font.size.md};
+ font-weight: ${themeCssVariables.font.weight.regular};
outline: none;
width: 100%;
&::placeholder {
- color: ${({ theme }) => theme.font.color.light};
- font-weight: ${({ theme }) => theme.font.weight.medium};
+ color: ${themeCssVariables.font.color.light};
+ font-weight: ${themeCssVariables.font.weight.medium};
}
&:disabled {
- color: ${({ theme }) => theme.font.color.tertiary};
+ color: ${themeCssVariables.font.color.tertiary};
}
`;
@@ -76,7 +80,7 @@ export const SearchInput = ({
disabled,
className,
}: SearchInputProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const [isFocused, setIsFocused] = useState(false);
const filterButton = <IconButton Icon={IconFilter} variant="secondary" />;
diff --git a/packages/twenty-ui/src/input/components/Toggle.tsx b/packages/twenty-ui/src/input/components/Toggle.tsx
index a1350549daa..83ea7fcf5dc 100644
--- a/packages/twenty-ui/src/input/components/Toggle.tsx
+++ b/packages/twenty-ui/src/input/components/Toggle.tsx
@@ -1,5 +1,6 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { VisibilityHiddenInput } from '@ui/accessibility';
+import { themeCssVariables } from '@ui/theme';
import { motion } from 'framer-motion';
export type ToggleSize = 'small' | 'medium';
@@ -13,8 +14,10 @@ type ContainerProps = {
const StyledContainer = styled.label<ContainerProps>`
align-items: center;
- background-color: ${({ theme, isOn, color }) =>
- isOn ? (color ?? theme.color.blue) : theme.background.transparent.medium};
+ background-color: ${({ isOn, color }) =>
+ isOn
+ ? (color ?? themeCssVariables.color.blue)
+ : themeCssVariables.background.transparent.medium};
border-radius: 10px;
cursor: pointer;
display: flex;
@@ -28,10 +31,10 @@ const StyledContainer = styled.label<ContainerProps>`
width: ${({ toggleSize }) => (toggleSize === 'small' ? 24 : 32)}px;
`;
-const StyledCircle = styled(motion.span)<{
+const StyledCircleBase = styled.span<{
size: ToggleSize;
}>`
- background-color: ${({ theme }) => theme.background.primary};
+ background-color: ${themeCssVariables.background.primary};
border-radius: 50%;
display: block;
height: ${({ size }) => (size === 'small' ? 12 : 16)}px;
@@ -40,6 +43,8 @@ const StyledCircle = styled(motion.span)<{
width: ${({ size }) => (size === 'small' ? 12 : 16)}px;
`;
+const StyledCircle = motion.create(StyledCircleBase);
+
export type ToggleProps = {
id?: string;
value?: boolean;
diff --git a/packages/twenty-ui/src/input/components/__stories__/SearchInput.stories.tsx b/packages/twenty-ui/src/input/components/__stories__/SearchInput.stories.tsx
new file mode 100644
index 00000000000..e454a75fc04
--- /dev/null
+++ b/packages/twenty-ui/src/input/components/__stories__/SearchInput.stories.tsx
@@ -0,0 +1,54 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { ComponentDecorator } from '@ui/testing';
+import { useState } from 'react';
+
+import { SearchInput } from '../SearchInput';
+
+type InteractiveSearchInputProps = {
+ placeholder?: string;
+ disabled?: boolean;
+ autoFocus?: boolean;
+ className?: string;
+};
+
+const InteractiveSearchInput = ({
+ placeholder,
+ disabled,
+ autoFocus,
+ className,
+}: InteractiveSearchInputProps) => {
+ const [value, setValue] = useState('');
+
+ return (
+ <SearchInput
+ value={value}
+ onChange={setValue}
+ placeholder={placeholder}
+ disabled={disabled}
+ autoFocus={autoFocus}
+ className={className}
+ />
+ );
+};
+
+const meta: Meta<typeof InteractiveSearchInput> = {
+ title: 'UI/Input/SearchInput',
+ component: InteractiveSearchInput,
+ decorators: [ComponentDecorator],
+};
+
+export default meta;
+type Story = StoryObj<typeof InteractiveSearchInput>;
+
+export const Default: Story = {
+ args: {
+ placeholder: 'Search...',
+ },
+};
+
+export const Disabled: Story = {
+ args: {
+ placeholder: 'Search...',
+ disabled: true,
+ },
+};
diff --git a/packages/twenty-ui/src/json-visualizer/components/JsonNestedNode.tsx b/packages/twenty-ui/src/json-visualizer/components/JsonNestedNode.tsx
index 689d4fdecc2..935bd21a4d7 100644
--- a/packages/twenty-ui/src/json-visualizer/components/JsonNestedNode.tsx
+++ b/packages/twenty-ui/src/json-visualizer/components/JsonNestedNode.tsx
@@ -1,14 +1,13 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { isNonEmptyString } from '@sniptt/guards';
import { type IconComponent } from '@ui/display';
import { JsonArrow } from '@ui/json-visualizer/components/internal/JsonArrow';
-import { JsonList } from '@ui/json-visualizer/components/internal/JsonList';
import { JsonNodeLabel } from '@ui/json-visualizer/components/internal/JsonNodeLabel';
import { JsonNodeValue } from '@ui/json-visualizer/components/internal/JsonNodeValue';
import { JsonNode } from '@ui/json-visualizer/components/JsonNode';
import { useJsonTreeContextOrThrow } from '@ui/json-visualizer/hooks/useJsonTreeContextOrThrow';
import { type JsonNodeHighlighting } from '@ui/json-visualizer/types/JsonNodeHighlighting';
-import { ANIMATION } from '@ui/theme';
+import { ANIMATION, themeCssVariables } from '@ui/theme';
import { AnimatePresence, motion } from 'framer-motion';
import { useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
@@ -22,15 +21,35 @@ const StyledContainer = styled.li`
const StyledLabelContainer = styled.div`
display: flex;
align-items: center;
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
`;
-const StyledElementsCount = styled.span<{ variant?: 'red' }>`
- color: ${({ theme, variant }) =>
- variant === 'red' ? theme.font.color.danger : theme.font.color.tertiary};
+const StyledElementsCount = styled.span<{
+ variant?: 'red';
+}>`
+ color: ${({ variant }) =>
+ variant === 'red'
+ ? themeCssVariables.font.color.danger
+ : themeCssVariables.font.color.tertiary};
`;
-const StyledJsonList = styled(JsonList)``.withComponent(motion.ul);
+const StyledJsonListBase = styled.ul<{
+ depth: number;
+}>`
+ margin: 0;
+ padding: 0;
+ display: grid;
+ row-gap: ${themeCssVariables.spacing[2]};
+ ${({ depth }) =>
+ depth > 0
+ ? `padding-left: ${themeCssVariables.spacing[8]};
+ > :first-of-type {
+ margin-top: ${themeCssVariables.spacing[2]};
+ }`
+ : ''}
+`;
+
+const StyledJsonList = motion.create(StyledJsonListBase);
export const JsonNestedNode = ({
label,
diff --git a/packages/twenty-ui/src/json-visualizer/components/JsonValueNode.tsx b/packages/twenty-ui/src/json-visualizer/components/JsonValueNode.tsx
index 6a7fa0d791c..fe1e48618d3 100644
--- a/packages/twenty-ui/src/json-visualizer/components/JsonValueNode.tsx
+++ b/packages/twenty-ui/src/json-visualizer/components/JsonValueNode.tsx
@@ -1,12 +1,13 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
import { JsonListItem } from '@ui/json-visualizer/components/internal/JsonListItem';
import { JsonNodeLabel } from '@ui/json-visualizer/components/internal/JsonNodeLabel';
import { JsonNodeValue } from '@ui/json-visualizer/components/internal/JsonNodeValue';
import { type JsonNodeHighlighting } from '@ui/json-visualizer/types/JsonNodeHighlighting';
+import { themeCssVariables } from '@ui/theme';
const StyledListItem = styled(JsonListItem)`
- column-gap: ${({ theme }) => theme.spacing(2)};
+ column-gap: ${themeCssVariables.spacing[2]};
`;
type JsonValueNodeProps = {
diff --git a/packages/twenty-ui/src/json-visualizer/components/internal/JsonArrow.tsx b/packages/twenty-ui/src/json-visualizer/components/internal/JsonArrow.tsx
index 73737db9b08..8e2b8a9a7fd 100644
--- a/packages/twenty-ui/src/json-visualizer/components/internal/JsonArrow.tsx
+++ b/packages/twenty-ui/src/json-visualizer/components/internal/JsonArrow.tsx
@@ -1,25 +1,29 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { VisibilityHidden } from '@ui/accessibility';
import { IconChevronDown } from '@ui/display';
import { useJsonTreeContextOrThrow } from '@ui/json-visualizer/hooks/useJsonTreeContextOrThrow';
-import { ANIMATION } from '@ui/theme';
+import { ANIMATION, ThemeContext, themeCssVariables } from '@ui/theme';
import { motion } from 'framer-motion';
+import { useContext } from 'react';
-const StyledButton = styled(motion.button)<{ variant?: 'blue' | 'red' }>`
+const StyledButton = styled.button<{
+ variant?: 'blue' | 'red';
+}>`
align-items: center;
- background-color: ${({ theme, variant }) =>
+ background-color: ${({ variant }) =>
+ variant === 'red'
+ ? themeCssVariables.background.danger
+ : themeCssVariables.background.transparent.lighter};
+ border-color: ${({ variant }) =>
variant === 'red'
- ? theme.background.danger
- : theme.background.transparent.lighter};
- border-color: ${({ theme, variant }) =>
- variant === 'red' ? theme.border.color.danger : theme.border.color.medium};
- border-radius: ${({ theme }) => theme.border.radius.sm};
+ ? themeCssVariables.border.color.danger
+ : themeCssVariables.border.color.medium};
+ border-radius: ${themeCssVariables.border.radius.sm};
border-style: solid;
border-width: 1px;
display: flex;
justify-content: center;
- padding-inline: ${({ theme }) => theme.spacing(1)};
+ padding-inline: ${themeCssVariables.spacing[1]};
height: 24px;
width: 24px;
box-sizing: border-box;
@@ -37,7 +41,7 @@ export const JsonArrow = ({
onClick: () => void;
variant?: 'blue' | 'red';
}) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const { arrowButtonCollapsedLabel, arrowButtonExpandedLabel } =
useJsonTreeContextOrThrow();
diff --git a/packages/twenty-ui/src/json-visualizer/components/internal/JsonList.tsx b/packages/twenty-ui/src/json-visualizer/components/internal/JsonList.tsx
index 9fb23958d0f..c6a5b560b93 100644
--- a/packages/twenty-ui/src/json-visualizer/components/internal/JsonList.tsx
+++ b/packages/twenty-ui/src/json-visualizer/components/internal/JsonList.tsx
@@ -1,22 +1,23 @@
-import { css } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
const StyledList = styled.ul<{ depth: number }>`
margin: 0;
padding: 0;
display: grid;
- row-gap: ${({ theme }) => theme.spacing(2)};
+ row-gap: ${themeCssVariables.spacing[2]};
- ${({ theme, depth }) =>
- depth > 0 &&
- css`
- padding-left: ${theme.spacing(8)};
+ ${({ depth }) =>
+ depth > 0
+ ? `
+ padding-left: ${themeCssVariables.spacing[8]};
> :first-of-type {
- margin-top: ${theme.spacing(2)};
+ margin-top: ${themeCssVariables.spacing[2]};
}
- `}
+ `
+ : ''}
`;
export { StyledList as JsonList };
diff --git a/packages/twenty-ui/src/json-visualizer/components/internal/JsonListItem.tsx b/packages/twenty-ui/src/json-visualizer/components/internal/JsonListItem.tsx
index ab6b28eb50b..186a0edef3f 100644
--- a/packages/twenty-ui/src/json-visualizer/components/internal/JsonListItem.tsx
+++ b/packages/twenty-ui/src/json-visualizer/components/internal/JsonListItem.tsx
@@ -1,4 +1,4 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
const StyledListItem = styled.li`
align-items: center;
diff --git a/packages/twenty-ui/src/json-visualizer/components/internal/JsonNodeLabel.tsx b/packages/twenty-ui/src/json-visualizer/components/internal/JsonNodeLabel.tsx
index 6d9459fcb32..8a7ad25c26d 100644
--- a/packages/twenty-ui/src/json-visualizer/components/internal/JsonNodeLabel.tsx
+++ b/packages/twenty-ui/src/json-visualizer/components/internal/JsonNodeLabel.tsx
@@ -1,40 +1,41 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
import { type JsonNodeHighlighting } from '@ui/json-visualizer/types/JsonNodeHighlighting';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
+import { useContext } from 'react';
const StyledLabelContainer = styled.span<{
highlighting?: JsonNodeHighlighting;
}>`
- background-color: ${({ theme, highlighting }) =>
+ background-color: ${({ highlighting }) =>
highlighting === 'blue'
- ? theme.color.blue3
+ ? themeCssVariables.color.blue3
: highlighting === 'red'
- ? theme.background.danger
- : theme.background.transparent.lighter};
- border-color: ${({ theme, highlighting }) =>
+ ? themeCssVariables.background.danger
+ : themeCssVariables.background.transparent.lighter};
+ border-color: ${({ highlighting }) =>
highlighting === 'blue'
- ? theme.color.blue5
+ ? themeCssVariables.color.blue5
: highlighting === 'red'
- ? theme.border.color.danger
- : theme.border.color.medium};
- color: ${({ theme, highlighting }) =>
+ ? themeCssVariables.border.color.danger
+ : themeCssVariables.border.color.medium};
+ color: ${({ highlighting }) =>
highlighting === 'blue'
- ? theme.color.blue
+ ? themeCssVariables.color.blue
: highlighting === 'red'
- ? theme.font.color.danger
- : theme.font.color.primary};
- border-radius: ${({ theme }) => theme.border.radius.sm};
+ ? themeCssVariables.font.color.danger
+ : themeCssVariables.font.color.primary};
+ border-radius: ${themeCssVariables.border.radius.sm};
border-style: solid;
border-width: 1px;
- column-gap: ${({ theme }) => theme.spacing(2)};
+ column-gap: ${themeCssVariables.spacing[2]};
display: inline-flex;
align-items: center;
height: 24px;
box-sizing: border-box;
- font-size: ${({ theme }) => theme.font.size.md};
+ font-size: ${themeCssVariables.font.size.md};
white-space: nowrap;
- padding-inline: ${({ theme }) => theme.spacing(2)};
+ padding-inline: ${themeCssVariables.spacing[2]};
> span {
align-items: center;
@@ -52,7 +53,7 @@ export const JsonNodeLabel = ({
Icon: IconComponent;
highlighting?: JsonNodeHighlighting | undefined;
}) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledLabelContainer highlighting={highlighting}>
diff --git a/packages/twenty-ui/src/json-visualizer/components/internal/JsonNodeValue.tsx b/packages/twenty-ui/src/json-visualizer/components/internal/JsonNodeValue.tsx
index 486b654127a..f5254df4f8f 100644
--- a/packages/twenty-ui/src/json-visualizer/components/internal/JsonNodeValue.tsx
+++ b/packages/twenty-ui/src/json-visualizer/components/internal/JsonNodeValue.tsx
@@ -1,18 +1,19 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { useJsonTreeContextOrThrow } from '@ui/json-visualizer/hooks/useJsonTreeContextOrThrow';
import { type JsonNodeHighlighting } from '@ui/json-visualizer/types/JsonNodeHighlighting';
+import { themeCssVariables } from '@ui/theme';
const StyledText = styled.span<{
highlighting: JsonNodeHighlighting | undefined;
}>`
align-items: center;
box-sizing: border-box;
- color: ${({ theme, highlighting }) =>
+ color: ${({ highlighting }) =>
highlighting === 'blue'
- ? theme.color.blue8
+ ? themeCssVariables.color.blue8
: highlighting === 'red'
- ? theme.color.red8
- : theme.font.color.tertiary};
+ ? themeCssVariables.color.red8
+ : themeCssVariables.font.color.tertiary};
display: inline-flex;
height: 24px;
line-height: 1;
diff --git a/packages/twenty-ui/src/layout/animated-expandable-container/__stories__/AnimatedExpandableContainer.stories.tsx b/packages/twenty-ui/src/layout/animated-expandable-container/__stories__/AnimatedExpandableContainer.stories.tsx
index 31dfca262e0..1ec8acca4dc 100644
--- a/packages/twenty-ui/src/layout/animated-expandable-container/__stories__/AnimatedExpandableContainer.stories.tsx
+++ b/packages/twenty-ui/src/layout/animated-expandable-container/__stories__/AnimatedExpandableContainer.stories.tsx
@@ -1,10 +1,11 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { ComponentDecorator } from '@ui/testing';
-import { useState } from 'react';
+import { useContext, useState } from 'react';
+import { ThemeContext, type ThemeType } from '@ui/theme';
import { AnimatedExpandableContainer } from '../components/AnimatedExpandableContainer';
-const StyledButton = styled.button`
+const StyledButton = styled.button<{ theme: ThemeType }>`
padding: ${({ theme }) => theme.spacing(2)} ${({ theme }) => theme.spacing(4)};
background-color: ${({ theme }) => theme.color.blue10};
color: ${({ theme }) => theme.font.color.primary};
@@ -19,11 +20,11 @@ const StyledButton = styled.button`
`;
const StyledButtonWrapper = styled.div<{ dimension: 'width' | 'height' }>`
- ${({ dimension }) => dimension === 'height' && `width: 600px;`}
- ${({ dimension }) => dimension === 'width' && `height: 300px;`}
+ height: ${({ dimension }) => (dimension === 'width' ? '300px' : 'auto')};
+ width: ${({ dimension }) => (dimension === 'height' ? '600px' : 'auto')};
`;
-const StyledExpandableWrapper = styled.div`
+const StyledExpandableWrapper = styled.div<{ theme: ThemeType }>`
background-color: ${({ theme }) => theme.background.primary};
height: 100%;
width: 100%;
@@ -32,11 +33,12 @@ const StyledExpandableWrapper = styled.div`
const StyledContent = styled.div<{
dimension: 'width' | 'height';
mode: 'scroll-height' | 'fit-content';
+ theme: ThemeType;
}>`
padding: ${({ theme }) => theme.spacing(3)};
- ${({ dimension, mode }) =>
- dimension === 'height' && mode === 'scroll-height' && `height: 200px;`}
- ${({ dimension }) => dimension === 'width' && `width: 400px;`}
+ height: ${({ dimension, mode }) =>
+ dimension === 'height' && mode === 'scroll-height' ? '200px' : 'auto'};
+ width: ${({ dimension }) => (dimension === 'width' ? '400px' : 'auto')};
p {
color: ${({ theme }) => theme.font.color.primary};
@@ -61,11 +63,12 @@ const AnimatedExpandableContainerWithButton = ({
isExpanded: initialIsExpanded,
...args
}: AnimatedExpandableContainerWithButtonProps) => {
+ const { theme } = useContext(ThemeContext);
const [isExpanded, setIsExpanded] = useState(initialIsExpanded);
return (
<StyledButtonWrapper dimension={args.dimension}>
- <StyledButton onClick={() => setIsExpanded(!isExpanded)}>
+ <StyledButton theme={theme} onClick={() => setIsExpanded(!isExpanded)}>
{isExpanded ? 'Collapse' : 'Expand'}
</StyledButton>
<AnimatedExpandableContainer
@@ -74,8 +77,12 @@ const AnimatedExpandableContainerWithButton = ({
mode={args.mode}
animationDurations={args.animationDurations}
>
- <StyledExpandableWrapper>
- <StyledContent dimension={args.dimension} mode={args.mode}>
+ <StyledExpandableWrapper theme={theme}>
+ <StyledContent
+ dimension={args.dimension}
+ mode={args.mode}
+ theme={theme}
+ >
<p>
This is some content inside the AnimatedExpandableContainer. It
will animate smoothly when expanding or collapsing.
diff --git a/packages/twenty-ui/src/layout/animated-expandable-container/components/AnimatedExpandableContainer.tsx b/packages/twenty-ui/src/layout/animated-expandable-container/components/AnimatedExpandableContainer.tsx
index 4f9bc75e39f..4cfedde570b 100644
--- a/packages/twenty-ui/src/layout/animated-expandable-container/components/AnimatedExpandableContainer.tsx
+++ b/packages/twenty-ui/src/layout/animated-expandable-container/components/AnimatedExpandableContainer.tsx
@@ -1,28 +1,14 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
import { type AnimationDimension } from '@ui/layout/animated-expandable-container/types/AnimationDimension';
import { type AnimationDurationObject } from '@ui/layout/animated-expandable-container/types/AnimationDurationObject';
import { type AnimationDurations } from '@ui/layout/animated-expandable-container/types/AnimationDurations';
import { type AnimationMode } from '@ui/layout/animated-expandable-container/types/AnimationMode';
import { type AnimationSize } from '@ui/layout/animated-expandable-container/types/AnimationSize';
import { getExpandableAnimationConfig } from '@ui/layout/animated-expandable-container/utils/getExpandableAnimationConfig';
+import { ThemeContext } from '@ui/theme';
import { AnimatePresence, motion } from 'framer-motion';
-import { type ReactNode, useRef, useState } from 'react';
+import { type ReactNode, useContext, useRef, useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
-const StyledMotionContainer = styled(motion.div)<{
- containAnimation: boolean;
-}>`
- ${({ containAnimation }) =>
- containAnimation &&
- `
- display: flex;
- flex-direction: column;
- overflow: hidden;
- width: 100%;
- `}
-`;
-
type AnimatedExpandableContainerProps = {
children: ReactNode;
isExpanded: boolean;
@@ -42,7 +28,7 @@ export const AnimatedExpandableContainer = ({
containAnimation = true,
initial = true,
}: AnimatedExpandableContainerProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const contentRef = useRef<HTMLDivElement>(null);
const [size, setSize] = useState<AnimationSize>(0);
@@ -75,17 +61,26 @@ export const AnimatedExpandableContainer = ({
return (
<AnimatePresence initial={initial}>
{isExpanded && (
- <StyledMotionContainer
- containAnimation={containAnimation}
+ <motion.div
ref={contentRef}
initial="initial"
animate="animate"
exit="exit"
variants={motionAnimationVariants}
onAnimationStart={updateSize}
+ style={
+ containAnimation
+ ? {
+ display: 'flex',
+ flexDirection: 'column',
+ overflow: 'hidden',
+ width: '100%',
+ }
+ : undefined
+ }
>
{children}
- </StyledMotionContainer>
+ </motion.div>
)}
</AnimatePresence>
);
diff --git a/packages/twenty-ui/src/layout/animated-placeholder/components/AnimatedPlaceholder.tsx b/packages/twenty-ui/src/layout/animated-placeholder/components/AnimatedPlaceholder.tsx
index 32343df6215..48b4c05aeb0 100644
--- a/packages/twenty-ui/src/layout/animated-placeholder/components/AnimatedPlaceholder.tsx
+++ b/packages/twenty-ui/src/layout/animated-placeholder/components/AnimatedPlaceholder.tsx
@@ -1,11 +1,11 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { BACKGROUND } from '@ui/layout/animated-placeholder/constants/Background';
import { DARK_BACKGROUND } from '@ui/layout/animated-placeholder/constants/DarkBackground';
import { DARK_MOVING_IMAGE } from '@ui/layout/animated-placeholder/constants/DarkMovingImage';
import { MOVING_IMAGE } from '@ui/layout/animated-placeholder/constants/MovingImage';
+import { ThemeContext } from '@ui/theme';
import { animate, motion, useMotionValue, useTransform } from 'framer-motion';
-import { useEffect } from 'react';
+import { useContext, useEffect } from 'react';
const StyledContainer = styled.div`
display: flex;
@@ -26,14 +26,8 @@ const StyledBackgroundImage = styled.img<StyledImageProps>`
type === 'error500' || type === 'error404' ? '245px' : '160px'};
`;
-const StyledMovingImage = styled(motion.img)<StyledImageProps>`
- position: absolute;
- max-width: ${({ type }) =>
- type === 'error500' || type === 'error404' ? '185px' : '130px'};
- max-height: ${({ type }) =>
- type === 'error500' || type === 'error404' ? '185px' : '130px'};
- z-index: 2;
-`;
+const getMovingImageSize = (type: string) =>
+ type === 'error500' || type === 'error404' ? '185px' : '130px';
export type AnimatedPlaceholderType =
| keyof typeof BACKGROUND
@@ -44,7 +38,7 @@ interface AnimatedPlaceholderProps {
}
export const AnimatedPlaceholder = ({ type }: AnimatedPlaceholderProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const x = useMotionValue(window.innerWidth / 2);
const y = useMotionValue(window.innerHeight / 2);
@@ -94,14 +88,20 @@ export const AnimatedPlaceholder = ({ type }: AnimatedPlaceholderProps) => {
alt=""
type={type}
/>
- <StyledMovingImage
+ <motion.img
src={
theme.name === 'dark' ? DARK_MOVING_IMAGE[type] : MOVING_IMAGE[type]
}
alt=""
- style={{ translateX, translateY }}
+ style={{
+ position: 'absolute',
+ maxWidth: getMovingImageSize(type),
+ maxHeight: getMovingImageSize(type),
+ zIndex: 2,
+ translateX,
+ translateY,
+ }}
transition={{ type: 'spring', stiffness: 100, damping: 10 }}
- type={type}
/>
</StyledContainer>
);
diff --git a/packages/twenty-ui/src/layout/animated-placeholder/components/EmptyPlaceholderStyled.tsx b/packages/twenty-ui/src/layout/animated-placeholder/components/EmptyPlaceholderStyled.tsx
index e942ef6c99b..de93d2d3dca 100644
--- a/packages/twenty-ui/src/layout/animated-placeholder/components/EmptyPlaceholderStyled.tsx
+++ b/packages/twenty-ui/src/layout/animated-placeholder/components/EmptyPlaceholderStyled.tsx
@@ -1,18 +1,47 @@
-import styled from '@emotion/styled';
-import { motion } from 'framer-motion';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
+import { type HTMLMotionProps, motion } from 'framer-motion';
+import { type ReactNode } from 'react';
-const StyledEmptyContainer = styled(motion.div)`
+const StyledEmptyContainerBase = styled.div`
align-items: center;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
- gap: ${({ theme }) => theme.spacing(6)};
+ gap: ${themeCssVariables.spacing[6]};
justify-content: center;
text-align: center;
`;
-export { StyledEmptyContainer as AnimatedPlaceholderEmptyContainer };
+const MotionEmptyContainer = motion.create(StyledEmptyContainerBase);
+
+type AnimatedPlaceholderEmptyContainerProps = Pick<
+ HTMLMotionProps<'div'>,
+ 'initial' | 'animate' | 'transition'
+> & {
+ children?: ReactNode;
+ className?: string;
+};
+
+export const AnimatedPlaceholderEmptyContainer = ({
+ children,
+ className,
+ initial,
+ animate,
+ transition,
+}: AnimatedPlaceholderEmptyContainerProps) => {
+ return (
+ <MotionEmptyContainer
+ className={className}
+ initial={initial}
+ animate={animate}
+ transition={transition}
+ >
+ {children}
+ </MotionEmptyContainer>
+ );
+};
export const EMPTY_PLACEHOLDER_TRANSITION_PROPS = {
initial: { opacity: 0 },
@@ -22,34 +51,31 @@ export const EMPTY_PLACEHOLDER_TRANSITION_PROPS = {
},
};
-const StyledEmptyTextContainer = styled.div`
+// eslint-disable-next-line twenty/styled-components-prefixed-with-styled
+export const AnimatedPlaceholderEmptyTextContainer = styled.div`
align-items: center;
display: flex;
flex-direction: column;
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
justify-content: center;
text-align: center;
width: 100%;
`;
-export { StyledEmptyTextContainer as AnimatedPlaceholderEmptyTextContainer };
-
-const StyledEmptyTitle = styled.div`
- color: ${({ theme }) => theme.font.color.primary};
- font-size: ${({ theme }) => theme.font.size.lg};
- font-weight: ${({ theme }) => theme.font.weight.semiBold};
+// eslint-disable-next-line twenty/styled-components-prefixed-with-styled
+export const AnimatedPlaceholderEmptyTitle = styled.div`
+ color: ${themeCssVariables.font.color.primary};
+ font-size: ${themeCssVariables.font.size.lg};
+ font-weight: ${themeCssVariables.font.weight.semiBold};
`;
-export { StyledEmptyTitle as AnimatedPlaceholderEmptyTitle };
-
-const StyledEmptySubTitle = styled.div`
- color: ${({ theme }) => theme.font.color.tertiary};
- font-size: ${({ theme }) => theme.font.size.sm};
- font-weight: ${({ theme }) => theme.font.weight.regular};
- line-height: ${({ theme }) => theme.text.lineHeight.lg};
+// eslint-disable-next-line twenty/styled-components-prefixed-with-styled
+export const AnimatedPlaceholderEmptySubTitle = styled.div`
+ color: ${themeCssVariables.font.color.tertiary};
+ font-size: ${themeCssVariables.font.size.sm};
+ font-weight: ${themeCssVariables.font.weight.regular};
+ line-height: ${themeCssVariables.text.lineHeight.lg};
max-height: 2.8em;
overflow: hidden;
width: 50%;
`;
-
-export { StyledEmptySubTitle as AnimatedPlaceholderEmptySubTitle };
diff --git a/packages/twenty-ui/src/layout/animated-placeholder/components/ErrorPlaceholderStyled.tsx b/packages/twenty-ui/src/layout/animated-placeholder/components/ErrorPlaceholderStyled.tsx
index 99790b58b50..ec5066817f7 100644
--- a/packages/twenty-ui/src/layout/animated-placeholder/components/ErrorPlaceholderStyled.tsx
+++ b/packages/twenty-ui/src/layout/animated-placeholder/components/ErrorPlaceholderStyled.tsx
@@ -1,46 +1,43 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
-const StyledErrorContainer = styled.div`
+// eslint-disable-next-line twenty/styled-components-prefixed-with-styled
+export const AnimatedPlaceholderErrorContainer = styled.div`
align-items: center;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
- gap: ${({ theme }) => theme.spacing(8)};
+ gap: ${themeCssVariables.spacing[8]};
justify-content: center;
text-align: center;
`;
-export { StyledErrorContainer as AnimatedPlaceholderErrorContainer };
-
-const StyledErrorTextContainer = styled.div`
+// eslint-disable-next-line twenty/styled-components-prefixed-with-styled
+export const AnimatedPlaceholderErrorTextContainer = styled.div`
align-items: center;
display: flex;
flex-direction: column;
- gap: ${({ theme }) => theme.spacing(4)};
+ gap: ${themeCssVariables.spacing[4]};
justify-content: center;
text-align: center;
width: 100%;
`;
-export { StyledErrorTextContainer as AnimatedPlaceholderErrorTextContainer };
-
-const StyledErrorTitle = styled.div`
- color: ${({ theme }) => theme.font.color.primary};
- font-size: ${({ theme }) => theme.font.size.xl};
- font-weight: ${({ theme }) => theme.font.weight.semiBold};
- line-height: ${({ theme }) => theme.text.lineHeight.lg};
+// eslint-disable-next-line twenty/styled-components-prefixed-with-styled
+export const AnimatedPlaceholderErrorTitle = styled.div`
+ color: ${themeCssVariables.font.color.primary};
+ font-size: ${themeCssVariables.font.size.xl};
+ font-weight: ${themeCssVariables.font.weight.semiBold};
+ line-height: ${themeCssVariables.text.lineHeight.lg};
`;
-export { StyledErrorTitle as AnimatedPlaceholderErrorTitle };
-
-const StyledErrorSubTitle = styled.div`
- color: ${({ theme }) => theme.font.color.tertiary};
- font-size: ${({ theme }) => theme.font.size.xs};
- font-weight: ${({ theme }) => theme.font.weight.regular};
- line-height: ${({ theme }) => theme.text.lineHeight.md};
+// eslint-disable-next-line twenty/styled-components-prefixed-with-styled
+export const AnimatedPlaceholderErrorSubTitle = styled.div`
+ color: ${themeCssVariables.font.color.tertiary};
+ font-size: ${themeCssVariables.font.size.xs};
+ font-weight: ${themeCssVariables.font.weight.regular};
+ line-height: ${themeCssVariables.text.lineHeight.md};
max-height: 2.4em;
overflow: hidden;
`;
-
-export { StyledErrorSubTitle as AnimatedPlaceholderErrorSubTitle };
diff --git a/packages/twenty-ui/src/layout/card/components/Card.tsx b/packages/twenty-ui/src/layout/card/components/Card.tsx
index 9064aae9ecc..eb3891da758 100644
--- a/packages/twenty-ui/src/layout/card/components/Card.tsx
+++ b/packages/twenty-ui/src/layout/card/components/Card.tsx
@@ -1,12 +1,42 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
+import { type ComponentPropsWithoutRef } from 'react';
-const StyledCard = styled.div<{ fullWidth?: boolean; rounded?: boolean }>`
- border: 1px solid ${({ theme }) => theme.border.color.medium};
- border-radius: ${({ theme, rounded }) =>
- rounded ? theme.border.radius.md : theme.border.radius.sm};
- color: ${({ theme }) => theme.font.color.secondary};
+const StyledCard = styled.div<{
+ fullWidth?: boolean;
+ rounded?: boolean;
+}>`
+ border: 1px solid ${themeCssVariables.border.color.medium};
+ border-radius: ${({ rounded }) =>
+ rounded
+ ? themeCssVariables.border.radius.md
+ : themeCssVariables.border.radius.sm};
+ color: ${themeCssVariables.font.color.secondary};
overflow: hidden;
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
`;
-export { StyledCard as Card };
+type CardProps = ComponentPropsWithoutRef<'div'> & {
+ fullWidth?: boolean;
+ rounded?: boolean;
+};
+
+export const Card = ({
+ children,
+ className,
+ fullWidth,
+ rounded,
+ ...rest
+}: CardProps) => {
+ return (
+ <StyledCard
+ className={className}
+ fullWidth={fullWidth}
+ rounded={rounded}
+ // eslint-disable-next-line react/jsx-props-no-spreading
+ {...rest}
+ >
+ {children}
+ </StyledCard>
+ );
+};
diff --git a/packages/twenty-ui/src/layout/card/components/CardContent.tsx b/packages/twenty-ui/src/layout/card/components/CardContent.tsx
index 5c7c5fb94b2..90cf9b18038 100644
--- a/packages/twenty-ui/src/layout/card/components/CardContent.tsx
+++ b/packages/twenty-ui/src/layout/card/components/CardContent.tsx
@@ -1,17 +1,36 @@
-import { css } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
import { motion } from 'framer-motion';
+import { type ComponentProps, type ReactNode } from 'react';
-const StyledCardContent = styled(motion.div)<{ divider?: boolean }>`
- background-color: ${({ theme }) => theme.background.secondary};
- padding: ${({ theme }) => theme.spacing(4)};
+const StyledCardContentBase = styled.div<{
+ divider?: boolean;
+}>`
+ background-color: ${themeCssVariables.background.secondary};
+ padding: ${themeCssVariables.spacing[4]};
- ${({ divider, theme }) =>
- divider
- ? css`
- border-bottom: 1px solid ${theme.border.color.medium};
- `
- : ''}
+ border-bottom: ${({ divider }) =>
+ divider ? `1px solid ${themeCssVariables.border.color.medium}` : 'none'};
`;
-export { StyledCardContent as CardContent };
+const MotionCardContent = motion.create(StyledCardContentBase);
+
+type CardContentProps = {
+ children?: ReactNode;
+ className?: string;
+ divider?: boolean;
+} & Omit<ComponentProps<typeof MotionCardContent>, 'theme'>;
+
+export const CardContent = ({
+ children,
+ className,
+ divider,
+ ...rest
+}: CardContentProps) => {
+ return (
+ // eslint-disable-next-line react/jsx-props-no-spreading
+ <MotionCardContent className={className} divider={divider} {...rest}>
+ {children}
+ </MotionCardContent>
+ );
+};
diff --git a/packages/twenty-ui/src/layout/card/components/CardFooter.tsx b/packages/twenty-ui/src/layout/card/components/CardFooter.tsx
index e1813bf98bf..40461f52155 100644
--- a/packages/twenty-ui/src/layout/card/components/CardFooter.tsx
+++ b/packages/twenty-ui/src/layout/card/components/CardFooter.tsx
@@ -1,12 +1,29 @@
-import { css } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
+import { type ComponentPropsWithoutRef } from 'react';
const StyledCardFooter = styled.div<{ divider?: boolean }>`
- background-color: ${({ theme }) => theme.background.primary};
- border-top: ${({ divider = true, theme }) =>
- divider ? css`1px solid ${theme.border.color.medium}` : 0};
- font-size: ${({ theme }) => theme.font.size.sm};
- padding: ${({ theme }) => theme.spacing(2, 4)};
+ background-color: ${themeCssVariables.background.primary};
+ border-top: ${({ divider = true }) =>
+ divider ? `1px solid ${themeCssVariables.border.color.medium}` : '0'};
+ font-size: ${themeCssVariables.font.size.sm};
+ padding: ${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[4]};
`;
-export { StyledCardFooter as CardFooter };
+type CardFooterProps = ComponentPropsWithoutRef<'div'> & {
+ divider?: boolean;
+};
+
+export const CardFooter = ({
+ children,
+ className,
+ divider,
+ ...rest
+}: CardFooterProps) => {
+ return (
+ // eslint-disable-next-line react/jsx-props-no-spreading
+ <StyledCardFooter className={className} divider={divider} {...rest}>
+ {children}
+ </StyledCardFooter>
+ );
+};
diff --git a/packages/twenty-ui/src/layout/card/components/CardHeader.tsx b/packages/twenty-ui/src/layout/card/components/CardHeader.tsx
index 8ee0d4e97d1..595b5e22eee 100644
--- a/packages/twenty-ui/src/layout/card/components/CardHeader.tsx
+++ b/packages/twenty-ui/src/layout/card/components/CardHeader.tsx
@@ -1,11 +1,26 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
+import { type ComponentPropsWithoutRef } from 'react';
const StyledCardHeader = styled.div`
- background-color: ${({ theme }) => theme.background.primary};
- border-bottom: 1px solid ${({ theme }) => theme.border.color.medium};
- font-size: ${({ theme }) => theme.font.size.sm};
- font-weight: ${({ theme }) => theme.font.weight.medium};
- padding: ${({ theme }) => theme.spacing(2, 4)};
+ background-color: ${themeCssVariables.background.primary};
+ border-bottom: 1px solid ${themeCssVariables.border.color.medium};
+ font-size: ${themeCssVariables.font.size.sm};
+ font-weight: ${themeCssVariables.font.weight.medium};
+ padding: ${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[4]};
`;
-export { StyledCardHeader as CardHeader };
+type CardHeaderProps = ComponentPropsWithoutRef<'div'>;
+
+export const CardHeader = ({
+ children,
+ className,
+ ...rest
+}: CardHeaderProps) => {
+ return (
+ // eslint-disable-next-line react/jsx-props-no-spreading
+ <StyledCardHeader className={className} {...rest}>
+ {children}
+ </StyledCardHeader>
+ );
+};
diff --git a/packages/twenty-ui/src/layout/card/components/__stories__/Card.stories.tsx b/packages/twenty-ui/src/layout/card/components/__stories__/Card.stories.tsx
index 37303446de4..5247fd11088 100644
--- a/packages/twenty-ui/src/layout/card/components/__stories__/Card.stories.tsx
+++ b/packages/twenty-ui/src/layout/card/components/__stories__/Card.stories.tsx
@@ -22,10 +22,7 @@ const meta: Meta<typeof Card> = {
<CardFooter>Lorem ipsum</CardFooter>
</Card>
),
- argTypes: {
- as: { control: false },
- theme: { control: false },
- },
+ argTypes: {},
};
export default meta;
diff --git a/packages/twenty-ui/src/layout/section/components/Section.tsx b/packages/twenty-ui/src/layout/section/components/Section.tsx
index f0502888221..15a832ca88e 100644
--- a/packages/twenty-ui/src/layout/section/components/Section.tsx
+++ b/packages/twenty-ui/src/layout/section/components/Section.tsx
@@ -1,5 +1,6 @@
import { type ReactNode } from 'react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from '@ui/theme';
type SectionProps = {
children: ReactNode;
@@ -25,7 +26,12 @@ const StyledSection = styled.div<{
fullWidth: boolean;
fontColor: SectionFontColor;
}>`
- color: ${({ theme, fontColor }) => theme.font.color[fontColor]};
+ color: ${({ fontColor }) =>
+ fontColor === 'primary'
+ ? themeCssVariables.font.color.primary
+ : fontColor === 'secondary'
+ ? themeCssVariables.font.color.secondary
+ : themeCssVariables.font.color.tertiary};
text-align: ${({ alignment }) => alignment};
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
`;
@@ -36,13 +42,15 @@ export const Section = ({
alignment = SectionAlignment.Left,
fullWidth = true,
fontColor = SectionFontColor.Primary,
-}: SectionProps) => (
- <StyledSection
- className={className}
- alignment={alignment}
- fullWidth={fullWidth}
- fontColor={fontColor}
- >
- {children}
- </StyledSection>
-);
+}: SectionProps) => {
+ return (
+ <StyledSection
+ className={className}
+ alignment={alignment}
+ fullWidth={fullWidth}
+ fontColor={fontColor}
+ >
+ {children}
+ </StyledSection>
+ );
+};
diff --git a/packages/twenty-ui/src/layout/section/components/__stories__/Section.stories.tsx b/packages/twenty-ui/src/layout/section/components/__stories__/Section.stories.tsx
new file mode 100644
index 00000000000..82a844e6382
--- /dev/null
+++ b/packages/twenty-ui/src/layout/section/components/__stories__/Section.stories.tsx
@@ -0,0 +1,33 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { ComponentDecorator } from '@ui/testing';
+
+import { Section, SectionAlignment, SectionFontColor } from '../Section';
+
+const meta: Meta<typeof Section> = {
+ title: 'UI/Layout/Section',
+ component: Section,
+ decorators: [ComponentDecorator],
+};
+
+export default meta;
+type Story = StoryObj<typeof Section>;
+
+export const Default: Story = {
+ args: {
+ children: 'Section content goes here',
+ },
+};
+
+export const Centered: Story = {
+ args: {
+ children: 'Centered section content',
+ alignment: SectionAlignment.Center,
+ },
+};
+
+export const SecondaryColor: Story = {
+ args: {
+ children: 'Secondary font color section',
+ fontColor: SectionFontColor.Secondary,
+ },
+};
diff --git a/packages/twenty-ui/src/navigation/link/components/AdvancedSettingsToggle.tsx b/packages/twenty-ui/src/navigation/link/components/AdvancedSettingsToggle.tsx
index f6d0e8e531c..fa4108a6c8c 100644
--- a/packages/twenty-ui/src/navigation/link/components/AdvancedSettingsToggle.tsx
+++ b/packages/twenty-ui/src/navigation/link/components/AdvancedSettingsToggle.tsx
@@ -1,28 +1,28 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { IconPoint } from '@ui/display';
import { Toggle } from '@ui/input';
-import { useId } from 'react';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
+import { useContext, useId } from 'react';
const StyledContainer = styled.div`
align-items: center;
display: flex;
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
position: relative;
- height: ${({ theme }) => theme.spacing(5)};
- padding: ${({ theme }) => theme.spacing(1)};
+ height: ${themeCssVariables.spacing[5]};
+ padding: ${themeCssVariables.spacing[1]};
`;
const StyledText = styled.div`
- color: ${({ theme }) => theme.font.color.secondary};
- font-size: ${({ theme }) => theme.font.size.sm};
- font-weight: ${({ theme }) => theme.font.weight.medium};
+ color: ${themeCssVariables.font.color.secondary};
+ font-size: ${themeCssVariables.font.size.sm};
+ font-weight: ${themeCssVariables.font.weight.medium};
`;
const StyledIconContainer = styled.div`
align-items: center;
display: flex;
- left: ${({ theme }) => theme.spacing(-5)};
+ left: calc(-1 * ${themeCssVariables.spacing[5]});
position: absolute;
`;
@@ -50,7 +50,7 @@ export const AdvancedSettingsToggle = ({
};
const instanceId = useId();
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledContainer>
diff --git a/packages/twenty-ui/src/navigation/link/components/ClickToActionLink.tsx b/packages/twenty-ui/src/navigation/link/components/ClickToActionLink.tsx
index dd7067c15a9..dc50951d3c2 100644
--- a/packages/twenty-ui/src/navigation/link/components/ClickToActionLink.tsx
+++ b/packages/twenty-ui/src/navigation/link/components/ClickToActionLink.tsx
@@ -1,18 +1,20 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import React from 'react';
+import { themeCssVariables } from '@ui/theme';
+
const StyledButtonLink = styled.a`
align-items: center;
- color: ${({ theme }) => theme.font.color.light};
+ color: ${themeCssVariables.font.color.light};
display: flex;
- font-size: ${({ theme }) => theme.font.size.sm};
- font-weight: ${({ theme }) => theme.font.weight.medium};
- gap: ${({ theme }) => theme.spacing(1)};
- padding: 0 ${({ theme }) => theme.spacing(1)};
+ font-size: ${themeCssVariables.font.size.sm};
+ font-weight: ${themeCssVariables.font.weight.medium};
+ gap: ${themeCssVariables.spacing[1]};
+ padding: 0 ${themeCssVariables.spacing[1]};
text-decoration: none;
:hover {
- color: ${({ theme }) => theme.font.color.tertiary};
+ color: ${themeCssVariables.font.color.tertiary};
cursor: pointer;
}
`;
diff --git a/packages/twenty-ui/src/navigation/link/components/ContactLink.tsx b/packages/twenty-ui/src/navigation/link/components/ContactLink.tsx
index 647b7ccd05f..04b6bdaa8a4 100644
--- a/packages/twenty-ui/src/navigation/link/components/ContactLink.tsx
+++ b/packages/twenty-ui/src/navigation/link/components/ContactLink.tsx
@@ -1,17 +1,15 @@
-import * as React from 'react';
-import { type Theme, withTheme } from '@emotion/react';
import { styled } from '@linaria/react';
+import * as React from 'react';
+
+import { themeCssVariables } from '@ui/theme';
-const StyledClickableLink = withTheme(styled.a<{
- theme: Theme;
+const StyledClickableLink = styled.a<{
maxWidth?: number;
}>`
color: inherit;
overflow: hidden;
text-decoration: underline;
- text-decoration-color: ${({ theme }) => theme.border.color.strong};
- text-overflow: ellipsis;
-
+ text-decoration-color: ${themeCssVariables.border.color.strong};
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
@@ -19,9 +17,9 @@ const StyledClickableLink = withTheme(styled.a<{
max-width: ${({ maxWidth }) => maxWidth ?? '100%'};
&:hover {
- text-decoration-color: ${({ theme }) => theme.font.color.primary};
+ text-decoration-color: ${themeCssVariables.font.color.primary};
}
-`);
+`;
type ContactLinkProps = {
href: string;
@@ -35,13 +33,15 @@ export const ContactLink = ({
children,
onClick,
maxWidth,
-}: ContactLinkProps) => (
- <StyledClickableLink
- maxWidth={maxWidth}
- target="_blank"
- onClick={onClick}
- href={href}
- >
- {children}
- </StyledClickableLink>
-);
+}: ContactLinkProps) => {
+ return (
+ <StyledClickableLink
+ maxWidth={maxWidth}
+ target="_blank"
+ onClick={onClick}
+ href={href}
+ >
+ {children}
+ </StyledClickableLink>
+ );
+};
diff --git a/packages/twenty-ui/src/navigation/link/components/GithubVersionLink.tsx b/packages/twenty-ui/src/navigation/link/components/GithubVersionLink.tsx
index 69d7fc0085e..a0888a869a8 100644
--- a/packages/twenty-ui/src/navigation/link/components/GithubVersionLink.tsx
+++ b/packages/twenty-ui/src/navigation/link/components/GithubVersionLink.tsx
@@ -1,5 +1,6 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IconBrandGithub } from '@ui/display';
+import { ThemeContext } from '@ui/theme';
import { ClickToActionLink } from '@ui/navigation/link/components/ClickToActionLink';
import { GITHUB_LINK } from '../constants/GithubLink';
@@ -8,7 +9,7 @@ interface GithubVersionLinkProps {
}
export const GithubVersionLink = ({ version }: GithubVersionLinkProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<ClickToActionLink href={GITHUB_LINK} target="_blank" rel="noreferrer">
diff --git a/packages/twenty-ui/src/navigation/link/components/RawLink.tsx b/packages/twenty-ui/src/navigation/link/components/RawLink.tsx
index cb1444417ac..ae3b1325306 100644
--- a/packages/twenty-ui/src/navigation/link/components/RawLink.tsx
+++ b/packages/twenty-ui/src/navigation/link/components/RawLink.tsx
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Link as ReactLink } from 'react-router-dom';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
type RawLinkProps = {
className?: string;
diff --git a/packages/twenty-ui/src/navigation/link/components/RoundedLink.tsx b/packages/twenty-ui/src/navigation/link/components/RoundedLink.tsx
index 25bccd9a83d..a3b5f9452c0 100644
--- a/packages/twenty-ui/src/navigation/link/components/RoundedLink.tsx
+++ b/packages/twenty-ui/src/navigation/link/components/RoundedLink.tsx
@@ -1,7 +1,7 @@
import { styled } from '@linaria/react';
import { isNonEmptyString } from '@sniptt/guards';
-import { FONT_COMMON, THEME_COMMON, ThemeContext } from '@ui/theme';
-import { type MouseEvent, useContext } from 'react';
+import { themeCssVariables } from '@ui/theme';
+import { type MouseEvent } from 'react';
type RoundedLinkProps = {
href: string;
@@ -10,53 +10,33 @@ type RoundedLinkProps = {
className?: string;
};
-const fontSizeMd = FONT_COMMON.size.md;
-const spacing1 = THEME_COMMON.spacing(1);
-const spacing2 = THEME_COMMON.spacing(2);
-
-const spacingMultiplicator = THEME_COMMON.spacingMultiplicator;
-
-const StyledLink = styled.a<{
- color: string;
- background: string;
- backgroundHover: string;
- backgroundActive: string;
- border: string;
-}>`
+const StyledLink = styled.a`
align-items: center;
- background-color: ${({ background }) => background};
- border: 1px solid ${({ border }) => border};
-
+ background-color: ${themeCssVariables.background.transparent.lighter};
+ border: 1px solid ${themeCssVariables.border.color.strong};
border-radius: 50px;
- color: ${({ color }) => color};
-
+ color: ${themeCssVariables.font.color.primary};
cursor: pointer;
display: inline-flex;
- font-weight: ${fontSizeMd};
-
- gap: ${spacing1};
-
+ font-weight: ${themeCssVariables.font.size.md};
+ gap: ${themeCssVariables.spacing[1]};
height: 10px;
justify-content: center;
-
- max-width: calc(100% - ${spacingMultiplicator} * 2px);
-
+ max-width: calc(100% - ${themeCssVariables.spacingMultiplicator} * 2px);
min-width: fit-content;
-
overflow: hidden;
- padding: ${spacing1} ${spacing2};
-
+ padding: ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]};
text-decoration: none;
text-overflow: ellipsis;
user-select: none;
white-space: nowrap;
&:hover {
- background-color: ${({ backgroundHover }) => backgroundHover};
+ background-color: ${themeCssVariables.background.transparent.light};
}
&:active {
- background-color: ${({ backgroundActive }) => backgroundActive};
+ background-color: ${themeCssVariables.background.transparent.medium};
}
`;
@@ -66,21 +46,12 @@ export const RoundedLink = ({
onClick,
className,
}: RoundedLinkProps) => {
- const { theme } = useContext(ThemeContext);
-
- const background = theme.background.transparent.lighter;
- const backgroundHover = theme.background.transparent.light;
- const backgroundActive = theme.background.transparent.medium;
- const border = theme.border.color.strong;
- const color = theme.font.color.primary;
-
if (!isNonEmptyString(label)) {
return <></>;
}
const handleClick = (event: MouseEvent<HTMLElement>) => {
event.stopPropagation();
-
onClick?.(event);
};
@@ -90,11 +61,6 @@ export const RoundedLink = ({
target="_blank"
rel="noreferrer"
onClick={handleClick}
- color={color}
- background={background}
- backgroundHover={backgroundHover}
- backgroundActive={backgroundActive}
- border={border}
className={className}
>
{label}
diff --git a/packages/twenty-ui/src/navigation/link/components/UndecoratedLink.tsx b/packages/twenty-ui/src/navigation/link/components/UndecoratedLink.tsx
index f67f8ad7c5a..11091d89d61 100644
--- a/packages/twenty-ui/src/navigation/link/components/UndecoratedLink.tsx
+++ b/packages/twenty-ui/src/navigation/link/components/UndecoratedLink.tsx
@@ -1,17 +1,11 @@
-import styled from '@emotion/styled';
+import { css } from '@linaria/core';
import React from 'react';
-import { Link, type LinkProps } from 'react-router-dom';
+import { Link } from 'react-router-dom';
-type StyledLinkProps = LinkProps & {
- fullWidth?: boolean;
-};
-
-const StyledUndecoratedLink = styled(
- // eslint-disable-next-line react/jsx-props-no-spreading
- ({ fullWidth: _, ...props }: StyledLinkProps) => <Link {...props} />,
-)<StyledLinkProps>`
+// Linaria's styled(anonymousFunction) pattern strips the function body during
+// build, so we use the css tag and apply it directly on the Link component.
+const undecoratedLinkClass = css`
text-decoration: none;
- width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
`;
type UndecoratedLinkProps = {
@@ -30,13 +24,14 @@ export const UndecoratedLink = ({
fullWidth = false,
}: UndecoratedLinkProps) => {
return (
- <StyledUndecoratedLink
+ <Link
to={to as string}
replace={replace}
onClick={onClick}
- fullWidth={fullWidth}
+ className={undecoratedLinkClass}
+ style={fullWidth ? { width: '100%' } : undefined}
>
{children}
- </StyledUndecoratedLink>
+ </Link>
);
};
diff --git a/packages/twenty-ui/src/navigation/menu/components/MenuPicker.tsx b/packages/twenty-ui/src/navigation/menu/components/MenuPicker.tsx
index 83929d0aa94..431d2354702 100644
--- a/packages/twenty-ui/src/navigation/menu/components/MenuPicker.tsx
+++ b/packages/twenty-ui/src/navigation/menu/components/MenuPicker.tsx
@@ -1,12 +1,13 @@
-import { css, useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { isNonEmptyString } from '@sniptt/guards';
+import { useContext } from 'react';
import {
AppTooltip,
TooltipDelay,
TooltipPosition,
type IconComponent,
} from '@ui/display';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
import { isDefined } from 'twenty-shared/utils';
const StyledMenuPicker = styled.button<{
@@ -19,92 +20,89 @@ const StyledMenuPicker = styled.button<{
outline: inherit;
color: inherit;
align-items: center;
- border: 1px solid ${({ theme }) => theme.border.color.medium};
- border-radius: ${({ theme }) => theme.border.radius.sm};
+ border: 1px solid ${themeCssVariables.border.color.medium};
+ border-radius: ${themeCssVariables.border.radius.sm};
cursor: pointer;
display: flex;
flex-direction: column;
- gap: ${({ theme }) => theme.spacing(1)};
+ gap: ${themeCssVariables.spacing[1]};
justify-content: center;
- min-height: ${({ theme }) => theme.spacing(8)};
- padding: ${({ theme }) => `${theme.spacing(1.5)} ${theme.spacing(1)}`};
- transition: all ${({ theme }) => theme.animation.duration.instant}s ease;
+ min-height: ${themeCssVariables.spacing[8]};
+ padding: ${themeCssVariables.spacing[1.5]} ${themeCssVariables.spacing[1]};
+ transition: all calc(${themeCssVariables.animation.duration.instant} * 1s)
+ ease;
user-select: none;
width: 100%;
- ${({ theme, selected, disabled }) => {
+ background: ${({ disabled }) =>
+ disabled ? themeCssVariables.background.secondary : 'transparent'};
+
+ border-color: ${({ selected, disabled }) => {
if (disabled) {
- return css`
- background: ${theme.background.secondary};
- border-color: ${theme.border.color.medium};
- color: ${theme.font.color.extraLight};
- cursor: default;
- `;
+ return themeCssVariables.border.color.medium;
}
-
if (selected) {
- return css`
- background: transparent;
- border-color: ${theme.color.blue};
- color: ${theme.color.blue};
+ return themeCssVariables.color.blue;
+ }
+ return themeCssVariables.border.color.medium;
+ }};
- &:hover {
- background: ${theme.background.transparent.primary};
- }
- `;
+ color: ${({ selected, disabled }) => {
+ if (disabled) {
+ return themeCssVariables.font.color.extraLight;
+ }
+ if (selected) {
+ return themeCssVariables.color.blue;
}
+ return themeCssVariables.font.color.tertiary;
+ }};
- return css`
- background: transparent;
- border-color: ${theme.border.color.medium};
- color: ${theme.font.color.tertiary};
+ cursor: ${({ disabled }) => (disabled ? 'default' : 'pointer')};
- &:hover {
- background: ${theme.background.transparent.light};
+ &:hover {
+ background: ${({ selected, disabled }) => {
+ if (disabled) {
+ return themeCssVariables.background.secondary;
+ }
+ if (selected) {
+ return themeCssVariables.background.transparent.primary;
}
- `;
- }}
+ return themeCssVariables.background.transparent.light;
+ }};
+ }
`;
const StyledIconContainer = styled.div`
align-items: center;
display: flex;
flex-shrink: 0;
- height: ${({ theme }) => theme.icon.size.md}px;
+ height: calc(${themeCssVariables.icon.size.md} * 1px);
justify-content: center;
- width: ${({ theme }) => theme.icon.size.md}px;
+ width: calc(${themeCssVariables.icon.size.md} * 1px);
`;
const StyledLabel = styled.div<{
disabled: boolean;
selected: boolean;
}>`
- font-family: ${({ theme }) => theme.font.family};
- font-size: ${({ theme }) => theme.font.size.xs};
- font-weight: ${({ theme }) => theme.font.weight.semiBold};
- max-width: 100%;
- overflow: hidden;
- text-align: center;
- text-overflow: ellipsis;
- white-space: nowrap;
-
- ${({ theme, selected, disabled }) => {
+ color: ${({ selected, disabled }) => {
if (disabled) {
- return css`
- color: ${theme.font.color.extraLight};
- `;
+ return themeCssVariables.font.color.extraLight;
}
-
if (selected) {
- return css`
- color: ${theme.color.blue};
- `;
+ return themeCssVariables.color.blue;
}
+ return themeCssVariables.font.color.tertiary;
+ }};
+ font-family: ${themeCssVariables.font.family};
+ font-size: ${themeCssVariables.font.size.xs};
+ font-weight: ${themeCssVariables.font.weight.semiBold};
+ max-width: 100%;
+ overflow: hidden;
+ text-align: center;
+ text-overflow: ellipsis;
- return css`
- color: ${theme.font.color.tertiary};
- `;
- }}
+ white-space: nowrap;
`;
export type MenuPickerProps = {
@@ -136,7 +134,7 @@ export const MenuPicker = ({
tooltipDelay = TooltipDelay.noDelay,
tooltipOffset = 5,
}: MenuPickerProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<>
diff --git a/packages/twenty-ui/src/navigation/menu/components/__stories__/MenuPicker.stories.tsx b/packages/twenty-ui/src/navigation/menu/components/__stories__/MenuPicker.stories.tsx
index bcd448ad101..f7188214ddc 100644
--- a/packages/twenty-ui/src/navigation/menu/components/__stories__/MenuPicker.stories.tsx
+++ b/packages/twenty-ui/src/navigation/menu/components/__stories__/MenuPicker.stories.tsx
@@ -1,8 +1,10 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { IconChartPie, TooltipDelay } from '@ui/display';
import { MenuPicker } from '@ui/navigation/menu/components/MenuPicker';
import { ComponentDecorator } from '@ui/testing';
+import { type ReactNode, useContext } from 'react';
+import { ThemeContext, type ThemeType } from '@ui/theme';
const meta: Meta<typeof MenuPicker> = {
title: 'UI/Navigation/Menu/MenuPicker',
@@ -48,13 +50,18 @@ export const WithoutLabel: Story = {
},
};
-const StyledTitle = styled.h4`
+const StyledTitle = styled.h4<{ theme: ThemeType }>`
align-items: center;
color: ${({ theme }) => theme.font.color.tertiary};
font-size: 12px;
margin-bottom: 8px;
`;
+const SectionTitle = ({ children }: { children?: ReactNode }) => {
+ const { theme } = useContext(ThemeContext);
+ return <StyledTitle theme={theme}>{children}</StyledTitle>;
+};
+
export const AllStates: Story = {
render: () => (
<div
@@ -66,11 +73,11 @@ export const AllStates: Story = {
}}
>
<div>
- <StyledTitle>Default</StyledTitle>
+ <SectionTitle>Default</SectionTitle>
<MenuPicker id="default" icon={IconChartPie} label="Default" />
</div>
<div>
- <StyledTitle>Selected</StyledTitle>
+ <SectionTitle>Selected</SectionTitle>
<MenuPicker
id="selected"
icon={IconChartPie}
@@ -79,7 +86,7 @@ export const AllStates: Story = {
/>
</div>
<div>
- <StyledTitle>Disabled</StyledTitle>
+ <SectionTitle>Disabled</SectionTitle>
<MenuPicker
id="disabled"
icon={IconChartPie}
@@ -88,7 +95,7 @@ export const AllStates: Story = {
/>
</div>
<div>
- <StyledTitle>No Label</StyledTitle>
+ <SectionTitle>No Label</SectionTitle>
<MenuPicker
id="no-label"
icon={IconChartPie}
@@ -97,7 +104,7 @@ export const AllStates: Story = {
/>
</div>
<div>
- <StyledTitle> With Tooltip</StyledTitle>
+ <SectionTitle>With Tooltip</SectionTitle>
<MenuPicker
id="tooltip"
icon={IconChartPie}
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItem.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItem.tsx
index d8597dca0ae..d2ce59ab41f 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItem.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItem.tsx
@@ -1,4 +1,3 @@
-import { useTheme } from '@emotion/react';
import { IconChevronRight, type IconComponent } from '@ui/display';
import { type LightIconButtonProps } from '@ui/input/button/components/LightIconButton';
import { LightIconButtonGroup } from '@ui/input/button/components/LightIconButtonGroup';
@@ -7,10 +6,12 @@ import {
type MouseEvent,
type ReactElement,
type ReactNode,
+ useContext,
} from 'react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { MenuItemHotKeys } from '@ui/navigation/menu/menu-item/components/MenuItemHotKeys';
+import { ThemeContext } from '@ui/theme';
import { motion } from 'framer-motion';
import { MenuItemLeftContent } from '../internals/components/MenuItemLeftContent';
import {
@@ -82,7 +83,7 @@ export const MenuItem = ({
hotKeys,
isSubMenuOpened = false,
}: MenuItemProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const showIconButtons = Array.isArray(iconButtons) && iconButtons.length > 0;
const handleMenuItemClick = (event: MouseEvent<HTMLDivElement>) => {
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemHotKeys.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemHotKeys.tsx
index a3ba70e5393..37c622af03c 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemHotKeys.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemHotKeys.tsx
@@ -1,32 +1,34 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import React from 'react';
+import { themeCssVariables } from '@ui/theme';
+
const StyledCommandTextContainer = styled.div`
align-items: center;
display: flex;
flex-direction: row;
- gap: ${({ theme }) => theme.spacing(1)};
+ gap: ${themeCssVariables.spacing[1]};
justify-content: center;
`;
const StyledCommandText = styled.div`
- color: ${({ theme }) => theme.font.color.light};
+ color: ${themeCssVariables.font.color.light};
vertical-align: middle;
white-space: nowrap;
`;
const StyledCommandKey = styled.div`
align-items: center;
- background-color: ${({ theme }) => theme.background.secondary};
- border: 1px solid ${({ theme }) => theme.border.color.strong};
- border-radius: ${({ theme }) => theme.border.radius.sm};
- box-shadow: ${({ theme }) => theme.boxShadow.underline};
+ background-color: ${themeCssVariables.background.secondary};
+ border: 1px solid ${themeCssVariables.border.color.strong};
+ border-radius: ${themeCssVariables.border.radius.sm};
+ box-shadow: ${themeCssVariables.boxShadow.underline};
display: flex;
flex-direction: column;
height: 18px;
justify-content: center;
text-align: center;
- width: ${({ theme }) => theme.spacing(4)};
+ width: ${themeCssVariables.spacing[4]};
`;
export type MenuItemHotKeysProps = {
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemMultiSelect.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemMultiSelect.tsx
index f16937eb473..b94345b1bb6 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemMultiSelect.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemMultiSelect.tsx
@@ -1,17 +1,17 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { Tag } from '@ui/components';
import { type IconComponent } from '@ui/display';
import { Checkbox } from '@ui/input/components/Checkbox';
import { MenuItemLeftContent } from '@ui/navigation/menu/menu-item/internals/components/MenuItemLeftContent';
-import { type ThemeColor } from '@ui/theme';
+import { type ThemeColor, themeCssVariables } from '@ui/theme';
import { StyledMenuItemBase } from '../internals/components/StyledMenuItemBase';
const StyledLeftContentWithCheckboxContainer = styled.div`
align-items: center;
display: flex;
flex-direction: row;
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
min-width: 0;
overflow: hidden;
`;
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemMultiSelectAvatar.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemMultiSelectAvatar.tsx
index c6fc82d0407..c75d33cc951 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemMultiSelectAvatar.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemMultiSelectAvatar.tsx
@@ -1,8 +1,9 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type ReactNode } from 'react';
import { OverflowingTextWithTooltip } from '@ui/display';
import { Checkbox } from '@ui/input/components/Checkbox';
+import { themeCssVariables } from '@ui/theme';
import {
StyledMenuItemBase,
StyledMenuItemLabel,
@@ -14,7 +15,7 @@ const StyledLeftContentWithCheckboxContainer = styled.div`
align-items: center;
display: flex;
flex-direction: row;
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
width: 100%;
`;
@@ -22,7 +23,7 @@ const StyledTextContainer = styled.div`
display: flex;
align-items: center;
flex: 1 0 0;
- gap: ${({ theme }) => theme.spacing(1)};
+ gap: ${themeCssVariables.spacing[1]};
max-width: 100%;
text-overflow: ellipsis;
overflow: hidden;
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemNavigate.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemNavigate.tsx
index 7e951a21082..1ab67c1efab 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemNavigate.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemNavigate.tsx
@@ -1,6 +1,7 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { IconChevronRight, type IconComponent } from '@ui/display';
+import { ThemeContext } from '@ui/theme';
import { MenuItemLeftContent } from '../internals/components/MenuItemLeftContent';
import {
StyledMenuItemBase,
@@ -22,7 +23,7 @@ export const MenuItemNavigate = ({
className,
onClick,
}: MenuItemNavigateProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledMenuItemBase onClick={onClick} className={className}>
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelect.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelect.tsx
index 524c5ca4509..22b6b06b99f 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelect.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelect.tsx
@@ -1,5 +1,4 @@
-import { css, useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { isString } from '@sniptt/guards';
import {
@@ -8,7 +7,8 @@ import {
OverflowingTextWithTooltip,
type IconComponent,
} from '@ui/display';
-import { type ReactNode } from 'react';
+import { type ReactNode, useContext } from 'react';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
import { MenuItemLeftContent } from '../internals/components/MenuItemLeftContent';
import {
StyledMenuItemBase,
@@ -21,24 +21,29 @@ export const StyledMenuItemSelect = styled(StyledMenuItemBase)<{
disabled?: boolean;
focused?: boolean;
}>`
- ${({ theme, disabled, focused }) => {
+ background: ${({ disabled, focused }) => {
if (disabled === true) {
- return css`
- background: inherit;
- &:hover {
- background: inherit;
- }
+ return 'inherit';
+ }
+ if (focused === true) {
+ return themeCssVariables.background.transparent.light;
+ }
+ return '';
+ }};
- color: ${theme.font.color.tertiary};
+ &:hover {
+ background: ${({ disabled }) =>
+ disabled === true
+ ? 'inherit'
+ : themeCssVariables.background.transparent.light};
+ }
- cursor: default;
- `;
- } else if (focused === true) {
- return css`
- background: ${theme.background.transparent.light};
- `;
- }
- }}
+ color: ${({ disabled }) =>
+ disabled === true
+ ? themeCssVariables.font.color.tertiary
+ : themeCssVariables.font.color.secondary};
+
+ cursor: ${({ disabled }) => (disabled === true ? 'default' : 'pointer')};
`;
type MenuItemSelectProps = {
@@ -70,7 +75,7 @@ export const MenuItemSelect = ({
contextualText,
contextualTextPosition = 'left',
}: MenuItemSelectProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledMenuItemSelect
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectAvatar.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectAvatar.tsx
index 36411bb69c9..6fbf7a67363 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectAvatar.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectAvatar.tsx
@@ -1,5 +1,4 @@
-import { useTheme } from '@emotion/react';
-import { type ReactNode } from 'react';
+import { useContext, type ReactNode } from 'react';
import {
StyledMenuItemIconCheck,
@@ -8,8 +7,9 @@ import {
StyledMenuItemLeftContent,
} from '../internals/components/StyledMenuItemBase';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { OverflowingTextWithTooltip } from '@ui/display';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
import { StyledMenuItemSelect } from './MenuItemSelect';
type MenuItemSelectAvatarProps = {
@@ -28,7 +28,7 @@ const StyledTextContainer = styled.div`
display: flex;
align-items: center;
flex: 1 0 0;
- gap: ${({ theme }) => theme.spacing(1)};
+ gap: ${themeCssVariables.spacing[1]};
max-width: 100%;
text-overflow: ellipsis;
overflow: hidden;
@@ -45,7 +45,7 @@ export const MenuItemSelectAvatar = ({
focused,
testId,
}: MenuItemSelectAvatarProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledMenuItemSelect
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectColor.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectColor.tsx
index dc0871b8505..da26d1172f1 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectColor.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectColor.tsx
@@ -1,4 +1,4 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import {
StyledMenuItemIconCheck,
@@ -7,7 +7,7 @@ import {
} from '../internals/components/StyledMenuItemBase';
import { ColorSample, type ColorSampleVariant } from '@ui/display';
-import { type ThemeColor } from '@ui/theme';
+import { type ThemeColor, ThemeContext } from '@ui/theme';
import {
DEFAULT_COLOR_LABELS,
type ColorLabels,
@@ -35,7 +35,7 @@ export const MenuItemSelectColor = ({
variant = 'default',
colorLabels = DEFAULT_COLOR_LABELS,
}: MenuItemSelectColorProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledMenuItemSelect
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectTag.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectTag.tsx
index cdc0d3f3911..dab45bf897b 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectTag.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSelectTag.tsx
@@ -1,4 +1,4 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import {
StyledMenuItemIconCheck,
@@ -7,7 +7,7 @@ import {
import { Tag } from '@ui/components';
import { type IconComponent } from '@ui/display';
-import { type ThemeColor } from '@ui/theme';
+import { type ThemeColor, ThemeContext } from '@ui/theme';
import { StyledMenuItemSelect } from './MenuItemSelect';
type MenuItemSelectTagProps = {
@@ -33,7 +33,7 @@ export const MenuItemSelectTag = ({
variant = 'solid',
LeftIcon,
}: MenuItemSelectTagProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledMenuItemSelect
onClick={onClick}
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSuggestion.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSuggestion.tsx
index 82d2d8764bb..51ea57cf36b 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSuggestion.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemSuggestion.tsx
@@ -1,8 +1,8 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type MouseEvent } from 'react';
import { type IconComponent } from '@ui/display';
-import { HOVER_BACKGROUND } from '@ui/theme';
+import { themeCssVariables } from '@ui/theme';
import { MenuItemLeftContent } from '../internals/components/MenuItemLeftContent';
import { StyledMenuItemLeftContent } from '../internals/components/StyledMenuItemBase';
@@ -20,32 +20,35 @@ export type MenuItemSuggestionProps = {
const StyledSuggestionMenuItem = styled.li<{
selected?: boolean;
}>`
- --horizontal-padding: ${({ theme }) => theme.spacing(1)};
- --vertical-padding: ${({ theme }) => theme.spacing(2)};
+ --horizontal-padding: ${themeCssVariables.spacing[1]};
+ --vertical-padding: ${themeCssVariables.spacing[2]};
align-items: center;
- border-radius: ${({ theme }) => theme.border.radius.sm};
+ border-radius: ${themeCssVariables.border.radius.sm};
cursor: pointer;
display: flex;
flex-direction: row;
- font-size: ${({ theme }) => theme.font.size.sm};
+ font-size: ${themeCssVariables.font.size.sm};
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
height: calc(32px - 2 * var(--vertical-padding));
justify-content: space-between;
padding: var(--vertical-padding) var(--horizontal-padding);
- background: ${({ selected, theme }) =>
- selected ? theme.background.transparent.medium : ''};
- color: ${({ theme }) => theme.font.color.secondary};
+ background: ${({ selected }) =>
+ selected ? themeCssVariables.background.transparent.medium : ''};
+ color: ${themeCssVariables.font.color.secondary};
- ${HOVER_BACKGROUND};
+ transition: background 0.1s ease;
+ &:hover {
+ background: ${themeCssVariables.background.transparent.light};
+ }
position: relative;
user-select: none;
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemToggle.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemToggle.tsx
index 8d2f99e27ed..7491eb2e3ce 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemToggle.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemToggle.tsx
@@ -1,4 +1,4 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display';
import { Toggle, type ToggleSize } from '@ui/input';
import { MenuItemLeftContent } from '../internals/components/MenuItemLeftContent';
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIcon.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIcon.tsx
index 184f58d6610..cfa519276d2 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIcon.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIcon.tsx
@@ -1,7 +1,8 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { type IconComponent } from '@ui/display';
import { MenuItemIconBoxContainer } from './MenuItemIconBoxContainer';
+import { ThemeContext } from '@ui/theme';
export type MenuItemIconProps = {
Icon: IconComponent | null | undefined;
@@ -12,7 +13,7 @@ export const MenuItemIcon = ({
Icon,
withContainer = false,
}: MenuItemIconProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
if (!Icon) {
return null;
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIconBoxContainer.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIconBoxContainer.tsx
index 2583ab24e7b..14be9cef5e5 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIconBoxContainer.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIconBoxContainer.tsx
@@ -1,12 +1,29 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { type ReactNode } from 'react';
-export const StyledIconContainer = styled.div`
+import { themeCssVariables } from '@ui/theme';
+
+const StyledIconContainerBase = styled.div`
align-items: flex-start;
- background: ${({ theme }) => theme.background.transparent.light};
- border-radius: ${({ theme }) => theme.border.radius.sm};
+ background: ${themeCssVariables.background.transparent.light};
+ border-radius: ${themeCssVariables.border.radius.sm};
display: flex;
flex-direction: column;
- padding: ${({ theme }) => theme.spacing(1)};
+ padding: ${themeCssVariables.spacing[1]};
`;
+export const StyledIconContainer = ({
+ children,
+ className,
+}: {
+ children?: ReactNode;
+ className?: string;
+}) => {
+ return (
+ <StyledIconContainerBase className={className}>
+ {children}
+ </StyledIconContainerBase>
+ );
+};
+
export { StyledIconContainer as MenuItemIconBoxContainer };
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIconWithGripSwap.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIconWithGripSwap.tsx
index 42b3552db52..22c5bf40fcf 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIconWithGripSwap.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemIconWithGripSwap.tsx
@@ -1,7 +1,8 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type IconComponent, IconGripVertical } from '@ui/display';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
import { MenuItemIconBoxContainer } from './MenuItemIconBoxContainer';
const StyledIconSwapContainer = styled.div`
@@ -13,14 +14,16 @@ const StyledIconSwapContainer = styled.div`
const StyledDefaultIcon = styled.div`
display: flex;
- transition: opacity ${({ theme }) => theme.animation.duration.instant}s ease;
+ transition: opacity calc(${themeCssVariables.animation.duration.instant} * 1s)
+ ease;
`;
const StyledHoverIcon = styled.div`
position: absolute;
display: flex;
opacity: 0;
- transition: opacity ${({ theme }) => theme.animation.duration.instant}s ease;
+ transition: opacity calc(${themeCssVariables.animation.duration.instant} * 1s)
+ ease;
`;
export type MenuItemIconWithGripSwapProps = {
@@ -34,7 +37,7 @@ export const MenuItemIconWithGripSwap = ({
withIconContainer = false,
gripIconColor,
}: MenuItemIconWithGripSwapProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
if (!LeftIcon) {
return null;
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemLeftContent.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemLeftContent.tsx
index 555599d6c16..a1bf1069097 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemLeftContent.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/MenuItemLeftContent.tsx
@@ -1,13 +1,13 @@
-import { useTheme } from '@emotion/react';
import { isNonEmptyString, isString } from '@sniptt/guards';
-import { type ReactNode } from 'react';
+import { useContext, type ReactNode } from 'react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import {
type IconComponent,
IconGripVertical,
OverflowingTextWithTooltip,
} from '@ui/display';
+import { ThemeContext } from '@ui/theme';
import { type MenuItemDraggableGripMode } from '../../types/MenuItemDraggableGripMode';
import { MenuItemIcon } from './MenuItemIcon';
import { MenuItemIconBoxContainer } from './MenuItemIconBoxContainer';
@@ -55,7 +55,7 @@ export const MenuItemLeftContent = ({
gripMode = 'never',
disabled = false,
}: MenuItemLeftContentProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const gripIconColor = withIconContainer
? theme.font.color.tertiary
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/StyledMenuItemBase.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/StyledMenuItemBase.tsx
index 67463c5d88d..c668ed4d76c 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/StyledMenuItemBase.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/internals/components/StyledMenuItemBase.tsx
@@ -1,10 +1,9 @@
-import { css } from '@emotion/react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { isUndefined } from '@sniptt/guards';
import { IconCheck } from '@ui/display';
-import { HOVER_BACKGROUND } from '@ui/theme';
+import { themeCssVariables } from '@ui/theme';
import { type MenuItemAccent } from '../../types/MenuItemAccent';
export type MenuItemBaseProps = {
@@ -17,67 +16,58 @@ export type MenuItemBaseProps = {
};
export const StyledMenuItemBase = styled.div<MenuItemBaseProps>`
- --horizontal-padding: ${({ theme }) => theme.spacing(1)};
- --vertical-padding: ${({ theme }) => theme.spacing(2)};
+ --horizontal-padding: ${themeCssVariables.spacing[1]};
+ --vertical-padding: ${themeCssVariables.spacing[2]};
align-items: center;
- border-radius: ${({ theme }) => theme.border.radius.sm};
+ border-radius: ${themeCssVariables.border.radius.sm};
cursor: pointer;
display: flex;
flex-direction: row;
- font-size: ${({ theme }) => theme.font.size.sm};
+ font-size: ${themeCssVariables.font.size.sm};
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
height: calc(32px - 2 * var(--vertical-padding));
justify-content: space-between;
padding: var(--vertical-padding) var(--horizontal-padding);
- ${({ theme, isKeySelected }) =>
- isKeySelected ? `background: ${theme.background.transparent.light};` : ''}
+ background: ${({ isKeySelected, focused }) =>
+ isKeySelected || focused
+ ? themeCssVariables.background.transparent.light
+ : ''};
- ${({ isHoverBackgroundDisabled, disabled }) =>
- (disabled || isHoverBackgroundDisabled) ?? HOVER_BACKGROUND};
+ transition: ${({ isHoverBackgroundDisabled, disabled }) =>
+ disabled || isHoverBackgroundDisabled ? 'none' : 'background 0.1s ease'};
- ${({ theme, accent, disabled }) => {
+ color: ${({ accent, disabled }) => {
if (!isUndefined(disabled) && disabled !== false) {
- return css`
- color: ${theme.font.color.tertiary};
- `;
+ return themeCssVariables.font.color.tertiary;
}
-
switch (accent) {
- case 'danger': {
- return css`
- color: ${theme.font.color.danger};
- &:hover {
- background: ${theme.background.transparent.danger};
- }
- `;
- }
- case 'placeholder': {
- return css`
- color: ${theme.font.color.tertiary};
- `;
- }
+ case 'danger':
+ return themeCssVariables.font.color.danger;
+ case 'placeholder':
+ return themeCssVariables.font.color.tertiary;
case 'default':
- default: {
- return css`
- color: ${theme.font.color.secondary};
- `;
- }
+ default:
+ return themeCssVariables.font.color.secondary;
}
- }}
+ }};
- ${({ focused, theme }) =>
- focused &&
- css`
- background: ${theme.background.transparent.light};
- `};
+ &:hover {
+ background: ${({ accent, disabled, isHoverBackgroundDisabled }) => {
+ if (disabled === true) return '';
+ if (accent === 'danger')
+ return themeCssVariables.background.transparent.danger;
+ if (isHoverBackgroundDisabled === true) return 'transparent';
+ return themeCssVariables.background.transparent.light;
+ }};
+ }
position: relative;
user-select: none;
@@ -88,8 +78,8 @@ export const StyledMenuItemBase = styled.div<MenuItemBaseProps>`
export const StyledMenuItemLabel = styled.div`
display: flex;
flex-direction: row;
- font-size: ${({ theme }) => theme.font.size.md};
- font-weight: ${({ theme }) => theme.font.weight.regular};
+ font-size: ${themeCssVariables.font.size.md};
+ font-weight: ${themeCssVariables.font.weight.regular};
overflow: hidden;
@@ -97,11 +87,11 @@ export const StyledMenuItemLabel = styled.div`
`;
export const StyledMenuItemLabelLight = styled(StyledMenuItemLabel)`
- color: ${({ theme }) => theme.font.color.light};
+ color: ${themeCssVariables.font.color.light};
`;
export const StyledNoIconFiller = styled.div`
- width: ${({ theme }) => theme.spacing(1)};
+ width: ${themeCssVariables.spacing[1]};
`;
export const StyledMenuItemLeftContent = styled.div`
@@ -110,7 +100,7 @@ export const StyledMenuItemLeftContent = styled.div`
flex-direction: row;
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
min-width: 0;
width: 100%;
@@ -123,7 +113,7 @@ export const StyledMenuItemRightContent = styled.div`
align-items: center;
display: flex;
flex-direction: row;
- gap: ${({ theme }) => theme.spacing(2)};
+ gap: ${themeCssVariables.spacing[2]};
& svg {
flex-shrink: 0;
@@ -137,31 +127,29 @@ export const StyledDraggableItem = styled.div`
display: flex;
`;
-export const StyledHoverableMenuItemBase = styled(StyledMenuItemBase)<{
- disabled?: boolean;
+type HoverableMenuItemBaseProps = {
isIconDisplayedOnHoverOnly?: boolean;
cursor?: 'drag' | 'default';
-}>`
- ${({ isIconDisplayedOnHoverOnly, theme }) =>
- isIconDisplayedOnHoverOnly &&
- css`
- & .hoverable-buttons {
- opacity: 0;
- right: ${theme.spacing(2)};
- }
-
- &:hover {
- & .hoverable-buttons {
- opacity: 1;
- }
- }
- `};
+} & MenuItemBaseProps;
+export const StyledHoverableMenuItemBase = styled(
+ StyledMenuItemBase,
+)<HoverableMenuItemBaseProps>`
& .hoverable-buttons {
- transition: opacity ${({ theme }) => theme.animation.duration.instant}s ease;
+ opacity: ${({ isIconDisplayedOnHoverOnly }) =>
+ isIconDisplayedOnHoverOnly === true ? '0' : '1'};
+ right: ${({ isIconDisplayedOnHoverOnly }) =>
+ isIconDisplayedOnHoverOnly === true
+ ? themeCssVariables.spacing[2]
+ : 'auto'};
+ transition: opacity
+ calc(${themeCssVariables.animation.duration.instant} * 1s) ease;
}
&:hover {
+ & .hoverable-buttons {
+ opacity: 1;
+ }
& .grip-swap-default-icon {
opacity: 0;
}
@@ -186,15 +174,15 @@ export const StyledHoverableMenuItemBase = styled(StyledMenuItemBase)<{
export const StyledMenuItemIconCheck = styled(IconCheck)`
flex-shrink: 0;
- margin-right: ${({ theme }) => theme.spacing(1)};
+ margin-right: ${themeCssVariables.spacing[1]};
`;
export const StyledMenuItemContextualText = styled.div`
- color: ${({ theme }) => theme.font.color.light};
+ color: ${themeCssVariables.font.color.light};
font-family: inherit;
font-size: inherit;
font-weight: inherit;
- padding-left: ${({ theme }) => theme.spacing(1)};
+ padding-left: ${themeCssVariables.spacing[1]};
flex-shrink: 1;
overflow: hidden;
`;
diff --git a/packages/twenty-ui/src/navigation/navigation-bar/components/NavigationBar.tsx b/packages/twenty-ui/src/navigation/navigation-bar/components/NavigationBar.tsx
index cd53d51f56c..2d81eefe920 100644
--- a/packages/twenty-ui/src/navigation/navigation-bar/components/NavigationBar.tsx
+++ b/packages/twenty-ui/src/navigation/navigation-bar/components/NavigationBar.tsx
@@ -1,13 +1,15 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+
import { type IconComponent } from '@ui/display/icon/types/IconComponent';
+import { themeCssVariables } from '@ui/theme';
import { NavigationBarItem } from './NavigationBarItem';
const StyledContainer = styled.div`
display: flex;
- gap: ${({ theme }) => theme.spacing(4)};
+ gap: ${themeCssVariables.spacing[4]};
justify-content: center;
- padding: ${({ theme }) => theme.spacing(3)};
+ padding: ${themeCssVariables.spacing[3]};
z-index: 1001;
`;
@@ -19,15 +21,17 @@ type NavigationBarProps = {
export const NavigationBar = ({
activeItemName,
items,
-}: NavigationBarProps) => (
- <StyledContainer>
- {items.map(({ Icon, name, onClick }) => (
- <NavigationBarItem
- key={name}
- Icon={Icon}
- isActive={activeItemName === name}
- onClick={onClick}
- />
- ))}
- </StyledContainer>
-);
+}: NavigationBarProps) => {
+ return (
+ <StyledContainer>
+ {items.map(({ Icon, name, onClick }) => (
+ <NavigationBarItem
+ key={name}
+ Icon={Icon}
+ isActive={activeItemName === name}
+ onClick={onClick}
+ />
+ ))}
+ </StyledContainer>
+ );
+};
diff --git a/packages/twenty-ui/src/navigation/navigation-bar/components/NavigationBarItem.tsx b/packages/twenty-ui/src/navigation/navigation-bar/components/NavigationBarItem.tsx
index 7f893f57454..085d6266a60 100644
--- a/packages/twenty-ui/src/navigation/navigation-bar/components/NavigationBarItem.tsx
+++ b/packages/twenty-ui/src/navigation/navigation-bar/components/NavigationBarItem.tsx
@@ -1,22 +1,24 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
+import { useContext } from 'react';
+
+import { styled } from '@linaria/react';
import { type IconComponent } from '@ui/display/icon/types/IconComponent';
+import { ThemeContext, themeCssVariables } from '@ui/theme';
const StyledIconButton = styled.div<{ isActive?: boolean }>`
align-items: center;
- background-color: ${({ isActive, theme }) =>
- isActive ? theme.background.transparent.light : 'none'};
- border-radius: ${({ theme }) => theme.spacing(1)};
+ background-color: ${({ isActive }) =>
+ isActive ? themeCssVariables.background.transparent.light : 'none'};
+ border-radius: ${themeCssVariables.spacing[1]};
cursor: pointer;
display: flex;
- height: ${({ theme }) => theme.spacing(10)};
+ height: ${themeCssVariables.spacing[10]};
justify-content: center;
- transition: background-color ${({ theme }) => theme.animation.duration.fast}s
- ease;
- width: ${({ theme }) => theme.spacing(10)};
+ transition: background-color
+ calc(${themeCssVariables.animation.duration.fast} * 1s) ease;
+ width: ${themeCssVariables.spacing[10]};
&:hover {
- background-color: ${({ theme }) => theme.background.transparent.light};
+ background-color: ${themeCssVariables.background.transparent.light};
}
`;
@@ -31,7 +33,7 @@ export const NavigationBarItem = ({
isActive,
onClick,
}: NavigationBarItemProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledIconButton isActive={isActive} onClick={onClick}>
diff --git a/packages/twenty-ui/src/navigation/navigation-bar/components/__stories__/NavigationBar.stories.tsx b/packages/twenty-ui/src/navigation/navigation-bar/components/__stories__/NavigationBar.stories.tsx
new file mode 100644
index 00000000000..6da40879b6b
--- /dev/null
+++ b/packages/twenty-ui/src/navigation/navigation-bar/components/__stories__/NavigationBar.stories.tsx
@@ -0,0 +1,25 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { IconHome, IconSearch, IconSettings } from '@ui/display';
+import { ComponentDecorator } from '@ui/testing';
+
+import { NavigationBar } from '../NavigationBar';
+
+const meta: Meta<typeof NavigationBar> = {
+ title: 'UI/Navigation/NavigationBar/NavigationBar',
+ component: NavigationBar,
+ decorators: [ComponentDecorator],
+};
+
+export default meta;
+type Story = StoryObj<typeof NavigationBar>;
+
+export const Default: Story = {
+ args: {
+ activeItemName: 'Home',
+ items: [
+ { name: 'Home', Icon: IconHome, onClick: () => {} },
+ { name: 'Search', Icon: IconSearch, onClick: () => {} },
+ { name: 'Settings', Icon: IconSettings, onClick: () => {} },
+ ],
+ },
+};
diff --git a/packages/twenty-ui/src/navigation/notification-counter/components/NotificationCounter.tsx b/packages/twenty-ui/src/navigation/notification-counter/components/NotificationCounter.tsx
index d193adb72ad..83aa886ff38 100644
--- a/packages/twenty-ui/src/navigation/notification-counter/components/NotificationCounter.tsx
+++ b/packages/twenty-ui/src/navigation/notification-counter/components/NotificationCounter.tsx
@@ -1,4 +1,6 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+
+import { themeCssVariables } from '@ui/theme';
const StyledNotificationCounter = styled.div<{
variant: 'primary' | 'secondary';
@@ -9,14 +11,14 @@ const StyledNotificationCounter = styled.div<{
display: flex;
align-items: center;
justify-content: center;
- font-size: ${({ theme }) => theme.font.size.xxs};
- font-weight: ${({ theme }) => theme.font.weight.semiBold};
- background: ${({ theme, variant }) =>
+ font-size: ${themeCssVariables.font.size.xxs};
+ font-weight: ${themeCssVariables.font.weight.semiBold};
+ background: ${({ variant }) =>
variant === 'primary'
- ? theme.color.blue
- : theme.background.transparent.light};
- color: ${({ theme, variant }) =>
- variant === 'primary' ? 'white' : theme.font.color.secondary};
+ ? themeCssVariables.color.blue
+ : themeCssVariables.background.transparent.light};
+ color: ${({ variant }) =>
+ variant === 'primary' ? 'white' : themeCssVariables.font.color.secondary};
`;
type NotificationCounterProps = {
diff --git a/packages/twenty-ui/src/testing/ComponentStorybookLayout.tsx b/packages/twenty-ui/src/testing/ComponentStorybookLayout.tsx
index f4f22b46aa7..9592f182e50 100644
--- a/packages/twenty-ui/src/testing/ComponentStorybookLayout.tsx
+++ b/packages/twenty-ui/src/testing/ComponentStorybookLayout.tsx
@@ -1,10 +1,13 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
+import { useContext } from 'react';
import { isDefined } from 'twenty-shared/utils';
+import { ThemeContext, type ThemeType } from '@ui/theme';
const StyledLayout = styled.div<{
width?: number;
backgroundColor?: string | undefined;
height: number | 'fit-content';
+ theme: ThemeType;
}>`
background: ${({ theme, backgroundColor }) =>
backgroundColor ?? theme.background.primary};
@@ -38,12 +41,17 @@ export const ComponentStorybookLayout = ({
backgroundColor,
height,
children,
-}: ComponentStorybookLayoutProps) => (
- <StyledLayout
- width={width}
- backgroundColor={backgroundColor}
- height={isDefined(height) ? height : 'fit-content'}
- >
- {children}
- </StyledLayout>
-);
+}: ComponentStorybookLayoutProps) => {
+ const { theme } = useContext(ThemeContext);
+
+ return (
+ <StyledLayout
+ width={width}
+ backgroundColor={backgroundColor}
+ height={isDefined(height) ? height : 'fit-content'}
+ theme={theme}
+ >
+ {children}
+ </StyledLayout>
+ );
+};
diff --git a/packages/twenty-ui/src/testing/decorators/CatalogDecorator.tsx b/packages/twenty-ui/src/testing/decorators/CatalogDecorator.tsx
index dc922d50924..ffc32ea836c 100644
--- a/packages/twenty-ui/src/testing/decorators/CatalogDecorator.tsx
+++ b/packages/twenty-ui/src/testing/decorators/CatalogDecorator.tsx
@@ -1,15 +1,16 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { isNumber, isString } from '@sniptt/guards';
import { type Decorator } from '@storybook/react-vite';
-import { type ComponentProps, type JSX } from 'react';
+import { type ComponentProps, type JSX, useContext } from 'react';
+import { ThemeContext, type ThemeType } from '@ui/theme';
-const StyledColumnTitle = styled.h1`
+const StyledColumnTitle = styled.h1<{ theme: ThemeType }>`
font-size: ${({ theme }) => theme.font.size.lg};
font-weight: ${({ theme }) => theme.font.weight.semiBold};
margin: ${({ theme }) => theme.spacing(2)};
`;
-const StyledRowsTitle = styled.h2`
+const StyledRowsTitle = styled.h2<{ theme: ThemeType }>`
color: ${({ theme }) => theme.font.color.secondary};
font-size: ${({ theme }) => theme.font.size.md};
font-weight: ${({ theme }) => theme.font.weight.semiBold};
@@ -17,7 +18,7 @@ const StyledRowsTitle = styled.h2`
width: 100px;
`;
-const StyledRowTitle = styled.h3`
+const StyledRowTitle = styled.h3<{ theme: ThemeType }>`
color: ${({ theme }) => theme.font.color.tertiary};
font-size: ${({ theme }) => theme.font.size.md};
font-weight: ${({ theme }) => theme.font.weight.semiBold};
@@ -25,7 +26,7 @@ const StyledRowTitle = styled.h3`
width: 100px;
`;
-const StyledElementTitle = styled.span`
+const StyledElementTitle = styled.span<{ theme: ThemeType }>`
color: ${({ theme }) => theme.font.color.light};
font-size: ${({ theme }) => theme.font.size.xs};
font-weight: ${({ theme }) => theme.font.weight.semiBold};
@@ -39,19 +40,19 @@ const StyledContainer = styled.div`
flex-direction: row;
`;
-const StyledColumnContainer = styled.div`
+const StyledColumnContainer = styled.div<{ theme: ThemeType }>`
display: flex;
flex-direction: column;
padding: ${({ theme }) => theme.spacing(2)};
`;
-const StyledRowsContainer = styled.div`
+const StyledRowsContainer = styled.div<{ theme: ThemeType }>`
display: flex;
flex-direction: column;
gap: ${({ theme }) => theme.spacing(2)};
`;
-const StyledRowContainer = styled.div`
+const StyledRowContainer = styled.div<{ theme: ThemeType }>`
display: flex;
flex: 1;
flex-direction: row;
@@ -63,7 +64,7 @@ const StyledElementContainer = styled.div<{ width: number }>`
${({ width }) => width && `min-width: ${width}px;`}
`;
-const StyledCellContainer = styled.div`
+const StyledCellContainer = styled.div<{ theme: ThemeType }>`
align-items: center;
display: flex;
flex-direction: column;
@@ -97,6 +98,8 @@ export type CatalogOptions = {
};
export const CatalogDecorator: Decorator = (Story, context) => {
+ const { theme } = useContext(ThemeContext);
+
const {
catalog: { dimensions = [], options = {} } = {
dimensions: [],
@@ -118,27 +121,31 @@ export const CatalogDecorator: Decorator = (Story, context) => {
return (
<StyledContainer>
{dimension4.values.map((value4: any) => (
- <StyledColumnContainer key={value4}>
- <StyledColumnTitle>
+ <StyledColumnContainer key={value4} theme={theme}>
+ <StyledColumnTitle theme={theme}>
{dimension4.labels?.(value4) ??
(isStringOrNumber(value4) ? value4 : '')}
</StyledColumnTitle>
{dimension3.values.map((value3: any) => (
- <StyledRowsContainer key={value3}>
- <StyledRowsTitle>
+ <StyledRowsContainer key={value3} theme={theme}>
+ <StyledRowsTitle theme={theme}>
{dimension3.labels?.(value3) ??
(isStringOrNumber(value3) ? value3 : '')}
</StyledRowsTitle>
{dimension2.values.map((value2: any) => (
- <StyledRowContainer key={value2}>
- <StyledRowTitle>
+ <StyledRowContainer key={value2} theme={theme}>
+ <StyledRowTitle theme={theme}>
{dimension2.labels?.(value2) ??
(isStringOrNumber(value2) ? value2 : '')}
</StyledRowTitle>
{dimension1.values.map((value1: any) => {
return (
- <StyledCellContainer key={value1} id={value1}>
- <StyledElementTitle>
+ <StyledCellContainer
+ key={value1}
+ id={value1}
+ theme={theme}
+ >
+ <StyledElementTitle theme={theme}>
{dimension1.labels?.(value1) ??
(isStringOrNumber(value1) ? value1 : '')}
</StyledElementTitle>
diff --git a/packages/twenty-ui/src/theme/constants/HoverBackground.ts b/packages/twenty-ui/src/theme/constants/HoverBackground.ts
index cbd9b9e0e4a..18aa11c14b2 100644
--- a/packages/twenty-ui/src/theme/constants/HoverBackground.ts
+++ b/packages/twenty-ui/src/theme/constants/HoverBackground.ts
@@ -1,6 +1,6 @@
-import { css } from '@emotion/react';
+import { type ThemeType } from '..';
-export const HOVER_BACKGROUND = (props: any) => css`
+export const HOVER_BACKGROUND = (props: { theme: ThemeType }) => `
transition: background 0.1s ease;
&:hover {
background: ${props.theme.background.transparent.light};
diff --git a/packages/twenty-ui/src/theme/constants/TextInputStyle.ts b/packages/twenty-ui/src/theme/constants/TextInputStyle.ts
index d996785daa5..58ee707b2c9 100644
--- a/packages/twenty-ui/src/theme/constants/TextInputStyle.ts
+++ b/packages/twenty-ui/src/theme/constants/TextInputStyle.ts
@@ -1,8 +1,6 @@
-import { css } from '@emotion/react';
-
import { type ThemeType } from '..';
-export const TEXT_INPUT_STYLE = (props: { theme: ThemeType }) => css`
+export const TEXT_INPUT_STYLE = (props: { theme: ThemeType }) => `
background-color: transparent;
border: none;
color: ${props.theme.font.color.primary};
diff --git a/packages/twenty-ui/src/theme/constants/ThemeCssVariables.ts b/packages/twenty-ui/src/theme/constants/ThemeCssVariables.ts
new file mode 100644
index 00000000000..7c15a272a25
--- /dev/null
+++ b/packages/twenty-ui/src/theme/constants/ThemeCssVariables.ts
@@ -0,0 +1,18 @@
+import { THEME_LIGHT } from '@ui/theme/constants/ThemeLight';
+import { type ThemeType } from '@ui/theme/types/ThemeType';
+import { buildThemeReferencingRootCssVariables } from '@ui/theme/utils/buildThemeReferencingRootCssVariables';
+
+type DeepCSSVariableRefs<T> = {
+ [K in keyof T]: T[K] extends (...args: never[]) => unknown
+ ? Record<string | number, string>
+ : T[K] extends Record<string, unknown>
+ ? DeepCSSVariableRefs<T[K]>
+ : string;
+};
+
+// eslint-disable-next-line @typescript-eslint/naming-convention
+export const themeCssVariables: DeepCSSVariableRefs<ThemeType> =
+ buildThemeReferencingRootCssVariables({
+ themeNode: THEME_LIGHT,
+ prefix: 't',
+ }) as DeepCSSVariableRefs<ThemeType>;
diff --git a/packages/twenty-ui/src/theme/index.ts b/packages/twenty-ui/src/theme/index.ts
index 7af5b920652..f4baf1a7e2b 100644
--- a/packages/twenty-ui/src/theme/index.ts
+++ b/packages/twenty-ui/src/theme/index.ts
@@ -51,6 +51,7 @@ export { TAG_LIGHT } from './constants/TagLight';
export { TEXT } from './constants/Text';
export { TEXT_INPUT_STYLE } from './constants/TextInputStyle';
export { THEME_COMMON } from './constants/ThemeCommon';
+export { themeCssVariables } from './constants/ThemeCssVariables';
export { THEME_DARK } from './constants/ThemeDark';
export { THEME_LIGHT } from './constants/ThemeLight';
export { TRANSPARENT_COLORS_DARK } from './constants/TransparentColorsDark';
@@ -60,7 +61,10 @@ export {
ThemeContext,
ThemeContextProvider,
} from './provider/ThemeContextProvider';
+export { ThemeCssVariableInjectorEffect } from './provider/ThemeCssVariableInjectorEffect';
export { ThemeProvider } from './provider/ThemeProvider';
export type { ThemeType } from './types/ThemeType';
+export { buildThemeReferencingRootCssVariables } from './utils/buildThemeReferencingRootCssVariables';
export { getNextThemeColor } from './utils/getNextThemeColor';
-export { themeColorSchema } from './utils/themeColorSchema';
+export { prepareThemeForRootCssVariableInjection } from './utils/prepareThemeForRootCssVariableInjection';
+export { SPACING_VALUES } from './utils/spacingValues';
diff --git a/packages/twenty-ui/src/theme/provider/ThemeContextProvider.tsx b/packages/twenty-ui/src/theme/provider/ThemeContextProvider.tsx
index 2cb55ac30e9..0b6c3f3be31 100644
--- a/packages/twenty-ui/src/theme/provider/ThemeContextProvider.tsx
+++ b/packages/twenty-ui/src/theme/provider/ThemeContextProvider.tsx
@@ -1,6 +1,7 @@
import { createContext } from 'react';
import { type ThemeType } from '@ui/theme/types/ThemeType';
+import { ThemeCssVariableInjectorEffect } from '@ui/theme/provider/ThemeCssVariableInjectorEffect';
export type ThemeContextType = {
theme: ThemeType;
@@ -18,6 +19,9 @@ export const ThemeContextProvider = ({
theme: ThemeType;
}) => {
return (
- <ThemeContext.Provider value={{ theme }}>{children}</ThemeContext.Provider>
+ <ThemeContext.Provider value={{ theme }}>
+ <ThemeCssVariableInjectorEffect theme={theme} />
+ {children}
+ </ThemeContext.Provider>
);
};
diff --git a/packages/twenty-ui/src/theme/provider/ThemeCssVariableInjectorEffect.tsx b/packages/twenty-ui/src/theme/provider/ThemeCssVariableInjectorEffect.tsx
new file mode 100644
index 00000000000..9ccd51cf75d
--- /dev/null
+++ b/packages/twenty-ui/src/theme/provider/ThemeCssVariableInjectorEffect.tsx
@@ -0,0 +1,33 @@
+import { useLayoutEffect, useMemo } from 'react';
+
+import { type ThemeType } from '@ui/theme/types/ThemeType';
+import { prepareThemeForRootCssVariableInjection } from '@ui/theme/utils/prepareThemeForRootCssVariableInjection';
+
+export const ThemeCssVariableInjectorEffect = ({
+ theme,
+}: {
+ theme: ThemeType;
+}) => {
+ const themeCssVariableEntries = useMemo(
+ () =>
+ prepareThemeForRootCssVariableInjection({
+ themeNode: theme as unknown as Record<string, unknown>,
+ prefix: 't',
+ }),
+ [theme],
+ );
+
+ useLayoutEffect(() => {
+ const root = document.documentElement;
+ for (const [name, value] of themeCssVariableEntries) {
+ root.style.setProperty(name, value);
+ }
+ return () => {
+ for (const [name] of themeCssVariableEntries) {
+ root.style.removeProperty(name);
+ }
+ };
+ }, [themeCssVariableEntries]);
+
+ return null;
+};
diff --git a/packages/twenty-ui/src/theme/provider/ThemeProvider.tsx b/packages/twenty-ui/src/theme/provider/ThemeProvider.tsx
index 241851905d3..612853fdc19 100644
--- a/packages/twenty-ui/src/theme/provider/ThemeProvider.tsx
+++ b/packages/twenty-ui/src/theme/provider/ThemeProvider.tsx
@@ -1,4 +1,3 @@
-import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
import { type ReactNode } from 'react';
import { ThemeContextProvider } from '@ui/theme/provider/ThemeContextProvider';
@@ -11,9 +10,5 @@ type ThemeProviderProps = {
};
export const ThemeProvider = ({ theme, children }: ThemeProviderProps) => {
- return (
- <EmotionThemeProvider theme={theme}>
- <ThemeContextProvider theme={theme}>{children}</ThemeContextProvider>
- </EmotionThemeProvider>
- );
+ return <ThemeContextProvider theme={theme}>{children}</ThemeContextProvider>;
};
diff --git a/packages/twenty-ui/src/theme/utils/__tests__/buildThemeReferencingRootCssVariables.test.ts b/packages/twenty-ui/src/theme/utils/__tests__/buildThemeReferencingRootCssVariables.test.ts
new file mode 100644
index 00000000000..93af1419c2f
--- /dev/null
+++ b/packages/twenty-ui/src/theme/utils/__tests__/buildThemeReferencingRootCssVariables.test.ts
@@ -0,0 +1,41 @@
+import { buildThemeReferencingRootCssVariables } from '../buildThemeReferencingRootCssVariables';
+
+describe('buildThemeReferencingRootCssVariables', () => {
+ it('replaces primitive leaves with var() references', () => {
+ const result = buildThemeReferencingRootCssVariables({
+ themeNode: { fontSize: '14px', lineHeight: 1.5 },
+ prefix: 't',
+ });
+
+ expect(result).toEqual({
+ fontSize: 'var(--t-font-size)',
+ lineHeight: 'var(--t-line-height)',
+ });
+ });
+
+ it('recurses into nested objects', () => {
+ const result = buildThemeReferencingRootCssVariables({
+ themeNode: { font: { color: { primary: 'someValue' } } },
+ prefix: 't',
+ });
+
+ expect(result).toEqual({
+ font: {
+ color: { primary: 'var(--t-font-color-primary)' },
+ },
+ });
+ });
+
+ it('expands spacing functions into keyed var() refs', () => {
+ const result = buildThemeReferencingRootCssVariables({
+ themeNode: { spacing: (n: number) => `${n * 4}px` },
+ prefix: 't',
+ });
+
+ const spacing = result.spacing as Record<string | number, string>;
+ expect(spacing[0]).toBe('var(--t-spacing-0)');
+ expect(spacing[4]).toBe('var(--t-spacing-4)');
+ expect(spacing[0.5]).toBe('var(--t-spacing-0_5)');
+ expect(spacing[1.5]).toBe('var(--t-spacing-1_5)');
+ });
+});
diff --git a/packages/twenty-ui/src/theme/utils/__tests__/prepareThemeForRootCssVariableInjection.test.ts b/packages/twenty-ui/src/theme/utils/__tests__/prepareThemeForRootCssVariableInjection.test.ts
new file mode 100644
index 00000000000..4e4cef52025
--- /dev/null
+++ b/packages/twenty-ui/src/theme/utils/__tests__/prepareThemeForRootCssVariableInjection.test.ts
@@ -0,0 +1,41 @@
+import { prepareThemeForRootCssVariableInjection } from '../prepareThemeForRootCssVariableInjection';
+
+describe('prepareThemeForRootCssVariableInjection', () => {
+ it('collects flat entries from primitive leaves', () => {
+ const entries = prepareThemeForRootCssVariableInjection({
+ themeNode: { fontSize: '14px' },
+ prefix: 't',
+ });
+
+ expect(entries).toEqual([['--t-font-size', '14px']]);
+ });
+
+ it('recurses into nested objects', () => {
+ const entries = prepareThemeForRootCssVariableInjection({
+ themeNode: { font: { color: { primary: 'someValue' } } },
+ prefix: 't',
+ });
+
+ expect(entries).toEqual([['--t-font-color-primary', 'someValue']]);
+ });
+
+ it('expands spacing functions into entries', () => {
+ const entries = prepareThemeForRootCssVariableInjection({
+ themeNode: { spacing: (n: number) => `${n * 4}px` },
+ prefix: 't',
+ });
+
+ expect(entries).toContainEqual(['--t-spacing-0', '0px']);
+ expect(entries).toContainEqual(['--t-spacing-4', '16px']);
+ expect(entries).toContainEqual(['--t-spacing-0_5', '2px']);
+ });
+
+ it('stringifies numeric values', () => {
+ const entries = prepareThemeForRootCssVariableInjection({
+ themeNode: { opacity: 0.5 },
+ prefix: 't',
+ });
+
+ expect(entries).toEqual([['--t-opacity', '0.5']]);
+ });
+});
diff --git a/packages/twenty-ui/src/theme/utils/buildThemeReferencingRootCssVariables.ts b/packages/twenty-ui/src/theme/utils/buildThemeReferencingRootCssVariables.ts
new file mode 100644
index 00000000000..1cccbde2ddf
--- /dev/null
+++ b/packages/twenty-ui/src/theme/utils/buildThemeReferencingRootCssVariables.ts
@@ -0,0 +1,63 @@
+import { SPACING_VALUES } from '@ui/theme/utils/spacingValues';
+
+const camelToKebab = (str: string): string =>
+ str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
+
+const isPlainObject = (value: unknown): value is Record<string, unknown> =>
+ typeof value === 'object' && value !== null && !Array.isArray(value);
+
+const formatSpacingKey = (n: number): string => String(n).replace('.', '_');
+
+const buildSpacingVariableRefs = (
+ name: string,
+): Record<string | number, string> => {
+ const spacing: Record<string | number, string> = {};
+ for (const n of SPACING_VALUES) {
+ spacing[n] = `var(--${name}-${formatSpacingKey(n)})`;
+ }
+ return spacing;
+};
+
+const buildVariableRefForEntry = ({
+ key,
+ value,
+ name,
+}: {
+ key: string;
+ value: unknown;
+ name: string;
+}): unknown => {
+ if (typeof value === 'function' && key === 'spacing') {
+ return buildSpacingVariableRefs(name);
+ }
+
+ if (isPlainObject(value)) {
+ return buildThemeReferencingRootCssVariables({
+ themeNode: value,
+ prefix: name,
+ });
+ }
+
+ return `var(--${name})`;
+};
+
+// Builds a nested object that mirrors the theme shape, where every leaf
+// is replaced with a CSS var(--t-…) reference string.
+// { font: { color: { primary: '#333' } } }
+// → { font: { color: { primary: 'var(--t-font-color-primary)' } } }
+export const buildThemeReferencingRootCssVariables = ({
+ themeNode,
+ prefix,
+}: {
+ themeNode: Record<string, unknown>;
+ prefix: string;
+}): Record<string, unknown> => {
+ const result: Record<string, unknown> = {};
+
+ for (const [key, value] of Object.entries(themeNode)) {
+ const name = `${prefix}-${camelToKebab(key)}`;
+ result[key] = buildVariableRefForEntry({ key, value, name });
+ }
+
+ return result;
+};
diff --git a/packages/twenty-ui/src/theme/utils/prepareThemeForRootCssVariableInjection.ts b/packages/twenty-ui/src/theme/utils/prepareThemeForRootCssVariableInjection.ts
new file mode 100644
index 00000000000..2d22ccfed2c
--- /dev/null
+++ b/packages/twenty-ui/src/theme/utils/prepareThemeForRootCssVariableInjection.ts
@@ -0,0 +1,54 @@
+import { SPACING_VALUES } from '@ui/theme/utils/spacingValues';
+
+const camelToKebab = (str: string): string =>
+ str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
+
+const isPlainObject = (value: unknown): value is Record<string, unknown> =>
+ typeof value === 'object' && value !== null && !Array.isArray(value);
+
+const formatSpacingKey = (n: number): string => String(n).replace('.', '_');
+
+const collectSpacingEntries = (
+ name: string,
+ spacingFn: (...args: number[]) => string,
+): [string, string][] =>
+ SPACING_VALUES.map((n) => [`--${name}-${formatSpacingKey(n)}`, spacingFn(n)]);
+
+const collectEntriesForValue = ({
+ key,
+ value,
+ name,
+}: {
+ key: string;
+ value: unknown;
+ name: string;
+}): [string, string][] => {
+ if (typeof value === 'function' && key === 'spacing') {
+ return collectSpacingEntries(name, value as (...args: number[]) => string);
+ }
+
+ if (isPlainObject(value)) {
+ return prepareThemeForRootCssVariableInjection({
+ themeNode: value,
+ prefix: name,
+ });
+ }
+
+ return [[`--${name}`, String(value)]];
+};
+
+// Collects a flat [--css-variable-name, value] list by walking a runtime
+// theme object. Used to inject custom properties onto the DOM root.
+// { font: { color: { primary: '#333' } } }
+// → [['--t-font-color-primary', '#333']]
+export const prepareThemeForRootCssVariableInjection = ({
+ themeNode,
+ prefix,
+}: {
+ themeNode: Record<string, unknown>;
+ prefix: string;
+}): [string, string][] =>
+ Object.entries(themeNode).flatMap(([key, value]) => {
+ const name = `${prefix}-${camelToKebab(key)}`;
+ return collectEntriesForValue({ key, value, name });
+ });
diff --git a/packages/twenty-ui/src/theme/utils/spacingValues.ts b/packages/twenty-ui/src/theme/utils/spacingValues.ts
new file mode 100644
index 00000000000..a501708ef3c
--- /dev/null
+++ b/packages/twenty-ui/src/theme/utils/spacingValues.ts
@@ -0,0 +1,5 @@
+export const SPACING_VALUES = [
+ ...Array.from({ length: 33 }, (_, i) => i),
+ 0.5,
+ 1.5,
+];
diff --git a/packages/twenty-ui/src/utilities/animation/components/AnimatedCircleLoading.tsx b/packages/twenty-ui/src/utilities/animation/components/AnimatedCircleLoading.tsx
index cca1aee22eb..61e03d09be7 100644
--- a/packages/twenty-ui/src/utilities/animation/components/AnimatedCircleLoading.tsx
+++ b/packages/twenty-ui/src/utilities/animation/components/AnimatedCircleLoading.tsx
@@ -1,7 +1,8 @@
-import React from 'react';
+import React, { useContext } from 'react';
import { motion } from 'framer-motion';
-import styled from '@emotion/styled';
-import { useTheme } from '@emotion/react';
+import { styled } from '@linaria/react';
+
+import { ThemeContext } from '@ui/theme';
const StyledAnimatedContainer = styled(motion.div)`
align-items: center;
@@ -14,7 +15,7 @@ export const AnimatedCircleLoading = ({
}: {
children: React.ReactNode;
}) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<StyledAnimatedContainer
initial={{ rotate: 0 }}
diff --git a/packages/twenty-ui/src/utilities/animation/components/AnimatedEaseIn.tsx b/packages/twenty-ui/src/utilities/animation/components/AnimatedEaseIn.tsx
index 8c3f17ef43c..1791d3df34c 100644
--- a/packages/twenty-ui/src/utilities/animation/components/AnimatedEaseIn.tsx
+++ b/packages/twenty-ui/src/utilities/animation/components/AnimatedEaseIn.tsx
@@ -1,5 +1,5 @@
-import { useTheme } from '@emotion/react';
-import { type AnimationDuration } from '@ui/theme';
+import { useContext } from 'react';
+import { type AnimationDuration, ThemeContext } from '@ui/theme';
import { motion } from 'framer-motion';
type AnimatedEaseInProps = Omit<
@@ -13,7 +13,7 @@ export const AnimatedEaseIn = ({
children,
duration = 'normal',
}: AnimatedEaseInProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const initial = { opacity: 0 };
const animate = { opacity: 1 };
const transition = {
diff --git a/packages/twenty-ui/src/utilities/animation/components/AnimatedEaseInOut.tsx b/packages/twenty-ui/src/utilities/animation/components/AnimatedEaseInOut.tsx
index 61d4e2fa5ed..6b3683ef7c2 100644
--- a/packages/twenty-ui/src/utilities/animation/components/AnimatedEaseInOut.tsx
+++ b/packages/twenty-ui/src/utilities/animation/components/AnimatedEaseInOut.tsx
@@ -1,5 +1,5 @@
-import { useTheme } from '@emotion/react';
-import { type AnimationDuration } from '@ui/theme';
+import { useContext } from 'react';
+import { type AnimationDuration, ThemeContext } from '@ui/theme';
import { AnimatePresence, motion } from 'framer-motion';
type AnimatedEaseInOutProps = {
@@ -19,7 +19,7 @@ export const AnimatedEaseInOut = ({
duration = 'normal',
initial = true,
}: AnimatedEaseInOutProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<AnimatePresence initial={initial}>
diff --git a/packages/twenty-ui/src/utilities/animation/components/AnimatedFadeOut.tsx b/packages/twenty-ui/src/utilities/animation/components/AnimatedFadeOut.tsx
index 18d44ff5d3a..fcd2937d467 100644
--- a/packages/twenty-ui/src/utilities/animation/components/AnimatedFadeOut.tsx
+++ b/packages/twenty-ui/src/utilities/animation/components/AnimatedFadeOut.tsx
@@ -1,5 +1,5 @@
-import { useTheme } from '@emotion/react';
-import { type AnimationDuration } from '@ui/theme';
+import { useContext } from 'react';
+import { type AnimationDuration, ThemeContext } from '@ui/theme';
import { AnimatePresence, motion } from 'framer-motion';
type AnimatedFadeOutProps = {
@@ -17,7 +17,7 @@ export const AnimatedFadeOut = ({
marginBottom,
marginTop,
}: AnimatedFadeOutProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<AnimatePresence>
{isOpen && (
diff --git a/packages/twenty-ui/src/utilities/animation/components/AnimatedRotate.tsx b/packages/twenty-ui/src/utilities/animation/components/AnimatedRotate.tsx
index 98760f0f27b..8a4dbed3ab2 100644
--- a/packages/twenty-ui/src/utilities/animation/components/AnimatedRotate.tsx
+++ b/packages/twenty-ui/src/utilities/animation/components/AnimatedRotate.tsx
@@ -1,6 +1,7 @@
-import { useTheme } from '@emotion/react';
-import styled from '@emotion/styled';
-import { type AnimationDuration } from '@ui/theme';
+import { useContext } from 'react';
+
+import { styled } from '@linaria/react';
+import { ThemeContext, type AnimationDuration } from '@ui/theme';
import { type HTMLMotionProps, motion } from 'framer-motion';
type AnimatedRotateProps = Omit<
@@ -22,7 +23,7 @@ export const AnimatedRotate = ({
duration = 'fast',
animateOnHover,
}: AnimatedRotateProps): JSX.Element => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
const initial = { opacity: 0, rotate: -90 };
const animate = { opacity: 1, rotate: 0 };
const exit = { opacity: 0, rotate: 90 };
diff --git a/packages/twenty-ui/src/utilities/animation/components/AnimatedTextWord.tsx b/packages/twenty-ui/src/utilities/animation/components/AnimatedTextWord.tsx
index 11419b21b39..03cd8d41de0 100644
--- a/packages/twenty-ui/src/utilities/animation/components/AnimatedTextWord.tsx
+++ b/packages/twenty-ui/src/utilities/animation/components/AnimatedTextWord.tsx
@@ -1,5 +1,5 @@
import React, { useMemo } from 'react';
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { motion } from 'framer-motion';
const StyledContainer = styled(motion.div)`
diff --git a/packages/twenty-ui/src/utilities/animation/components/AnimatedTranslation.tsx b/packages/twenty-ui/src/utilities/animation/components/AnimatedTranslation.tsx
index e22ba407e7e..e782399860a 100644
--- a/packages/twenty-ui/src/utilities/animation/components/AnimatedTranslation.tsx
+++ b/packages/twenty-ui/src/utilities/animation/components/AnimatedTranslation.tsx
@@ -1,12 +1,13 @@
-import { useTheme } from '@emotion/react';
+import { useContext } from 'react';
import { motion } from 'framer-motion';
+import { ThemeContext } from '@ui/theme';
type AnimatedTranslationProps = {
children: React.ReactNode;
};
export const AnimatedTranslation = ({ children }: AnimatedTranslationProps) => {
- const theme = useTheme();
+ const { theme } = useContext(ThemeContext);
return (
<motion.div
diff --git a/packages/twenty-ui/src/theme/utils/themeColorSchema.ts b/packages/twenty-ui/src/utilities/color/utils/themeColorSchema.ts
similarity index 100%
rename from packages/twenty-ui/src/theme/utils/themeColorSchema.ts
rename to packages/twenty-ui/src/utilities/color/utils/themeColorSchema.ts
diff --git a/packages/twenty-ui/src/utilities/dimensions/components/AutogrowWrapper.tsx b/packages/twenty-ui/src/utilities/dimensions/components/AutogrowWrapper.tsx
index 012fa21d33e..08280100a77 100644
--- a/packages/twenty-ui/src/utilities/dimensions/components/AutogrowWrapper.tsx
+++ b/packages/twenty-ui/src/utilities/dimensions/components/AutogrowWrapper.tsx
@@ -1,4 +1,4 @@
-import styled from '@emotion/styled';
+import { styled } from '@linaria/react';
import { type ReactNode } from 'react';
type AutogrowWrapperProps = {
diff --git a/packages/twenty-ui/src/utilities/index.ts b/packages/twenty-ui/src/utilities/index.ts
index 832ad501954..1c5549a4a54 100644
--- a/packages/twenty-ui/src/utilities/index.ts
+++ b/packages/twenty-ui/src/utilities/index.ts
@@ -20,6 +20,7 @@ export {
stringToThemeColor,
stringToThemeColorP3String,
} from './color/utils/stringToThemeColorP3String';
+export { themeColorSchema } from './color/utils/themeColorSchema';
export { REACT_APP_SERVER_BASE_URL } from './config';
export { getOsControlSymbol } from './device/getOsControlSymbol';
export { getOsShortcutSeparator } from './device/getOsShortcutSeparator';
diff --git a/packages/twenty-ui/vite.config.individual.ts b/packages/twenty-ui/vite.config.individual.ts
index 9d05bf65b7a..94a7a7288a9 100644
--- a/packages/twenty-ui/vite.config.individual.ts
+++ b/packages/twenty-ui/vite.config.individual.ts
@@ -29,27 +29,13 @@ export default defineConfig(() => {
cacheDir: '../../node_modules/.vite/packages/twenty-ui-individual',
assetsInclude: ['src/**/*.svg'],
plugins: [
- react({
- jsxImportSource: '@emotion/react',
- plugins: [['@swc/plugin-emotion', {}]],
- }),
+ react(),
tsconfigPaths({
root: __dirname,
projects: ['tsconfig.json'],
}),
svgr(),
wyw({
- include: [
- '**/OverflowingTextWithTooltip.tsx',
- '**/Tag.tsx',
- '**/Avatar.tsx',
- '**/Chip.tsx',
- '**/LinkChip.tsx',
- '**/Avatar.tsx',
- '**/AvatarChipLeftComponent.tsx',
- '**/ContactLink.tsx',
- '**/RoundedLink.tsx',
- ],
babelOptions: {
presets: ['@babel/preset-typescript', '@babel/preset-react'],
},
diff --git a/packages/twenty-ui/vite.config.ts b/packages/twenty-ui/vite.config.ts
index b849a478edf..9b6d9d64529 100644
--- a/packages/twenty-ui/vite.config.ts
+++ b/packages/twenty-ui/vite.config.ts
@@ -73,10 +73,7 @@ export default defineConfig(({ command }) => {
cacheDir: '../../node_modules/.vite/packages/twenty-ui',
assetsInclude: ['src/**/*.svg'],
plugins: [
- react({
- jsxImportSource: '@emotion/react',
- plugins: [['@swc/plugin-emotion', {}]],
- }),
+ react(),
tsconfigPaths({
root: __dirname,
projects: ['tsconfig.json'],
@@ -85,17 +82,6 @@ export default defineConfig(({ command }) => {
dts(dtsConfig),
checker(checkersConfig),
wyw({
- include: [
- '**/OverflowingTextWithTooltip.tsx',
- '**/Tag.tsx',
- '**/Avatar.tsx',
- '**/Chip.tsx',
- '**/LinkChip.tsx',
- '**/Avatar.tsx',
- '**/AvatarChipLeftComponent.tsx',
- '**/ContactLink.tsx',
- '**/RoundedLink.tsx',
- ],
babelOptions: {
presets: ['@babel/preset-typescript', '@babel/preset-react'],
},