Skip to content

Commit a26379b

Browse files
authored
Merge branch 'master' into emit-event
2 parents 11b6ded + ecf2612 commit a26379b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4606
-520
lines changed

.storybook/utils.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ const listProperties = (obj) =>
3737
print = true;
3838
}
3939

40-
// If printing is allowed, the value exists and is not null and is not a slot
40+
// If printing is allowed, the value exists and is not null
4141
if (
4242
print &&
4343
typeof v !== "undefined" &&
44-
(v !== null && v !== "null") &&
45-
p !== "slot"
44+
(v !== null && v !== "null")
4645
) {
4746
string += p;
4847
// If the value is a boolean and is false, or the value is not a string true
@@ -60,7 +59,7 @@ const listProperties = (obj) =>
6059
}
6160
}
6261
}
63-
return string.toLowerCase();
62+
return string;
6463
})
6564
.join(" ");
6665

README.md

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,8 @@ _Note: You will need to use [Node](https://nodejs.org/en/) v.7 or higher._
3131

3232
## Support
3333

34-
Though we have tested and verified general usability within these frameworks, PFE makes no guarantees about compatibility within specific sites & applications. Please test accordingly.
35-
36-
37-
**PFE component** | **web** | **angular** | **react** | **vue**
38-
----- |----|-----|-----|----|
39-
[pfe-accordion ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-accordion ) | yes| yes | yes | yes
40-
[pfe-autocomplete ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-autocomplete ) | yes| no | yes | yes
41-
[pfe-avatar ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-avatar ) | yes| yes | yes | yes
42-
[pfe-band ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-band ) | yes| yes | yes | yes
43-
[pfe-card ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-card ) | yes| yes | yes | yes
44-
[pfe-collapse ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-collapse ) | yes| yes | yes | yes
45-
[pfe-content-set ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-content-set ) | yes| no | yes | yes
46-
[pfe-cta ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-cta ) | yes| yes | yes | yes
47-
[pfe-datetime ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-datetime ) | yes| no | yes | yes
48-
[pfe-health-index ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-health-index ) | yes| yes | yes | yes
49-
[pfe-icon ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-icon ) | yes| yes | yes | yes
50-
[pfe-icon-panel ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-icon-panel ) | yes| yes | yes | yes
51-
[pfe-layouts ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-layouts ) | yes| yes | yes | yes
52-
[pfe-markdown ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-markdown ) | yes| yes | yes | yes
53-
[pfe-modal ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-modal ) | yes| yes | yes | yes
54-
[pfe-navigation ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-navigation ) | yes| yes | yes | yes
55-
[pfe-number ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-number ) | yes| no | yes | yes
56-
[pfe-page-status ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-page-status ) | yes| yes | yes | yes
57-
[pfe-progress-indicator ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-progress-indicator ) | yes| yes | yes | yes
58-
[pfe-sass ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-sass ) | yes| yes | yes | yes
59-
[pfe-tabs ](https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-tabs ) | yes| yes | yes | yes
34+
Though we have tested and verified general usability within these frameworks, PFE makes no guarantees about compatibility within specific sites & applications. Please test accordingly. For more details, check out the [official status card per component](https://github.com/patternfly/patternfly-elements/issues?q=is%3Aopen+is%3Aissue+label%3A%22status+tracking+only%22) or visit the [status page on the documentation site](https://patternfly.github.io/patternfly-elements/getting-started/component-status/).
35+
6036

6137

6238
---

docs/content/getting-started/_index.md

Lines changed: 187 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,82 @@ menu = "start"
99
tags = [ "start" ]
1010
+++
1111

12+
## Getting Started
13+
14+
Check out the demo files within each component for examples of the attributes and possible variable overrides. The readme.md files within each component should have descriptions about the supported attributes & variables.
15+
16+
The list below is the recommended approach to using web components and overriding style properties, in order.
17+
1218

1319
## 1. Install PatternFly Elements
1420

1521

16-
Use [NPM](https://www.npmjs.com/) (Node Package Manager) to install the whole PatternFly Elements library or a handful of individual PatternFly Elements.
22+
Use [NPM](https://www.npmjs.com/) (Node Package Manager) to install individual PatternFly Elements.
1723

1824
```bash
1925
npm install --save @patternfly/pfe-card
26+
npm install --save @patternfly/pfe-cta
2027
```
2128

22-
Or, utilize the Red Hat asset library! When it exists!
2329

30+
## 2. Include PatternFly Elements JavaScript
2431

25-
26-
## 2. Include PatternFly Elements on a page
27-
28-
You have some options:
32+
There are a few options:
2933

3034
1. Load JavaScript modules via script tag: `script type="module"`
31-
1. Downloads all of the dependencies on its own
32-
2. [Only supported in modern browsers](https://caniuse.com/#search=module)
35+
1. Downloads all of the dependencies on its own.
36+
2. [Only supported in modern browsers](https://caniuse.com/#search=module).
3337
2. Include the PatternFly Element and its dependencies on the page(s) or within the app.
3438

3539
```html
3640
import '@patternfly/pfe-card/pfe-card.js';
3741
import '@patternfly/pfe-cta/pfe-cta.js';
3842
```
3943

40-
3. Use [require.js](https://requirejs.org/) JavaScript file and module loader
44+
3. Use [require.js](https://requirejs.org/) JavaScript file and module loader.
4145
- Learn more about [Polyfills](/getting-started/polyfills)
42-
3. Load individual PatternFly Element scripts, but bundle the polyfills with the base `pfelement.js` file
43-
1. All elements are based off of pfelement.js so including the polyfills with this one file would mean you only need to include the pfelement.js file before you include anything else
44-
4. Bundle all of the scripts together into one
45-
5. TBD Idea: polyfill.io > webservice (build something similar internal to Red Hat - component service)
46-
1. pipe needed polyfills for website, checks headers, runtime
47-
2. delivers dynamic JS
48-
3. If I want pfe-card - it gets the pfe-card.js + required other files (serves up js bundle)
46+
3. Load individual PatternFly Element scripts, but bundle the polyfills with the base `pfelement.js` file.
47+
1. All elements are based off of pfelement.js so including the polyfills with this one file would mean you only need to include the pfelement.js file before you include anything else.
48+
4. Bundle all of the scripts together into one rollup, and include that.
49+
4950

5051

5152

5253
## 3. Use PatternFly Elements markup
5354

54-
You can use PatternFly Elements with other standard HTML markup in your app or page:
55+
Different components have different intended uses. We tend to think of them in 3 distinct groups:
56+
57+
- Content, such as a call-to-action: `pfe-cta`
58+
- Containers, such as a card: `pfe-card`
59+
- Combos, such as the pattern which captures sets of content and renders it as an accordion or tab set: `pfe-content-set`
60+
61+
62+
### Content Components
63+
64+
The beauty of web components is that they have much of the styling built-into the tag itself. Start with the tags first.
65+
66+
```
67+
<body>
68+
<pfe-cta>
69+
<a href="#">Learn more</a>
70+
</pfe-cta>
71+
</body>
72+
```
73+
74+
75+
76+
### Container components (see also container notes below)
77+
78+
```
79+
<body>
80+
<pfe-card pfe-color="darkest">
81+
<p>Hello world.</p>
82+
</pfe-card>
83+
</body>
84+
```
85+
86+
87+
You can use PatternFly Elements alongside other standard HTML markup in your app or page. Here's a React app example:
5588

5689
```html
5790
import React, { Component } from 'react';
@@ -73,12 +106,12 @@ class App extends Component {
73106
</p>
74107
<div className="body">
75108
<pfe-card>
76-
<h2 slot="header">Default card</h2>
109+
<h2 slot="pfe-card--header">Default card</h2>
77110
<p>This is the default pfe-card and <a href="#">a link</a>.</p>
78111
<p>Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition.</p>
79112
<p>Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.</p>
80-
<div slot="footer">
81-
<pfe-cta priority="secondary"><a href="#">Learn more</a></pfe-cta>
113+
<div slot="pfe-card--footer">
114+
<pfe-cta pfe-priority="secondary"><a href="#">Learn more</a></pfe-cta>
82115
</div>
83116
</pfe-card>
84117
</div>
@@ -92,17 +125,142 @@ class App extends Component {
92125

93126
## 4. Add attributes
94127

95-
You may choose to add attributes such as `priority` or `color` as needed to adjust usage of palette color, context, or priority.
128+
You may choose to add attributes such as `pfe-variant`, `pfe-priority` or `pfe-color` as needed to adjust usage of general theme, palette color, or priority. Check the readme file of a component to see what attributes are supported. Or check out the [Storybook](https://patternfly.github.io/patternfly-elements/demo) to preview how the attributes work.
96129

97-
```html
98-
<pfe-card color="darkest">
99-
<h2 slot="header">Dark card</h2>
100-
<p>Lorem ipsum.</p>
101-
<pfe-cta color="complement" priority="primary" on="dark" slot="footer">
102-
<a href="#">Important call-to-action</a>
103-
</pfe-cta>
104-
</pfe-card>
130+
#### General
131+
132+
"Priority" & "variant" attributes will change various styles throughout the component, as a set:
133+
134+
```
135+
<pfe-cta pfe-priority="primary">...</pfe-cta>
136+
<pfe-tabs pfe-variant="earth">...</pfe-tabs>
137+
```
138+
139+
**Full list:**
140+
141+
* `pfe-priority`
142+
* `pfe-variant`
143+
144+
145+
#### Specific
146+
147+
"Color" and "align" attributes change those specific properties respectively, but do not alter the overall look & feel.
148+
149+
```
150+
<pfe-cta pfe-color="accent">...</pfe-cta>
151+
```
152+
153+
154+
#### **Full list:**
155+
156+
* `pfe-align`
157+
* `pfe-color`
158+
* `vertical`
159+
* `horizontal`
160+
161+
162+
## 5. Use CSS variables to provide hooks for customization or as a means of updating internal styles
163+
164+
CSS variables are subject to the normal cascade, so consider where you want these overrides to propogate.
165+
166+
167+
#### Page-level CSS, [theme](https://static.redhat.com/libs/redhat/redhat-theme/2/advanced-theme.css) variables
168+
169+
Theme variables will impact all components on the page where this CSS is loaded.
170+
171+
172+
```
173+
// your-page.css
174+
:root {
175+
--pfe-theme--color--ui-accent: green;
176+
--pfe-theme--color--surface--darker: navy;
177+
}
105178
```
106179

107180

181+
_Note_: overriding local variables (i.e., --pfe-cta--foo) will not work at this level. Those overrides can only be done on the component via tag name, class, or ID.
108182

183+
184+
#### Page-level CSS, component variables
185+
186+
187+
```
188+
/* your-page.css */
189+
pfe-cta {
190+
--pfe-cta--BackgroundColor: green;
191+
}
192+
pfe-band {
193+
--pfe-band--Padding--vertical: 34px;
194+
}
195+
```
196+
197+
198+
199+
### Component-level inline CSS
200+
201+
As a last resort, you may choose to override variables with inline styles. This could be desirable if you only need one component to deviate from the design system. Note that this incurs some level of risk, especially related to colors, as you are opting out of the color combinations in the system.
202+
203+
204+
```
205+
<pfe-cta style="--pfe-cta--BackgroundColor:pink">
206+
```
207+
208+
209+
## 6. Victory!
210+
211+
Be sure to browser test within your own site or application. If you run into any trouble, please file an issue in the [issue queue](https://github.com/patternfly/patternfly-elements/issues).
212+
213+
<hr/>
214+
215+
216+
## FAQ
217+
218+
### Should I use on=dark or color=darkest on my container? What's the difference?
219+
220+
* `on=dark` is being deprecated. Instead, custom classes already on the page should set broadcast values.
221+
* The original goal for `on=dark` was all about context, but instead of having to provide another attribute somewhere, the card or a band or another container will inform any nested components that the text color needs to change through the set of broadcast variables. Existing broadcast vars (defined in `$BROADCAST-VARS`) include: `text`, `ui-link`, `ui-link--hover`, `ui-link--visited`, `ui-link--focus`.
222+
* If your page has a custom background color for a band or card, you should set the background and also set the broadcast colors.
223+
224+
225+
```
226+
.custom-dark-band {
227+
background: black;
228+
--pfe-broadcasted--color--text: var(--pfe-theme--color--text--on-dark, #fff);
229+
--pfe-broadcasted--color--ui-link: var(--pfe-theme--color--ui-link--on-dark, #73bcf7);
230+
--pfe-broadcasted--color--ui-link--hover: var(--pfe-theme--color--ui-link--on-dark--hover, pink);
231+
--pfe-broadcasted--color--ui-link--visited: var(--pfe-theme--color--ui-link--on-dark--visited, pink);
232+
--pfe-broadcasted--color--ui-link--focus: var(--pfe-theme--color--ui-link--on-dark--focus, pink);
233+
}
234+
```
235+
236+
In themes (like the advanced-theme.css file from the Red Hat Theme ) we apply broadcast variables to plain links, because they are light DOM and also have default colors applied by the browser. This CSS file not only includes variables but also styles for headlines and links on the page. It sets the colors for these elements using a CSS variable, which web components can change the value of.
237+
238+
For example, advanced-theme.css includes:
239+
240+
```
241+
.PFElement a {
242+
color: var(--pfe-broadcasted--color--ui-link);
243+
}
244+
```
245+
246+
We choose not to apply broadcast colors to text elements like paragraphs because it still would not be high enough specificity to override anything coming from pre-existing stylesheets, and paragraphs will inherit color from parents.
247+
248+
249+
```
250+
// this would not really be helpful to add to cp-theme or redhat-theme
251+
h1, h2, h3, h4, h5, h6, p {
252+
color: var(--pfe-broadcasted--color--text);
253+
}
254+
// if there was some class like this in the theme, It would override it anyway.
255+
body.editorial .body1.generic1 {
256+
color: #646464;
257+
}
258+
```
259+
260+
Instead, in the host of components, use:
261+
262+
```
263+
:host {
264+
color: var(--pfe-broadcasted--color--text);
265+
}
266+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
+++
2+
title = "What's available?"
3+
description = "Status of each PatternFly Elements component"
4+
weight = 1
5+
draft = false
6+
bref = ""
7+
toc = true
8+
menu = "start"
9+
tags = [ "start" ]
10+
+++
11+
12+
13+
Though we have tested and verified general usability within these frameworks, PFE makes no guarantees about compatibility within specific sites & applications. Please test accordingly. For more details, check out the [official status card per component](https://github.com/patternfly/patternfly-elements/issues?q=is%3Aopen+is%3Aissue+label%3A%22status+tracking+only%22).
14+
15+
<br/>
16+
17+
<iframe width="785" height="538" seamless frameborder="0" scrolling="no" src="https://docs.google.com/spreadsheets/d/e/2PACX-1vRfQ-5bKA57rXGt6QssqB4r7qweiCuODpQTL2qsKLMGSz582WOdaMBr1axvuQ88nu1UAo30n1EK_Qke/pubchart?oid=51483830&amp;format=interactive"></iframe>

0 commit comments

Comments
 (0)