Skip to content

Commit

Permalink
styled forms
Browse files Browse the repository at this point in the history
  • Loading branch information
IrynaSlavinska committed Dec 31, 2023
1 parent 52f227f commit 9c63b02
Show file tree
Hide file tree
Showing 20 changed files with 183 additions and 30 deletions.
11 changes: 5 additions & 6 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Routes, Route } from 'react-router-dom';
// import { lazy } from 'react';
import { lazy } from 'react';
import { Routes, Route } from 'react-router-dom';

import Layout from './Layout/Layout';
import RegisterPage from 'pages/RegisterPage';
import LoginPage from 'pages/LoginPage';
import ContactsPage from 'pages/ContactsPage';
import NotFound from 'pages/NotFound';
import ContactsPage from 'pages/ContactsPage/ContactsPage';
import RegisterPage from 'pages/RegisterPage/RegisterPage';
import NotFound from 'pages/NotFound/NotFound';

const HomePage = lazy(() => import('pages/HomePage/HomePage'));
const LoginPage = lazy(() => import('pages/LoginPage/LoginPage'));

const App = () => {
return (
Expand Down
26 changes: 17 additions & 9 deletions src/components/Layout/Layout.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
import { NavLink, Outlet } from 'react-router-dom';
import { Outlet } from 'react-router-dom';
import { Suspense } from 'react';
import { Header, Navigation, NavItem, Container } from './Layout.styled';
import {
Container,
Header,
Navigation,
NavItem,
StyledLink,
Main,
} from './Layout.styled';

const Layout = () => {
return (
<Container>
<Header>
<Navigation>
<NavItem>
<NavLink to="/">Home</NavLink>
<StyledLink to="/">Home</StyledLink>
</NavItem>
<NavItem>
<NavLink to="register">Register</NavLink>
<StyledLink to="register">Register</StyledLink>
</NavItem>
<NavItem>
<NavLink to="login">Log In</NavLink>
<StyledLink to="login">Log In</StyledLink>
</NavItem>
<NavItem>
<NavLink to="contacts">Contacts</NavLink>
<StyledLink to="contacts">Contacts</StyledLink>
</NavItem>
</Navigation>
</Header>
<main>
<Suspense fallback={<div>Loading...</div>}>

<Main>
<Suspense fallback={null}>
<Outlet />
</Suspense>
</main>
</Main>
</Container>
);
};
Expand Down
16 changes: 14 additions & 2 deletions src/components/Layout/Layout.styled.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled from '@emotion/styled';
import { NavLink } from 'react-router-dom';

export const Container = styled.div`
width: 1400px;
Expand All @@ -15,12 +16,23 @@ export const Navigation = styled.ul`
gap: 50px;
`;

export const NavItem = styled.li`
export const NavItem = styled.li``;

export const StyledLink = styled(NavLink)`
font-size: 20px;
color: #000000;
background-color: #bfa89e;
padding: 8px;
border-radius: 4px;
&: active {
&.active {
color: #ebf5ee;
background-color: #8b786d;
padding: 8px;
border-radius: 4px;
}
`;

export const Main = styled.main`
padding: 32px;
`;
17 changes: 17 additions & 0 deletions src/components/LoginForm/LoginForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Form, Label, Input, SubmitButton } from './LoginForm.styled';

export const LoginForm = () => {
return (
<Form>
<Label>
Email
<Input type="email" name="email" />
</Label>
<Label>
Password
<Input type="password" name="password" />
</Label>
<SubmitButton type="submit">Log In</SubmitButton>
</Form>
);
};
44 changes: 44 additions & 0 deletions src/components/LoginForm/LoginForm.styled.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import styled from '@emotion/styled';

export const Form = styled.form`
width: 400px;
background-color: #bfa89e;
padding: 12px;
border-radius: 8px;
`;

export const Label = styled.label`
display: flex;
flex-direction: column;
margin-bottom: 16px;
color: #000000;
font-size: 18px;
margin-bottom: 12px;
`;

export const Input = styled.input`
padding: 4px;
font-size: 18px;
border-radius: 4px;
border: 2px solid transparent;
outline: transparent;
&: focus {
border-color: #78a1bb;
}
&: hover {
border-color: #78a1bb;
}
`;

export const SubmitButton = styled.button`
padding: 8px 24px;
font-size: 16px;
color: #ebf5ee;
background-color: #8b786d;
&: hover {
background-color: #78a1bb;
}
`;
21 changes: 21 additions & 0 deletions src/components/RegisterForm/RegisterForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Form, Label, Input, SubmitButton } from './RegisterForm.styled';

export const RegisterForm = () => {
return (
<Form>
<Label>
Username
<Input type="text" name="text" />
</Label>
<Label>
Email
<Input type="email" name="email" />
</Label>
<Label>
Password
<Input type="password" name="password" />
</Label>
<SubmitButton type="submit">Register</SubmitButton>
</Form>
);
};
44 changes: 44 additions & 0 deletions src/components/RegisterForm/RegisterForm.styled.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import styled from '@emotion/styled';

export const Form = styled.form`
width: 400px;
background-color: #bfa89e;
padding: 12px;
border-radius: 8px;
`;

export const Label = styled.label`
display: flex;
flex-direction: column;
margin-bottom: 16px;
color: #000000;
font-size: 18px;
margin-bottom: 12px;
`;

export const Input = styled.input`
padding: 4px;
font-size: 18px;
border-radius: 4px;
border: 2px solid transparent;
outline: transparent;
&: focus {
border-color: #78a1bb;
}
&: hover {
border-color: #78a1bb;
}
`;

export const SubmitButton = styled.button`
padding: 8px 24px;
font-size: 16px;
color: #ebf5ee;
background-color: #8b786d;
&: hover {
background-color: #78a1bb;
}
`;
4 changes: 2 additions & 2 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ol {
}
a {
text-decoration: none;
color: #ebf5ee;
color: #000000;
}

body {
Expand Down Expand Up @@ -68,5 +68,5 @@ body::-webkit-scrollbar-thumb {
text-align: center;
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 4px;
}
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import App from 'components/App';
import './index.css';

import { BrowserRouter } from 'react-router-dom';
// import { Provider } from 'react-redux';
// import { store } from './redux/store';

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
{/* <Provider store={store}> */}
<BrowserRouter basename="/goit-react-hw-08-phonebook">
<App />
</BrowserRouter>
{/* </Provider> */}
</React.StrictMode>
);
File renamed without changes.
Empty file.
2 changes: 1 addition & 1 deletion src/pages/HomePage/HomePage.styled.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const HomeContainer = styled.div`
background-size: cover;
margin: 0 auto;
max-width: 1400px;
height: 89vh;
height: 80vh;
display: flex;
justify-content: center;
Expand Down
5 changes: 0 additions & 5 deletions src/pages/LoginPage.jsx

This file was deleted.

7 changes: 7 additions & 0 deletions src/pages/LoginPage/LoginPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { LoginForm } from 'components/LoginForm/LoginForm';

const LoginPage = () => {
return <LoginForm />;
};

export default LoginPage;
Empty file.
File renamed without changes.
Empty file.
5 changes: 0 additions & 5 deletions src/pages/RegisterPage.jsx

This file was deleted.

7 changes: 7 additions & 0 deletions src/pages/RegisterPage/RegisterPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { RegisterForm } from 'components/RegisterForm/RegisterForm';

const RegisterPage = () => {
return <RegisterForm />;
};

export default RegisterPage;
Empty file.

0 comments on commit 9c63b02

Please sign in to comment.