The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix empty relation card vertical padding (#25595)
Thomas des Francs61bcd4f6c0da
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/WidgetCardContent.tsx b/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/WidgetCardContent.tsxindex 0fa308db3f4..9b3ec14a78b 100644--- a/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/WidgetCardContent.tsx+++ b/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/WidgetCardContent.tsx@@ -43,6 +43,10 @@ const StyledWidgetCardContent = styled.div<WidgetCardContentStyledProps>`&:empty {margin-top: 0;padding: 0;+ padding-bottom: ${({ hasHeader, variant }) =>+ hasHeader && variant === 'flush'+ ? 'var(--widget-card-title-padding-top)'+ : '0'};}`;diff --git a/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/__stories__/WidgetCard.stories.tsx b/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/__stories__/WidgetCard.stories.tsxindex 0532fbdc362..f5a8d676a80 100644--- a/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/__stories__/WidgetCard.stories.tsx+++ b/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/__stories__/WidgetCard.stories.tsx@@ -2,8 +2,12 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';import { type CSSProperties } from 'react';import { expect, within } from 'storybook/test';+import { PageLayoutTestWrapper } from '@/page-layout/hooks/__tests__/PageLayoutTestWrapper';import { WidgetCard } from '@/page-layout/widgets/widget-card/components/WidgetCard';+import { WidgetCardContent } from '@/page-layout/widgets/widget-card/components/WidgetCardContent';+import { WidgetCardHeader } from '@/page-layout/widgets/widget-card/components/WidgetCardHeader';import { ComponentDecorator } from 'twenty-ui/testing';+import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';const meta: Meta<typeof WidgetCard> = {title: 'Modules/PageLayout/Widgets/WidgetCard',@@ -88,3 +92,54 @@ export const FlushWhileDragging: Story = {await expect(cardStyle.backgroundColor).not.toBe('rgba(0, 0, 0, 0)');},};++export const EmptyFlush: Story = {+ args: {+ variant: 'flush',+ },+ decorators: [MemoryRouterDecorator],+ render: (args) => (+ <PageLayoutTestWrapper>+ <div style={{ width: 320, '--widget-height': 'auto' } as CSSProperties}>+ {/* oxlint-disable-next-line react/jsx-props-no-spreading */}+ <WidgetCard {...args}>+ <WidgetCardHeader+ widgetId="empty-widget-card"+ variant={args.variant}+ isInEditMode={args.isEditable}+ title="Calendar Event"+ />+ <WidgetCardContent+ variant={args.variant}+ hasHeader+ isEditable={args.isEditable}+ />+ </WidgetCard>+ </div>+ </PageLayoutTestWrapper>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const card = canvas.getByTestId('widget-card');+ const title = canvas.getByText('Calendar Event');++ await expect(title).toBeVisible();++ const cardBounds = card.getBoundingClientRect();+ const titleBounds = title.getBoundingClientRect();+ const topInset = titleBounds.top - cardBounds.top;+ const bottomInset = cardBounds.bottom - titleBounds.bottom;++ await expect(bottomInset).toBeGreaterThan(0);+ await expect(bottomInset).toBeCloseTo(topInset, 1);+ },+};++export const EmptyFlushInEditMode: Story = {+ ...EmptyFlush,+ args: {+ variant: 'flush',+ isEditable: true,+ isEditing: true,+ },+};