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

Convert blockquote to web component #984

Merged
merged 68 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
a1bb776
feat: add web component support to blockquote
Dec 7, 2018
f22aeeb
style: fix indentation on blockquote.schema.yml
Dec 7, 2018
0a4f9d9
feat: add support for content and author to blockquote web component
Dec 11, 2018
1afe6cc
style: stylelint fixes
Dec 11, 2018
d964a4d
Merge branch 'master' of https://github.com/bolt-design-system/bolt i…
Dec 17, 2018
20205b4
refactor: add validateProps to base class, add param for schema
Dec 17, 2018
93bad4b
feat: remove 'content' prop from blockquote web component, use valida…
Dec 18, 2018
ce16411
fix: remove unused 'content' prop in render
Dec 19, 2018
b2de101
refactor: move getComponentRootElement code block into helper function
Dec 19, 2018
07d60e5
Merge branch 'master' of https://github.com/bolt-design-system/bolt i…
Dec 19, 2018
74322ea
fix: add ajv to core package.json
Dec 19, 2018
ebbd229
chore: yarn lock
Dec 19, 2018
83729e3
style: fix import order
Dec 19, 2018
d1e940d
fix: remove unneeded rendered() method
Dec 19, 2018
95b49f9
refactor: remove set fullBleed/indent booleans to strings
Dec 19, 2018
28131f0
feat: pass validated size prop
Dec 19, 2018
dda8331
refactor: remove component_name variable, unneeded 'bolt-component' attr
Dec 19, 2018
2c7a789
Merge branch 'master' of https://github.com/bolt-design-system/bolt i…
Dec 27, 2018
07469db
Merge branch 'master' of https://github.com/bolt-design-system/bolt i…
Dec 31, 2018
5eb8a29
feat: add 'shallow' argument to convertInitialTags
Dec 31, 2018
7a218d7
feat: add moveChildrenToRoot option to decorator
Jan 2, 2019
7f8f546
chore: remove sample usage in blockquote SCSS
Jan 2, 2019
b82338b
feat: add slotted styles, remove attribute selectors
Jan 2, 2019
4e65ced
refactor: update blockquote to use latest base class component conven…
Jan 2, 2019
8603947
feat: import missing styles needed for twig templates
Jan 2, 2019
149695f
feat: add missing features to web component implementation of blockquote
Jan 2, 2019
4b35687
docs: add code examples for testing blockquote
Jan 2, 2019
48eac5e
merge master into 'feature/convert-blockquote-to-web-component'
Jan 2, 2019
d4ce9e2
docs: add docs for web component version of blockquote
Jan 2, 2019
e2abc17
style: eslint fix
Jan 2, 2019
7e4e788
feat: temporarily set lazyload to false, does not work yet in shadow dom
Jan 3, 2019
bb4ef00
chore: remove sample usage in blockquote twig file
Jan 3, 2019
a9b2bbe
feat: do not set unnecessary props on twig generated blockquotes
Jan 3, 2019
2fa709f
Merge branch 'master' of https://github.com/bolt-design-system/bolt i…
Jan 3, 2019
32f9162
docs: change attribute in web component demo
Jan 4, 2019
9834f53
refactor: roll back variable prefix pattern, refactor border options
Jan 4, 2019
e1bd40b
Merge branch 'master' of https://github.com/bolt-design-system/bolt i…
Jan 4, 2019
e352a3d
feat: add merge_attributes() function to TwigFunctions, make availabl…
Jan 8, 2019
84b1371
fix: border classname on blockquote
Jan 8, 2019
8455c07
fix: pass correct variable in alignment validation
Jan 8, 2019
94089c1
refactor: reference size options directly in schema
Jan 8, 2019
09e9f40
refactor: add missing twig conventions shown in wiki, add new pattern…
Jan 8, 2019
38732cf
Merge branch 'master' of https://github.com/bolt-design-system/bolt i…
Jan 8, 2019
cdb8528
refactor: include basic slot support in the existing image, logo, and…
sghoweri Jan 10, 2019
a1b645e
refactor: update slotted selectors to work with first/last-child + cl…
sghoweri Jan 10, 2019
27fc1a2
fix: tweak the slotted logo styles to work as expected inside a slot
sghoweri Jan 10, 2019
43f77e9
refactor: updating and cleaning up blockquote rendering to take bette…
sghoweri Jan 10, 2019
784df6f
chore: adjust scope of child selectors + fix height difference of ima…
sghoweri Jan 11, 2019
8a47235
fix: revert commenting out author footer while testing
sghoweri Jan 11, 2019
d942886
fix: proactively load the text component's JS to speed up initial ren…
sghoweri Jan 11, 2019
ac9521a
chore: automatically remove min-height 100vh style when compiling Pat…
sghoweri Jan 11, 2019
b94a4c1
refactor: update text component to support <cite> tags; update author…
sghoweri Jan 11, 2019
5d3fc3a
chore: update package.json to include <bolt-text> and image as a depe…
sghoweri Jan 11, 2019
cf0a027
refactor: make blockquote logo conditional
sghoweri Jan 11, 2019
60fa53c
refactor: break out the blockquote's author into more standalone sub-…
sghoweri Jan 11, 2019
10f1ec7
feat: automatically re-render + re-evaluate slots and classes added w…
sghoweri Jan 11, 2019
04d37ee
chore: re-arrange Sass to fix linting issue
sghoweri Jan 11, 2019
db45071
Merge pull request #1031 from bolt-design-system/feature/blockquote-w…
danielamorse Jan 11, 2019
8bddb16
fix: stylelint
Jan 11, 2019
e52d9c6
fix: move margin to blockquote image, not every footer item
Jan 11, 2019
5678159
docs: update web component demo page, add section for additional attr…
Jan 11, 2019
a0051dd
feature: move placement of twig "blocks" in blockquote template
Jan 14, 2019
089cd05
feat: remove twig blocks completely
Jan 14, 2019
d42d642
style: fix indentation
Jan 15, 2019
3817443
fix: Add 'spaceless' around typography template, otherwise outputs ex…
Jan 15, 2019
8c2de4f
feat: add support for quotes with and without <p>
Jan 15, 2019
c104d85
docs: update schema to note <p> tag support
Jan 15, 2019
eeb81b3
docs: add testing steps for blockquote
Jan 15, 2019
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{% macro code_example(code, copy) %}
<bolt-code-snippet syntax="dark" lang="html" {{ copy ? 'copy-to-clipboard' : '' }}>{% spaceless %}
{{ code | replace({
'<': '&lt;',
'>': '&gt;',
}) | trim | raw }}
{% endspaceless %}</bolt-code-snippet>
{% endmacro %}

