Skip to content

Commit 7de7c9e

Browse files
author
Daniel Morse
committed
feat: add lang as a prop, update demo
1 parent 24b46da commit 7de7c9e

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,58 @@
1+
<bolt-text>
2+
For language-specific quotes, Blockquote inherits the value of the closest <code>lang</code> attribute. Override that value by setting the <code>lang</code> prop directly on the component.
3+
</bolt-text>
4+
15
{% include "@bolt-components-headline/headline.twig" with {
26
text: "English",
37
size: "xlarge",
48
tag: "h2"
59
} only %}
6-
7-
<div lang="en" class="u-bolt-margin-bottom-large">
810
{% include "@bolt-components-blockquote/blockquote.twig" with {
911
"author": {
1012
"name": "Michelangelo di Lodovico Buonarroti Simoni",
1113
"title": "Renaissance Artist"
1214
},
1315
"content": "<p>The greater danger for most of us lies not in setting our aim too high and falling short; but in setting our aim too low, and achieving our mark.</p>"
1416
} %}
15-
</div>
16-
1717

1818
{% include "@bolt-components-headline/headline.twig" with {
1919
text: "German",
2020
size: "xlarge",
2121
tag: "h2"
2222
} only %}
23-
24-
<div lang="de" class="u-bolt-margin-bottom-large">
2523
{% include "@bolt-components-blockquote/blockquote.twig" with {
2624
"author": {
2725
"name": "Michelangelo di Lodovico Buonarroti Simoni",
2826
"title": "Renaissance Artist"
2927
},
30-
"content": "<p>Echtzeit bedeutet Relevanz. Kunden erwarten von uns, dass wir jederzeit wissen, was sie gerade denken.</p>"
28+
"content": "<p>Echtzeit bedeutet Relevanz. Kunden erwarten von uns, dass wir jederzeit wissen, was sie gerade denken.</p>",
29+
"lang": "de"
3130
} %}
32-
</div>
33-
3431

3532
{% include "@bolt-components-headline/headline.twig" with {
3633
text: "French",
3734
size: "xlarge",
3835
tag: "h2"
3936
} only %}
40-
41-
<div lang="fr" class="u-bolt-margin-bottom-large">
4237
{% include "@bolt-components-blockquote/blockquote.twig" with {
4338
"author": {
4439
"name": "Michelangelo di Lodovico Buonarroti Simoni",
4540
"title": "Renaissance Artist"
4641
},
47-
"content": "<p>Davantage de temps réel, c'est plus de pertinence. Les clients s’attendent à ce que nous lisions dans leurs pensées, dans l’instant présent.</p>"
42+
"content": "<p>Davantage de temps réel, c'est plus de pertinence. Les clients s’attendent à ce que nous lisions dans leurs pensées, dans l’instant présent.</p>",
43+
"lang": "fr"
4844
} %}
49-
</div>
50-
5145

5246
{% include "@bolt-components-headline/headline.twig" with {
5347
text: "Japanese",
5448
size: "xlarge",
5549
tag: "h2"
5650
} only %}
57-
58-
<div lang="ja" class="u-bolt-margin-bottom-large">
5951
{% include "@bolt-components-blockquote/blockquote.twig" with {
6052
"author": {
6153
"name": "Michelangelo di Lodovico Buonarroti Simoni",
6254
"title": "Renaissance Artist"
6355
},
64-
"content": "<p>リアルタイムであればあるほど、関連性は高まります。顧客は自分たちが今何を考えているかこちらが把握することを期待しています。</p>"
56+
"content": "<p>リアルタイムであればあるほど、関連性は高まります。顧客は自分たちが今何を考えているかこちらが把握することを期待しています。</p>",
57+
"lang": "ja"
6558
} %}
66-
</div>

packages/components/bolt-blockquote/blockquote.schema.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ properties:
4545
description: Hide quotation marks.
4646
default: false
4747
type: boolean
48+
lang:
49+
description: Set language-specific quotation marks. By default, inherits the value of the closest `lang` attribute.
50+
type: string
4851
logo:
4952
description: Add a logo component.
5053
type: object

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class BoltBlockquote extends withLitHtml() {
2222
indent: props.boolean,
2323
fullBleed: props.boolean,
2424
noQuotes: props.boolean,
25+
lang: props.string,
2526
authorName: props.string,
2627
authorTitle: props.string,
2728
authorImage: props.string,
@@ -141,6 +142,7 @@ class BoltBlockquote extends withLitHtml() {
141142
indent,
142143
fullBleed,
143144
noQuotes,
145+
lang,
144146
authorName,
145147
authorTitle,
146148
authorImage,
@@ -159,9 +161,6 @@ class BoltBlockquote extends withLitHtml() {
159161
[`c-bolt-blockquote--no-quotes`]: noQuotes,
160162
});
161163

162-
// Get closest [lang] tag and add to blockquote element so that CSS selector will work inside shadow DOM
163-
const lang = this.closest('[lang]');
164-
165164
let footerItems = [];
166165
footerItems.push(AuthorImage(this), AuthorName(this), AuthorTitle(this));
167166

@@ -187,7 +186,13 @@ class BoltBlockquote extends withLitHtml() {
187186
<blockquote
188187
class="${classes}"
189188
lang="${ifDefined(
190-
lang ? lang.getAttribute('lang').toLowerCase() : undefined,
189+
lang
190+
? lang
191+
: this.closest('[lang]')
192+
? this.closest('[lang]')
193+
.getAttribute('lang')
194+
.toLowerCase()
195+
: undefined,
191196
)}"
192197
>
193198
${this.slots.logo

0 commit comments

Comments
 (0)