Skip to content

Commit f9c2813

Browse files
castastrophestarryeyez024kylebuch8
authored
fix: Add a warning about updating the on attribute before upgrade (#809)
* fix Add a warning about updating the on attribute before upgrade * fix Update documentation * updating the changelog * fix Move warning for on attribute into connectedCallback * fix Remove on from storybook * fix Remove references to on attribute from documentation and demos * fix Add theme preview to stories for components that support theme * fix Revert theming updates to storybook into a separate branch Co-authored-by: Kendall Totten <[email protected]> Co-authored-by: Kyle Buchanan <[email protected]>
1 parent a55449b commit f9c2813

File tree

17 files changed

+139
-168
lines changed

17 files changed

+139
-168
lines changed

.storybook/config.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@ addParameters({
1414
brandUrl: "/"
1515
}
1616
},
17-
backgrounds: [{
18-
name: "light",
19-
value: "#fff",
20-
default: true
21-
},{
22-
name: "dark",
23-
value: "#252525"
24-
}, {
25-
name: "saturated",
26-
value: "#007a87"
27-
}]
17+
backgrounds: [
18+
{
19+
name: "light",
20+
value: "#fff",
21+
default: true
22+
},
23+
{
24+
name: "dark",
25+
value: "#252525"
26+
},
27+
{
28+
name: "saturated",
29+
value: "#007a87"
30+
}
31+
]
2832
});
2933

