Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

524-refactor: Widget OptionItem #542

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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
4 changes: 2 additions & 2 deletions src/widgets/contribute/ui/contribute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import image from '@/shared/assets/contribute.webp';
import { Image } from '@/shared/ui/image';
import { Paragraph } from '@/shared/ui/paragraph';
import { WidgetTitle } from '@/shared/ui/widget-title';
import { OptionItem, OptionItemProps } from '@/widgets/option-item';
import { OptionItem } from '@/widgets/option-item';

import './contribute.scss';

const contributeOptions: OptionItemProps[] = [
const contributeOptions = [
{
title: 'Mentorship',
description:
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/option-item/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { OptionItem, type OptionItemProps } from './ui/option-item';
export { OptionItem } from './ui/option-item';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { OptionItem } from './ui/option-item';
import { OptionItem } from './option-item';
import { renderWithRouter } from '@/shared/__tests__/utils';

describe('OptionItem component', () => {
Expand Down
12 changes: 5 additions & 7 deletions src/widgets/option-item/ui/option-item.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
// todo it not widget
import { LinkCustom } from '@/shared/ui/link-custom';
import { Paragraph } from '@/shared/ui/paragraph';

import './option-item.scss';

export type OptionItemProps = {
type OptionItemProps = {
title: string;
description: string;
linkLabel?: string;
href?: string;
};

export const OptionItem = ({ title, description, linkLabel, href = '' }: OptionItemProps) => (
<div key={title} className="option">
<article key={title} className="option">
<h3 className="option-title">{title}</h3>
<p className="option-description" role="text">
{description}
</p>
<Paragraph className="option-description">{description}</Paragraph>
{linkLabel && (
<LinkCustom href={href} variant="primary" external>
{linkLabel}
</LinkCustom>
)}
</div>
</article>
);
4 changes: 1 addition & 3 deletions src/widgets/study-with-us/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { OptionItemProps } from '@/widgets/option-item/ui/option-item';

export const studyOptions: OptionItemProps[] = [
export const studyOptions = [
{
title: 'Teach and empower',
description:
Expand Down
8 changes: 6 additions & 2 deletions src/widgets/study-with-us/study-with-us.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ describe('School Component', () => {
});

it('renders the correct description for each study option', () => {
const descriptions = screen.getAllByRole('text');
const descriptions = screen.getAllByTestId('paragraph');

descriptions.forEach((description, index) => {
const optionDescription = descriptions.filter((paragraph) =>
paragraph.classList.contains('option-description'),
);

optionDescription.forEach((description, index) => {
expect(description.textContent).toBe(studyOptions[index].description);
});
});
Expand Down
Loading