Skip to content

The open alternative to Salesforce, designed for AI.

Add soft accent badges (#28313)

Raphaël Bosicf864b6003bb
diff --git a/.github/workflows/ci-cli.yaml b/.github/workflows/ci-cli.yaml
index e3a22b01bde..1d85da9f8cf 100644
--- a/.github/workflows/ci-cli.yaml
+++ b/.github/workflows/ci-cli.yaml
@@ -72,7 +72,10 @@ jobs:
- name: Typecheck
run: npx tsgo -p packages/twenty-cli/tsconfig.json --noEmit
- name: Unit tests
- run: npx vitest run --maxWorkers=2
+ run: npx vitest run --maxWorkers=2 --exclude src/app/manifest/__tests__/manifest-parity.spec.ts
+ working-directory: packages/twenty-cli
+ - name: Manifest parity tests
+ run: npx vitest run --maxWorkers=1 src/app/manifest/__tests__/manifest-parity.spec.ts
working-directory: packages/twenty-cli
- name: Test app publishing with an isolated local registry
run: |
diff --git a/packages/twenty-docs/snippets/ui/generated/data-display/badge.mdx b/packages/twenty-docs/snippets/ui/generated/data-display/badge.mdx
index fa236d69c78..1b30d52ca11 100644
--- a/packages/twenty-docs/snippets/ui/generated/data-display/badge.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/data-display/badge.mdx
@@ -15,8 +15,8 @@
Caller-provided text, numbers, icons, or other inline content.
</ParamField>
-<ParamField body="color" type="&quot;inherit&quot; | &quot;primary&quot; | &quot;secondary&quot; | &quot;tertiary&quot;" default="tertiary">
- Neutral tertiary, inherited text, primary accent, or secondary treatment.
+<ParamField body="color" type="&quot;accent&quot; | &quot;inherit&quot; | &quot;primary&quot; | &quot;secondary&quot; | &quot;tertiary&quot;" default="tertiary">
+ Neutral tertiary, inherited text, solid primary accent, soft accent tint, or secondary treatment.
</ParamField>
<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
diff --git a/packages/twenty-docs/ui/primitives/data-display/badge.mdx b/packages/twenty-docs/ui/primitives/data-display/badge.mdx
index 2e05eac76d4..2ed9e777eae 100644
--- a/packages/twenty-docs/ui/primitives/data-display/badge.mdx
+++ b/packages/twenty-docs/ui/primitives/data-display/badge.mdx
@@ -67,11 +67,12 @@ export const BadgeAppearances = () => (
<Badge size="xs" color="secondary" shape="circle">
12
</Badge>
+ <Badge color="accent">Last used</Badge>
</Text>
);
```
-`size` accepts `xs`, `sm`, or `md`. `color` accepts `tertiary`, `inherit`, `primary`, or `secondary`. `shape` accepts `pill` or `circle`. The defaults are `sm`, `tertiary`, and `pill`. The circular treatment has a fixed width equal to its height. Use `pill` for longer content, including abbreviated counts.
+`size` accepts `xs`, `sm`, or `md`. `color` accepts `tertiary`, `inherit`, `primary`, `secondary`, or `accent`. The `accent` treatment pairs an accent-tertiary fill with accent11 text in both themes. The solid `primary` treatment keeps its blue fill and on-accent text. `shape` accepts `pill` or `circle`. The defaults are `sm`, `tertiary`, and `pill`. The circular treatment has a fixed width equal to its height. Use `pill` for longer content, including abbreviated counts.
<StoryEmbed
storyId="ui-data-display-badge--colors"
@@ -79,6 +80,12 @@ export const BadgeAppearances = () => (
height={140}
/>
+<StoryEmbed
+ storyId="ui-data-display-badge--accent"
+ title="Soft accent badges in light and dark themes"
+ height={140}
+/>
+
## Counts and visibility
```tsx
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-badge.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-badge.front-component.tsx
index 03add8fec49..2b2752f1919 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-badge.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-badge.front-component.tsx
@@ -37,6 +37,9 @@ const BadgeExample = () => {
<Badge aria-label="Medium badge" size="md">
Medium
</Badge>
+ <Badge aria-label="Accent badge" color="accent">
+ Accent
+ </Badge>
<Badge
aria-label="Primary circle badge"
size="xs"
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/badgeTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/badgeTest.ts
index 0ff4040dff8..b1377da9b57 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/badgeTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/badgeTest.ts
@@ -23,6 +23,7 @@ export const badgeTest: TwentyUiGalleryPlayFunction = async ({
const primaryCircle = canvas.getByLabelText('Primary circle badge');
const secondaryCircle = canvas.getByLabelText('Secondary circle badge');
const inherited = canvas.getByLabelText('Inherited badge');
+ const accent = canvas.getByLabelText('Accent badge');
await waitFor(() => {
expect(extraSmall).toHaveStyle({ height: '14px' });
@@ -42,6 +43,13 @@ export const badgeTest: TwentyUiGalleryPlayFunction = async ({
expect(primaryCircleStyle.color).toBe(
primaryCircleStyle.getPropertyValue('--t-font-color-on-accent').trim(),
);
+ const accentStyle = getComputedStyle(accent);
+ expect(accentStyle.backgroundColor).toBe(
+ accentStyle.getPropertyValue('--t-accent-tertiary').trim(),
+ );
+ expect(accentStyle.color).toBe(
+ accentStyle.getPropertyValue('--t-accent-accent11').trim(),
+ );
expect(getComputedStyle(inherited).color).toBe('rgb(20, 80, 120)');
expect(getComputedStyle(inherited).fontWeight).toBe('600');
});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/dropdownTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/dropdownTest.ts
index f901223b89b..e772436863c 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/dropdownTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/dropdownTest.ts
@@ -104,8 +104,13 @@ export const dropdownTest: TwentyUiGalleryPlayFunction = async ({
await waitFor(() => expect(ada).toHaveFocus(), {
timeout: INTERACTION_TIMEOUT,
});
- expect(search).not.toHaveAttribute('aria-activedescendant');
- expect(ada).not.toHaveAttribute('data-highlighted');
+ await waitFor(
+ () => {
+ expect(search).not.toHaveAttribute('aria-activedescendant');
+ expect(ada).not.toHaveAttribute('data-highlighted');
+ },
+ { timeout: INTERACTION_TIMEOUT },
+ );
await userEvent.keyboard('{ArrowDown}');
await waitFor(() => expect(grace).toHaveFocus(), {
timeout: INTERACTION_TIMEOUT,
diff --git a/packages/twenty-front/src/modules/auth/sign-in-up/components/internal/LastUsedPill.tsx b/packages/twenty-front/src/modules/auth/sign-in-up/components/internal/LastUsedPill.tsx
index fce80e02831..c433e74547f 100644
--- a/packages/twenty-front/src/modules/auth/sign-in-up/components/internal/LastUsedPill.tsx
+++ b/packages/twenty-front/src/modules/auth/sign-in-up/components/internal/LastUsedPill.tsx
@@ -7,16 +7,12 @@ const StyledPillContainer = styled.span`
position: absolute;
right: -14px;
top: -10px;
+`;
- > span[data-badge-size] {
- background: ${themeCssVariables.accent.accent3};
- border: 1px solid ${themeCssVariables.accent.accent5};
- border-radius: ${themeCssVariables.border.radius.pill};
- color: ${themeCssVariables.accent.accent9};
- corner-shape: round;
- font-weight: ${themeCssVariables.font.weight.semiBold};
- height: ${themeCssVariables.spacing[5]};
- }
+const StyledLastUsedBadge = styled(Badge)`
+ border: 1px solid ${themeCssVariables.accent.accent5};
+ font-weight: ${themeCssVariables.font.weight.semiBold};
+ height: ${themeCssVariables.spacing[5]};
`;
export const LastUsedPill = () => {
@@ -24,13 +20,13 @@ export const LastUsedPill = () => {
return (
<StyledPillContainer>
- <Badge>
+ <StyledLastUsedBadge color="accent">
{t({
message: 'Last',
comment:
'Short label (keep brief) indicating the most recently used login method',
})}
- </Badge>
+ </StyledLastUsedBadge>
</StyledPillContainer>
);
};
diff --git a/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAdvancedFilterButton.tsx b/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAdvancedFilterButton.tsx
index f2b4171704d..2350cee5d7b 100644
--- a/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAdvancedFilterButton.tsx
+++ b/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAdvancedFilterButton.tsx
@@ -21,7 +21,6 @@ import { useOpenDropdown } from '@/ui/layout/dropdown/hooks/useOpenDropdown';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { useGetCurrentViewOnly } from '@/views/hooks/useGetCurrentViewOnly';
import { getViewBarAdvancedFilterDropdownId } from '@/views/utils/getViewBarAdvancedFilterDropdownId';
-import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { flushSync } from 'react-dom';
import { RecordFilterGroupLogicalOperator } from 'twenty-shared/types';
@@ -29,16 +28,8 @@ import { isDefined } from 'twenty-shared/utils';
import { doNotTranslate } from 'twenty-shared/i18n';
import { IconFilter } from 'twenty-ui/icon';
import { Badge } from 'twenty-ui/primitives/data-display';
-import { themeCssVariables } from 'twenty-ui/theme';
import { v4 } from 'uuid';
-const StyledBadgeContainer = styled.span`
- > span[data-badge-size] {
- background: ${themeCssVariables.color.blue3};
- color: ${themeCssVariables.color.blue};
- }
-`;
-
export const ViewBarFilterDropdownAdvancedFilterButton = () => {
const rootRecordFilterGroup = useAtomComponentSelectorValue(
rootLevelRecordFilterGroupComponentSelector,
@@ -158,9 +149,9 @@ export const ViewBarFilterDropdownAdvancedFilterButton = () => {
focused={isSelectedItemId}
endIcon={
advancedFilterQuerySubFilterCount > 0 ? (
- <StyledBadgeContainer>
- <Badge>{advancedFilterQuerySubFilterCount.toString()}</Badge>
- </StyledBadgeContainer>
+ <Badge color="accent">
+ {advancedFilterQuerySubFilterCount.toString()}
+ </Badge>
) : undefined
}
>{t`Advanced filter`}</ListItemButton>
diff --git a/packages/twenty-front/src/modules/views/components/__stories__/ViewBarFilterDropdown.stories.tsx b/packages/twenty-front/src/modules/views/components/__stories__/ViewBarFilterDropdown.stories.tsx
index 754642624ad..e9c3dc80af0 100644
--- a/packages/twenty-front/src/modules/views/components/__stories__/ViewBarFilterDropdown.stories.tsx
+++ b/packages/twenty-front/src/modules/views/components/__stories__/ViewBarFilterDropdown.stories.tsx
@@ -300,8 +300,8 @@ export const AdvancedFilterCountBadge: Story = {
await expect(badge).toBeVisible();
await expect(badge).toHaveStyle({
- backgroundColor: badgeStyle.getPropertyValue('--t-color-blue3'),
- color: badgeStyle.getPropertyValue('--t-color-blue'),
+ backgroundColor: badgeStyle.getPropertyValue('--t-accent-tertiary'),
+ color: badgeStyle.getPropertyValue('--t-accent-accent11'),
});
},
};
diff --git a/packages/twenty-ui/docs/badgePropDescriptions.ts b/packages/twenty-ui/docs/badgePropDescriptions.ts
index 1f853b58ac3..c421e747197 100644
--- a/packages/twenty-ui/docs/badgePropDescriptions.ts
+++ b/packages/twenty-ui/docs/badgePropDescriptions.ts
@@ -4,7 +4,7 @@ export const BADGE_PROP_DESCRIPTIONS = {
children: 'Caller-provided text, numbers, icons, or other inline content.',
size: 'Compact height, font size, and spacing: xs, sm, or md.',
color:
- 'Neutral tertiary, inherited text, primary accent, or secondary treatment.',
+ 'Neutral tertiary, inherited text, solid primary accent, soft accent tint, or secondary treatment.',
shape:
'Rounded pill label or fixed circle with width equal to its height. Use pill for longer content.',
render:
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 09687065d55..42fcd8549c3 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -1195,10 +1195,10 @@
},
{
"name": "color",
- "type": "\"inherit\" | \"primary\" | \"secondary\" | \"tertiary\"",
+ "type": "\"accent\" | \"inherit\" | \"primary\" | \"secondary\" | \"tertiary\"",
"required": false,
"defaultValue": "tertiary",
- "description": "Neutral tertiary, inherited text, primary accent, or secondary treatment."
+ "description": "Neutral tertiary, inherited text, solid primary accent, soft accent tint, or secondary treatment."
},
{
"name": "render",
diff --git a/packages/twenty-ui/src/components/feedback/Toaster/__stories__/Toaster.lifecycle.stories.tsx b/packages/twenty-ui/src/components/feedback/Toaster/__stories__/Toaster.lifecycle.stories.tsx
index fe3a50eee80..ad8048e4a56 100644
--- a/packages/twenty-ui/src/components/feedback/Toaster/__stories__/Toaster.lifecycle.stories.tsx
+++ b/packages/twenty-ui/src/components/feedback/Toaster/__stories__/Toaster.lifecycle.stories.tsx
@@ -372,8 +372,10 @@ export const HoverAndFocusPauseAcrossMirrors: Story = {
name: 'Update unrelated notification',
}),
);
- expect(first.getByText('Updated unrelated notification')).toBeVisible();
- expect(second.getByText('Updated unrelated notification')).toBeVisible();
+ await waitFor(() => {
+ expect(first.getByText('Updated unrelated notification')).toBeVisible();
+ expect(second.getByText('Updated unrelated notification')).toBeVisible();
+ });
expect(getCountdown(firstToast)).toBe(firstCountdown);
expect(getCountdown(secondToast)).toBe(secondCountdown);
await user.unhover(firstToast);
diff --git a/packages/twenty-ui/src/primitives/data-display/Badge/Badge.module.scss b/packages/twenty-ui/src/primitives/data-display/Badge/Badge.module.scss
index fcbe40e9ab4..bd97e6aca48 100644
--- a/packages/twenty-ui/src/primitives/data-display/Badge/Badge.module.scss
+++ b/packages/twenty-ui/src/primitives/data-display/Badge/Badge.module.scss
@@ -49,6 +49,11 @@
color: var(--t-font-color-on-accent);
}
+ &[data-badge-color='accent'] {
+ background: var(--t-accent-tertiary);
+ color: var(--t-accent-accent11);
+ }
+
&[data-badge-color='secondary'] {
color: var(--t-font-color-secondary);
}
diff --git a/packages/twenty-ui/src/primitives/data-display/Badge/__stories__/Badge.stories.tsx b/packages/twenty-ui/src/primitives/data-display/Badge/__stories__/Badge.stories.tsx
index c6e9cd93b0e..7deddb8dd21 100644
--- a/packages/twenty-ui/src/primitives/data-display/Badge/__stories__/Badge.stories.tsx
+++ b/packages/twenty-ui/src/primitives/data-display/Badge/__stories__/Badge.stories.tsx
@@ -10,6 +10,7 @@ import { type BadgeSize } from '@ui/primitives/data-display/Badge/types/BadgeSiz
import { Button } from '@ui/primitives/input/Button/Button';
import { Tabs } from '@ui/primitives/navigation/Tabs/Tabs';
import { Text } from '@ui/primitives/typography/Text/Text';
+import { ThemeProvider, themeCssVariables } from '@ui/theme';
import {
A11Y_DEFER_COLOR_CONTRAST,
CatalogDecorator,
@@ -79,6 +80,7 @@ export const Colors: CatalogStory<Story, typeof Badge> = {
'inherit',
'primary',
'secondary',
+ 'accent',
] satisfies BadgeColor[],
props: (color: BadgeColor) => ({ color }),
},
@@ -87,6 +89,48 @@ export const Colors: CatalogStory<Story, typeof Badge> = {
},
};
+export const Accent: Story = {
+ parameters: {
+ a11y: {
+ test: 'error',
+ config: { rules: [{ id: 'color-contrast', enabled: true }] },
+ },
+ },
+ render: () => (
+ <Text render={<div />} style={{ display: 'flex', gap: 16 }}>
+ {(['light', 'dark'] as const).map((colorScheme) => (
+ <ThemeProvider
+ key={colorScheme}
+ colorScheme={colorScheme}
+ applyToRoot={false}
+ >
+ <Text
+ render={<div />}
+ style={{
+ alignItems: 'center',
+ backgroundColor: themeCssVariables.background.primary,
+ display: 'flex',
+ gap: 8,
+ padding: 16,
+ }}
+ >
+ {(['xs', 'sm', 'md'] as const).map((size) => (
+ <Badge
+ key={size}
+ color="accent"
+ size={size}
+ aria-label={`${colorScheme} accent ${size}`}
+ >
+ Accent
+ </Badge>
+ ))}
+ </Text>
+ </ThemeProvider>
+ ))}
+ </Text>
+ ),
+};
+
export const VisualRegression: CatalogStory<Story, typeof Badge> = {
tags: ['!autodocs'],
args: { children: 3 },
@@ -105,6 +149,7 @@ export const VisualRegression: CatalogStory<Story, typeof Badge> = {
'inherit',
'primary',
'secondary',
+ 'accent',
] satisfies BadgeColor[],
props: (color: BadgeColor) => ({ color }),
},
@@ -119,7 +164,7 @@ export const VisualRegression: CatalogStory<Story, typeof Badge> = {
decorators: [CatalogDecorator],
play: async ({ canvasElement }) => {
const badges = within(canvasElement).getAllByText('3');
- await expect(badges).toHaveLength(24);
+ await expect(badges).toHaveLength(30);
for (const badge of badges) {
await expect(badge).toBeVisible();
diff --git a/packages/twenty-ui/src/primitives/data-display/Badge/types/BadgeColor.ts b/packages/twenty-ui/src/primitives/data-display/Badge/types/BadgeColor.ts
index 39ab5c1d317..389fc1a4717 100644
--- a/packages/twenty-ui/src/primitives/data-display/Badge/types/BadgeColor.ts
+++ b/packages/twenty-ui/src/primitives/data-display/Badge/types/BadgeColor.ts
@@ -1 +1,6 @@
-export type BadgeColor = 'tertiary' | 'inherit' | 'primary' | 'secondary';
+export type BadgeColor =
+ | 'tertiary'
+ | 'inherit'
+ | 'primary'
+ | 'secondary'
+ | 'accent';