Skip to content

Commit

Permalink
Merge pull request #331 from Wystov/feat/262-upcoming-courses-color-i…
Browse files Browse the repository at this point in the history
…cons

262-feat: colorful icons in upcoming courses
  • Loading branch information
SpaNb4 authored Jun 24, 2024
2 parents 25df77f + 7028797 commit b21f509
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 135 deletions.
5 changes: 0 additions & 5 deletions src/widgets/courses-school/lib/getCourseIcon.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions src/widgets/courses-school/lib/icons.data.tsx

This file was deleted.

24 changes: 16 additions & 8 deletions src/widgets/courses-school/ui/CourseCard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import classNames from 'classnames/bind';
import { Course } from '@/app/types';
import { ArrowIcon } from '@/shared/icons';
import Image from '@/shared/ui/image';
import { LinkCustom } from '@/shared/ui/link-custom';

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

const cx = classNames.bind(styles);

type addFields = {
buttonText: string;
icon: JSX.Element | null;
iconSrc: string;
};

type PropsType = Pick<Course, 'title' | 'language' | 'startDate' | 'detailsUrl'> & addFields;
Expand All @@ -15,16 +21,18 @@ export const CourseCard = ({
startDate,
detailsUrl,
buttonText,
icon,
iconSrc,
}: PropsType) => {
return (
<section className="course-card">
<figure className="icon-container">{icon}</figure>
<div className="course-info">
<p className="name">{title}</p>
<p className="date">{`${startDate}${language[0].toUpperCase()}`}</p>
<section className={cx('course-card')}>
<figure className={cx('icon-container')}>
<Image src={iconSrc} alt={title} />
</figure>
<div className={cx('course-info')}>
<p className={cx('name')}>{title}</p>
<p className={cx('date')}>{`${startDate}${language[0].toUpperCase()}`}</p>
</div>
<div className="details-container">
<div className={cx('details-container')}>
<LinkCustom
href={detailsUrl}
icon={<ArrowIcon size="16px" />}
Expand Down
91 changes: 91 additions & 0 deletions src/widgets/courses-school/ui/courses.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
.course-title {
margin-top: 24px;
margin-bottom: 0;

font-size: 36px;
font-weight: $font-weight-medium;
line-height: 44px;
letter-spacing: 0;
}

.image {
@include media-laptop {
margin-top: 24px;
}

img {
width: 299px;
height: 193px;
}
}

.course-list {
@include media-laptop {
width: 100%;
}

display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: space-between;

width: 800px;

.course-card {
@extend %transition-all;

@include media-hover {
&:hover {
box-shadow: 0 4px 16px 0 rgb(0 0 0 / 12%);
}
}

display: flex;
align-items: center;
justify-content: space-between;

width: 100%;
margin-top: 24px;

.icon-container {
display: flex;
align-items: center;
justify-content: center;
padding: 16px;

img {
width: 48px;
height: 36px;
object-fit: contain;
}
}

.course-info {
width: 100%;
text-align: left;

.name {
margin-top: 0;
margin-bottom: 0;

font-size: 18px;
font-weight: $font-weight-medium;
line-height: 24px;
color: $color-black;
}

.date {
margin-top: 8px;
margin-bottom: 0;

font-size: 14px;
line-height: 20px;
color: $color-gray-600;
}
}

.details-container {
padding: 16px;
}
}
}
94 changes: 0 additions & 94 deletions src/widgets/courses-school/ui/courses.scss

This file was deleted.

25 changes: 12 additions & 13 deletions src/widgets/courses-school/ui/courses.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import classNames from 'classnames/bind';
import { CourseCard } from './CourseCard';
import { getCourseIcon } from '../lib/getCourseIcon';
import { IconsTitle } from '../lib/icons.data';
import { selectCourses } from '../lib/selectCourses';
import { ROUTES } from '@/app/const';

Expand All @@ -9,7 +8,9 @@ import { useWindowSize } from '@/shared/hooks/use-window-size';
import { ArrowIcon, RsBanner } from '@/shared/icons';
import { LinkCustom } from '@/shared/ui/link-custom';

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

const cx = classNames.bind(styles);

export const Courses = () => {
const size = useWindowSize();
Expand All @@ -25,34 +26,32 @@ export const Courses = () => {
linkLabel = 'More';
}

const coursesContent = coursesData?.map(({ title, language, startDate, detailsUrl }) => {
const courseIcon = getCourseIcon(title as IconsTitle);

const coursesContent = coursesData?.map(({ title, language, startDate, detailsUrl, iconSrc }) => {
return (
<CourseCard
title={title}
language={language}
startDate={startDate}
detailsUrl={detailsUrl}
icon={courseIcon}
iconSrc={iconSrc}
buttonText={linkLabel}
key={title}
/>
);
});

return (
<article id="upcoming-courses" className="courses container">
<section className="courses content">
<h4 className="title">Upcoming courses</h4>
<div className="column-2">
<div className="courses" data-testid="courses-list">
<article id="upcoming-courses" className={cx('container')}>
<section className={cx('content')}>
<h4 className={cx('course-title')}>Upcoming courses</h4>
<div className={cx('column-2')}>
<div className={cx('course-list')} data-testid="courses-list">
{coursesContent}
<LinkCustom href={ROUTES.COURSES} icon={<ArrowIcon />} variant="colored" button>
Go to courses
</LinkCustom>
</div>
<figure className="image">
<figure className={cx('image')}>
<RsBanner />
</figure>
</div>
Expand Down

0 comments on commit b21f509

Please sign in to comment.