Skip to content

Commit

Permalink
Merge pull request #37 from WildCodeSchool/release/style-modale
Browse files Browse the repository at this point in the history
Release/style modale
  • Loading branch information
TheoSkymel authored Feb 27, 2025
2 parents d33efea + 283ebac commit f40bddb
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 43 deletions.
1 change: 1 addition & 0 deletions public/pictures/remove-fave.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/components/card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ export default function Card({ character, image, onAddToFavorites, onClick, onRe
</button>
{isFavoritePage && (
<button
className='delete-fav'
onClick={(e) => {
e.stopPropagation();
onRemove();
}}
>
Remove from Favorites
<img className='remove-fav' src='/pictures/remove-fave.svg' alt='' />
</button>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/loader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '../style/loader.scss';
export default function Loader() {
return (
<div className='load'>
<img src='/pictures/hammer.png' alt='' /> <p> Loading..... </p>
<img src='/pictures/hammer.png' alt='' />
</div>
);
}
2 changes: 1 addition & 1 deletion src/components/modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function Modal({ isOpen, onClose, children }) {
<div className='modal-overlay'>
<div className='modal-content'>
<button className='btn-modal' onClick={onClose}>
&times;
x
</button>
{children}
</div>
Expand Down
20 changes: 16 additions & 4 deletions src/components/search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { useState } from 'react';
import '../style/search.scss';
import Characters from './characters.jsx';
import Comics from './comics.jsx';
import Loader from './loader.jsx';

const publicKey = import.meta.env.VITE_PUBLIC_KEY;

export default function Search() {
const [characterData, setCharacterData] = useState(null);
const [comicData, setComicData] = useState(null);
const [characterName, setCharacterName] = useState('');
const [loading, setLoading] = useState(false);

const handleSubmit = (event) => {
event.preventDefault();
Expand All @@ -18,6 +20,7 @@ export default function Search() {
};

const getCharacterData = () => {
setLoading(true);
setCharacterData(null);
setComicData(null);

Expand All @@ -32,10 +35,12 @@ export default function Search() {
setCharacterData({ ...result.data, results: filteredCharacters });
})
// eslint-disable-next-line no-console
.catch((error) => console.log(error));
.catch((error) => console.log(error))
.finally(() => setLoading(false));
};

const getComicData = (characterId) => {
setLoading(true);
window.scrollTo({ top: 0, left: 0 });

const url = `https://gateway.marvel.com/v1/public/characters/${characterId}/comics?apikey=${publicKey}`;
Expand All @@ -49,7 +54,8 @@ export default function Search() {
setComicData({ ...result.data, results: filteredComics });
})
// eslint-disable-next-line no-console
.catch((error) => console.log(error));
.catch((error) => console.log(error))
.finally(() => setLoading(false));
};

const handleChange = (event) => {
Expand All @@ -62,11 +68,17 @@ export default function Search() {
<input type='text' placeholder='Search' value={characterName} onChange={handleChange} />
</form>

{!comicData && characterData && characterData.results[0] && (
{loading && (
<div>
<Loader />
</div>
)}

{!loading && !comicData && characterData && characterData.results[0] && (
<Characters data={characterData.results} onClick={getComicData} />
)}

{comicData && comicData.results[0] && <Comics data={comicData.results} onClick={() => {}} />}
{!loading && comicData && comicData.results[0] && <Comics data={comicData.results} onClick={() => {}} />}
</>
);
}
2 changes: 1 addition & 1 deletion src/pages/favorite-page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function FavoritePage({ favorites, removeFromFavorites }) {
<h1 className='typo'>My Favorite Characters</h1>
<div className='grid-box'>
{favorites.length === 0 ? (
<h1>No favorites added yet.</h1>
<h1 className='h1-favorite'>No favorites added yet.</h1>
) : (
favorites.map((character) => (
<Card
Expand Down
87 changes: 66 additions & 21 deletions src/style/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,35 +91,80 @@
transform: scale(1.1) rotate(-35deg);
}
}
.delete-fav {
border: none;
background: none;
}
.remove-fav {
position: relative;
width: 25px;
height: 25px;
transform: rotate(-45deg);
animation: beat 1s infinite ease-in-out;
margin-left: -20px;
margin-top: 16px;
box-shadow: 5px 3px 5px;
margin: 0 auto;

.character-title {
display: flex;
justify-content: center;
align-items: center;
width: 150px;

border: solid, $text-color;
background-color: $background-card;
opacity: 85%;
height: 70px;
// margin-top: 10px;
border-radius: 8px;
cursor: pointer;
&:hover {
transform: scale(1.1);
transition: transform 0.5s;
filter: brightness(0.9);

&::before,
&::after {
content: '';
position: absolute;
width: 50px;
height: 50px;
border-radius: 50%;
}

&::before {
top: -50px;
left: 0;
}

&::after {
top: 0;
left: 50px;
}
}
}

h2 {
color: $text-color;
text-align: center;
font-size: 1.1em;
font-family: $font-family;
@keyframes beat {
0%,
100% {
transform: scale(1) rotate(-15deg);
}
50% {
transform: scale(1.1) rotate(-35deg);
}
}
}
.character-title {
display: flex;
justify-content: center;
align-items: center;
width: 150px;

border: solid, $text-color;
background-color: $background-card;
opacity: 85%;
height: 70px;
// margin-top: 10px;
border-radius: 8px;
cursor: pointer;
&:hover {
transform: scale(1.1);
transition: transform 0.5s;
filter: brightness(0.9);
}
}

h2 {
color: $text-color;
text-align: center;
font-size: 1.1em;
font-family: $font-family;
}

@media screen and (min-width: 200px) and (max-width: 479px) {
.grid-box {
Expand Down
7 changes: 6 additions & 1 deletion src/style/favorite-page.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
@use 'settings.scss' as *;
.favorite {
padding: 20px 0 0 20px;

.h1-favorite {
color: white;
font-size: 1.5rem;
text-align: center;
font-family: 'Aclonica', sans-serif;
}
.favor {
display: none;
}
Expand Down
7 changes: 0 additions & 7 deletions src/style/loader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
flex-direction: column;
align-items: center;

p {
padding-bottom: 20px;
color: white;
font-size: 50px;

font-family: $font-family;
}
img {
width: 150px;
animation: spin 1s linear infinite;
Expand Down
13 changes: 9 additions & 4 deletions src/style/modal.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
@use 'settings' as *;

.modal-overlay {
color: $text-color;
color: #f4f4f4;
position: fixed;
top: 0;
left: 0;
top: -1px;
left: 0%;
right: 0;
padding: 37px;
bottom: 0;
max-width: 100%;
z-index: 1000;
background: $background-comics;
background: rgba(0, 0, 0, 0.5);

.modal-content {
padding: 0 20px;
border-radius: 8px;
position: relative;
width: 87%;
background: #460702;
left: 6%;

.btn-modal {
position: absolute;
Expand Down
5 changes: 3 additions & 2 deletions src/style/profile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@
padding: 1rem;
border-radius: $border-radius;
background: $background-card;
width: 450px;

h3 {
font-size: 3.3rem;
font-size: 2.5rem;
font-family: $font-family;
}
p {
font-size: 1.5rem;
font-size: 1rem;
font-family: $font-family;
line-height: 1.5;
}
Expand Down

0 comments on commit f40bddb

Please sign in to comment.