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

348-refactor: Title component refactor #350

Merged
merged 71 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
24f9411
feat: 348 - add cva package
NikitaStarmoussov Jun 26, 2024
ef00d5e
feat: 348 - add new size constants
NikitaStarmoussov Jun 26, 2024
209f463
feat: 348 - delete h2 default margin
NikitaStarmoussov Jun 26, 2024
39d993e
feat: 348 - add widget-title component
NikitaStarmoussov Jun 26, 2024
662fb8f
refactor: 348 - Title to WidgetTitle in Parthered
NikitaStarmoussov Jun 26, 2024
7ad774a
refactor: 348 - Title to WidgetTitle in General
NikitaStarmoussov Jun 26, 2024
54fd975
refactor: 348 - add fixme anchor for h1 in main
NikitaStarmoussov Jun 26, 2024
cf3e2c8
refactor: 348 - Title to WidgetTitle in About
NikitaStarmoussov Jun 26, 2024
e85543f
refactor: 348 - Title to WidgetTitle in About-Home
NikitaStarmoussov Jun 26, 2024
39e24a3
refactor: 348 - Title to WidgetTitle in About-School
NikitaStarmoussov Jun 26, 2024
b43e5b1
refactor: 348 - Title to WidgetTitle in Alumni
NikitaStarmoussov Jun 26, 2024
359dd9d
refactor: 348 - Title to WidgetTitle in Angular-Topics
NikitaStarmoussov Jun 26, 2024
aada313
refactor: 348 - Title to WidgetTitle in Certification
NikitaStarmoussov Jun 26, 2024
7a612e1
refactor: 348 - Title to WidgetTitle in Communication
NikitaStarmoussov Jun 26, 2024
f9a6a03
refactor: 348 - Title to WidgetTitle in Community
NikitaStarmoussov Jun 26, 2024
cdbb271
refactor: 348 - Title to WidgetTitle in Contribute
NikitaStarmoussov Jun 26, 2024
90a3cb6
refactor: 348 - Title to WidgetTitle in Course-main
NikitaStarmoussov Jun 26, 2024
0476e9d
refactor: 348 - Title to WidgetTitle in Courses
NikitaStarmoussov Jun 26, 2024
055ef8d
refactor: 348 - remove unsused styles in courses
NikitaStarmoussov Jun 26, 2024
c5ec487
refactor: 348 - add widget-title in course-school
NikitaStarmoussov Jun 26, 2024
2155955
refactor: 348 - Title to WidgetTitle in Events
NikitaStarmoussov Jun 26, 2024
6c2d58b
refactor: 348 - Title to WidgetTitle in FAQ
NikitaStarmoussov Jun 26, 2024
93722c0
refactor: 348 - Title to WidgetTitle in Main
NikitaStarmoussov Jun 26, 2024
195f076
refactor: 348 - Title to WidgetTitle in Mentoring
NikitaStarmoussov Jun 26, 2024
c4aa427
refactor: 348 - Title to WidgetTitle in Mentors
NikitaStarmoussov Jun 26, 2024
6a8ba39
refactor: 348 - Title to WidgetTitle in Mentors-wanted
NikitaStarmoussov Jun 26, 2024
5fa330a
refactor: 348 - Title to WidgetTitle in Merch
NikitaStarmoussov Jun 26, 2024
5b2a46e
refactor: 348 - Title to WidgetTitle in Numbers
NikitaStarmoussov Jun 26, 2024
8d1f86f
refactor: 348 - Title to WidgetTitle in Pictures
NikitaStarmoussov Jun 26, 2024
56b9cfe
refactor: 348 - Title to WidgetTitle in Principles
NikitaStarmoussov Jun 26, 2024
4b9f862
refactor: 348 - Title to WidgetTitle in Required
NikitaStarmoussov Jun 26, 2024
91ba3c8
refactor: 348 - Title to WidgetTitle in Speakers
NikitaStarmoussov Jun 26, 2024
cc960aa
refactor: 348 - Title to WidgetTitle in Study-path
NikitaStarmoussov Jun 26, 2024
64dc156
refactor: 348 - Title to WidgetTitle in Study-with-us
NikitaStarmoussov Jun 26, 2024
2b67df9
refactor: 348 - Title to WidgetTitle in Support
NikitaStarmoussov Jun 26, 2024
1fd8a02
refactor: 348 - Title to WidgetTitle in Trainers
NikitaStarmoussov Jun 26, 2024
5c5e9d6
refactor: 348 - Title to WidgetTitle in Training-program
NikitaStarmoussov Jun 26, 2024
008d6e4
refactor: 348 - deletw commented code
NikitaStarmoussov Jun 26, 2024
75b7a68
refactor: 348 - add vars for tablet font-size
NikitaStarmoussov Jun 27, 2024
709c995
refactor: 348 - Title to WidgetTitle in About-video
NikitaStarmoussov Jun 27, 2024
a77ca10
refactor: 348 - Add vars for MainTitle
NikitaStarmoussov Jun 27, 2024
6590407
refactor: 348 - reset default h1 margin
NikitaStarmoussov Jun 27, 2024
4e2d85b
refactor: 348 - add MainTitle comp
NikitaStarmoussov Jun 27, 2024
bc87ae7
refactor: 348 - Title to MainTitle in courses/main
NikitaStarmoussov Jun 27, 2024
d35f028
refactor: 348 - delete widget main styles for title
NikitaStarmoussov Jun 27, 2024
706509d
refactor: 348 - Title to MainTitle in widgets/main
NikitaStarmoussov Jun 27, 2024
5b33608
refactor: 348 - Delete exports in widget-title
NikitaStarmoussov Jun 27, 2024
8179dbd
refactor: 348 - update vars for widget-title
NikitaStarmoussov Jun 27, 2024
99f9c51
refactor: 348 - update reset for headiang tag
NikitaStarmoussov Jun 27, 2024
27c99a5
refactor: 348 - to model and bind classnames
NikitaStarmoussov Jun 27, 2024
2f695f6
refactor: 348 - delete h1 margin
NikitaStarmoussov Jun 27, 2024
fb3b8b0
refactor: 348 - add public api for widget-title
NikitaStarmoussov Jun 27, 2024
b4563d5
refactor: 348 - update paths /widget-title
NikitaStarmoussov Jun 27, 2024
9c3d31f
refactor: 348 - add model and bind calssnames for main-title
NikitaStarmoussov Jun 27, 2024
7285427
Merge branch 'main' into refactor/348-title-comp-refactor
SpaNb4 Jun 27, 2024
61dbfeb
refactor: 348 - delete unused &
NikitaStarmoussov Jun 27, 2024
60a37f4
refactor: 348 - update classnames name and add to tests
NikitaStarmoussov Jun 27, 2024
c24de11
Merge remote-tracking branch 'origin/refactor/348-title-comp-refactor…
NikitaStarmoussov Jun 27, 2024
946783e
refactor: 348 - add export for cx and add tests for MainTitle
NikitaStarmoussov Jun 27, 2024
29af17c
feat: 348 - add public api and update paths
NikitaStarmoussov Jun 27, 2024
3c41102
refactor: 348 - delete unused style
NikitaStarmoussov Jun 27, 2024
a25eabc
refactor: 348 - delete dublicate style
NikitaStarmoussov Jun 27, 2024
a720115
refactor: 348 - delete model in widget-title and update naming for bi…
NikitaStarmoussov Jun 27, 2024
45f8b35
refactor: 348 - delete model in main-title
NikitaStarmoussov Jun 27, 2024
f40928d
refactro: 348 - delete old Title component
NikitaStarmoussov Jun 28, 2024
9cb8134
refactor: 348 - update import into react
NikitaStarmoussov Jun 28, 2024
e9117a2
refactor: 348 delete model file for main-title
NikitaStarmoussov Jun 29, 2024
f461cc0
Merge branch 'main' into refactor/348-title-comp-refactor
ansivgit Jul 2, 2024
7e04bc6
fix: 348 - fix after review
ansivgit Jul 2, 2024
266530d
fix: 348 - off eslint issue
ansivgit Jul 2, 2024
b40d9be
Merge branch 'main' into refactor/348-title-comp-refactor
NikitaStarmoussov Jul 4, 2024
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
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default [
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
'react-refresh/only-export-components': [
'warn',
'off',
{ allowConstantExport: true },
],

Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"prepare": "husky"
},
"dependencies": {
"class-variance-authority": "^0.7.0",
"classnames": "^2.5.1",
"dayjs": "^1.11.11",
"nextjs-toploader": "^1.6.12",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { AwsLogo, EpamLogo, GithubLogo, JetBrainsLogo } from '@/shared/icons';
import { WidgetTitle } from '@/shared/ui/widget-title';

import './partnered.scss';

export const Partnered = () => (
<div className="partnered container" data-testid="partnered">
<div className="partnered content">
<div className="title">Partnered with</div>
<WidgetTitle size="small">Partnered with</WidgetTitle>
<div className="partners">
<EpamLogo />
<JetBrainsLogo />
Expand Down
4 changes: 4 additions & 0 deletions src/app/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ li {
padding: 0;
}

h2 {
margin: 0;
}

figure {
margin: 0;
padding: 0;
Expand Down
3 changes: 2 additions & 1 deletion src/app/styles/normalize.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ main {
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
* delete h1 margin
*/

h1 {
margin: 0.67em 0;
margin: 0;
font-size: 2em;
}

Expand Down
4 changes: 2 additions & 2 deletions src/entities/courses/ui/general/general.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Link } from 'react-router-dom';
import { Title } from '@/shared/ui/title';
import { WidgetTitle } from '@/shared/ui/widget-title';

import './general.scss';

export const General = () => {
return (
<section className="general container">
<div className="general content">
<Title text="General" />
<WidgetTitle size="small">General</WidgetTitle>
<div className="general-info">
<div className="materials">
<h2 className="title">Materials</h2>
Expand Down
4 changes: 2 additions & 2 deletions src/entities/courses/ui/main/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import mentors from '@/shared/assets/mentor-with-his-students.webp';
import Image from '@/shared/ui/image';
import { Title, TitleType } from '@/shared/ui/title';
import { MainTitle } from '@/shared/ui/main-title';

import './main.scss';

Expand All @@ -10,7 +10,7 @@ export const Main = () => {
<div className="courses-main content">
<div className="left">
<div className="title-container">
<Title text="Our Courses" type={TitleType.ExtraBig} />
<MainTitle>Our Courses</MainTitle>
</div>
<h2 className="description">Journey to full stack mastery</h2>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/shared/ui/main-title/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { MainTitle } from './main-title';
11 changes: 11 additions & 0 deletions src/shared/ui/main-title/main-title.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.title {
font-size: 96px;
font-weight: 700;
color: $color-black;
text-align: left;
letter-spacing: -0.04em;

@include media-tablet {
font-size: 60px;
}
}
38 changes: 38 additions & 0 deletions src/shared/ui/main-title/main-title.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { MainTitle, cx } from './main-title';

describe('MainTitle component', () => {
it('renders without crashing', () => {
render(<MainTitle>TestTitle</MainTitle>);
const title = screen.getByText('TestTitle');

expect(title).toBeInTheDocument();
});

it('displays h1 tag', () => {
render(<MainTitle />);
const element = screen.getByRole('heading', { level: 1 });

expect(element).toBeInTheDocument();
});

it('displays styles correctly', () => {
render(<MainTitle />);
const element = screen.getByRole('heading', { level: 1 });

expect(element).toHaveClass(cx('title'));
});

it('renders children correctly', () => {
render(
<MainTitle>
<div>Child element</div>
</MainTitle>,
);

const child = screen.getByText('Child element');

expect(child).toBeInTheDocument();
});
});
22 changes: 22 additions & 0 deletions src/shared/ui/main-title/main-title.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { HTMLAttributes } from 'react';
import { VariantProps, cva } from 'class-variance-authority';
import classNames from 'classnames/bind';

import styles from './main-title.module.scss';

type MainTitleProps = HTMLAttributes<HTMLHeadingElement> & VariantProps<typeof mainTitleVariants>;

export const cx = classNames.bind(styles);

const mainTitleVariants = cva(cx('title'));

export const MainTitle = ({ children, className, ...props }: MainTitleProps) => {
return (
<h1
{...props}
className={mainTitleVariants({ className })}
>
{children}
</h1>
);
};
2 changes: 0 additions & 2 deletions src/shared/ui/title/index.ts

This file was deleted.

58 changes: 0 additions & 58 deletions src/shared/ui/title/title.scss

This file was deleted.

46 changes: 0 additions & 46 deletions src/shared/ui/title/title.test.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions src/shared/ui/title/title.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions src/shared/ui/title/types.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/shared/ui/widget-title/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { WidgetTitle } from './widget-title';
43 changes: 43 additions & 0 deletions src/shared/ui/widget-title/widget-title.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.title {
font-weight: $font-weight-medium;
letter-spacing: -0.04em;

&::before {
margin-right: 8px;
color: $color-red;
}
}

.small {
font-size: 36px;
line-height: 44px;
letter-spacing: 0;
}

.medium {
font-size: 44px;
line-height: 52px;

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

.large {
font-size: 52px;
line-height: 64px;

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

.lines::before {
content: 'β€–';
}

.asterisk::before {
content: '*';
}
Loading
Loading