{% import _self as blockquote_demo %}

{% set blockquote_demo_simple %}
<bolt-blockquote author-name="Michelangelo di Lodovico Buonarroti Simoni" author-title="Renaissance Artist" author-image="/images/placeholders/500x500.jpg">
<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>
</bolt-blockquote>
{% endset %}

{% set blockquote_demo_attributes %}
<bolt-blockquote align-items="center" border="horizontal" author-name="Michelangelo di Lodovico Buonarroti Simoni" author-title="Renaissance Artist" author-image="/images/placeholders/500x500.jpg">
<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>
</bolt-blockquote>
{% endset %}

{% set blockquote_demo_logo %}
<bolt-blockquote author-name="Michelangelo di Lodovico Buonarroti Simoni" author-title="Renaissance Artist" author-image="/images/placeholders/500x500.jpg">
<img slot="logo" src="/images/content/logos/logo-paypal.svg" alt="PayPal Logo">
<p>The greater danger for most of us lies not in setting our aim too high and falling short...</p>
<p>In fact, the greater danger is setting our aim too low and achieving our mark.</p>
</bolt-blockquote>
{% endset %}

<div class="o-bolt-wrapper">
<bolt-text headline>
Web Component Usage
</bolt-text>
<bolt-text>
Bolt Link is a web component that renders a semantic blockquote with Bolt styles. For a simple blockquote, wrap your quote content in the <bolt-code-snippet display="inline" lang="html">&lt;bolt-blockquote&gt;</bolt-code-snippet> custom element. Note: you must wrap your quote text in <bolt-code-snippet display="inline" lang="html">&lt;p&gt;</bolt-code-snippet> tags for the appropriate quotation marks to appear. Add attribution to the quote by adding the <bolt-code-snippet display="inline" lang="html">author-name</bolt-code-snippet>, <bolt-code-snippet display="inline" lang="html">author-title</bolt-code-snippet>, and <bolt-code-snippet display="inline" lang="html">author-image</bolt-code-snippet> attributes to <bolt-code-snippet display="inline" lang="html">&lt;bolt-blockquote&gt;</bolt-code-snippet>.
</bolt-text>
<div class="t-bolt-light u-bolt-margin-bottom-small u-bolt-padding-medium">
{% grid "o-bolt-grid--flex o-bolt-grid--matrix o-bolt-grid--center" %}
{% cell "u-bolt-width-12/12" %}
{{ blockquote_demo_simple }}
{% endcell %}
{% endgrid %}
</div>
<div class="u-bolt-margin-bottom-large">
{% include blockquote_demo.code_example(blockquote_demo_simple, true) %}
</div>
</div>

