components uses css modules; other refactoring

This commit is contained in:
tmshv committed 2020-03-29 01:41:10 +03:00
1 parent 0cd61e0ed9
commit d65aba19a0
28 files changed
+137 -94

No files matched your search

+10 -4
View File
@@ -1,8 +1,14 @@
import './styles.css'
import s from './styles.module.css'
import cx from 'classnames'
import Link from 'next/link'
import { Image } from '../Image'
const layoutClass = {
simple: s.simple,
featured: s.featured,
}
export type CardLayout = 'simple' | 'featured'
export type CardProps = {
style?: React.CSSProperties
@@ -16,10 +22,10 @@ export type CardProps = {
}
export const Card: React.FC<CardProps> = props => (
<div className={cx('card', props.layout)} style={props.style}>
<div className={cx(s.card, layoutClass[props.layout])} style={props.style}>
<Link href={props.href}>
<a>
<div className={'card-image'}>
<div className={s.image}>
<Image
alt={props.img.alt}
src={props.img.src}
@@ -27,7 +33,7 @@ export const Card: React.FC<CardProps> = props => (
/>
</div>
<div className={'card-body'}>
<div className={s.body}>
{props.children}
</div>
</a>
@@ -1,3 +1,5 @@
/* CARD */
.card {
border-radius: var(--radius);
box-shadow: var(--shadow);
@@ -23,13 +25,13 @@
position: relative;
}
.card-image {
.image {
position: relative;
width: 100%;
height: 100%;
}
.card-image img {
.image img {
width: 100%;
height: 100%;
object-fit: cover;
@@ -41,19 +43,19 @@
left: 0;
}
.card-body {
.body {
background-color: var(--color-back);
padding: var(--size-m);
}
/* SIMPLE */
.card.simple .card-body {
.simple .body {
position: relative;
padding-top: 0;
}
.card.simple .card-body:before {
.simple .body:before {
position: absolute;
content: '';
background-color: var(--color-back);
@@ -65,14 +67,14 @@
left: 0;
}
.card.simple > a {
.simple > a {
display: flex;
flex-direction: column;
}
/* FEATURED */
.card.featured .card-body {
.featured .body {
position: absolute;
--offset: var(--size-m);