Skip to content

Commit

Permalink
more precision changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sirineJ committed Mar 11, 2025
1 parent 6bbb7bd commit 0ce4180
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ describe('ComparisonTable', () => {
it('should update displayed plans when a new plan is picked', async () => {
render(<ComparisonTable {...baseProps} />);
expect(
screen.getByRole('columnheader', { name: 'POS plus 14.99$ /month' }),
screen.getByRole('columnheader', { name: 'plus 15$/month' }),
).toBeInTheDocument();

await userEvent.selectOptions(
screen.getByLabelText(baseProps.selectFirstPlanLabel),
'POS Pro',
);
expect(
screen.getByRole('columnheader', { name: 'POS plus 14.99$ /month' }),
screen.getByRole('columnheader', { name: 'plus 15$/month' }),
).toBeVisible();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ export default {
const baseProps: ComparisonTableProps = {
caption: 'Compare plans',
plans: [posPlan, posPlusPlan, posProPlan],
sections: [
bankingBasicsSection,
productCatalogSection,
bookingsSection,
cashManagementSection,
],
sections: [bankingBasicsSection],
showAllFeaturesLabel: 'Show all features',
selectSecondPlanLabel: 'Select a second plan',
selectFirstPlanLabel: 'Select a first plan',
Expand All @@ -50,5 +45,17 @@ const baseProps: ComparisonTableProps = {
export const Base = (args: ComparisonTableProps) => (
<ComparisonTable {...args} />
);

Base.args = baseProps;
export const Collapsed = (args: ComparisonTableProps) => (
<ComparisonTable {...args} />
);

Collapsed.args = {
...baseProps,
sections: [
...baseProps.sections,
productCatalogSection,
bookingsSection,
cashManagementSection,
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const ComparisonTable = forwardRef<
}

const [activePlans, setActivePlans] = useState<number[]>([0, 1]);
const isMobile = useMedia('(max-width: 479px)');
const isMobile = useMedia('(max-width: 767px)');

const planOptions = plans.map((plan, index) => ({
label: plan.title,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
.base {
display: flex;
gap: var(--cui-spacings-kilo);
justify-content: center;
width: 100%;
margin-bottom: var(--cui-spacings-giga);
}

.select {
width: 100%;
@media (max-width: 479px) {
.select {
width: 100%;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,17 @@
color-mix(in sRGB, var(--cui-bg-normal) 100%, transparent)
);
}

@media (max-width: 767px) {
.base th {
width: 30%;
}

.base th:first-child {
width: 40%;
}

.base {
table-layout: fixed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('PlanTable', () => {
expect(screen.getAllByRole('columnheader')).toHaveLength(2);
expect(
screen.queryByRole('columnheader', {
name: 'POS Pro plus 24.99$ /month Join now',
name: 'POS Pro plus 25$ /month Join now',
}),
).not.toBeInTheDocument();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { applyMultipleRefs } from '../../../../util/refs.js';
import { throttle } from '../../../../util/helpers.js';
import { Compact } from '../../../Compact/index.js';
import { useMedia } from '../../../../hooks/useMedia/index.js';
import { Body } from '../../../Body/index.js';

import classes from './PlanTable.module.css';

Expand Down Expand Up @@ -75,7 +76,7 @@ export const PlanTable = forwardRef<HTMLTableElement, PlanTableProps>(
ref,
) => {
const tableRef = useRef<HTMLTableElement>(null);
const isMobile = useMedia('(max-width: 479px)');
const isMobile = useMedia('(max-width: 767px)');
const [isCollapsed, setIsCollapsed] = useState(
sections.reduce(
(totalRows, section) => totalRows + section.features.length + 1,
Expand Down Expand Up @@ -117,6 +118,8 @@ export const PlanTable = forwardRef<HTMLTableElement, PlanTableProps>(
}
}, [isCollapsed]);

const SectionTitleElement = isMobile ? Compact : Body;

return (
<div className={classes.wrapper}>
<table
Expand Down Expand Up @@ -151,12 +154,9 @@ export const PlanTable = forwardRef<HTMLTableElement, PlanTableProps>(
top: `${headerHeight}px`,
}}
>
<Compact
size={isMobile ? 'm' : 'l'}
weight={isMobile ? 'semibold' : 'bold'}
>
<SectionTitleElement size="m" weight="semibold">
{row.title}
</Compact>
</SectionTitleElement>
</th>
</tr>
{row.features.map((feature) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,3 @@
.description {
text-align: start;
}

.border {
border-left: 1px solid var(--cui-border-divider);
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const TableCell = ({
toggletip,
...props
}: TableCellProps) => {
const isMobile = useMedia('(max-width: 479px)');
const isMobile = useMedia('(max-width: 767px)');
const Element = isHeader ? 'th' : 'td';
let cellValue = <BooleanValue label={label} value={false} />;
if (typeof value === 'string') {
Expand All @@ -69,7 +69,7 @@ export const TableCell = ({

return (
<Element
className={clsx(classes.base, !isHeader && classes.border, className)}
className={clsx(classes.base, className)}
scope={isHeader ? 'row' : undefined}
{...props}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
flex-direction: column;
align-items: center;
justify-content: center;
padding: 0 var(--cui-spacings-mega);
min-height: 96px;
padding: 0 var(--cui-spacings-kilo);
border-right: 1px solid var(--cui-border-subtle);
}

.wrapper {
padding: var(--cui-spacings-mega) 0;
vertical-align: bottom;
}

.title {
Expand All @@ -19,6 +20,12 @@
margin-bottom: var(--cui-spacings-bit);
}

.description {
margin-bottom: var(--cui-spacings-mega);
@media (min-width: 768px) {
.base {
padding: 0 var(--cui-spacings-mega);
}

.description {
margin-bottom: var(--cui-spacings-mega);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,18 @@ export const TableHeader = ({
tier,
callToAction,
}: TableHeaderProps) => {
const isMobile = useMedia('(max-width: 479px)');
const isMobile = useMedia('(max-width: 767px)');

return (
<th scope="col" className={classes.wrapper}>
<div className={classes.base}>
<div>
<Compact
className={classes.title}
size={isMobile ? 's' : 'm'}
weight="bold"
>
{title}
</Compact>
{tier && <TierIndicator {...tier} size="s" />}
<div className={classes.title}>
{(!isMobile || (isMobile && !tier)) && (
<Compact size={isMobile ? 'm' : 'l'} weight="bold">
{title}
</Compact>
)}
{tier && <TierIndicator {...tier} size={isMobile ? 's' : 'm'} />}
</div>

<Body size={isMobile ? 's' : 'm'} className={classes.description}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.border {
border-left: 1px solid var(--cui-border-divider);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import type { HTMLAttributes } from 'react';

import { TableCell, type TableCellProps } from '../TableCell/TableCell.js';
import { clsx } from '../../../../styles/clsx.js';

import classes from './FeatureRow.module.css';

export interface FeatureRowProps extends HTMLAttributes<HTMLTableRowElement> {
featureDescription: Pick<
Expand All @@ -42,7 +45,12 @@ export const FeatureRow = ({
toggletip={featureDescription.toggletip}
/>
{values.map(({ value, label }, index) => (
<TableCell key={`${label}-${index}`} value={value} label={label} />
<TableCell
className={clsx(index > 0 && classes.border)}
key={`${label}-${index}`}
value={value}
label={label}
/>
))}
</tr>
);
4 changes: 2 additions & 2 deletions packages/circuit-ui/components/ComparisonTable/fixtures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const posPlusPlan: TableHeaderProps = {
title: 'POS',
id: 'pos_plus',
tier: { variant: 'plus' },
description: '14.99$ /month',
description: '15$/month',
callToAction: {
children: 'Join now',
href: 'https://sumup.com/plus',
Expand All @@ -46,7 +46,7 @@ export const posProPlan: TableHeaderProps = {
title: 'POS Pro',
id: 'pos_pro',
tier: { variant: 'plus' },
description: '24.99$ /month',
description: '25$/month',
callToAction: {
children: 'Join now',
href: 'https://sumup.com/pro',
Expand Down

0 comments on commit 0ce4180

Please sign in to comment.