Skip to content

765-fix: Fix styles active menu item #814

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

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6bef3a0
fix: 765 - change style of active menu item. Fix lighthouse problem
JuliaAnt Mar 12, 2025
c615691
fix: 765 - fix paddings and event handlers
JuliaAnt Mar 14, 2025
b881010
fix: 765 - fix event handling logic and styles in NavItem. Update hea…
JuliaAnt Apr 8, 2025
d07e389
feat: 765 - add icon to donate-navItem. Change logo on mentorship page
JuliaAnt Apr 8, 2025
2940fa5
fix: 765 - fix dropdown styles and add static links for rsschool page
JuliaAnt Apr 9, 2025
b9217b0
refactor: 765 - change mobile menu
JuliaAnt Apr 10, 2025
5cc6aa8
refactor: 765 - add content to support-dropdown and links to mentorsh…
JuliaAnt Apr 11, 2025
95ceacf
refactor: 765 - add breadcrumbs to mobile menu and fix styles
JuliaAnt Apr 12, 2025
62b0a0e
fix: 765 - fix support-text color in footer
JuliaAnt Apr 12, 2025
5783f35
fix: 765 - merge branch 'main'
JuliaAnt Apr 12, 2025
47405ac
fix: 765 - fix links for courses and mentorship
JuliaAnt Apr 12, 2025
f8ee5fa
refactor: 765 - add key codes to constants
JuliaAnt Apr 12, 2025
ae4356a
fix: 765 - fix dropdown width and hover of menu elements
JuliaAnt Apr 14, 2025
1391e68
fix: 765 - fix styles of navigation menu
JuliaAnt Apr 30, 2025
f9bc32a
fix: 765 - fix styles of mobile menu. Add mobile-menu-item. Remove re…
JuliaAnt May 3, 2025
faa0957
fix: 765 - fix logo. Fix description to mentorship and courses. Fix h…
JuliaAnt May 8, 2025
c873703
fix: 765 - merge branch 'main'
JuliaAnt May 8, 2025
cc7e7f0
fix: 765 - fix menu item underline and gap
JuliaAnt May 8, 2025
e819b19
fix: 765 - fix linter error
JuliaAnt May 8, 2025
342aaa7
fix: 765 - fix donate options and keyboard navigation. Add variables …
JuliaAnt May 18, 2025
252a8e4
fix: 765 - remove white class from header and fix margin
JuliaAnt May 18, 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
15 changes: 11 additions & 4 deletions dev-data/donate-options.data.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import boostyIconMenu from '@/shared/assets/svg/boosty-icon-menu.svg';
import openCollective from '@/shared/assets/svg/opencollective-icon.svg';
import { LINKS } from '@/shared/constants';
import { BoostyIcon, OpenCollectiveIcon } from '@/shared/icons';

export const donateOptions = [
{
id: 1,
linkLabel: 'Donate now',
icon: 'openCollective',
buttonLinkLabel: 'Donate now',
menuLinkLabel: 'Donate on Opencollective',
buttonIcon: OpenCollectiveIcon,
menuIcon: openCollective,
href: LINKS.DONATE_OPEN_COLLECTIVE,
},
{
id: 2,
linkLabel: 'Subscribe now',
icon: 'boosty',
buttonLinkLabel: 'Subscribe now',
menuLinkLabel: 'Subscribe on Boosty',
buttonIcon: BoostyIcon,
menuIcon: boostyIconMenu,
href: LINKS.DONATE_BOOSTY,
},
];
12 changes: 11 additions & 1 deletion dev-data/school-menu-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@ export const schoolMenuStaticLinks = [
detailsUrl: `/#${ANCHORS.UPCOMING_COURSES}`,
description: 'Schedule your study',
},
{
title: 'Support Us',
detailsUrl: `/#${ANCHORS.DONATE}`,
description: 'Every donation, big or small, helps!',
},
{
title: 'Mentors Wanted',
detailsUrl: `/#${ANCHORS.MENTORS_WANTED}`,
description: 'Help others to become professionals',
},
];

