Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add circleimage / milestone card component #409

Merged
merged 5 commits into from
Aug 15, 2023
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
2 changes: 1 addition & 1 deletion dist/css/explorer-1.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/scss/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@import 'components/BaseImagePlaceholder';
@import 'components/BasePlaceholder';
@import 'components/BackToTop';
@import 'components/BlockCircleImageCard';
@import 'components/BlockImageCarousel';
@import 'components/BlockImageCarouselItem';
@import 'components/BlockImageGallery';
Expand Down
21 changes: 21 additions & 0 deletions src/scss/components/_BlockCircleImageCard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.BlockCircleImageCard {
--image-size: 90px;

display: flex;
align-items: center;
gap: calc(var(--image-size) / 2);

@screen lg {
--image-size: 130px;
}

.BaseImagePlaceholder {
width: var(--image-size);
height: var(--image-size);
margin: 0 calc(-1 * var(--image-size) / 2);
}

&.imageOnRight {
flex-direction: row-reverse;
}
}
7 changes: 7 additions & 0 deletions storybook/stories/_docs/overview_blocks.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,12 @@ Reserved for the top of the page. Learn more about our heroes on the [heroes ove
'Features an image with a text overlay, with a hover effect. Recommended for use with shorter text. `BlockLinkTile` is an item type option available in `BlockLinkCarousel`.',
storyId: 'components-blocks-blocklinktile--card',
},
{
heading: 'BlockCircleImageCard',
description:
'Features a circular image alongside text, with a drop shadow and no hover effects. The image can be positioned on the left or the right.',
storyId: 'components-blocks-blockcircleimagecard--card',
fullWidth: true,
},
]}
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { BaseImagePlaceholderTemplate } from '../BaseImagePlaceholder/BaseImagePlaceholder'
import { BaseHeadingTemplate } from '../BaseHeading/BaseHeading'

export const BlockCircleImageCardTemplate = ({
type = 'imageOnLeft',
imageOnRight = false,
title,
label,
secondaryLabel = '',
image,
customClass = '',
}) => {
return `
<div class="BlockCircleImageCard shadow-jpl ${
imageOnRight ? 'imageOnRight' : ''
} ${customClass}">
${BaseImagePlaceholderTemplate({
theme: 'transparent-theme',
src: image.src.url,
srcset: image.srcSet,
alt: image.alt,
width: image.src.width,
height: image.src.height,
objectFitClass: 'object-cover',
imageClass: 'rounded-full border-4 border-white',
wrapperClass: `h-full`,
})}
<div class="content relative px-8 py-8">
<div class="text-gray-dark text-subtitle mb-3">${label}</div>
${
secondaryLabel
? `<div class="text-gray-mid-dark text-subtitle">${secondaryLabel}</div>`
: ''
}
${BaseHeadingTemplate({
text: title,
size: 'h5',
tag: 'h3',
headingClass: 'mt-3',
})}
</div>
</div>
`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { BlockCircleImageCardTemplate } from './BlockCircleImageCard'

export default {
title: 'Components/Blocks/BlockCircleImageCard',
argTypes: {
imageOnRight: {
type: { name: 'boolean', required: false },
description: 'Determines position of the image',
table: {
defaultValue: { summary: 'false' },
},
},
title: {
type: { name: 'string', required: true },
description: 'Heading',
},
label: {
type: { name: 'string', required: true },
description: 'Subtitle',
},
secondaryLabel: {
type: { name: 'string', required: false },
description: 'Secondary subtitle',
},
image: {
type: { name: 'object', required: true },
description: 'Image object',
},
},
decorators: [
(Story) =>
`<div id="storyRoot" class="max-w-xl mx-auto container">${Story()}</div>`,
],
parameters: {
viewMode: 'docs',
docs: {
description: {
component:
'Features a circular image alongside text, with a drop shadow and no hover effects. The image can be positioned on the left or the right.',
},
},
html: {
root: '#storyRoot',
},
},
}

export const Card = BlockCircleImageCardTemplate.bind({})
Card.storyName = 'BlockCircleImageCard'
Card.args = {
imageOnRight: false,
title: 'First Flight of Technology for Returning Warheads from Space',
label: 'September 20, 1956',
secondaryLabel: 'Re-entry test vehicle program',
image: {
src: {
url: 'https://picsum.photos/130/130',
width: 130,
height: 130,
},
srcSet:
'https://picsum.photos/90/90 320w, https://picsum.photos/130/130 1024w',
alt: 'Alt text for image',
},
}