<div class="o-bolt-wrapper">
<bolt-text headline>
Additional Options
</bolt-text>
<bolt-text>
Apply additional configuration options via attributes on the <bolt-code-snippet display="inline" lang="html">&lt;bolt-blockquote&gt;</bolt-code-snippet> element. Attribute names and values match the Twig schema but use "kebab-case" instead of "camelCase". For example, <bolt-code-snippet display="inline" lang="html">alignItems</bolt-code-snippet> becomes <bolt-code-snippet display="inline" lang="html">align-items</bolt-code-snippet>.
</bolt-text>
<div class="t-bolt-light u-bolt-margin-bottom-small u-bolt-padding-medium">
{% grid "o-bolt-grid--flex o-bolt-grid--matrix o-bolt-grid--center" %}
{% cell "u-bolt-width-12/12" %}
{{ blockquote_demo_attributes }}
{% endcell %}
{% endgrid %}
</div>
<div class="u-bolt-margin-bottom-large">
{% include blockquote_demo.code_example(blockquote_demo_attributes, true) %}
</div>
</div>

<div class="o-bolt-wrapper">
<bolt-text headline>
Advanced Usage
</bolt-text>
<bolt-text>
To add a logo to <bolt-code-snippet display="inline" lang="html">&lt;bolt-blockquote&gt;</bolt-code-snippet> place logo content (for example: <bolt-code-snippet display="inline" lang="html">&lt;bolt-logo&gt;</bolt-code-snippet> or <bolt-code-snippet display="inline" lang="html">&lt;img&gt;</bolt-code-snippet>) next to blockquote text, and add the attribute <bolt-code-snippet display="inline" lang="html">slot="logo"</bolt-code-snippet> to the logo's outermost container.
</bolt-text>
<div class="t-bolt-light u-bolt-margin-bottom-small u-bolt-padding-medium">
{% grid "o-bolt-grid--flex o-bolt-grid--matrix o-bolt-grid--center" %}
{% cell "u-bolt-width-12/12" %}
{{ blockquote_demo_logo }}
{% endcell %}
{% endgrid %}
</div>
<div class="u-bolt-margin-bottom-large">
{% include blockquote_demo.code_example(blockquote_demo_logo, true) %}
</div>
</div>
5 changes: 2 additions & 3 deletions docs-site/src/templates/_site-head.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{% set cacheBuster = bolt.data.config.prod ? "?v=" ~ bolt.data.fullManifest.version : "" %}

<!DOCTYPE html>
<html lang="en-US" class="{{ bolt.data.config.prod ? '' : 'js-fonts-loaded' }}">
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width" />
Expand Down Expand Up @@ -83,5 +83,4 @@
{% endif %} #}

</head>
<body class="c-bolt-site c-bds-layout {% if currentUrl == 'index.html' %} t-bolt-xdark {% endif %} c-bds-layout--{{ urlChunks | length >= 2 ? urlChunks|first : 'parent' }} {{ hasSidebar ? 'c-bds-layout--has-sidebar' : ''}}">

<body class="c-bolt-site c-bds-layout {% if currentUrl == 'index.html' %} t-bolt-xdark {% endif %} c-bds-layout--{{ urlChunks | length >= 2 ? urlChunks|first : 'parent' }} {{ hasSidebar ? 'c-bds-layout--has-sidebar' : ''}} {{ patternLabFoot ? 'u-bolt-min-height-none' : '' }}">
34 changes: 34 additions & 0 deletions packages/components/bolt-blockquote/TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Testing Steps

## Simple Use Case

