Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions src/__cosmos__/fixtures/Typography.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,100 @@ export default function TypographyFixture() {
</CodeExample>
</div>

{/* Semantic Color Variants */}
<div className="lsd:border lsd:border-lsd-border lsd:p-6 lsd:rounded-lg">
<Typography
variant="h3"
className="lsd:mb-4 lsd:pb-2 lsd:border-b lsd:border-lsd-border"
>
Semantic Color Variants
</Typography>
<CodeExample
title="Semantic Color Variants"
code={`<div className="lsd:flex lsd:flex-col lsd:gap-2">
<Typography variant="body1" color="destructive">
Destructive - Error or danger message
</Typography>
<Typography variant="body1" color="success">
Success - Operation completed successfully
</Typography>
<Typography variant="body1" color="warning">
Warning - Cautionary message
</Typography>
<Typography variant="body1" color="info">
Info - Informational message
</Typography>
</div>`}
>
<div className="lsd:flex lsd:flex-col lsd:gap-2">
<Typography variant="body1" color="destructive">
Destructive - Error or danger message
</Typography>
<Typography variant="body1" color="success">
Success - Operation completed successfully
</Typography>
<Typography variant="body1" color="warning">
Warning - Cautionary message
</Typography>
<Typography variant="body1" color="info">
Info - Informational message
</Typography>
</div>
</CodeExample>
</div>

{/* Multi-Color Text */}
<div className="lsd:border lsd:border-lsd-border lsd:p-6 lsd:rounded-lg">
<Typography
variant="h3"
className="lsd:mb-4 lsd:pb-2 lsd:border-b lsd:border-lsd-border"
>
Multi-Color Text
</Typography>
<CodeExample
title="Multi-Color Text"
code={`<Typography variant="body1">
<Typography as="span" color="primary">Primary</Typography>
{' and '}
<Typography as="span" color="success">success</Typography>
{' text together'}
</Typography>

<Typography variant="body1">
Status: <Typography as="span" color="success">Completed</Typography>
</Typography>

<Typography variant="body1">
<Typography as="span" color="destructive">Error:</Typography> Something went wrong
</Typography>`}
>
<div className="lsd:flex lsd:flex-col lsd:gap-4">
<Typography variant="body1">
<Typography as="span" color="primary">
Primary
</Typography>
{' and '}
<Typography as="span" color="success">
success
</Typography>
{' text together'}
</Typography>
<Typography variant="body1">
Status:{' '}
<Typography as="span" color="success">
Completed
</Typography>
</Typography>
<Typography variant="body1">
<Typography as="span" color="destructive">
Error:
</Typography>{' '}
Something went wrong
</Typography>
</div>
</CodeExample>
</div>

{/* Font Family Variants */}
<div className="lsd:border lsd:border-lsd-border lsd:p-6 lsd:rounded-lg">
<Typography
Expand Down
4 changes: 4 additions & 0 deletions src/components/ui/typography/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export const typographyVariants = cva('', {
color: {
primary: 'lsd:text-lsd-text-primary',
secondary: 'lsd:text-lsd-text-secondary',
destructive: 'lsd:text-lsd-destructive-text',
success: 'lsd:text-lsd-success-text',
warning: 'lsd:text-lsd-warning-text',
info: 'lsd:text-lsd-info-text',
},
},
defaultVariants: {
Expand Down
48 changes: 48 additions & 0 deletions src/components/ui/typography/typography.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,30 @@ describe('Typography', () => {
expect(element).toHaveClass('lsd:text-lsd-text-secondary');
});

it('applies destructive color classes correctly', () => {
render(<Typography color="destructive">Destructive</Typography>);
const element = screen.getByText('Destructive');
expect(element).toHaveClass('lsd:text-lsd-destructive-text');
});

it('applies success color classes correctly', () => {
render(<Typography color="success">Success</Typography>);
const element = screen.getByText('Success');
expect(element).toHaveClass('lsd:text-lsd-success-text');
});

it('applies warning color classes correctly', () => {
render(<Typography color="warning">Warning</Typography>);
const element = screen.getByText('Warning');
expect(element).toHaveClass('lsd:text-lsd-warning-text');
});

it('applies info color classes correctly', () => {
render(<Typography color="info">Info</Typography>);
const element = screen.getByText('Info');
expect(element).toHaveClass('lsd:text-lsd-info-text');
});

it('merges custom className with component classes', () => {
render(<Typography className="custom-class">Custom</Typography>);
const element = screen.getByText('Custom');
Expand Down Expand Up @@ -256,6 +280,30 @@ describe('typographyVariants', () => {
);
});

it('returns correct classes for destructive color', () => {
expect(typographyVariants({ color: 'destructive' })).toContain(
'lsd:text-lsd-destructive-text',
);
});

it('returns correct classes for success color', () => {
expect(typographyVariants({ color: 'success' })).toContain(
'lsd:text-lsd-success-text',
);
});

it('returns correct classes for warning color', () => {
expect(typographyVariants({ color: 'warning' })).toContain(
'lsd:text-lsd-warning-text',
);
});

it('returns correct classes for info color', () => {
expect(typographyVariants({ color: 'info' })).toContain(
'lsd:text-lsd-info-text',
);
});

it('uses default variant when not specified', () => {
expect(typographyVariants({})).toContain('lsd:text-[1rem]');
});
Expand Down