Skip to content

Commit

Permalink
Add styles for Contactlist from Chakra
Browse files Browse the repository at this point in the history
  • Loading branch information
EmiliaWenta committed Dec 7, 2023
1 parent 618a43b commit d9aab48
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 36 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-helmet": "^6.1.0",
"react-loader-spinner": "^5.4.5",
"react-loader-spinner": "^5.5.0",
"react-redux": "^8.1.3",
"react-router-dom": "^6.20.0",
"react-scripts": "5.0.1",
Expand Down
36 changes: 29 additions & 7 deletions src/components/ContactList/ContactList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ import { useSelector } from 'react-redux/es/hooks/useSelector';
import ContactListItem from './ContactListItem/ContactListItem';
import { selectFilterValue, selectContacts } from '../../redux/selectors';

import { Heading } from '@chakra-ui/react';

import css from './ContactList.module.css';
import {
Box,
Flex,
Heading,
Input,
List,
ListItem,
ListIcon,
OrderedList,
UnorderedList,
Text,
} from '@chakra-ui/react';

export default function ContactList() {
const { contacts } = useSelector(selectContacts);
const filterValue = useSelector(selectFilterValue);

const contactsValue = contacts.length;

const contactListItem = contacts
.filter(item => item.name.toLowerCase().includes(filterValue.toLowerCase()))
.map(item => (
Expand All @@ -25,10 +36,21 @@ export default function ContactList() {

return (
<>
<Heading as="h2" size="md" color="#2196f3">
Contacts
</Heading>
<ul className={css.contactList}>{contactListItem}</ul>
<Box>
<Flex
flexDirection="column"
gap="10px"
justify="center"
align="center"
paddingTop="30px"
>
<Heading as="h2" size="md" color="#2196f3">
Your contacts:
</Heading>
{contactsValue === 0 && <Text>You don't saved contacts yet.</Text>}
<List spacing={3}>{contactListItem}</List>
</Flex>
</Box>
</>
);
}
55 changes: 42 additions & 13 deletions src/components/ContactList/ContactListItem/ContactListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@ import { useDispatch } from 'react-redux';

import { deleteContact } from '../../../redux/reducers/contacts/operations';

import css from './ContactListItem.module.css';
import {
Box,
Flex,
Heading,
Input,
List,
ListItem,
ListIcon,
OrderedList,
UnorderedList,
Button,
Card,
CardBody,
Text,
} from '@chakra-ui/react';
import { PhoneIcon, DeleteIcon } from '@chakra-ui/icons';

export default function ContactListItem({ id, name, number }) {
const dispatch = useDispatch();
Expand All @@ -14,18 +29,32 @@ export default function ContactListItem({ id, name, number }) {
};

return (
<li className={css.contactListItem__item} key={id.toString()}>
{name}: {number}
<button
className={css.contactListItem__button}
type="button"
onClick={() => {
handleRemove(id);
}}
>
Delete
</button>
</li>
<ListItem key={id.toString()} width="450px" align="flex-start">
<Card>
<CardBody>
<Flex gap="10px" justifyContent="space-between" alignItems="center">
<ListIcon as={PhoneIcon} color="blue.500" />
{name}: {number}
<Button
leftIcon={<DeleteIcon />}
colorScheme="teal"
variant="solid"
type="button"
bg="#2196f3"
color="white"
size="sm"
_hover={{ bg: 'darkblue' }}
_active={{ bg: 'darkblue' }}
onClick={() => {
handleRemove(id);
}}
>
Delete
</Button>
</Flex>
</CardBody>
</Card>
</ListItem>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.contactListItem__item {
/* .contactListItem__item {
color: #1f67a3;
display: flex;
width: 450px;
Expand All @@ -22,4 +22,4 @@
.contactListItem__button:hover {
background-color: #4396d9;
}
} */
2 changes: 2 additions & 0 deletions src/components/Filter/Filter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default function Filter() {
borderColor="#d8dee4"
size="md"
borderRadius="6px"
maxWidth="400px"
minWidth="350px"
width="50%"
onChange={handleFilter}
/>
Expand Down
11 changes: 5 additions & 6 deletions src/components/Layout/Layout.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
// import { Suspense } from 'react';
import { Suspense } from 'react';
import { Outlet } from 'react-router-dom';
// import Loader from '../Loader/Loader';
import Loader from '../Loader/Loader';
import { Link } from 'react-router-dom';
// import { StyledHeader, StyledLink } from './Layout.styled';
import { useAuth } from 'hook/useAuth';
Expand Down Expand Up @@ -89,13 +89,12 @@ export const Layout = () => {
</TabList>

<TabPanels>
<Outlet />
<Suspense fallback={<Loader />}>
<Outlet />
</Suspense>
</TabPanels>
</Tabs>
<ThemeToggler />
{/* <Suspense fallback={<Loader />}>
//
</Suspense> */}
</>
);
};
1 change: 1 addition & 0 deletions src/redux/reducers/auth/authSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const authSlice = createSlice({
state.isLoading = true;
})
.addCase(currentUser.fulfilled, (state, action) => {
state.isLoading = false;
state.isLoggedIn = true;
state.user = action.payload.name;
})
Expand Down
1 change: 1 addition & 0 deletions src/redux/selectors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const selectContacts = state => state.contact;
export const selectFilterValue = state => state.filter;
export const selectIsLoading = state => state.contact.isLoading;

export const selectisLoggedIn = state => state.auth.isLoggedIn;

Expand Down

0 comments on commit d9aab48

Please sign in to comment.