Skip to content

Commit 90dc9c5

Browse files
author
Daniel Morse
committed
fix: replace bolt-text and skip mutation observer to fix IE bug
1 parent d373d79 commit 90dc9c5

File tree

3 files changed

+108
-19
lines changed

3 files changed

+108
-19
lines changed
Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
import { html } from '@bolt/core/renderers/renderer-lit-html';
2+
import classNames from 'classnames/bind';
3+
import styles from '../blockquote.scss';
4+
import textStyles from '@bolt/components-text/index.scss';
5+
6+
let cx = classNames.bind([styles, textStyles]);
27

38
export const AuthorName = elem => {
49
const { props, slots } = elem;
10+
11+
const textClasses = cx(
12+
'c-bolt-text-v2',
13+
'c-bolt-text-v2--block',
14+
'c-bolt-text-v2--body',
15+
'c-bolt-text-v2--font-size-xsmall',
16+
'c-bolt-text-v2--font-weight-bold',
17+
'c-bolt-text-v2--font-style-regular',
18+
'c-bolt-text-v2--color-theme-headline',
19+
'c-bolt-text-v2--letter-spacing-regular',
20+
'c-bolt-text-v2--align-inherit',
21+
'c-bolt-text-v2--text-transform-regular',
22+
'c-bolt-text-v2--line-height-regular',
23+
'c-bolt-text-v2--opacity-100',
24+
);
25+
526
if (slots['author-name'] || props.authorName) {
627
return html`
7-
<bolt-text
8-
tag="cite"
9-
font-size="xsmall"
10-
color="theme-headline"
11-
font-weight="bold"
12-
>
28+
<cite class="${textClasses}">
1329
${elem.slots['author-name']
1430
? elem.slot('author-name')
1531
: props.authorName}
16-
</bolt-text>
32+
</cite>
1733
`;
1834
}
1935
};
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
import { html } from '@bolt/core/renderers/renderer-lit-html';
2+
import classNames from 'classnames/bind';
3+
import styles from '../blockquote.scss';
4+
import textStyles from '@bolt/components-text/index.scss';
5+
6+
let cx = classNames.bind([styles, textStyles]);
27

38
export const AuthorTitle = elem => {
49
const { props, slots } = elem;
10+
11+
const textClasses = cx(
12+
'c-bolt-text-v2',
13+
'c-bolt-text-v2--block',
14+
'c-bolt-text-v2--body',
15+
'c-bolt-text-v2--font-size-xsmall',
16+
'c-bolt-text-v2--font-weight-regular',
17+
'c-bolt-text-v2--font-style-regular',
18+
'c-bolt-text-v2--color-theme-headline',
19+
'c-bolt-text-v2--letter-spacing-regular',
20+
'c-bolt-text-v2--align-inherit',
21+
'c-bolt-text-v2--text-transform-regular',
22+
'c-bolt-text-v2--line-height-regular',
23+
'c-bolt-text-v2--opacity-100',
24+
);
25+
526
if (slots['author-title'] || props.authorTitle) {
627
return html`
7-
<bolt-text tag="cite" font-size="xsmall" color="theme-headline">
28+
<cite class="${textClasses}">
829
${elem.slots['author-title']
930
? elem.slot('author-title')
1031
: props.authorTitle}
11-
</bolt-text>
32+
</cite>
1233
`;
1334
}
1435
};

packages/components/bolt-blockquote/src/blockquote.js

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { withLitHtml, html } from '@bolt/core/renderers/renderer-lit-html';
44
import { convertInitialTags } from '@bolt/core/decorators';
55
import classNames from 'classnames/bind';
66
import styles from './blockquote.scss';
7+
import textStyles from '@bolt/components-text/index.scss';
78
import schema from '../blockquote.schema.yml';
89
import { AuthorImage, AuthorName, AuthorTitle } from './Author';
910

10-
let cx = classNames.bind(styles);
11+
let cx = classNames.bind([styles, textStyles]);
1112

1213
@define
1314
@convertInitialTags('blockquote') // The first matching tag will have its attributes converted to component props
@@ -37,7 +38,10 @@ class BoltBlockquote extends withLitHtml() {
3738
super.rendered && super.rendered();
3839
const self = this;
3940

40-
if (window.MutationObserver) {
41+
// @todo: I've added this.useShadow here to exclude IE.
42+
// In IE-only this mutation callback causes multiple re-renders
43+
// and causes component to disappear.
44+
if (window.MutationObserver && this.useShadow) {
4145
// Re-generate slots + re-render when mutations are observed
4246
const mutationCallback = function(mutationsList, observer) {
4347
self.slots = self._checkSlots();
@@ -164,8 +168,23 @@ class BoltBlockquote extends withLitHtml() {
164168

165169
this.addClassesToSlottedChildren();
166170

171+
const textClasses = cx(
172+
'c-bolt-text-v2',
173+
'c-bolt-text-v2--block',
174+
'c-bolt-text-v2--body',
175+
'c-bolt-text-v2--font-size-xlarge',
176+
'c-bolt-text-v2--font-weight-semibold',
177+
'c-bolt-text-v2--font-style-regular',
178+
'c-bolt-text-v2--color-theme-headline',
179+
'c-bolt-text-v2--letter-spacing-regular',
180+
'c-bolt-text-v2--align-inherit',
181+
'c-bolt-text-v2--text-transform-regular',
182+
'c-bolt-text-v2--line-height-regular',
183+
'c-bolt-text-v2--opacity-100',
184+
);
185+
167186
return html`
168-
${this.addStyles([styles])}
187+
${this.addStyles([styles, textStyles])}
169188
<blockquote class="${classes}" is="shadow-root">
170189
${this.slots.logo
171190
? html`
@@ -175,14 +194,9 @@ class BoltBlockquote extends withLitHtml() {
175194
`
176195
: ''}
177196
<div class="${cx('c-bolt-blockquote__quote')}">
178-
<bolt-text
179-
tag="div"
180-
font-size="${size}"
181-
font-weight="semibold"
182-
color="theme-headline"
183-
>
197+
<div class="${textClasses}">
184198
${this.slot('default')}
185-
</bolt-text>
199+
</div>
186200
</div>
187201
${footerItems.length > 0
188202
? html`
@@ -203,3 +217,41 @@ class BoltBlockquote extends withLitHtml() {
203217
}
204218

205219
export { BoltBlockquote };
220+
221+
// @todo: Original return statement - backing this out until `bolt-text` is ready for release
222+
// return html`
223+
// ${this.addStyles([styles])}
224+
// <blockquote class="${classes}" is="shadow-root">
225+
// ${this.slots.logo
226+
// ? html`
227+
// <div class="${cx('c-bolt-blockquote__logo')}">
228+
// ${this.slot('logo')}
229+
// </div>
230+
// `
231+
// : ''}
232+
// <div class="${cx('c-bolt-blockquote__quote')}">
233+
// <bolt-text
234+
// tag="div"
235+
// font-size="${size}"
236+
// font-weight="semibold"
237+
// color="theme-headline"
238+
// >
239+
// ${this.slot('default')}
240+
// </bolt-text>
241+
// </div>
242+
// ${footerItems.length > 0
243+
// ? html`
244+
// <footer class="${cx('c-bolt-blockquote__footer')}">
245+
// ${footerItems.map(
246+
// footerItem => html`
247+
// <div class="${cx('c-bolt-blockquote__footer-item')}">
248+
// ${footerItem}
249+
// </div>
250+
// `,
251+
// )}
252+
// </footer>
253+
// `
254+
// : ''}
255+
// </blockquote>
256+
// `;
257+
// }

0 commit comments

Comments
 (0)