As a user, I view a simple Blockquote. [View example &raquo;](https://feature-convert-blockquote-to-web-component.boltdesignsystem.com/pattern-lab/patterns/02-components-blockquote-05-blockquote/02-components-blockquote-05-blockquote.html)

### Quotation

I verify that:

- The blockquote contains a quotation.
- The quotation has opening and closing quotation marks.
- If the quotation contains more than one paragraph, the closing quotation mark comes only at the end of the second paragraph.

### Author information

Blockquotes may include the author's photo, name, and title after the quotation.

If there is information about the author, I verify that:

- The author's photo (optional) is below the quotation, after a small space.
- The author's name and/or title is smaller in size than the quotation.
- The author's name is bold and the author's title is normal font weight.

### Decoration

Blockquotes may have decorative borders.

If there is a decorative border, I verify that:

- The border color is green.
- The border appears to the left of the quotation content.
- The border spans from the top of the quotation to the last piece of author information.
- There is a small space between the border and the quotation and author content.
33 changes: 16 additions & 17 deletions packages/components/bolt-blockquote/blockquote.schema.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
$schema: http://json-schema.org/draft-04/schema#
title: Blockquote
type: object
required:
Expand All @@ -8,7 +7,7 @@ properties:
type: object
description: A Drupal-style attributes object with extra attributes to append to this component.
content:
description: Text to appear in blockquote.
description: Text to appear in blockquote (Twig only). May be plain text or text wrapped in <p> tags.
type: string
size:
description: Text size.
Expand Down Expand Up @@ -43,19 +42,19 @@ properties:
default: false
type: boolean
logo:
description: Add a logo component.
type: object
ref: '@bolt-components-logo/logo.schema.yml'
description: Add a logo component.
type: object
ref: '@bolt-components-logo/logo.schema.yml'
author:
description: Author of the quote.
type: object
properties:
name:
type: string
description: Author's name.
title:
type: string
description: Author's title.
image:
type: object
ref: '@bolt-components-image/image.schema.yml'
description: Author of the quote.
type: object
properties:
name:
type: string
description: Author's name.
title:
type: string
description: Author's title.
image:
type: object
ref: '@bolt-components-image/image.schema.yml'
5 changes: 5 additions & 0 deletions packages/components/bolt-blockquote/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { polyfillLoader } from '@bolt/core/polyfills';

polyfillLoader.then(res => {
import(/* webpackMode: 'eager', webpackChunkName: 'bolt-blockquote' */ './src/blockquote');
});
1 change: 1 addition & 0 deletions packages/components/bolt-blockquote/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'src/blockquote.scss';
8 changes: 6 additions & 2 deletions packages/components/bolt-blockquote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@
"license": "MIT",
"repository": "https://github.com/bolt-design-system/bolt/tree/master/packages/components/bolt-blockquote",
"bugs": "https://github.com/bolt-design-system/bolt/issues",
"style": "src/blockquote.scss",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@bolt/core": "^2.3.0-rc.0"
"@bolt/core": "^2.3.0-rc.0",
"@bolt/components-text": "^2.3.0-rc.0",
"@bolt/components-image": "^2.3.0-rc.0"
},
"style": "index.scss",
"main": "index.js",
"twig": "src/blockquote.twig",
"schema": "blockquote.schema.yml",
"gitHead": "b47538629e315eeecbdfcb8d0c22e787b3bcc089"
}
28 changes: 28 additions & 0 deletions packages/components/bolt-blockquote/src/Author/AuthorImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { html } from '@bolt/core/renderers/renderer-lit-html';
import { ifDefined } from 'lit-html/directives/if-defined';
import classNames from 'classnames/bind';
import styles from '../blockquote.scss';

const cx = classNames.bind(styles);

export const AuthorImage = elem => {
const { props, slots } = elem;
if (slots['author-image'] || props.authorImage) {
return html`
<div class="${cx('c-bolt-blockquote__image')}">
${
slots['author-image']
? html`
${elem.slot('author-image')}
`
: html`
<img
src="${props.authorImage}"
alt=${ifDefined(props.authorTitle)}
/>
`
}
</div>
`;
}
};
21 changes: 21 additions & 0 deletions packages/components/bolt-blockquote/src/Author/AuthorName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { html } from '@bolt/core/renderers/renderer-lit-html';

export const AuthorName = elem => {
const { props, slots } = elem;
if (slots['author-name'] || props.authorName) {
return html`
<bolt-text
tag="cite"
font-size="xsmall"
color="theme-headline"
font-weight="bold"
>
${
elem.slots['author-name']
? elem.slot('author-name')
: props.authorName
}
</bolt-text>
`;
}
};
16 changes: 16 additions & 0 deletions packages/components/bolt-blockquote/src/Author/AuthorTitle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { html } from '@bolt/core/renderers/renderer-lit-html';

export const AuthorTitle = elem => {
const { props, slots } = elem;
if (slots['author-title'] || props.authorTitle) {
return html`
<bolt-text tag="cite" font-size="xsmall" color="theme-headline">
${
elem.slots['author-title']
? elem.slot('author-title')
: props.authorTitle
}
</bolt-text>
`;
}
};
3 changes: 3 additions & 0 deletions packages/components/bolt-blockquote/src/Author/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { AuthorImage } from './AuthorImage';
export { AuthorName } from './AuthorName';
export { AuthorTitle } from './AuthorTitle';
Loading