Skip to content

Commit 927305d

Browse files
authored
fix(callout-quote): card appearance not correct in mobile (#12294)
### Related Ticket(s) https://jsw.ibm.com/browse/ADCMS-9014 ### Description Card appearance for the callout-quote in mobile was not correct with Figma specs. Source and Footer should be inside of the cards
1 parent 5eed2f0 commit 927305d

3 files changed

Lines changed: 66 additions & 4 deletions

File tree

packages/styles/scss/components/callout-quote/_callout-quote.scss

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2024
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -109,4 +109,48 @@
109109
margin: $spacing-05;
110110
}
111111
}
112+
113+
:host(#{$c4d-prefix}-callout-quote[appearance='card']) {
114+
@include breakpoint-down(md) {
115+
padding-block-end: 0;
116+
117+
div.cds--quote__source {
118+
margin-block: 1rem -1rem;
119+
margin-inline-start: -2rem;
120+
}
121+
122+
div.cds--quote__footer {
123+
margin-inline-start: -2rem;
124+
125+
/* stylelint-disable-next-line */
126+
> c4d-hr {
127+
/* stylelint-disable-next-line */
128+
margin-right: -0.1rem;
129+
margin-inline-end: 2rem;
130+
}
131+
}
132+
133+
.cds--quote__wrapper > blockquote > .cds--quote__source,
134+
.cds--quote__wrapper > blockquote > .cds--quote__footer {
135+
display: block;
136+
}
137+
138+
.cds--quote__wrapper .cds--quote__source,
139+
.cds--quote__wrapper .cds--quote__footer {
140+
display: none;
141+
}
142+
}
143+
144+
@include breakpoint-up(md) {
145+
.cds--quote__wrapper > blockquote > .cds--quote__source,
146+
.cds--quote__wrapper > blockquote > .cds--quote__footer {
147+
display: none;
148+
}
149+
150+
.cds--quote__wrapper .cds--quote__source,
151+
.cds--quote__wrapper .cds--quote__footer {
152+
display: block;
153+
}
154+
}
155+
}
112156
}

packages/web-components/src/components/callout-quote/__stories__/callout-quote.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default {
9999
quoteTypes['double-curved']
100100
),
101101
appearance: select(
102-
'Appearance (Default - legacy | card and bubble-quote are mobile only):',
102+
'Appearance (card and bubble-quote - MOBILE ONLY | Default - legacy):',
103103
appearance,
104104
appearance['legacy']
105105
),

packages/web-components/src/components/quote/quote.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@
77
* LICENSE file in the root directory of this source tree.
88
*/
99
import { LitElement, html } from 'lit';
10-
import { property } from 'lit/decorators.js';
10+
import { property, state } from 'lit/decorators.js';
1111
import settings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js';
1212
import styles from './quote.scss';
1313
import StableSelectorMixin from '../../globals/mixins/stable-selector';
1414
import { APPEARANCE, QUOTE_TYPES } from './defs';
1515
import '../horizontal-rule/horizontal-rule';
1616
import { carbonElement as customElement } from '@carbon/web-components/es/globals/decorators/carbon-element.js';
1717
import LocaleAPI from '@carbon/ibmdotcom-services/es/services/Locale/Locale.js';
18+
import HostListenerMixin from '@carbon/web-components/es/globals/mixins/host-listener.js';
19+
import MediaQueryMixin, {
20+
MQBreakpoints,
21+
MQDirs,
22+
} from '../../component-mixins/media-query/media-query';
1823

1924
export { QUOTE_TYPES };
2025

@@ -50,7 +55,10 @@ const slotExistencePropertyNames = {
5055
* @csspart bubble-pointer-stroke-svg - The stroke color of the pointer. Usage `c4d-quote::part(bubble-pointer-stroke-svg)`
5156
*/
5257
@customElement(`${c4dPrefix}-quote`)
53-
class C4DQuote extends StableSelectorMixin(LitElement) {
58+
class C4DQuote extends MediaQueryMixin(
59+
HostListenerMixin(StableSelectorMixin(LitElement)),
60+
{ [MQBreakpoints.MD]: MQDirs.MIN }
61+
) {
5462
/**
5563
* Defines rendered quote mark style
5664
* styles:
@@ -91,6 +99,9 @@ class C4DQuote extends StableSelectorMixin(LitElement) {
9199
*/
92100
protected _hasFooter = false;
93101

102+
@state()
103+
_isMobile = !this.carbonBreakpoints.md.matches;
104+
94105
/**
95106
* Handles `slotchange` event.
96107
*/
@@ -102,6 +113,10 @@ class C4DQuote extends StableSelectorMixin(LitElement) {
102113
});
103114
}
104115

116+
mediaQueryCallbackMD() {
117+
this._isMobile = !this.carbonBreakpoints.md.matches;
118+
}
119+
105120
protected _handleSlotChange({ target }: Event) {
106121
const { name } = target as HTMLSlotElement;
107122
const hasContent = (target as HTMLSlotElement)
@@ -268,6 +283,9 @@ class C4DQuote extends StableSelectorMixin(LitElement) {
268283
part="mark mark--closing">
269284
${marks.close}
270285
</span>
286+
${this._isMobile && this.appearance == 'card'
287+
? html` ${this._renderSource()} ${this._renderFooter()} `
288+
: ''}
271289
</blockquote>
272290
`;
273291
}

0 commit comments

Comments
 (0)