3034
function loadStories() {

.storybook/utils.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ String.prototype.sentenceCase = function() {
2424
};
2525

2626
// Print attributes based on an object
27-
export const listProperties = (obj) =>
27+
export const listProperties = obj =>
2828
Object.entries(obj)
2929
.map(set => {
3030
let string = " ";
@@ -43,11 +43,7 @@ export const listProperties = (obj) =>
4343
}
4444

4545
// If printing is allowed, the value exists and is not null
46-
if (
47-
print &&
48-
typeof v !== "undefined" &&
49-
(v !== null && v !== "null")
50-
) {
46+
if (print && typeof v !== "undefined" && v !== null && v !== "null") {
5147
string += p;
5248
// If the value is a string and the value is not equal to the string "true"
5349
if (typeof v === "string" && v !== "true") {
@@ -81,7 +77,7 @@ export function customTag(obj) {
8177
// If a tag is defined, use that, else use a div
8278
if (obj.tag) {
8379
start += `<${obj.tag}`;
84-
end += !selfClosing.includes(obj.tag) ? `</${obj.tag}>` : "";
80+
end += !selfClosing.includes(obj.tag) ? `</${obj.tag}>` : "";
8581
} else {
8682
start += "<div";
8783
end += "</div>";
@@ -90,7 +86,9 @@ export function customTag(obj) {
9086
start += obj.attributes ? listProperties(obj.attributes || {}) : "";
9187
start += !selfClosing.includes(obj.tag) ? ">" : "/>";
9288
}
93-
return `${start}${typeof obj.content !== "undefined" ? obj.content || autoContent() : ""}${end}`;
89+
return `${start}${
90+
typeof obj.content !== "undefined" ? obj.content || autoContent() : ""
91+
}${end}`;
9492
}
9593

9694
const parseMarkup = string => {
@@ -154,7 +152,7 @@ const renderSlots = (slots = []) =>
154152
let parsed = parseMarkup(slot.content);
155153
Object.assign(slot, parsed);
156154
}
157-
return slot.content || slot.tag && selfClosing.includes(slot.tag)
155+
return slot.content || (slot.tag && selfClosing.includes(slot.tag))
158156
? customTag({
159157
tag: slot.tag,
160158
slot: slot.slot,
@@ -168,7 +166,7 @@ const renderSlots = (slots = []) =>
168166
// Creates a component dynamically based on inputs
169167
export function component(tag, attributes = {}, slots = [], noSlot = false) {
170168
return `<${tag}${listProperties(attributes)}>${
171-
slots.length > 0 ? renderSlots(slots) : (!noSlot) ? autoContent() : ""
169+
slots.length > 0 ? renderSlots(slots) : !noSlot ? autoContent() : ""
172170
}</${tag}>`;
173171
}
174172

@@ -221,7 +219,7 @@ export function autoPropKnobs(properties, bridge) {
221219
prefixed = false;
222220
}
223221

224-
if(prefixed) {
222+
if (prefixed) {
225223
attr = `pfe-${attr}`;
226224
}
227225

CHANGELOG-prerelease.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Prerelese 45 ( TBD )
22

3-
- [](https://github.com/patternfly/patternfly-elements/commit/) feat: add event emission to pfe-select
3+
- [eb74cb8](https://github.com/patternfly/patternfly-elements/commit/eb74cb8f989048164fbb6ed1508c502659a752ed) feat: add event emission to pfe-select
4+
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: Add a warning about updating the on attribute before upgrade
45

56
## Prerelease 44 ( 2020-04-02 )
67

docs/content/develop/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Before getting started, it's important to note that because this is a library, e
2525
- If it is a `container` component, then it should focus on creating sections in which components can be placed. These will handle surface colors, padding, some layout, but no typography styles. Examples include: `pfe-card`, `pfe-band`
2626
- If it is a `combo` component, then it should not contain any styles of its own (exception: you might need to set the display value of the host) but rather, it will pull together other components into a set that is logical for content editors or developers. These components can also make decisions about the way the children components are laid out or which components are called based on built-in logic for that combo.
2727
3. Components should be context aware, if possible.
28-
- `Content` components should be equipped with styles for the `on="dark"` attribute, so that they can be used on both light and dark backgrounds.
28+
- `Content` components should be equipped with styles for light, dark, and saturated backgrounds.
2929
4. Framework agnostic
3030
- A PatternFly Element should "just work" when you drop it onto any page (provided the proper polyfills are there). It should have ALL the styles it needs, when coupled with a PFE Theme.
3131

@@ -44,7 +44,7 @@ A component always touches all four sides of its parent container. For example,
4444

4545
**Example: [Call-to-action](https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-cta/src)**
4646

47-
This component has attributes which invoke the multiple style changes on a call-to-action link. It also has `on="dark"` styles built-in so that colors will automatically adjust on dark surfaces
47+
This component has attributes which invoke the multiple style changes on a call-to-action link. It has styles built-in so that colors will automatically adjust to surfaces.
4848

4949
## Combo Elements
5050

docs/content/theme/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This is because the accent color should be the brightest and boldest, and the pr
2828
Additionally, each component comes equipped to adjust its colors depending on where it's placed on the page. For example, should you need to put a default CTA (which is blue) on a dark blue card, the CTA will need to adapt. You can do this by informing the component of its context (on a dark background) by giving the `on` attribute the value of `dark`.
2929

3030
<pfe-card pfe-color="dark">
31-
<pfe-cta pfe-color="base" on="dark">
31+
<pfe-cta pfe-color="base">
3232
<a href="#">Default</a>
3333
</pfe-cta>
3434
</pfe-card>
@@ -39,4 +39,4 @@ Should you need to deviate from this color usage, and set your primary CTA to us
3939
<a href="#">Primary</a>
4040
</pfe-cta>
4141

42-
Please note that if you are opting to override colors of components, they will not automatically respond to the `on="dark"` attribute any longer.
42+
Please note that if you are opting to override colors of components, they will not automatically respond to the theme context any longer.

elements/pfe-accordion/demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ <h3>Where do the main characters work as adults?</h3>
306306
</section>
307307

308308
<section class="saturated-background on-saturated">
309-
<h2>pfe-accordion [on="saturated"]</h2><br/>
309+
<h2>&lt;pfe-accordion&gt; on a custom saturated background</h2><br/>
310310
<pfe-accordion>
311311
<pfe-accordion-header>
312312
<h3>Why do wizards need money if they could just create it?</h3>

elements/pfe-accordion/demo/pfe-accordion.story.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,7 @@ stories.add(PfeAccordion.tag, () => {
3838
let headings = [];
3939
let panels = [];
4040

41-
// const props = PfeAccordion.properties;
42-
const props = {
43-
on: {
44-
title: "Theme",
45-
type: "string",
46-
enum: ["light", "dark"],
47-
default: "light",
48-
prefixed: false
49-
}
50-
};
41+
const props = PfeAccordion.properties;
5142

5243
config.prop = tools.autoPropKnobs(props, storybookBridge);
5344

elements/pfe-content-set/demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ <h4 pfe-content-set--header>Heading 3</h4>
236236

237237
<pfe-band pfe-color="darkest">
238238

239-
<pfe-content-set on="dark">
239+
<pfe-content-set>
240240
<h4 pfe-content-set--header>Heading 1</h4>
241241
<div pfe-content-set--panel>
242242
<p>Content for heading 1. Maecenas faucibus mollis interdum. Maecenas sed diam eget risus varius blandit sit

elements/pfe-sass/README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,3 @@ Let's use the pfe-cta as an example. We can start by defining local variables, n
4848
--pfe-cta--Color: var(theme--surface-accent--link);
4949
}
5050
```
51-
52-
53-
54-
### On=dark is being deprecated.
55-
56-
**Instead, custom classes already on the page should set broadcast values:**
57-
58-
```css
59-
.on-dark {
60-
--pfe-broadcasted--text: var(--pfe-theme--color--text--on-dark, #fff);
61-
--pfe-broadcasted--link: var(--pfe-theme--color--link--on-dark, #73bcf7);
62-
--pfe-broadcasted--link--hover: var(--pfe-theme--color--link--on-dark--hover, #2b9af3);
63-
--pfe-broadcasted--link--visited:var(--pfe-theme--color--link--on-dark--visited, #73bcf7);
64-
--pfe-broadcasted--link--focus: var(--pfe-theme--color--link--on-dark--focus, #2b9af3);
65-
}
66-
```

elements/pfe-styles/demo/theme-test.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,15 +517,15 @@ <h2>Call-to-action component</h2>
517517
<h2>Band component</h2>
518518
</header>
519519
<article style="display: grid; grid-gap: 20px; grid-template-columns: repeat(3, 1fr);">
520-
<pfe-card pfe-color="lightest" class="border-card PFElement" pfelement="" has_body="" has_footer="" pfe-type="container" on="light">
520+
<pfe-card pfe-color="lightest" class="border-card">
521521
<img src="https://web-dev-drupal-carobert.dev.a1.vary.redhat.com/cms/managed-files/placeholder.jpg"
522522
pfe-overflow="top right left" style="max-height: 200px;">
523523
<h3 class="pfe-headline-3">Card component</h3>
524524
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor.</p>
525525
<pfe-cta slot="pfe-card--footer"><a href="#">Call-to-action component</a></pfe-cta>
526526
</pfe-card>
527527

528-
<pfe-card pfe-color="complement" pfe-size="small" class="resource-card PFElement" pfelement="" has_header="" has_body="" has_footer="" pfe-type="container" on="saturated">
528+
<pfe-card pfe-color="complement" pfe-size="small" class="resource-card">
529529
<h3 slot="pfe-card--header">
530530
<span>Card heading</span>
531531
</h3>
@@ -538,9 +538,8 @@ <h3 slot="pfe-card--header">
538538
</pfe-card>
539539

540540
<pfe-card pfe-color="accent"
541-
pfe-img-src="https://web-dev-drupal-carobert.dev.a1.vary.redhat.com/cms/managed-files/bkgd-training-value-2000x727.png"
542-
class="custom-styles PFElement" pfelement="" has_body="" has_footer="" pfe-type="container" on="saturated"
543-
style="background-image: url(&quot;https://web-dev-drupal-carobert.dev.a1.vary.redhat.com/cms/managed-files/bkgd-training-value-2000x727.png&quot;);">
541+
pfe-img-src="https://www.redhat.com/cms/managed-files/bkgd-training-value-2000x727.png"
542+
class="custom-styles">
544543
<pfe-icon icon="rh-atom" circled="lightest" size="lg">
545544
<h3 class="pfe-headline-3">Card heading</h3>
546545
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore

0 commit comments

Comments
 (0)