Skip to content

742-refactor: Update subtitle to support heading tags #844

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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
de1d4b9
refactor: 742 - update subtitle to support heading tags
oibioib Mar 9, 2025
7b9bb6f
test: 742 - add tests for different heading tags in subtitle
oibioib Mar 9, 2025
882f10c
refactor: 742 - change MentorFeedbackCard
oibioib Mar 9, 2025
e148dab
refactor: 742 - change MentorsAfterRegister
oibioib Mar 9, 2025
8efc46c
chore: 742 - merge main
oibioib Apr 7, 2025
d633733
chore: 742 - merge main
oibioib Apr 7, 2025
d90b767
refactor: 742 - make subtitle props naming consistent
oibioib Apr 8, 2025
97ffee7
refactor: 742 - add subtitle to search component
oibioib Apr 8, 2025
9ddf6eb
refactor: 742 - add subtitle to modal component
oibioib Apr 8, 2025
f861e24
refactor: 742 - change modal component styles
oibioib Apr 8, 2025
f513af1
refactor: 742 - add subtitle to event-card component
oibioib Apr 8, 2025
f67af9f
fix: 742 - add subtitle to event title
oibioib Apr 8, 2025
d74bf8a
refactor: 742 - add subtitle to trainer-card component
oibioib Apr 8, 2025
185da33
refactor: 742 - add subtitle to playlist component
oibioib Apr 8, 2025
9757a5f
refactor: 742 - add subtitle to school-menu component
oibioib Apr 9, 2025
1b771cf
fix: 742 - change school-menu line height
oibioib Apr 9, 2025
224fdd2
fix: 742 - change card-subtitle in trainer-card
oibioib Apr 9, 2025
cad043b
fix: 742 - add bold style to playlist title
oibioib Apr 10, 2025
dc6f3db
refactor: 742 - change subtitle styles classes
oibioib Apr 16, 2025
4f92b13
refactor: 742 - change tests
oibioib Apr 16, 2025
04db309
refactor: 742 - change subtitle order of parameters
oibioib Apr 16, 2025
99de2c3
refactor: 742 - change search gap
oibioib Apr 16, 2025
9f3d2ab
refactor: 742 - trainer card subtitle line-height
oibioib Apr 16, 2025
0adb410
refactor: 742 - change mentor-feedback-card
oibioib Apr 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
.docs-content {
display: flex;
flex-direction: column;
gap: 40px;
gap: 50px;

width: 100%;
min-width: 0;
Expand Down
3 changes: 2 additions & 1 deletion src/app/docs/components/search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createPortal } from 'react-dom';

import MOCKED_SEARCH from '../../mocked_search';
import { Language } from '@/shared/types';
import { Subtitle } from '@/shared/ui/subtitle';

import styles from './search.module.scss';

