Skip to content

Commit cb9556d

Browse files
docs: update installation / get started (#2561)
* docs: adding renderInstallation, updating get-started * docs: updating pfe-tools with install template * docs: updating gists to 2.3.2 * docs: triple backtick on new line * docs: generating quick start importmap * docs: moving create import map into plugin, adding to quick start and get started * docs: createImportMap adding content to return value for templating * Update tools/pfe-tools/11ty/templates/install.njk Co-authored-by: Benny Powers <[email protected]> * Update docs/quick-start.md Co-authored-by: Benny Powers <[email protected]> * Update docs/get-started.md Co-authored-by: Benny Powers <[email protected]> * Update tools/pfe-tools/11ty/templates/install.njk Co-authored-by: Benny Powers <[email protected]> * docs: expand details on jspm / npm, add warning message about using both --------- Co-authored-by: Benny Powers <[email protected]>
1 parent 69021bb commit cb9556d

File tree

28 files changed

+112
-61
lines changed

28 files changed

+112
-61
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = function(eleventyConfig) {
2+
eleventyConfig.addPairedAsyncShortcode('generateImportMap', async content => {
3+
const { Generator } = await import('@jspm/generator');
4+
5+
const generator = new Generator({
6+
defaultProvider: 'jspm',
7+
env: ['production', 'browser', 'module']
8+
});
9+
10+
const pins = await generator.addMappings(content);
11+
12+
const html = await generator.htmlInject(content, { pins, esModuleShims: true, whitespace: true });
13+
14+
return html;
15+
});
16+
};
17+

docs/docs/develop/import-maps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tags:
1212
}
1313
</style>
1414

15-
{% band %}
15+
{% band header="" %}
1616

1717
Import maps provide a way for developers to use shorter and more descriptive module specifiers in their code, which can improve code readability and maintainability. Instead of having to remember and type out lengthy URLs for each module, developers can use simple and memorable module specifiers that map to the correct URLs in the import map. Developers can still use tools like bundlers and minifiers, but now they can ship bare modules specifiers to production, and map those specifiers to the original source or to minified bundles.
1818

docs/get-started.md

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ title: Get started
2121
npm install --save @patternfly/elements
2222
```
2323

24-
This will install not only the pf-card, but also the core utilities and
24+
This will install not only the web components, but also the core utilities and
2525
styles,
2626
and will save it to your package.json.
2727
{% endband %}
@@ -41,46 +41,23 @@ title: Get started
4141
```
4242

4343
### In HTML
44-
To load the PatternFly Element web components in HTML you will need to use an importmap type script tag:
44+
Alternatively, to load the PatternFly Elements web components in HTML you will need to use an importmap type script tag:
4545
`<script type="importmap"> ... </script>` and module type script tag `<script type="module"> ... </script>`.
4646

4747
In this example, we load the [card](/components/card/) modules using an importmap from JSPM.
4848

4949
```html
50-
<!--
51-
JSPM Generator Import Map
52-
Edit URL: https://generator.jspm.io/#U2NgYGBkDM0rySzJSU1hcChILClJLcpLy6nUT81JzU3NKyl2MNIz0DPQL0jTTU4sSoHRelnFAN524ZI8AA
53-
-->
54-
<script type="importmap">
55-
{
56-
"imports": {
57-
"@patternfly/elements/pf-card/pf-card.js": "https://ga.jspm.io/npm:@patternfly/[email protected]/pf-card/pf-card.js"
58-
},
59-
"scopes": {
60-
"https://ga.jspm.io/": {
61-
"@lit/reactive-element": "https://ga.jspm.io/npm:@lit/[email protected]/reactive-element.js",
62-
"@lit/reactive-element/decorators/": "https://ga.jspm.io/npm:@lit/[email protected]/decorators/",
63-
"@patternfly/pfe-core/controllers/slot-controller.js": "https://ga.jspm.io/npm:@patternfly/[email protected]/controllers/slot-controller.js",
64-
"lit": "https://ga.jspm.io/npm:[email protected]/index.js",
65-
"lit-element/lit-element.js": "https://ga.jspm.io/npm:[email protected]/lit-element.js",
66-
"lit-html": "https://ga.jspm.io/npm:[email protected]/lit-html.js",
67-
"lit-html/": "https://ga.jspm.io/npm:[email protected]/",
68-
"lit/": "https://ga.jspm.io/npm:[email protected]/",
69-
"tslib": "https://ga.jspm.io/npm:[email protected]/modules/index.js"
70-
}
71-
}
72-
}
73-
</script>
74-
50+
{% generateImportMap %}
7551
<script type="module">
7652
import "@patternfly/elements/pf-card/pf-card.js";
7753
</script>
54+
{% endgenerateImportMap %}
7855
```
7956

