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

#1034 [Redesign] Update page size to10 for tablet screens #1035

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions FrontEnd/src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@ export const PASSWORD_PATTERN = /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8
export const NAME_SURNAME_PATTERN = /^(?=.{2,50}$)[a-zA-Zа-щюяьА-ЩЮЯЬїЇіІєЄґҐ']+(\s[a-zA-Zа-щюяьА-ЩЮЯЬїЇіІєЄґҐ']+)*$/;
export const COMPANY_NAME_PATTERN = /^.{2,100}$/;
export const MESSAGE_PATTERN = /^.{10,}$/;
export const SCREEN_WIDTH = {
tablet: 768,
smallDesktop: 1200,
desktop: 1512,
};
export const PAGE_SIZE = {
mobile: 4,
tablet: 10,
smallDesktop: 12,
desktop: 16,
};
21 changes: 12 additions & 9 deletions FrontEnd/src/pages/LandingPage/Companies/Companies.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import axios from 'axios';
import { useState } from 'react';
import useWindowWidth from '../../../hooks/useWindowWidth';
import { Link } from 'react-router-dom';
import styles from './Companies.module.css';
import Loader from '../../../components/Loader/Loader';
import CompanyCard from '../../../components/CompanyCard/CompanyCard';
import PropTypes from 'prop-types';
import useSWR from 'swr';
import { Col, Row } from 'antd';
import useSWR from 'swr';
import axios from 'axios';

import useWindowWidth from '../../../hooks/useWindowWidth';
import { SCREEN_WIDTH } from '../../../constants/constants';
import Loader from '../../../components/Loader/Loader';
import CompanyCard from '../../../components/CompanyCard/CompanyCard';

import styles from './Companies.module.css';