export const communityMenuStaticLinks = [
{
title: 'About',
title: 'About Community',
detailsUrl: `/${ROUTES.COMMUNITY}/#${ANCHORS.ABOUT_COMMUNITY}`,
description: 'Who we are',
},
Expand Down
2 changes: 2 additions & 0 deletions src/core/styles/_constants.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ $color-gray-800: hsl(216deg 4% 23%); // #393b3e;
$color-gray-700: hsl(204deg 3% 35%); // #575a5c;
$color-gray-600: hsl(216deg 2% 43%); // #6b6d70;
$color-gray-500: hsl(204deg 2% 59%); // #939698;
$color-gray-450: hsl(210deg 9% 62%); // #969fa8
$color-gray-400: hsl(204deg 3% 71%); // #b3b6b8;
$color-gray-300: hsl(216deg 7% 85%); // #d7d9dc;
$color-gray-250: hsl(212deg 19% 86%); // #d6dce3;
$color-gray-200: hsl(210deg 14% 91%); // #e6e9ec;
$color-gray-100: hsl(216deg 20% 95%); // #f0f2f5;
$color-gray-50: hsl(210deg 50% 98%); // #f6f9fc;
Expand Down
6 changes: 6 additions & 0 deletions src/core/styles/_mixins.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
@use 'constants' as *;

@mixin media-laptop-large {
@media (min-width: ($content-width + 1px)) {
@content;
}
}

@mixin media-laptop {
@media (max-width: $content-width) {
@content;
Expand Down
12 changes: 12 additions & 0 deletions src/shared/assets/svg/boosty-icon-menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/shared/assets/svg/heart-blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/shared/assets/svg/heart-yellow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/shared/assets/svg/rss-logo-blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion src/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ export const COURSE_LINKS = {
AWS_DEVOPS: 'https://rs.school/courses/aws-devops',
};

export const KEY_CODES = { ESCAPE: 'Escape' } as const;
export const KEY_CODES = {
ESCAPE: 'Escape',
ENTER: 'Enter',
SPACE: 'Space',
} as const;

export const HTTP_METHOD = {
GET: 'GET',
Expand Down Expand Up @@ -85,6 +89,15 @@ export const LINKS = {
ANGULAR_MENTORING: 'https://github.com/rolling-scopes-school/tasks/tree/master/angular/mentoring',
};

export const NAV_MENU_LABELS = {
RS_SCHOOL: 'RS School',
COURSES: 'Courses',
COMMUNITY: 'Community',
MENTORSHIP: 'Mentorship',
DOCS: 'Docs',
SUPPORT_US: 'Support Us',
};

export const ROUTES = {
HOME: '/',
COMMUNITY: 'community',
Expand Down
25 changes: 25 additions & 0 deletions src/shared/hooks/use-outside-click/use-outside-click.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useEffect } from 'react';

export function useOutsideClick<T extends HTMLElement>(
ref: React.RefObject<T | null>,
callback: () => void,
isDropdownOpen: boolean,
) {
useEffect(() => {
if (!isDropdownOpen) {
return;
}

const handleClickOutside = (e: MouseEvent) => {
if (ref.current && !ref.current.contains(e.target as Node)) {
callback();
}
};

document.addEventListener('mousedown', handleClickOutside);

return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, [ref, callback, isDropdownOpen]);
}
8 changes: 4 additions & 4 deletions src/shared/ui/logo/logo.module.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
.logo {
flex-shrink: 0;
width: 56px;
height: 56px;
width: 48px;
height: 48px;

img {
width: 100%;
height: 100%;
}

@include media-tablet-large {
width: 40px;
height: 40px;
width: 48px;
height: 48px;
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/shared/ui/logo/logo.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import { HTMLAttributes } from 'react';
import { type VariantProps, cva } from 'class-variance-authority';
import classNames from 'classnames/bind';
import Image from 'next/image';
import Image, { StaticImageData } from 'next/image';
import Link from 'next/link';

import logo from '@/shared/assets/svg/rss-logo.svg';
import { ROUTES } from '@/shared/constants';

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

type LogoProps = Pick<HTMLAttributes<HTMLElement>, 'className'> & VariantProps<typeof logoVariants>;
type LogoProps = Pick<HTMLAttributes<HTMLElement>, 'className'> &
VariantProps<typeof logoVariants> & {
icon?: StaticImageData;
};

export const cx = classNames.bind(styles);

const logoVariants = cva(cx('logo'), { variants: { type: { 'with-border': cx('with-border') } } });

export const Logo = ({ type, className }: LogoProps) => {
export const Logo = ({ type, className, icon = logo }: LogoProps) => {
return (
<Link
href={ROUTES.HOME}
Expand All @@ -25,7 +28,7 @@ export const Logo = ({ type, className }: LogoProps) => {
})}
data-testid="logo"
>
<Image src={logo} alt="RSS-logo" />
<Image src={icon} alt="RSS-logo" />
</Link>
);
};
8 changes: 8 additions & 0 deletions src/widgets/breadcrumbs/ui/breadcrumbs.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@
padding: 24px;
}
}

.mobile-breadcrumbs.breadcrumbs-content {
@include media-tablet-large {
width: 100%;
padding: 6px;
padding-left: 0;
}
}
8 changes: 6 additions & 2 deletions src/widgets/breadcrumbs/ui/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import styles from './breadcrumbs.module.scss';

const cx = classNames.bind(styles);

export const Breadcrumbs = () => {
type BreadcrumbsProps = {
className?: string;
};

export const Breadcrumbs = ({ className }: BreadcrumbsProps) => {
const pathname = usePathname();
const crumbs = pathname.split('/').filter(Boolean) as RouteValues[];

Expand All @@ -24,7 +28,7 @@ export const Breadcrumbs = () => {

return (
<nav className={cx('container')}>
<div className={cx('content', 'breadcrumbs-content')}>
<div className={cx('content', 'breadcrumbs-content', className)}>
<ul>
<BreadcrumbItem linkTo={ROUTES.HOME} text="Home" />
{transformedCrumbs.map((crumb, i) => (
Expand Down
6 changes: 5 additions & 1 deletion src/widgets/footer/footer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Copyright } from '@/widgets/footer/ui/copyright';
import { DesktopView } from '@/widgets/footer/ui/desktop-view';
import { MobileView } from '@/widgets/mobile-view';

vi.mock('next/navigation', () => ({ usePathname: () => '/' }));

describe('Footer', () => {
it('renders footer container', async () => {
const { getByTestId } = renderWithRouter(<Footer courses={mockedCourses} />);
Expand Down Expand Up @@ -36,7 +38,9 @@ describe('Footer', () => {

describe('MobileView', () => {
it('should render mobile view', () => {
const { getByTestId } = renderWithRouter(<MobileView courses={mockedCourses} type="footer" />);
const { getByTestId } = renderWithRouter(
<MobileView courses={mockedCourses} type="footer" />,
);
const mobileView = getByTestId('mobile-view');

expect(mobileView).toBeInTheDocument();
Expand Down
47 changes: 27 additions & 20 deletions src/widgets/header/header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,23 @@
left: 0;

width: 100%;
height: 64px;
height: 70px;
padding: 0 40px;
border-radius: 0;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;

transition: background-color 0.2s;

&.gray {
background-color: $color-yellow-500;
}
opacity: 1;
background-color: rgb(255 255 255);
box-shadow: rgb(0 0 0 / 8.2%) 0 1.026px 8.0694px 0;

&.blue {
background: $gradient-blue-background;
}
transition: background-color 0.2s;

&.none {
display: none;
}

&.white {
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;

opacity: 1;
background-color: rgb(255 255 255);
box-shadow: rgb(0 0 0 / 8.2%) 0 1.026px 8.0694px 0;
}

@include media-tablet-large {
height: 48px;
padding: 0 16px;
}
}
Expand All @@ -52,10 +40,11 @@
position: relative;

display: flex;
gap: 28px;
gap: 33.8px;
align-items: center;

height: 100%;
padding-inline-start: 0;

@include media-tablet-large {
display: none;
Expand Down Expand Up @@ -99,6 +88,7 @@

color: #000;

opacity: 0;
background-color: #fff;

transition: transform 0.4s ease-out;
Expand All @@ -107,8 +97,25 @@
.mobile-menu.open {
transform: translateY(0);
display: none;
opacity: 1;

@include media-tablet-large {
display: block;
}
}

.support-text {
display: flex;
flex-direction: column;
justify-content: space-between;

max-width: 470px;
margin-right: 62px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we not use margin and do it with an assistant property gap?


font-size: 14px;
list-style-type: none;

@include media-laptop-large {
margin-right: 30px;
}
}
Loading
Loading