Skip to content

Commit

Permalink
add toast, more styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolaus-B committed Feb 18, 2024
1 parent b6153a7 commit 3c36125
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 11 deletions.
38 changes: 38 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"modern-normalize": "^2.0.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-hot-toast": "^2.4.1",
"react-icons": "^5.0.1",
"react-loader-spinner": "^6.1.6",
"react-modal": "^3.16.1",
Expand Down
3 changes: 2 additions & 1 deletion src/components/AppLayout/AppLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
HeaderList,
Nav,
} from './AppLayout.styled';
import { Toaster } from 'react-hot-toast';

export const AppLayout = () => {
return (
Expand All @@ -31,7 +32,7 @@ export const AppLayout = () => {
<Outlet />
</Suspense>
</main>

<Toaster />
<GlobalStyle />
</>
);
Expand Down
24 changes: 20 additions & 4 deletions src/components/ArticleItem/ArticleItem.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import React from 'react';
import { Image, ImageContainer, Item } from './ArticleItem.styled';
import {
ArticleAuthor,
ArticleDescription,
ArticleTitle,
Image,
ImageContainer,
Item,
} from './ArticleItem.styled';

export const ArticleItem = ({ article }) => {
return (
Expand All @@ -13,9 +20,18 @@ export const ArticleItem = ({ article }) => {
alt="article title"
/>
</ImageContainer>
<h1>{article.author || 'No author'} </h1>
<h2>{article.title || 'No title'} </h2>
<p>{article.description || 'No description avalable'} </p>
<ArticleAuthor>
<span style={{ color: '#a2add0' }}>Author: </span>{' '}
{article.author || 'No author'}{' '}
</ArticleAuthor>
<ArticleTitle>
<span style={{ color: '#b7c7c3' }}>Title: </span>
{article.title || 'No title'}{' '}
</ArticleTitle>
<ArticleDescription>
<span style={{ color: '#ad6d88' }}>Description: </span>
{article.description || 'No description avalable'}{' '}
</ArticleDescription>
</Item>
);
};
5 changes: 5 additions & 0 deletions src/components/ArticleItem/ArticleItem.styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ export const Item = styled.li`
export const ImageContainer = styled.div`
width: 380px;
height: 240px;
margin-bottom: 10px;
`;

export const Image = styled.img`
width: 100%;
height: 100%;
`;

export const ArticleAuthor = styled.h3``;
export const ArticleTitle = styled.h2``;
export const ArticleDescription = styled.p``;
14 changes: 8 additions & 6 deletions src/components/UserForm/UserForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
FormField,
Label,
} from './UserForm.styled';
import toast from 'react-hot-toast';

const ArticleSchema = Yup.object().shape({
imageUrl: Yup.string(),
Expand Down Expand Up @@ -48,6 +49,7 @@ export const UserForm = () => {
article.title.toLowerCase() === values.title.toLowerCase()
)
) {
toast.error(`Article ${values.title} already exists`);
return;
}
dispatch(addArticle({ ...values, id: uid() }));
Expand All @@ -65,18 +67,18 @@ export const UserForm = () => {
<FormErrorMessage component={'span'} name="author" />
</Label>

<Label>
Description
<FormField name="description" placeholder="lorem" />
<FormErrorMessage component={'span'} name="description" />
</Label>

<Label>
Title
<FormField name="title" placeholder="lorem" />
<FormErrorMessage component={'span'} name="title" />
</Label>

<Label>
Description
<FormField name="description" placeholder="lorem" />
<FormErrorMessage component={'span'} name="description" />
</Label>

<FormButton type="submit">Add article</FormButton>
</FormContainer>
</Formik>
Expand Down

0 comments on commit 3c36125

Please sign in to comment.