Responsive : Mobile support

This commit is contained in:
TitiLaPierre
2024-10-09 17:08:22 +02:00
parent 46c8ab36a7
commit 629f04b182
9 changed files with 278 additions and 89 deletions

View File

@@ -112,6 +112,30 @@
}
}
@media screen and (max-width: 1100px) {
.page {
padding-inline: 25px;
}
.page-banner {
display: flex;
flex-direction: column;
align-items: center;
gap: 2rem;
}
.page-banner-image {
max-width: 100%;
max-height: 300px;
}
.page-banner-content {
position: relative;
translate: 0;
max-width: none;
}
.page-title {
font-size: 1.75rem;
}
}
.content-container {
padding-top: 2em;
padding-bottom: 2em;

View File

@@ -0,0 +1,67 @@
.box-container {
height: fit-content;
display: flex;
flex-direction: column;
gap: 2rem;
border-radius: 15px;
padding: 1.5rem;
background: var(--white);
box-shadow: var(--shadow);
position: relative;
}
.box-label {
position: absolute;
top: 0;
left: 50%;
translate: -50% -50%;
background: var(--main);
color: var(--white);
padding: 0.3em 1em;
font-size: 0.8em;
width: fit-content;
border-radius: 999px;
text-transform: uppercase;
font-weight: 700;
}
.box-title {
font-weight: 700;
font-size: 1.3em;
text-align: center;
}
.box-subtext {
color: var(--darkGray);
font-size: 0.8em;
text-align: center;
}
.box-parts {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
& > * {
max-height: 350px;
}
}
.box-data {
border-radius: 10px;
padding: 2rem 1rem;
background: var(--lightGray);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.box-data-number {
color: var(--main);
font-size: 3em;
font-weight: 700;
}
.box-data-subtext {
color: var(--darkGray);
font-size: 0.8em;
text-transform: uppercase;
}
.box-image {
display: block;
width: 100%;
border-radius: 10px;
}

View File

@@ -1,5 +1,7 @@
import React from "react";
import './box.css';
interface BoxImageProps {
type: "image";
src: string;

View File

@@ -1,15 +0,0 @@
import React from "react";
interface NavbarLinkProps {
text: string;
link: string;
isActive?: boolean;
}
export const NavbarLink: React.FC<NavbarLinkProps> = ({ text, link, isActive }) => {
return (
<a href={link} className={`navbar-link ${isActive ? "link_active" : ""}`}>
{text}
</a>
);
};

View File

@@ -47,4 +47,17 @@
color: var(--white);
font-size: 0.7em;
text-align: center;
}
@media screen and (max-width: 1100px) {
.footer {
padding-inline: 25px;
}
}
@media screen and (max-width: 750px) {
.footer-content {
gap: 3rem;
flex-direction: column;
}
}

View File

@@ -6,9 +6,9 @@
position: sticky;
top: 0;
left: 0;
z-index: 1000;
box-shadow: 0 10px 10px rgba(128, 128, 128, 0.1);
z-index: 500;
padding-inline: 100px;
box-shadow: var(--shadow);
}
.navbar-logo {
@@ -26,7 +26,7 @@
gap: 3em;
}
.navbar-link {
.navbar-link, .navbar-open {
text-decoration: none;
font-size: 1em;
height: 100%;
@@ -34,6 +34,10 @@
align-items: center;
font-weight: 400;
position: relative;
border: none;
background: none;
align-self: center;
cursor: pointer;
&.link_active::after {
content: "";
position: absolute;
@@ -44,4 +48,87 @@
background: var(--main);
border-radius: 999px;
}
}
.mobileNavbar {
background: var(--lightGray);
z-index: 1000;
padding: 1.5em 25px;
position: absolute;
top: 100%;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
gap: 1em;
}
.mobileNavbar-title {
font-size: 0.9em;
text-transform: uppercase;
font-weight: 600;
margin-bottom: 0.5em;
text-align: center;
position: relative;
&::before, &::after {
content: "";
position: absolute;
top: 50%;
width: 25px;
height: 4px;
background: var(--main);
translate: 0 -50%;
}
&::before { left: 0; }
&::after { right: 0; }
}
.mobileNavbar-links {
display: flex;
justify-content: center;
gap: 0.5em;
flex-wrap: wrap;
}
.mobileNavbar-link {
text-decoration: none;
font-size: 1em;
padding: 0.3em 1em;
font-weight: 400;
background: var(--white);
color: var(--darkGray);
transition: color 0.3s;
position: relative;
width: fit-content;
border-radius: 999px;
&.link_active {
color: var(--black);
text-decoration: underline var(--main) 2px;
}
/* &.link_active::after {
content: "";
position: absolute;
top: 50%;
right: -10px;
width: 20px;
height: 4px;
translate: 100% -50%;
border-radius: 999px;
background: var(--main);
} */
}
@media screen and (min-width: 1000px) {
.navbar-logo-img.img_small { display: none; }
.navbar-open { display: none; }
}
@media screen and (min-width: 850px) and (max-width: 999px) {
.navbar-logo-img.img_large { display: none; }
.navbar-open { display: none; }
}
@media screen and (max-width: 849px) {
.navbar-logo-img.img_small { display: none; }
.navbar-links { display: none; }
}
@media screen and (max-width: 1100px) {
.navbar {
padding-inline: 25px;
}
}

View File

@@ -1,7 +1,31 @@
import { NavbarLink } from '../../components/navbarlink/navbarLink';
import React from 'react';
import { Menu } from 'iconoir-react';
import './navbar.css';
interface NavbarLinkProps {
text: string;
link: string;
isActive?: boolean;
}
const NavbarLink: React.FC<NavbarLinkProps> = ({ text, link, isActive }) => {
return (
<a href={link} className={`navbar-link ${isActive ? "link_active" : ""}`}>
{text}
</a>
);
};
const MobileNavbarLink: React.FC<NavbarLinkProps> = ({ text, link, isActive }) => {
return (
<a href={link} className={`mobileNavbar-link ${isActive ? "link_active" : ""}`}>
{text}
</a>
);
};
export const Navbar = ({ activeLink }: { activeLink: number }) => {
const links = [
{ text: 'Accueil', link: '/' },
@@ -11,15 +35,23 @@ export const Navbar = ({ activeLink }: { activeLink: number }) => {
{ text: 'Partenaires', link: '/partenaires' },
{ text: 'Nous contacter', link: '/contact' },
]
const [isMobileMenuOpen, setIsMobileMenuOpen] = React.useState(false);
return (
<>
<nav className={'navbar'}>
<a href={'/'} className={'navbar-logo'}>
<img
className='navbar-logo-img'
className={'navbar-logo-img img_large'}
src={'https://r2.modelec.club/logo-full.png'} // TODO: Change to SVG logo / import it from assets
alt={'Modelec Logo'}
/>
<img
className={'navbar-logo-img img_small'}
src={'https://r2.modelec.club/logo.png'} // TODO: Change to SVG logo / import it from assets
alt={'Modelec Logo'}
/>
</a>
<div className={'navbar-links'}>
{
@@ -28,6 +60,21 @@ export const Navbar = ({ activeLink }: { activeLink: number }) => {
))
}
</div>
<button className={'navbar-open'} onClick={() => setIsMobileMenuOpen(old => !old)}>
<Menu />
</button>
{ isMobileMenuOpen &&
<nav className={'mobileNavbar'}>
<h1 className={'mobileNavbar-title'}>Se déplacer sur le site</h1>
<div className={'mobileNavbar-links'}>
{
links.map((link, index) => (
<MobileNavbarLink key={index} text={link.text} link={link.link} isActive={activeLink == index} />
))
}
</div>
</nav>
}
</nav>
</>
);

View File

@@ -34,74 +34,6 @@
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 5rem;
}
.box-container {
height: fit-content;
display: flex;
flex-direction: column;
gap: 2rem;
border-radius: 15px;
padding: 1.5rem;
background: var(--white);
box-shadow: var(--shadow);
position: relative;
}
.box-label {
position: absolute;
top: 0;
left: 50%;
translate: -50% -50%;
background: var(--main);
color: var(--white);
padding: 0.3em 1em;
font-size: 0.8em;
width: fit-content;
border-radius: 999px;
text-transform: uppercase;
font-weight: 700;
}
.box-title {
font-weight: 700;
font-size: 1.3em;
text-align: center;
}
.box-subtext {
color: var(--darkGray);
font-size: 0.8em;
text-align: center;
}
.box-parts {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
& > * {
max-height: 350px;
}
}
.box-data {
border-radius: 10px;
padding: 2rem 1rem;
background: var(--lightGray);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.box-data-number {
color: var(--main);
font-size: 3em;
font-weight: 700;
}
.box-data-subtext {
color: var(--darkGray);
font-size: 0.8em;
text-transform: uppercase;
}
.box-image {
display: block;
width: 100%;
max-width: 300px;
border-radius: 10px;
}
.partners {
box-shadow: 0 0 0 100vmax var(--black);
@@ -181,4 +113,37 @@
&.action_second {
color: var(--white);
}
}
@media screen and (max-width: 1100px) {
.dual {
gap: 25px;
}
}
@media screen and (max-width: 950px) {
.dual {
gap: 25px;
}
}
@media screen and (max-width: 700px) {
.media-container {
flex-direction: column;
border-radius: 15px;
}
.media-separator {
width: 1.5em;
height: 2px;
}
.media-link {
padding: 1em 1.5em;
}
}
@media screen and (max-width: 450px) {
.partners-actions {
flex-direction: column;
align-items: flex-start;
}
}

View File

@@ -16,7 +16,6 @@ const Home: React.FC = () => {
className={'page-banner-image'}
src={'https://r2.modelec.club/coupe-2024.png'}
alt={'Modelec Photo'}
id={'photo-coupe-home'}
/>
<div className={'page-banner-content'}>
<h3 className={'page-banner-header'}>Qui sommes-nous ?</h3>