Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 74 additions & 78 deletions src/components/CharacterCardSmall.css
Original file line number Diff line number Diff line change
@@ -1,127 +1,123 @@
.card-content {
container-type: inline-size;
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: min(100%, 19rem);
padding: 0.5rem;
align-self: start;
box-sizing: border-box;

width: 19rem;
height: 25.5rem;
border-radius: 1.5rem;
background-color: #5a7d0d;
}

@media (min-width: 600px) {
.card-content {
container-type: inline-size;
position: relative;
display: flex;
align-items: center;
justify-content: center;

width: 12rem;
height: 16.5rem;
border-radius: 1.5rem;
background-color: #5a7d0d;
}
.small-card-frame {
position: relative;
container-type: inline-size;
width: 100%;
aspect-ratio: 196 / 275;
}

.card-shape {
position: absolute;
width: 18rem;
height: 23rem;
}

@media (min-width: 600px) {
.card-shape {
position: absolute;
width: 11rem;
height: 16rem;
}
inset: 0;
display: block;
width: 100%;
height: 100%;
}

.character-info {
position: absolute;
inset: 5% 7%;
display: flex;
text-align: center;
flex-direction: column;
align-items: center;
position: absolute;
gap: 2cqw;
color: white;
z-index: 1;
text-align: center;
}

.character-image {
width: 15rem;
height: 15rem;
border-radius: 1.5rem;
}
display: block;
flex-shrink: 0;

@media (min-width: 600px) {
.character-image {
width: 10rem;
height: 10rem;
border-radius: 1.5rem;
}
width: 100%;
height: auto;
object-fit: cover;
border-radius: 1rem;
aspect-ratio: 1;
}

.card-buttons {
display: flex;
align-items: center;
justify-content: center;
max-width: inherit;
padding-top: 0.5rem;
flex-shrink: 0;
align-self: flex-start;

width: 75%;
height: 12cqw;
margin-left: 4%;
}

.star {
width: 1.5rem;
height: 1.5rem;
display: block;
width: 100%;
height: 100%;

filter: brightness(0) invert(1);
}

.favorite-button {
position: absolute;
left: 92%;
top: 94%;
transform: translate(-50%, -50%);

display: flex;
align-items: center;
justify-content: center;

width: 14%;
aspect-ratio: 1;
padding: 0;
border: none;
background: transparent;
border: 0;
transform: translateX(0.7rem) translateY(0.8rem);
cursor: pointer;
}

.star-favorite {
filter: brightness(0) saturate(100%) invert(84%) sepia(85%) saturate(829%)
hue-rotate(359deg) brightness(105%) contrast(104%);
filter: brightness(0) saturate(100%) invert(84%) sepia(85%) saturate(829%) hue-rotate(359deg) brightness(105%) contrast(104%);
}

.details-button {
display: block;
width: 100%;
height: 100%;
padding: 0;

border: none;
border-radius: 1rem;
background-color: white;
color: black;
border-radius: 1rem;
border: none;
width: 12rem;
height: 2rem;
font-size: clamp(0.75rem, 6cqw, 1rem);
cursor: pointer;
}

@media (min-width: 600px) {
.details-button {
background-color: white;
color: black;
border-radius: 1rem;
border: none;
width: 8rem;
height: 2rem;
}
}
.character-name {
flex: 1;
min-height: 0;
width: 100%;
margin: 0;
padding: 0;

p {
padding-top: 1rem;
padding-bottom: 1rem;
display: flex;
align-items: center;
justify-content: center;

font-size: 10cqw;
line-height: 1.1;
font-weight: 800;
font-size: 2rem;
overflow-wrap: anywhere;
overflow: auto;
}

@media (min-width: 600px) {
p {
padding: 0;
font-weight: 800;
font-size: 1.5rem;
@media (min-width: 768px) {
.card-content {
width: min(100%, 12rem);
}
}
}
53 changes: 29 additions & 24 deletions src/components/CharacterCardSmall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,36 @@ export default function CharacterCardSmall({
}: CharacterCardSmallProps) {
return (
<article className="card-content">
<img src={CardShape} alt="" className="card-shape" />
<div className="character-info">
<img src={image} alt="character image" className="character-image" />
<p className="character-name">{name}</p>
<div className="card-buttons">
<button type="button" className="details-button" onClick={onDetails}>
Details
</button>
<button
type="button"
className="favorite-button"
onClick={onToggleFavorite}
aria-label={
isFavorite
? `Remove ${name} from favorites`
: `Add ${name} to favorites`
}
>
<img
src={StarShape}
alt=""
className={`star ${isFavorite ? "star-favorite" : ""}`}
/>
</button>
<div className="small-card-frame">
<img src={CardShape} alt="" className="card-shape" />

<div className="character-info">
<img src={image} alt="character image" className="character-image" />
<p className="character-name">{name}</p>

<div className="card-buttons">
<button type="button" className="details-button" onClick={onDetails}>
Details
</button>
</div>
</div>

<button
type="button"
className="favorite-button"
onClick={onToggleFavorite}
aria-label={
isFavorite
? `Remove ${name} from favorites`
: `Add ${name} to favorites`
}
>
<img
src={StarShape}
alt=""
className={`star ${isFavorite ? "star-favorite" : ""}`}
/>
</button>
</div>
</article>
);
Expand Down
Loading