Expand Down Expand Up @@ -127,7 +128,7 @@ function Result({ result }: { result: PagefindSearchResult }) {
return (
<div>
<Link href={removeHtmlExtension(data.url)}>
<h3>{data.meta.title}</h3>
<Subtitle fontSize="extra-small" fontWeight="bold">{data.meta.title}</Subtitle>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change params to size & weight

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change Subtitle props
fontSize -> size
fontWeight -> weight
?

<p dangerouslySetInnerHTML={{ __html: data.excerpt }} />
</Link>

Expand Down
4 changes: 0 additions & 4 deletions src/entities/event/ui/event-card/event-card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,10 @@

.organized-by {
margin-bottom: 0;
font-weight: $font-weight-regular;
}

.event-organization {
margin-top: 10px;
font-size: 20px;
font-weight: $font-weight-medium;
}
}

Expand All @@ -66,7 +63,6 @@
.event-title {
margin-top: 16px;
margin-bottom: 0;
font-weight: $font-weight-medium;
line-height: 32px;

@include media-mobile {
Expand Down
15 changes: 11 additions & 4 deletions src/entities/event/ui/event-card/event-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import classNames from 'classnames/bind';

import { Event } from '@/entities/event';
import { LinkCustom } from '@/shared/ui/link-custom';
import { Subtitle } from '@/shared/ui/subtitle';

import styles from './event-card.module.scss';

Expand Down Expand Up @@ -30,12 +31,18 @@ export const EventCard = ({
<div className={cx('card-header')} data-testid="card-header">
<p className={cx('event-tag')}>{eventType}</p>
<section className={cx('about-organization')} data-testid="organization-section">
<h4 className={cx('organized-by')}>{organizedBy}</h4>
<h3 className={cx('event-organization')}>{organization}</h3>
<Subtitle className={cx('organized-by')} fontWeight="regular">
{organizedBy}
</Subtitle>
<Subtitle as="h4" className={cx('event-organization')} fontSize="extra-small">
{organization}
</Subtitle>
</section>
<section className={cx('about-event')} data-testid="about-section">
<h2 className={cx('event-title')}>{title}</h2>
<p title={additionalInfo} className={cx('event-additional-info')}>{additionalInfo}</p>
<Subtitle className={cx('event-title')}>{title}</Subtitle>
<p title={additionalInfo} className={cx('event-additional-info')}>
{additionalInfo}
</p>
</section>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,9 @@
flex-direction: column;
gap: 18px;

.card-title {
font-weight: $font-weight-bold;
}

.card-subtitle {
margin: 0;
font-size: 18px;
font-weight: $font-weight-medium;
line-height: 1.15;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,25 @@ export const MentorFeedbackCard = ({ name, course, review, photo }: MentorFeedba
data-testid="mentor-photo"
/>
<header className={cx('card-header')}>
<Subtitle fontSize="small" className={cx('card-title')} data-testid="card-title">
<Subtitle
as="h3"
className={cx('card-title')}
fontSize="small"
fontWeight="bold"
data-testid="card-title"
>
{name}
</Subtitle>
<h4 className={cx('card-subtitle')} data-testid="card-subtitle">
<Subtitle
as="h4"
className={cx('card-subtitle')}
fontWeight="medium"
fontSize="extra-small"
data-testid="card-subtitle"
>
<b>Course: </b>
{course}
</h4>
</Subtitle>
</header>
</section>
<div className={cx('card-content-wrapper')} data-testid="card-content-wrapper">
Expand Down
13 changes: 1 addition & 12 deletions src/entities/trainer/ui/trainers-card/trainer-card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,13 @@

.card-title {
margin: 0;
font-size: 24px;
font-weight: $font-weight-medium;
line-height: 32px;

@include media-tablet {
font-size: 20px;
}
}

.card-subtitle {
margin: 0;
font-size: 18px;
font-weight: $font-weight-medium;
line-height: 1.15;
color: $color-gray-500;

@include media-tablet {
font-size: 18px;
}
}

.card-content {
Expand Down
9 changes: 7 additions & 2 deletions src/entities/trainer/ui/trainers-card/trainer-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import classNames from 'classnames/bind';
import Image from 'next/image';

import { Trainer } from '../../types';
import { Subtitle } from '@/shared/ui/subtitle';

import styles from './trainer-card.module.scss';

Expand All @@ -15,8 +16,12 @@ export const TrainerCard = ({ name, bio, role, photo }: Trainer) => {
</div>
<div className={cx('card-text')}>
<header>
<h3 className={cx('card-title')}>{name}</h3>
<h4 className={cx('card-subtitle')}>{role}</h4>
<Subtitle className={cx('card-title')} fontSize="small">
{name}
</Subtitle>
<Subtitle as="h4" className={cx('card-subtitle')} fontSize="extra-small">
{role}
</Subtitle>
</header>
<p className={cx('card-content')}>{bio}</p>
</div>
Expand Down
4 changes: 0 additions & 4 deletions src/shared/ui/modal/modal.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@
}
}

.modal-title {
font-size: 20px;
}

.modal-body {
overflow-y: auto;
padding-bottom: 32px;
Expand Down
5 changes: 3 additions & 2 deletions src/shared/ui/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import classNames from 'classnames/bind';
import Image from 'next/image';
import { createPortal } from 'react-dom';

import { Subtitle } from '../subtitle';
import closeIcon from '@/shared/assets/svg/close.svg';
import { KEY_CODES } from '@/shared/constants';

Expand Down Expand Up @@ -101,9 +102,9 @@ export const Modal = ({ isOpen, onClose, children, title, className }: ModalProp
>
<div className={cx('modal-header', { 'no-title': !title })} data-testid="modal-header">
{title && (
<h2 className={cx('modal-title')} data-testid="modal-title">
<Subtitle fontSize="small" fontWeight="bold" data-testid="modal-title">
{title}
</h2>
</Subtitle>
)}
<button
className={cx('modal-close-button')}
Expand Down
90 changes: 51 additions & 39 deletions src/shared/ui/subtitle/subtitle.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,73 @@
margin: 0;
color: $color-gray-900;

&.extra-small-font-size {
font-size: 20px;
line-height: 28px;

@include media-tablet {
font-size: 18px;
line-height: 24px;
}
}

&.small-font-size {
font-size: 24px;
line-height: 32px;

@include media-tablet {
&.font-size {
&-extra-small {
font-size: 20px;
line-height: 28px;
}
}

&.medium-font-size {
font-size: 28px;
line-height: 36px;
@include media-tablet {
font-size: 18px;
line-height: 24px;
}
}

@include media-tablet {
&-small {
font-size: 24px;
line-height: 32px;
}
}

&.large-font-size {
font-size: 32px;
line-height: 40px;
@include media-tablet {
font-size: 20px;
line-height: 28px;
}
}

@include media-tablet {
&-medium {
font-size: 28px;
line-height: 36px;
}
}

&.extra-large-font-size {
font-size: 36px;
line-height: 44px;
@include media-tablet {
font-size: 24px;
line-height: 32px;
}
}

@include media-tablet {
&-large {
font-size: 32px;
line-height: 36px;
line-height: 40px;

@include media-tablet {
font-size: 28px;
line-height: 36px;
}
}
}

&.normal {
font-weight: $font-weight-medium;
&-extra-large {
font-size: 36px;
line-height: 44px;

@include media-tablet {
font-size: 32px;
line-height: 36px;
}
}
}

&.bold {
font-weight: $font-weight-bold;
&.font-weight {
&-light {
font-weight: $font-weight-light;
}

&-regular {
font-weight: $font-weight-regular;
}

&-medium {
font-weight: $font-weight-medium;
}

&-bold {
font-weight: $font-weight-bold;
}
}
}
19 changes: 13 additions & 6 deletions src/shared/ui/subtitle/subtitle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Subtitle component', () => {
render(<Subtitle>Default Font Size</Subtitle>);
const subtitle = screen.getByTestId('subtitle');

expect(subtitle).toHaveClass(cx('medium-font-size'));
expect(subtitle).toHaveClass(cx('font-size-medium'));
});

it('applies correct font size classes when specified', () => {
Expand All @@ -39,7 +39,7 @@ describe('Subtitle component', () => {
);
const subtitle = getByTestId('subtitle');

expect(subtitle).toHaveClass(cx(`${size}-font-size`));
expect(subtitle).toHaveClass(cx(`font-size-${size}`));
cleanup();
});
});
Expand All @@ -53,20 +53,27 @@ describe('Subtitle component', () => {

it('applies multiple variant classes correctly', () => {
render(
<Subtitle fontSize="large" className="custom-class">
<Subtitle className="custom-class" fontSize="large">
Multiple Variants
</Subtitle>,
);
const subtitle = screen.getByTestId('subtitle');

expect(subtitle).toHaveClass(cx('large-font-size'));
expect(subtitle).toHaveClass(cx('font-size-large'));
expect(subtitle).toHaveClass('custom-class');
});

it('renders as h3 element', () => {
render(<Subtitle>H3 Element</Subtitle>);
it('renders as h3 element by default', () => {
render(<Subtitle>h3</Subtitle>);
const subtitle = screen.getByTestId('subtitle');

expect(subtitle.tagName).toBe('H3');
});

it.each(['h2', 'h3', 'h4'] as const)('renders as %s element', (tag) => {
render(<Subtitle as={tag}>{tag}</Subtitle>);
const subtitle = screen.getByTestId('subtitle');

expect(subtitle.tagName).toBe(tag.toUpperCase());
});
});
Loading
Loading