Files
housesof/src/style/molecules/_photo-card.scss
Félix Péault cdabe6935b 🔥 Huge style refactoring by using SvelteKit built-in style tag
It's been tricky but got there finally! Hello `:global`
- Avoid using one global CSS file containing everything
- Import the component SCSS file in a script tag from the component file to allow style scoping and including it only when used
2022-06-22 23:26:00 +02:00

117 lines
2.9 KiB
SCSS

.photo-card {
& > * {
border-radius: 8px;
}
a {
display: block;
overflow: hidden;
cursor: zoom-in;
box-shadow: 0 16px 12px rgba(#000, 0.15), 0 26px 52px rgba(#000, 0.2);
transition: transform 0.7s var(--ease-quart);
will-change: transform;
}
:global(picture) {
width: 100%;
height: 100%;
background: $color-primary-tertiary20;
}
:global(img) {
display: block;
width: calc(100% + 2px);
height: calc(100% + 2px);
object-fit: cover;
transition: opacity 0.7s var(--ease-quart);
}
// Informations
&__info {
position: absolute;
z-index: 2;
bottom: 16px;
left: 20px;
right: 20px;
display: flex;
flex-wrap: wrap;
align-items: center;
color: $color-cream;
pointer-events: none;
font-size: clamp(#{rem(12px)}, 1.5vw, #{rem(14px)});
@include bp (sm) {
font-size: clamp(#{rem(12px)}, 1.2vw, #{rem(14px)});
}
:global(picture) {
width: 20px;
height: 20px;
margin-right: 12px;
border-radius: 100%;
overflow: hidden;
@include bp (sm) {
width: 24px;
height: 24px;
margin-right: 16px;
}
:global(img) {
display: block;
width: 100%;
height: 100%;
}
}
:global(p) {
max-width: min(80%, 300px);
line-height: 1.4;
}
& > :global(*) {
opacity: 0;
transform: translate3d(0, 8px, 0);
transition: opacity 0.7s var(--ease-quart), transform 0.8s var(--ease-quart);
@include bp (md) {
transform: translate3d(0, 8px, 0);
}
}
}
// Gradient
a:after {
content: "";
display: block;
opacity: 0;
position: absolute;
z-index: 1;
pointer-events: none;
bottom: 0;
left: 0;
width: 100%;
height: 50%;
background: linear-gradient(180deg, rgba(#2D1745, 0) 0%, #2D1745 100%);
transition: opacity 0.8s var(--ease-quart);
}
// Slightly zoom in and show info on hover
@media (hover: hover) {
a:hover {
transform: scale(1.0375) rotate(2deg) translateZ(0);
:global(.photo-card__info) {
:global(*) {
opacity: 1;
transform: translate3d(0,0,0);
}
:global(picture) {
transition-delay: 100ms;
}
:global(p) {
transition-delay: 180ms;
}
}
&:after {
opacity: 1;
}
}
}
}