Skip to content

Commit

Permalink
feat(@dpc-sdp/ripple-ui-core): add a "stacked" version of the cta card
Browse files Browse the repository at this point in the history
  • Loading branch information
David Featherston committed Mar 18, 2024
1 parent 1131019 commit dbb48c5
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
getBody,
getField,
getImageFromField,
getLinkFromField
} from '@dpc-sdp/ripple-tide-api'
Expand All @@ -25,16 +26,19 @@ export const callToActionMapping = (
)

const link = getLinkFromField(field, 'field_paragraph_cta')
const style = getField(field, 'field_paragraph_cta_style')

return {
component: 'TideLandingPageCallToAction',
id: field.drupal_internal__id,
layout: style === 'card' ? 'card' : undefined,
props: {
title: field.field_paragraph_title,
image: image,
url: link?.url,
ctaText: link?.text,
summary: getBody(field.field_paragraph_body?.processed)
summary: getBody(field.field_paragraph_body?.processed),
stacked: style === 'card'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@storybook/addon-docs'
import RplCallToAction from './RplCallToActionCard.vue'
import { a11yStoryCheck } from './../../../stories/interactions.js'
import { bpMin } from '../../lib/breakpoints'

export const SingleTemplate = (args) => ({
components: { RplCallToAction },
Expand Down Expand Up @@ -35,6 +36,12 @@ export const SingleTemplate = (args) => ({
<Meta
title='Core/Navigation/Card'
component={RplCallToAction}
parameters={{
layout: 'fullscreen',
chromatic: {
viewports: [bpMin.s, bpMin.l]
}
}}
argTypes={{
number: {
control: { type: 'select' },
Expand Down Expand Up @@ -84,3 +91,15 @@ export const SingleTemplate = (args) => ({
{SingleTemplate.bind()}
</Story>
</Canvas>

<Canvas>
<Story
name='Call to action - Stacked'
play={a11yStoryCheck}
args={{
stacked: true
}}
>
{SingleTemplate.bind()}
</Story>
</Canvas>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
useRippleEvent,
rplEventPayload
} from '../../composables/useRippleEvent'
import { computed } from 'vue'
interface Props {
el?: (typeof RplCardElements)[number]
Expand All @@ -18,14 +19,16 @@ interface Props {
url?: string
ctaText?: string
variant?: (typeof RplButtonVariants)[number]
stacked?: boolean
}
const props = withDefaults(defineProps<Props>(), {
el: 'div',
image: undefined,
url: undefined,
variant: 'filled',
ctaText: 'Call to action'
ctaText: 'Call to action',
stacked: false
})
const emit = defineEmits<{
Expand All @@ -49,13 +52,18 @@ const handleClick = () => {
{ global: true }
)
}
const classes = computed(() => ({
'rpl-card--inset': true,
'rpl-card--call-to-action-stacked': props.stacked
}))
</script>

<template>
<RplCard
ref="container"
type="call-to-action"
class="rpl-card--inset"
:class="classes"
:link="url"
:el="el"
>
Expand Down
20 changes: 20 additions & 0 deletions packages/ripple-ui-core/src/components/card/RplCard.css
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,26 @@
}
}

&--call-to-action-stacked {
@media (--rpl-bp-l) {
align-items: initial;
flex-direction: column;

.rpl-card__upper {
flex-basis: auto;
}

.rpl-card__media--inset {
margin-bottom: 0;
height: calc(100% - var(--rpl-sp-8));
}

.rpl-card__upper + .rpl-card__body {
margin-left: var(--rpl-sp-8);
}
}
}

&--category-grid {
background-color: transparent;
border-radius: 0;
Expand Down

0 comments on commit dbb48c5

Please sign in to comment.