Files
twenty/packages/twenty-website/src/ui/Body.tsx
T
Abdullah. 569d887d1e [Website] Cut over to the rebuilt site (#21825)
Renaming the package so any further PRs directed to the website are
targeted to the reworked code instead of diverging. Once merged, I will
start preparing this for deployment to dev to test before releasing to
prod. Any improvements will also be applied to this package.

I avoided making significant changes to API routes so nothing breaks,
but will test it thoroughly today to confirm. That said, everything is
ported - double checked.

Big diff PR, impossible to review, but last one! No more rebuilds.
2026-06-19 10:22:46 +02:00

75 lines
1.3 KiB
TypeScript

import { css } from '@linaria/core';
import { type ReactNode } from 'react';
import {
FONT_WEIGHT,
fontFamily,
type FontWeightToken,
semanticColor,
typeRampDeclarations,
} from '@/tokens';
const bodyClassName = css`
font-family: ${fontFamily('sans')};
&[data-weight='light'] {
font-weight: ${FONT_WEIGHT.light};
}
&[data-weight='regular'] {
font-weight: ${FONT_WEIGHT.regular};
}
&[data-weight='medium'] {
font-weight: ${FONT_WEIGHT.medium};
}
&[data-size='md'] {
${typeRampDeclarations('bodyMd')}
}
&[data-size='sm'] {
${typeRampDeclarations('bodySm')}
}
&[data-size='xs'] {
${typeRampDeclarations('bodyXs')}
}
&[data-muted] {
color: ${semanticColor.inkMuted};
}
`;
export type BodyElement = 'p' | 'span' | 'div';
export type BodySize = 'md' | 'sm' | 'xs';
export type BodyProps = {
as?: BodyElement;
children: ReactNode;
className?: string;
muted?: boolean;
size?: BodySize;
weight?: FontWeightToken;
};
export function Body({
as: Tag = 'p',
children,
className,
muted = false,
size = 'md',
weight = 'regular',
}: BodyProps) {
return (
<Tag
className={[bodyClassName, className].filter(Boolean).join(' ')}
data-muted={muted ? '' : undefined}
data-size={size}
data-weight={weight}
>
{children}
</Tag>
);
}