8057
To learn more about how to create importmaps, read our [creating an import map](/docs/develop/import-maps/) section, and go into more detail at [developer.mozilla.org](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap) or the [import map specification](https://html.spec.whatwg.org/multipage/webappapis.html#import-maps).
8158

8259
### Add PatternFly Elements markup
83-
Add a [card component](/components/card).
60+
When you have the import map script loaded on the page, you can add a [card component](/components/card) using html.
8461

8562
```html
8663
<pf-card>
@@ -96,6 +73,11 @@ title: Get started
9673
<pf-button slot="footer">OK</pf-button>
9774
</pf-card>
9875

76+
### Importmap and Markup
77+
78+
Altogether your import map code could look something like this [Lit Playground Demo](https://lit.dev/playground/#gist=453dc9f83854ff7ba09d02a0fc6a79d5).
79+
80+
9981
{% endband %}
10082

10183
{% band header="Add attributes" %}

docs/quick-start.md

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,12 @@ production.
3939
h1, h2, h3, h4 {
4040
font-family: "Red Hat Display";
4141
}
42-
</style>
43-
<!--
44-
JSPM Generator Import Map
45-
Edit URL: https://generator.jspm.io/#U2VhYGBkDM0rySzJSU1hcChILClJLcpLy6nUT81JzU3NKyl2MNIz0DMAADWC5vEpAA
46-
-->
47-
<script type="importmap">
48-
{
49-
"imports": {
50-
"@patternfly/elements": "https://ga.jspm.io/npm:@patternfly/[email protected]/pfe.min.js"
51-
},
52-
"scopes": {
53-
"https://ga.jspm.io/": {
54-
"@floating-ui/core": "https://ga.jspm.io/npm:@floating-ui/[email protected]/dist/floating-ui.core.browser.mjs",
55-
"@floating-ui/dom": "https://ga.jspm.io/npm:@floating-ui/[email protected]/dist/floating-ui.dom.browser.mjs",
56-
"@lit/reactive-element": "https://ga.jspm.io/npm:@lit/[email protected]/development/reactive-element.js",
57-
"@lit/reactive-element/decorators/": "https://ga.jspm.io/npm:@lit/[email protected]/development/decorators/",
58-
"lit": "https://ga.jspm.io/npm:[email protected]/index.js",
59-
"lit-element/lit-element.js": "https://ga.jspm.io/npm:[email protected]/development/lit-element.js",
60-
"lit-html": "https://ga.jspm.io/npm:[email protected]/development/lit-html.js",
61-
"lit-html/": "https://ga.jspm.io/npm:[email protected]/development/",
62-
"lit/": "https://ga.jspm.io/npm:[email protected]/",
63-
"tslib": "https://ga.jspm.io/npm:[email protected]/tslib.es6.js"
64-
}
65-
}
66-
}
67-
</script>
68-
<!-- ES Module Shims: Import maps polyfill for modules browsers without import maps support (all except Chrome 89+) -->
69-
<script async src="https://ga.jspm.io/npm:[email protected]/dist/es-module-shims.js" crossorigin="anonymous"></script>
70-
42+
</style>
43+
{% generateImportMap %}
7144
<script type="module">
72-
import * as Elements from "@patternfly/elements";
45+
import '@patternfly/elements';
7346
</script>
47+
{% endgenerateImportMap %}
7448
</head>
7549
<body>
7650
<header>
@@ -148,6 +122,6 @@ production.
148122
</html>
149123
```
150124

151-
[Lit Playground](https://lit.dev/playground/#gist=1540e63845ed8eeb88957a11ec234674&view-mode=code) example of the HTML above
125+
[Lit Playground](https://lit.dev/playground/#gist=77a0cb2d080de958f4415a4716908bf9) example of the HTML above
152126

153127
</section>

elements/pf-accordion/docs/pf-accordion.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% renderInstallation %} {% endrenderInstallation %}
2+
13
{% renderOverview %}
24
<pf-accordion>
35
<pf-accordion-header>
@@ -84,4 +86,4 @@
8486

8587
{% renderCssCustomProperties %}{% endrenderCssCustomProperties %}
8688

87-
{% renderCssParts %}{% endrenderCssParts %}
89+
{% renderCssParts %}{% endrenderCssParts %}

elements/pf-avatar/docs/pf-avatar.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% renderInstallation %} {% endrenderInstallation %}
2+
13
{% renderOverview %}
24
<pf-avatar alt="Libbie Koscinski"></pf-avatar>
35
{% endrenderOverview %}

elements/pf-badge/docs/pf-badge.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% renderInstallation %} {% endrenderInstallation %}
2+
13
{% renderOverview %}
24
<pf-badge state="read" number="17">17</pf-badge>
35
<pf-badge number="900" threshold="100">900</pf-badge>

elements/pf-button/docs/pf-button.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% renderInstallation %} {% endrenderInstallation %}
2+
13
<style>
24
pf-button + pf-button {
35
margin-inline-start: 4px;

elements/pf-card/docs/pf-card.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% renderInstallation %} {% endrenderInstallation %}
2+
13
{% renderOverview %}
24

35
Cards are flexible surfaces used to group information in a small layout. They give small previews of information or provide secondary content in relation to the content it's near. Several cards can be used together to group related information.

elements/pf-clipboard-copy/docs/pf-clipboard-copy.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% renderInstallation %} {% endrenderInstallation %}
2+
13
{% renderOverview %}
24
<pf-clipboard-copy value="This is editable"></pf-clipboard-copy>
35
{% endrenderOverview %}

0 commit comments

Comments
 (0)