The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Restore appearance card design (#27051)
Raphaël Bosic7299510dab9
diff --git a/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsAppearance.tsx b/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsAppearance.tsxindex b1bf96983f2..ce3c6e81284 100644--- a/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsAppearance.tsx+++ b/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsAppearance.tsx@@ -7,45 +7,23 @@ import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateimport { type ColorScheme } from '@/workspace-member/types/WorkspaceMember';import { isDefined } from 'twenty-shared/utils';import { Section } from 'twenty-ui/components';-import { Radio, RadioGroup } from 'twenty-ui/primitives/input';+import { RadioGroup } from 'twenty-ui/primitives/input';import { MOBILE_VIEWPORT, themeCssVariables } from 'twenty-ui/theme';-import { SettingsAppearancePreview } from '~/pages/settings/profile/appearance/components/SettingsAppearancePreview';+import { SettingsAppearanceOption } from '~/pages/settings/profile/appearance/components/SettingsAppearanceOption';const StyledChoices = styled.div`- box-sizing: border-box;- overflow-x: auto;- padding: ${themeCssVariables.spacing[1]};width: 100%;&& {flex-direction: row;gap: ${themeCssVariables.spacing[4]};}-`;--const StyledChoice = styled.div`- flex: 1 1 0;- min-width: 0;@media (max-width: ${MOBILE_VIEWPORT}px) {- flex: 0 0 160px;+ overflow-x: auto;}`;-const StyledChoiceContent = styled.div`- display: flex;- flex-direction: column;- gap: ${themeCssVariables.spacing[2]};- width: 100%;-`;--const StyledLabel = styled.span`- color: ${themeCssVariables.font.color.secondary};- font-size: ${themeCssVariables.font.size.xs};- font-weight: ${themeCssVariables.font.weight.medium};- padding-inline-end: ${themeCssVariables.spacing[6]};-`;-export const SettingsAppearance = () => {const { t } = useLingui();const { colorScheme, setColorScheme } = useColorScheme();@@ -69,18 +47,11 @@ export const SettingsAppearance = () => {}}>{choices.map(({ value, label }) => (- <Radio- render={<StyledChoice />}+ <SettingsAppearanceOptionkey={value}- variant="card"- value={value}- aria-label={label}- >- <StyledChoiceContent>- <StyledLabel>{label}</StyledLabel>- <SettingsAppearancePreview colorScheme={value} />- </StyledChoiceContent>- </Radio>+ colorScheme={value}+ label={label}+ />))}</RadioGroup></Section.Root>diff --git a/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsAppearanceOption.tsx b/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsAppearanceOption.tsxnew file mode 100644index 00000000000..1506b4f42f5--- /dev/null+++ b/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsAppearanceOption.tsx@@ -0,0 +1,108 @@+import { styled } from '@linaria/react';+import { useId } from 'react';++import { type ColorScheme } from '@/workspace-member/types/WorkspaceMember';+import { IconCheck } from 'twenty-ui/icon';+import { Radio } from 'twenty-ui/primitives/input';+import { MOBILE_VIEWPORT, themeCssVariables, useTheme } from 'twenty-ui/theme';+import { SettingsAppearancePreview } from '~/pages/settings/profile/appearance/components/SettingsAppearancePreview';++const StyledChoice = styled.label`+ display: flex;+ flex: 1 1 0;+ flex-direction: column;+ min-width: 0;++ @media (max-width: ${MOBILE_VIEWPORT}px) {+ flex: 0 0 160px;+ }+`;++const StyledRadio = styled.div`+ border-radius: ${themeCssVariables.border.radius.md};+ position: relative;++ && {+ display: block;+ width: 100%;+ }++ @media (max-width: ${MOBILE_VIEWPORT}px) {+ &&:focus-visible {+ outline-offset: -2px;+ }+ }+`;++const StyledCheckmark = styled.div`+ align-items: center;+ background-color: ${themeCssVariables.color.blue};+ border-radius: ${themeCssVariables.border.radius.rounded};+ bottom: ${themeCssVariables.spacing[2]};+ color: ${themeCssVariables.grayScale.gray1};+ corner-shape: round;+ display: flex;+ height: ${themeCssVariables.spacing[5]};+ inset-inline-end: ${themeCssVariables.spacing[2]};+ justify-content: center;+ opacity: 0;+ position: absolute;+ transition:+ opacity 0.3s ease-in-out,+ visibility 0s linear 0.3s;+ visibility: hidden;+ width: ${themeCssVariables.spacing[5]};++ [data-checked] > & {+ opacity: 1;+ transition:+ opacity 0.3s ease-in-out,+ visibility 0s;+ visibility: visible;+ }++ @media (prefers-reduced-motion: reduce) {+ &,+ [data-checked] > & {+ transition: none;+ }+ }+`;++const StyledLabel = styled.span`+ color: ${themeCssVariables.font.color.secondary};+ font-size: ${themeCssVariables.font.size.xs};+ font-weight: ${themeCssVariables.font.weight.medium};+ margin-top: ${themeCssVariables.spacing[2]};+`;++type SettingsAppearanceOptionProps = {+ colorScheme: ColorScheme;+ label: string;+};++export const SettingsAppearanceOption = ({+ colorScheme,+ label,+}: SettingsAppearanceOptionProps) => {+ const theme = useTheme();+ const labelId = useId();++ return (+ <StyledChoice>+ <Radio+ value={colorScheme}+ aria-labelledby={labelId}+ render={+ <StyledRadio>+ <SettingsAppearancePreview colorScheme={colorScheme} />+ <StyledCheckmark aria-hidden>+ <IconCheck size={theme.icon.size.sm} />+ </StyledCheckmark>+ </StyledRadio>+ }+ />+ <StyledLabel id={labelId}>{label}</StyledLabel>+ </StyledChoice>+ );+};diff --git a/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsAppearancePreview.tsx b/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsAppearancePreview.tsxindex 4469ae81a69..98740147d18 100644--- a/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsAppearancePreview.tsx+++ b/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsAppearancePreview.tsx@@ -26,6 +26,16 @@ const StyledSegment = styled.div`min-width: 0;padding-inline-start: ${themeCssVariables.spacing[6]};padding-top: ${themeCssVariables.spacing[6]};++ &:first-child {+ border-end-start-radius: ${themeCssVariables.border.radius.md};+ border-start-start-radius: ${themeCssVariables.border.radius.md};+ }++ &:last-child {+ border-end-end-radius: ${themeCssVariables.border.radius.md};+ border-start-end-radius: ${themeCssVariables.border.radius.md};+ }`;const StyledContent = styled.div`diff --git a/packages/twenty-front/src/pages/settings/profile/appearance/components/__stories__/SettingsAppearance.interactions.stories.tsx b/packages/twenty-front/src/pages/settings/profile/appearance/components/__stories__/SettingsAppearance.interactions.stories.tsxindex 07d34fdaec7..940c27ea5f2 100644--- a/packages/twenty-front/src/pages/settings/profile/appearance/components/__stories__/SettingsAppearance.interactions.stories.tsx+++ b/packages/twenty-front/src/pages/settings/profile/appearance/components/__stories__/SettingsAppearance.interactions.stories.tsx@@ -53,7 +53,7 @@ export const SelectionAndKeyboard: Story = {expect(group.getAllByRole('radio')).toHaveLength(3);expect(light).toBeChecked();- await userEvent.click(dark);+ await userEvent.click(group.getByText('Dark'));await waitFor(() => expect(dark).toBeChecked());expect(light).not.toBeChecked();expect(jotaiStore.get(persistedColorSchemeState.atom)).toBe('Dark');@@ -89,9 +89,12 @@ export const UnavailableMember: Story = {parameters: { disabled: true },play: async ({ canvasElement }) => {const canvas = within(canvasElement);- for (const radio of canvas.getAllByRole('radio')) {+ for (const label of ['Light', 'Dark', 'System settings']) {+ const radio = canvas.getByRole('radio', { name: label });+expect(radio).toHaveAttribute('aria-disabled', 'true');await userEvent.click(radio);+ await userEvent.click(canvas.getByText(label));}expect(savePreference).not.toHaveBeenCalled();expect(jotaiStore.get(persistedColorSchemeState.atom)).toBe('Light');diff --git a/packages/twenty-front/src/pages/settings/profile/appearance/components/__stories__/SettingsAppearance.stories.tsx b/packages/twenty-front/src/pages/settings/profile/appearance/components/__stories__/SettingsAppearance.stories.tsxindex 42c555f5c4e..ec95ae74604 100644--- a/packages/twenty-front/src/pages/settings/profile/appearance/components/__stories__/SettingsAppearance.stories.tsx+++ b/packages/twenty-front/src/pages/settings/profile/appearance/components/__stories__/SettingsAppearance.stories.tsx@@ -53,6 +53,16 @@ const meta = {? 'System settings': selectedColorScheme;+ for (const label of ['Light', 'Dark', 'System settings']) {+ const radioBounds = group+ .getByRole('radio', { name: label })+ .getBoundingClientRect();+ const labelBounds = group.getByText(label).getBoundingClientRect();++ expect(radioBounds.height).toBe(80);+ expect(labelBounds.top - radioBounds.bottom).toBe(8);+ }+expect(group.getAllByRole('radio', { checked: true })).toHaveLength(1);expect(group.getByRole('radio', { checked: true })).toHaveAccessibleName(selectedLabel,