Skip to content

Commit 791d8ec

Browse files
zeroedinbrianferrybennypowers
authored
docs: update developer content (#2409)
* docs: update developer/setup content * docs: update setup documentation * docs: updates to create and structure * docs: improvements to developer section * docs: correct link to new issues * docs: fix url in non markdown block * docs: update generate new component command * docs: add example to generation options * docs: update link to current custom elements working draft * feat: adding updated footer to the dev server * docs: improve getting started and quick start * docs: add screenshots and improve structure server info * docs: update pf-tabs example * Revert "feat: adding updated footer to the dev server" This reverts commit d07033b. * docs: update screenshots, javascript examples * docs: improve testing, add screenshots * docs: update playground url to use a gist url * docs: correct generate element switch table options * docs: update default directory path * docs: improve testing section on setup * docs: reword wrapper text * docs: update badges in README * docs: update README commands * docs: formatting and consistency updates, changing all example elements to pf-cool-element * docs: add creating import maps section * docs: improve get-started code example * docs: improve importmaps --------- Co-authored-by: Brian Ferry <[email protected]> Co-authored-by: Benny Powers <[email protected]>
1 parent 8ff162a commit 791d8ec

30 files changed

+554
-314
lines changed

README.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# PatternFly Elements [![Netlify status](https://api.netlify.com/api/v1/badges/bf40e3e7-4f98-4088-91d9-112dbe8a1872/deploy-status)](https://patternfly-elements.netlify.app) ![build status](https://img.shields.io/github/workflow/status/patternfly/patternfly-elements/Build%20&%20test/main) ![commit](https://badgen.net/github/last-commit/patternfly/patternfly-elements) ![latest version](https://img.shields.io/github/lerna-json/v/patternfly/patternfly-elements?label=version) ![contributors](https://img.shields.io/github/contributors/patternfly/patternfly-elements)
1+
# PatternFly Elements
2+
3+
[![latest version](https://img.shields.io/github/package-json/v/patternfly/patternfly-elements?filename=elements%2Fpackage.json)](https://github.com/patternfly/patternfly-elements/releases) [![contributors](https://img.shields.io/github/contributors/patternfly/patternfly-elements?color=%2306c)](https://github.com/patternfly/patternfly-elements/graphs/contributors) \
4+
\
5+
![build status](https://img.shields.io/github/actions/workflow/status/patternfly/patternfly-elements/tests.yml)
6+
![last commit](https://img.shields.io/github/last-commit/patternfly/patternfly-elements?color=%2306c) [![Netlify status](https://api.netlify.com/api/v1/badges/bf40e3e7-4f98-4088-91d9-112dbe8a1872/deploy-status?branch=main)](https://patternflyelements.com)
27

38
## Table of Contents
49

@@ -77,24 +82,12 @@ npm run test:vue
7782
npm run test:ci
7883
```
7984

80-
### Open a new pull request
81-
82-
```shell
83-
# Open a new pull request
84-
npm run pr
85-
```
86-
87-
### Documentation site
88-
View the documentation locally
85+
### Development and Documentation servers
8986
```shell
87+
# Development and documentation servers load simultaneously on localhost:port `:8000` and `:8080` respectively.
9088
npm run start
9189
```
9290

93-
Build the documentation site
94-
```shell
95-
npm run docs
96-
```
97-
9891
## Support
9992

10093
Though we have tested and verified general usability within these frameworks, PatternFly Elements makes no guarantees about compatibility within specific sites and applications. Please test accordingly.

docs/docs/develop/create.md

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
11
---
22
layout: layout-docs.njk
33
title: Create a PatternFly Element
4-
order: 2
4+
order: 20
55
tags:
66
- develop
77
---
88

9+
<style>
10+
img {
11+
max-width: 100%;
12+
}
13+
</style>
14+
915
{% band %}
1016

17+
## PatternFly Element generator
18+
1119
Before you begin, make sure you've followed the
1220
[Prerequisites](/docs/develop/setup#prerequisites) in
1321
[Setup](/docs/develop/setup).
1422

15-
<h3>PatternFly Element generator</h3>
16-
17-
Use the PatternFly Element generator to start the scaffolding process. From
18-
the root directory of the PatternFly Elements repository, run the following
19-
command.
23+
Then use the PatternFly Element generator to start the scaffolding process.
24+
25+
From the root directory of the PatternFly Elements repository, run the following
26+
command:
2027

2128
```bash
2229
npm run new
2330
```
2431

25-
The generator will ask you a series of questions to set up your project.
32+
The generator will then prompt you for the following:
2633

27-
1. Your element name:
28-
- Your element's name should be lowercase and needs to contain at least
29-
one hyphen. For rules on naming custom elements, refer to the W3C
30-
[Custom Elements Working
31-
Draft](https://www.w3.org/TR/custom-elements/#valid-custom-element-name).
32-
- PatternFly Elements prefixes elements with `pf-`. However, prefix your
33-
elements with whatever fits your project.
34-
- As an example, we'll create `pf-cool-element`.
34+
* What is the element's tag name?
35+
* Your element's name should be lowercase and needs to contain at least
36+
one hyphen. For rules on naming custom elements, refer to the W3C
37+
[Custom Elements Working Draft](https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name).
38+
* As an example, we'll create `pf-cool-element`.
39+
* PatternFly Elements should be prefixed with `pf-`. However, prefix your
40+
elements with whatever fits your project if you are using the generator outside of this project.
3541

36-
1. The [NPM scope](https://docs.npmjs.com/cli/v6/using-npm/scope) for the
37-
package. For example, patternfly elements packages like `@patternfly/pf-core`
38-
are published under the `patternfly` scope.
3942

40-
1. A number of questions about the npm package, including the author's name
41-
and email, etc.
43+
![npm run new command](/images/develop/npm-run-new.png)
4244

43-
After answering the questions, your new component will be created and
44-
bootstrapped in the repository.
45+
After answering, your new component will be created and bootstrapped in the repository.
4546

4647
Once that's done, switch directories to the element you just created. We'll
4748
`cd` into the `pf-cool-element` directory.
@@ -53,35 +54,16 @@ tags:
5354
Open your code editor to view the structure of the element.
5455
The element's source files are located directly in it's package root, in our
5556
case:
56-
- `pf-cool-element.ts` - The element class declaration
57-
- `pf-cool-element.css` - The element's CSS style module
58-
59-
These two files are the most important as they contain the actual element
60-
definition. In addition, there are a number of config files. Do not edit these files
61-
unless you know what you're doing.
62-
- `custom-elements-manifest.config.js` - Configuration for the
63-
custom-elements-manifest analyzer.
64-
- `custom-elements.json` - A manifest of your package's JS exports and
65-
custom elements.
66-
- `package.json` - NPM package configuration and scripts
67-
- `tsconfig.json` - TypeScript configuration for your monorepo.
68-
69-
For now, your `custom-elements.json` file is empty. If you'd like to generate
70-
content for it, run the `analyze` script in your element's workspace:
71-
72-
```bash
73-
npm run analyze
74-
```
7557

76-
This happens automatically when you build or publish your elements, so don't
77-
worry about forgetting to run it.
58+
* `pf-cool-element.ts` - The element class declaration
59+
* `pf-cool-element.css` - The element's CSS style module
7860

7961
The `demo` directory contains an HTML partial that you can edit to provide an
8062
interactive demo of your element.
8163

82-
The `test` directory contains unit test files for your elemen.
64+
The `test` directory contains unit test files for your element.
8365

84-
You'll also notice that the generator editted the root `tsconfig.json`, adding
66+
You'll also notice that the generator edited the root `tsconfig.json`, adding
8567
a `path` to our new element.
8668
This is important so that TypeScript knows where each of our packages in the
8769
monorepo are.

docs/docs/develop/css.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: layout-docs.njk
33
title: Write your CSS
4-
order: 5
4+
order: 50
55
tags:
66
- develop
77
---
@@ -34,20 +34,38 @@ Now we can update our styles, like so:
3434

3535
```css
3636
:host {
37-
display: flex;
37+
display: inline-flex;
3838
flex-direction: column;
3939
align-items: center;
4040
justify-content: center;
41+
border:
42+
var(--pf-global--BorderWidth--sm, 1px)
43+
solid
44+
var(--pf-global--BorderColor--100, #d2d2d2);
45+
padding: var(--pf-global--spacer--xl, 2rem);
46+
margin: var(--pf-global--spacer--md, 1rem);
4147
}
4248

4349
:host([hidden]) {
4450
display: none;
4551
}
52+
53+
#profile-pic {
54+
width: 60px;
55+
height: 60px;
56+
margin: var(--pf-global--spacer--md, 1rem);
57+
border:
58+
var(--pf-global--BorderWidth--sm, 1px)
59+
solid
60+
var(--pf-global--BorderColor--200, #8a8d90);
61+
border-radius: 50%;
62+
background-color: var(--pf-global--BackgroundColor--200, #f0f0f0);
63+
}
4664
```
4765

4866
After saving and viewing our demo page, our profile element looks much better.
4967

50-
![Demo Page CSS](/images/develop/develop-sass.png)
68+
![Demo Page CSS](/images/develop/develop-css.png)
5169

5270
A couple of things to note:
5371

@@ -58,8 +76,6 @@ Now that our `pf-cool-element` is more appealing, we'll add the follow button's
5876
and fill in the profile photo.
5977
We can accomplish both of these tasks by updating the `pf-cool-element.ts` file.
6078

61-
<a href="{{ '/theming/' | url }}">Learn more about applying a theme.</a>
62-
6379
<a class="cta" href="{{ '../javascript' | url }}">Next up: Write your JavaScript</a>
6480

65-
{% endband %}
81+
{% endband %}

docs/docs/develop/html.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: layout-docs.njk
33
title: Write your HTML
4-
order: 4
4+
order: 40
55
tags:
66
- develop
77
---
@@ -19,7 +19,7 @@ advantage of the slot and shadow root to make our element a bit more
1919
interesting.
2020

2121
PatternFly elements are written in [TypeScript](https://typescriptlang.org), a
22-
dialect of JavaScript which adds development-time type checking and other
22+
superset of JavaScript which adds development-time type checking and other
2323
features.
2424
If you are unfamiliar with TypeScript, read their getting-started documentation,
2525
and feel free to reach out to the PatternFly Elements team on our social media
@@ -53,29 +53,24 @@ We'll also need to update `/demo/pf-cool-element.html`
5353
so that the user's name is passed into the slot that we added in `pf-cool-element.ts`:
5454

5555
```html
56-
<link rel="stylesheet" href="./demo.css"/>
56+
<link rel="stylesheet" href="demo.css">
57+
<script type="module" src="pf-cool-element.js"></script>
58+
5759
<pf-cool-element>
5860
Kyle Buchanan
5961
</pf-cool-element>
6062
```
6163

62-
> Slots take the HTML from the light DOM and project it into the shadow DOM at a
63-
> given location.
64-
> To learn more about shadow DOM and how to use slots, check out [Shadow DOM v1:
65-
> Self-Contained Web
66-
> Components](https://developers.google.com/web/fundamentals/web-components/shadowdom).
64+
Slots take the HTML from the light DOM and project it into the shadow DOM at a given location.
6765

6866
Here's how it should look in the browser:
6967

7068
![demo page html step](/images/develop/develop-html.png)
7169

72-
Remember that any changes we make in the element directory are watched while the
73-
`npm run dev` command runs.
74-
When you save changes, the dev server reloads the page and shows you your
75-
changes automatically.
70+
Remember that any changes we make in the element directory are watched while the `npm run start` command runs. When you save changes, the dev server reloads the page and shows you your changes automatically.
7671

7772
Now that we've added the HTML, let's style our element by updating the CSS file.
7873

7974
<a class="cta" href="../css">Next up: Write your CSS</a>
8075

81-
{% endband %}
76+
{% endband %}

0 commit comments

Comments
 (0)