Skip to content

Commit be6139b

Browse files
feat: make login modal and form elements responsive to different screen sizes.
1 parent 218be34 commit be6139b

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

src/shared/ui/LoginButton/index.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22
import Image from 'next/image';
33
import cn from 'classnames';
4-
import { useCallback, useEffect, useState } from 'react';
4+
import { useCallback, useEffect, useMemo, useState } from 'react';
55
import { ModalComponent } from '@/shared/ui/Modal';
66
import { LoginForm } from '../LoginForm';
77
import { signOut, useSession } from 'next-auth/react';
@@ -12,6 +12,7 @@ import { getMaterials, getServices } from '@/shared/api';
1212
import { materialsState } from '@/shared/state/materials/state';
1313
import { serviceState } from '@/shared/state/services/state';
1414
import { Icon } from '@/shared/ui/Icon';
15+
import { useWindowWidth } from '@/shared/hooks';
1516

1617
type LoginButtonProps = {
1718
withIcon?: boolean;
@@ -52,7 +53,21 @@ export const LoginButton = observer(({ withIcon = true }: LoginButtonProps) => {
5253
userState.removeUserFromState();
5354
}
5455
}, [session.data?.user]);
55-
56+
const windowWidth = useWindowWidth();
57+
const style = useMemo(() => {
58+
if (windowWidth > 520) return { height: 300 };
59+
if (windowWidth >= 420)
60+
return {
61+
height: 'fit-content',
62+
['padding-bottom']: 10,
63+
['boz-sizing']: 'border-box',
64+
};
65+
return {
66+
height: 'fit-content',
67+
width: windowWidth - 20,
68+
['padding-bottom']: 10,
69+
};
70+
}, [windowWidth]);
5671
return (
5772
<div className={cn(s.itemContainer, { [s.itemContainerShort]: !withIcon })}>
5873
{withIcon && (
@@ -73,9 +88,7 @@ export const LoginButton = observer(({ withIcon = true }: LoginButtonProps) => {
7388
onClose={handleCloseModal}
7489
open={open}
7590
withControl={false}
76-
style={{
77-
height: 300,
78-
}}
91+
style={style}
7992
>
8093
<LoginForm />
8194
</ModalComponent>

src/shared/ui/LoginForm/SubmitButton/style.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
width: 300px;
1414
height: 35px;
1515
text-align: center;
16+
17+
@media (max-width: 340px) {
18+
width: 100%;
19+
}
1620
}
1721

1822
&:hover {

src/shared/ui/LoginForm/style.module.scss

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
}
3333
}
3434
&Footer {
35-
height: fit-content;
36-
box-sizing: border-box;
3735
display: flex;
3836
flex-direction: column;
3937
align-items: center;
4038
justify-content: center;
39+
height: fit-content;
40+
box-sizing: border-box;
4141
padding: 15px;
4242
}
4343
&OtherProviders {
@@ -47,13 +47,29 @@
4747
justify-content: center;
4848
position: relative;
4949

50+
form {
51+
@media (max-width: 390px) {
52+
display: flex;
53+
flex-direction: column;
54+
align-items: center;
55+
justify-content: center;
56+
height: fit-content;
57+
box-sizing: border-box;
58+
width: 90%;
59+
}
60+
}
61+
5062
&::before {
51-
content: "";
63+
content: '';
5264
width: 350px;
5365
height: 1px;
5466
background-color: #888888;
5567
position: absolute;
5668
top: -8px;
69+
70+
@media (max-width: 390px) {
71+
width: 90%;
72+
}
5773
}
5874
}
5975
}

0 commit comments

Comments
 (0)