Skip to content

Commit

Permalink
change(card): implement title on image within image section
Browse files Browse the repository at this point in the history
- this way we simplify the transformation from normal
  card to card with header on the image section
- heading on image is capitalized
  • Loading branch information
ichim-david committed Jan 19, 2023
1 parent 281f9c0 commit ff6cc60
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 33 deletions.
30 changes: 9 additions & 21 deletions src/ui/Card/Card.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ const CardTemplate = ({ variant, inverted, titleOnImage, card }) => (

{/* Title */}
{!titleOnImage || !card.hasImage ? (
<Card.Header>
<a href={card.href}>{card.title}</a>
</Card.Header>
<Card.Header>{card.title}</Card.Header>
) : (
''
)}

{/* Decription */}
{/* Description */}
<Card.Description>{card.description}</Card.Description>
</Card.Content>

Expand All @@ -108,21 +106,12 @@ const CardTemplate = ({ variant, inverted, titleOnImage, card }) => (
);

const CardImage = (card) => (
<div className="image-with-title">
<Image
as="a"
href={card.href}
src={card.imgUrl}
wrapped
ui={false}
alt="card image"
/>
<a href={card.href} className={'image'}>
<Image src={card.imgUrl} ui={false} alt="card image" />
<div className="gradient">
<Card.Header>
<a href={card.href}>{card.title}</a>
</Card.Header>
<Card.Header>{card.title}</Card.Header>
</div>
</div>
</a>
);

const MetaRight = (args) => (
Expand Down Expand Up @@ -213,7 +202,7 @@ CardGrid.args = {
fluid: true,
},
{
title: 'State of Europe\'s environment',
title: "State of Europe's environment",
description:
'Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis.Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis.',
hasImage: false,
Expand Down Expand Up @@ -272,7 +261,7 @@ FluidGrid.args = {
fluid: true,
},
{
title: 'State of Europe\'s environment',
title: "State of Europe's environment",
description:
'Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis.Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis.',
hasImage: false,
Expand Down Expand Up @@ -323,7 +312,6 @@ function CarouselCardsContent({
inverted,
settings,
cards,
...rest
}) {
const slider = React.useRef(null);
return (
Expand Down Expand Up @@ -382,7 +370,7 @@ CarouselCards.args = {
},
cards: [
{
title: 'State of Europe\'s environment',
title: "State of Europe's environment",
meta: 'March 20, 2022.',
imgUrl:
'https://www.eea.europa.eu/media/pictures/european-environment-agency-building-with/image_large',
Expand Down
20 changes: 8 additions & 12 deletions theme/themes/eea/views/card.overrides
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
}

.ui.cards > .card:not(.rounded) > .image,
.ui.card:not(.rounded) > .image,
.ui.card .image-with-title .image {
.ui.card:not(.rounded) > .image {
overflow: @cardImageOverflow;
height: @cardImageHeight;

Expand Down Expand Up @@ -256,18 +255,14 @@
Image with title
*******************************/
// Adding the default image css for image inside image-with-title
.ui.cards > .card > .image, .ui.card .image-with-title > .image {
.ui.cards > .card > .image {
position: relative;
display: block;
flex: 0 0 auto;
padding: 0em;
padding: 0;
background: transparent;
}

.image-with-title {
position: relative;
}

// Gradient Mixin
.gradientMix(@type; @colors; @dir: 0deg; @prefixes: webkit, moz, ms, o; @index: length(@prefixes)) when (@index > 0) {
.gradientMix(@type; @colors; @dir; @prefixes; (@index - 1));
Expand All @@ -281,7 +276,7 @@
}
}

.image-with-title .gradient {
.card .gradient {
display: flex;
align-items: end;
position: absolute;
Expand All @@ -292,18 +287,19 @@
.gradientMix(linear; rgba(46, 62, 76, 0.65) 38.6%, rgba(46, 62, 76, 0.169) 59.52%, rgba(69, 95, 106, 0) 79.64%; 13.39deg);
}

.image-with-title .header a {
.gradient .header {
font-size: var(--image-header-font-size, @imageTitleFontSize);
color: @imageTitleColor;
font-weight: @imageTitleFontWeight;
line-height: @imageTitleLineHeight;
text-transform: @imageTitleTextTransform;
}

@media only screen and (min-width: @tabletBreakpoint) {
.image-with-title .gradient {
.card .gradient {
padding-block: @imageTitlePaddingBlock;
}
.image-with-title .header a {
.gradient .header {
--image-header-font-size: @font-size-7;
}
}
Expand Down
1 change: 1 addition & 0 deletions theme/themes/eea/views/card.variables
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@
@imageTitleLineHeight: @font-lineheight-0;
@imageTitlePadding: @rem-space-6;
@imageTitlePaddingBlock: @rem-space-2;
@imageTitleTextTransform: uppercase;

/*******************************
Rounded Card
Expand Down

0 comments on commit ff6cc60

Please sign in to comment.