const MainCompanies = ({ isAuthorized }) => {
const baseUrl = process.env.REACT_APP_BASE_API_URL;
Expand Down Expand Up @@ -35,9 +38,9 @@ const MainCompanies = ({ isAuthorized }) => {
setSearchResults(newCompanies);
};

const linkText = windowWidth >= 768 ? 'Всі підприємства' : 'Всі';
const antdGutter = windowWidth >= 1200 ? [24, 24] : [0, 24];
const antdWrap = windowWidth < 1200;
const linkText = windowWidth >= SCREEN_WIDTH.tablet ? 'Всі підприємства' : 'Всі';
const antdGutter = windowWidth >= SCREEN_WIDTH.smallDesktop ? [24, 24] : [0, 24];
const antdWrap = windowWidth < SCREEN_WIDTH.smallDesktop;

return (
<div className={styles['new-companies-main']}>
Expand Down
17 changes: 6 additions & 11 deletions FrontEnd/src/pages/ProfileList/ProfileListPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { useSearchParams } from 'react-router-dom';
import axios from 'axios';
import useSWR from 'swr';
import useWindowWidth from '../../hooks/useWindowWidth';
import { definPageSize } from '../../utils/definePageSize';
import { PAGE_SIZE } from '../../constants/constants';
import { SCREEN_WIDTH } from '../../constants/constants';

import ErrorPage404 from '../ErrorPages/ErrorPage404';
import Loader from '../../components/Loader/Loader';
Expand Down Expand Up @@ -34,23 +37,15 @@ export default function ProfileListPage({ isAuthorized, isSaved }) {
const [profiles, setProfiles] = useState([]);
const [filters, setFilters] = useState([]);
const [currentPage, setCurrentPage] = useState(pageNumber);
const [pageSize, setPageSize] = useState(16);
const [pageSize, setPageSize] = useState(PAGE_SIZE.mobile);
const [activeTab, setActiveTab] = useState(searchParams.get('companyType') || 'all');
const [activeBtn, setActiveBtn] = useState(searchParams.get('activity') || 'all');

const windowWidth = useWindowWidth();
const linkText = windowWidth >= 768 ? 'Усі підприємства' : 'Усі';
const linkText = windowWidth >= SCREEN_WIDTH.tablet ? 'Усі підприємства' : 'Усі';

useEffect(() => {
if (windowWidth < 768) {
setPageSize(4);
} else if (windowWidth >= 768 && windowWidth < 1200) {
setPageSize(16);
} else if (windowWidth >= 1200 && windowWidth < 1512) {
setPageSize(12);
} else if (windowWidth >= 1512) {
setPageSize(16);
}
definPageSize(windowWidth, setPageSize);
}, [windowWidth]);

const [url, setUrl] = useState(
Expand Down
15 changes: 9 additions & 6 deletions FrontEnd/src/pages/ProfileList/ProfileListPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
width: 100vw;
display: flex;
flex-direction: column;

align-self: center;
}

.company-list__header--wrapper {
Expand All @@ -30,11 +30,10 @@
}

.company-list__title {
font-family: Geologica;
font-family: var(--font-main);
font-weight: 700;
line-height: 28.8px;
letter-spacing: 0.01em;

}

.company-list__tabs {
Expand Down Expand Up @@ -76,8 +75,8 @@
display: flex;
align-self: center;
flex-direction: column;
padding: 24px 27px 40px;
gap: 20px;
padding: 40px 15px;
gap: 16px;
}

.company-list__content--btns-wrapper {
Expand Down Expand Up @@ -123,6 +122,10 @@
.company-list__content {
width: 768px;
}

.company-list__content {
padding: 24px 24px 48px;
}
}

@media only screen and (min-width: 1200px) {
Expand All @@ -136,7 +139,7 @@
}

.company-list__content {
padding: 24px 35px 32px;
padding: 24px 32px 64px;
gap: 32px;
}

Expand Down
11 changes: 6 additions & 5 deletions FrontEnd/src/pages/ProfilePage/ProfilePage.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import css from './ProfilePage.module.css';
import Description from './ProfilePageComponents/Description';
import ProfileContent from './ProfilePageComponents/ProfileContent';
import { useState, useEffect } from 'react';
import { DirtyFormContext } from '../../context/DirtyFormContext';
import Loader from '../../components/Loader/Loader';
import { useAuth, useProfile } from '../../hooks';
import useWindowWidth from '../../hooks/useWindowWidth';
import { SCREEN_WIDTH } from '../../constants/constants';
import Loader from '../../components/Loader/Loader';
import Description from './ProfilePageComponents/Description';
import ProfileContent from './ProfilePageComponents/ProfileContent';
import EditProfileMobile from './Mobile/EditProfileMobile';
import css from './ProfilePage.module.css';

const ProfilePage = () => {
const [formIsDirty, setFormIsDirty] = useState(false);
Expand All @@ -28,7 +29,7 @@ const ProfilePage = () => {
}, [formIsDirty]);


if (windowWidth < 768) {
if (windowWidth < SCREEN_WIDTH.tablet) {
return (
<DirtyFormContext.Provider value={{ formIsDirty, setFormIsDirty }}>
<EditProfileMobile/>
Expand Down
15 changes: 5 additions & 10 deletions FrontEnd/src/pages/SearchPage/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import axios from 'axios';
import useSWR from 'swr';

import useWindowWidth from '../../hooks/useWindowWidth';
import { definPageSize } from '../../utils/definePageSize';
import { PAGE_SIZE } from '../../constants/constants';

import Loader from '../../components/Loader/Loader';
import ProfileList from '../ProfileList/ProfileList';
import styles from './Search.module.scss';
Expand All @@ -16,7 +19,7 @@ export function Search({ isAuthorized }) {
const searchTerm = searchParams.get('name');
const pageNumber = Number(searchParams.get('page')) || 1;
const [currentPage, setCurrentPage] = useState(pageNumber);
const [pageSize, setPageSize] = useState(16);
const [pageSize, setPageSize] = useState(PAGE_SIZE.mobile);
const servedAddress = process.env.REACT_APP_BASE_API_URL;

async function fetcher(url) {
Expand All @@ -43,15 +46,7 @@ export function Search({ isAuthorized }) {
const windowWidth = useWindowWidth();

useEffect(() => {
if (windowWidth < 768) {
setPageSize(4);
} else if (windowWidth >= 768 && windowWidth < 1200) {
setPageSize(16);
} else if (windowWidth >= 1200 && windowWidth < 1512) {
setPageSize(12);
} else if (windowWidth >= 1512) {
setPageSize(16);
}
definPageSize(windowWidth, setPageSize);
}, [windowWidth]);

const updateQueryParams = (newPage) => {
Expand Down
15 changes: 15 additions & 0 deletions FrontEnd/src/utils/definePageSize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { SCREEN_WIDTH } from '../constants/constants';
import { PAGE_SIZE } from '../constants/constants';

export function definPageSize (windowWidth, setPageSize) {
if (windowWidth < SCREEN_WIDTH.tablet) {
return setPageSize(PAGE_SIZE.mobile);
}
if (windowWidth < SCREEN_WIDTH.smallDesktop) {
return setPageSize(PAGE_SIZE.tablet);
}
if (windowWidth < SCREEN_WIDTH.desktop) {
return setPageSize(PAGE_SIZE.smallDesktop);
}
return setPageSize(PAGE_SIZE.desktop);
}
Loading