You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix: Update jump links assets
* fix: Update docs
* fix: Revert doc updates
* fix: Minor updates
* fix: Bringing in bug fixes from openshift
* fix: WOrking through issues
* fix: Working through issue with decomment on more complex templates
* fix: Working through horizontal nav styles; moving functionality into jump links nav
* fix: Working through jump links state
* fix: Update package-lock
* fix: Push rendering logic into template
* fix: Resolved horizontal/mobile rendering
* fix: Working through stickiness
* fix: Working through the stack of sticky elements
* fix: Working through stacking
* fix: Incorporate pf variables
* fix: Update formatting in sass files
* fix: Add a global instances registry for each component
* fix: Move find polyfill to pfelement
* fix: Note if an element is visible
* fix: Working through state
* fix: Working through scroll events
* fix: Set git status
* fix: Remove scroll handler for temporary one while smooth scrolling
* fix: Tidying up comments
* fix: Resolve conflict between multiple jump links on a page
* fix: Update mobile experience
* fix: Remove todo note
* fix: Added TODO notes from demo
* fix: Correcting the scroll offset by fixing the sticky state
* fix: Remove unneeded comments
* fix: Add panel change event to events object
* fix: Fix bug in autobuilder and add comments to JS
* fix: Adjust scrollTo if navigation element is stuck
* fix: Adding docs to functions; add change event to setters for panel and sections
* fix: Cleaning up padding and alignment
* fix: Add a few todo notes
* fix: Add jsdoc to pfe-jump-links
* fix: Revert gulp updates
* fix: Updating README
* fix: Update dependencies
* fix: Fixing the calculations
* fix: Remove unused code from panel
* fix: Account for the use of the spacers in the panel
* fix: Update changelo
* fix: Update tests to fix errors; still need to add more tests later
* fix: Jump links brings accordion now so no need to list it twice
* fix: Fussing with styles for Firefox
* fix: Resolve bad filter on NodeList
* fix: Wrap horizontal styles in media query
* fix: Update to use scope instead of children
* fix: Pull out loop into separate method
* fix: Account for height of accordion header on mobile
* feat: Adding todo notes and setting stuck value after scrolling
* fix: Accounting for accordions that aren't sticky yet
* Update elements/pfe-jump-links/src/pfe-jump-links-nav.js
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: CHANGELOG-1.x.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# 1.x.x (TBD)
1
+
# 1.10.0 (2021-07-08)
2
2
3
-
-[](https://github.com/patternfly/patternfly-elements/commit/)chore: Minor testing updates
3
+
-[](https://github.com/patternfly/patternfly-elements/commit/)feat: Jump links navigation rework to support panel customizations and elements in separate DOMs; horizontal designs aligned to kit
Copy file name to clipboardExpand all lines: elements/pfe-jump-links/README.md
+72-21Lines changed: 72 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,31 @@
1
1
# PatternFly Element | Jump links element
2
2
3
-
4
3
## Usage
5
-
This component watches the content inside a `<pfe-jump-links-panel>` and updates the corresponding `<pfe-jump-links-nav>` to indicate the section of the document currently being viewed. As a developer, you have the choice of whether you bring your own markup to the navigation element or have it build for you (see `autobuild` attribute below). Please note the shape of the markup that is required. In order to support sub-section highlighting, jump links must be somewhat opinionated about the DOM tree.
4
+
This component watches the content inside a panel and updates the connected `<pfe-jump-links-nav>` to indicate the section of the document currently being viewed. As a developer, you have the choice of whether you bring your own markup to the navigation or have it build for you (see `autobuild` attribute below). Please note the shape of the markup that is required. In order to support sub-section highlighting, jump links must be somewhat opinionated about the DOM tree.
5
+
6
+
Inside the panel, every section must have at least an `id` present. If using autobuild, the `id` needs to be present on the tag containing the label text or make use of the `nav-label` attribute to manually define the label. The `nav-label` attribute will always take precedence over the text content. For faster processing, include the class `.pfe-jump-links-panel__section` to any elements you want the navigation to watch. Each item meeting these requirements inside a panel are called sections.
7
+
8
+
When each section crosses the scroll threshold, the navigation will highlight to show it is active. If it has sub-sections, the nested children will become visible.
9
+
10
+
If you are manually building the navigation, ensure that every section's id is reflected in the href attribute of the corresponding `<a>` tag (see below).
11
+
12
+
## Wiring up jump links
13
+
14
+
There are a few approaches to connecting a navigation element to a panel.
15
+
16
+
Panels can be:
6
17
7
-
Inside the `<pfe-jump-links-panel>` add the class `.pfe-jump-links-panel__section` to any elements you want the navigation to watch; when that element crosses the scroll threshold, the navigation will highlight to show it is active. If it has sub-sections, add the class `.has-sub-section` to the section parent (i.e. section 8) and add `.sub-section` to the child sections (i.e. 8.1). Make sure to add an id to each section, this id should match to the href attribute of the corresponding `<a>` tag (see below).
18
+
1.`pfe-jump-links-panel` elements with a `scrolltarget` attribute equal to the `id`
19
+
2. Any element with a `scrolltarget` attribute equal to the `id` of the `pfe-jump-links-nav`.
20
+
3. Defined using the panel setter
8
21
9
-
## Wiring up the nav
22
+
For routes 1 and 2 above:
10
23
11
-
The panel and nav are connected via a scrolltarget and id. On the panel, add an attribute `scrolltarget="foo"`. This will correspond to the `pfe-jump-links-nav` on the page with `id="foo"`. The last step is to match the `<a>`tag's href attribute to specific sections (just like you would with same page anchor links). See below for a simple example with three sections where section two has two sub-sections:
24
+
The panel and navigation are connected via a scrolltarget and id. On the panel, add an attribute `scrolltarget="foo"`. This will correspond to the `pfe-jump-links-nav` on the page with `id="foo"`. If you are manually constructing the navigation, the last step is to match the `<a>`tags' href attribute to specific sections (just like you would with anchor links). See below for an example:
12
25
13
26
```html
14
-
<pfe-jump-links-navid="jumplinks1"default>
15
-
<h4slot="pfe-jump-links-nav--heading">Jump to section</h4>
27
+
<pfe-jump-links-navid="jumplinks1">
28
+
<h4slot="heading">Jump to section</h4>
16
29
<ul>
17
30
<li>
18
31
<ahref="#section1">Section 1</a>
@@ -33,29 +46,55 @@ The panel and nav are connected via a scrolltarget and id. On the panel, add an
33
46
</li>
34
47
</ul>
35
48
</pfe-jump-links-nav>
36
-
...
49
+
<!-- For approach #2 above, pfe-jump-links-panel could be substituted for a `div` -->
Using the panel setter requires capturing the `pfe-jump-links-nav` element from the document and setting it's `panel` property equal to the NodeItem you want to use.
Alternatively, you can manually define your sections (rather than their containing panel) by passing a NodeList to the sections setter. If you define the sections manually, you do _not_ need to define their panel.
if (nav && sections &§ions.length>0) nav.sections= sections;
88
+
});
89
+
```
90
+
51
91
### Accessibility
52
92
53
-
The template and DOM structure of this component are as follows:
93
+
The template inside the component are roughly as follows:
54
94
55
95
```html
56
96
<nav>
57
-
<h2hidden>Page navigation</h2> // this is visually hidden
58
-
<h4>Slotted content</h4>
97
+
<h4>Slotted heading (describes function)</h4>
59
98
<ul>
60
99
<li><a>Regular list item</a></li>
61
100
<li><a>List item with sub sections</a></li>
@@ -68,21 +107,33 @@ The template and DOM structure of this component are as follows:
68
107
</nav>
69
108
```
70
109
71
-
No extra roles or aria labels are required because we're using standard html tags in their prescribed uses.
72
-
73
110
## Slots
74
111
112
+
-`heading`: This slot is for the navigation element, `pfe-jump-links-nav` to identify the markup for the list's heading.
75
113
76
-
-`pfe-jump-links-nav--heading`: This slot is for the navigation element, `pfe-jump-links-nav` to identify the markup for the list's heading.
114
+
### Available slots but not currently rendered
115
+
<!-- @TODO We need designs for what to do with the information in these slots -->
116
+
-`cta`: This slot is for the call-to-action for `pfe-jump-links-nav` to identify the markup for the call-to-action element.
117
+
-`logo`: This slot is for the navigation element, `pfe-jump-links-nav` to identify the markup for the navigation logo.
77
118
78
-
The rest of the component works by creating a mirror shadowRoot based on the Light DOM markup.
119
+
The rest of the component works by creating a mirror shadowRoot based on the provided light DOM markup or, if using autobuild, it generates the mark-up based on the identified sections.
79
120
80
121
81
122
## Attributes
82
123
83
-
-`autobuild`: Flips the switch on the component to create its own markup for the navigation. You can add `pfe-jump-links-panel__section` to each section that should show in the nav. If you want to use sub-sections add `has-sub-section` to the parent section that should always show and the `sub-section` class to the children of that section. If you use this attribute, keep in mind that non-JavaScript environments (some search engines, browsers with JS disabled) will not see the proper markup.
124
+
### `pfe-jump-links-nav`
125
+
126
+
-`autobuild`: Creates its own markup for the navigation based on the defined sections.
127
+
128
+
-`horizontal`: Switches rendering of the jump links from vertical to a horizontal, secondary navigation style.
129
+
130
+
-`sr-text`: This attribute is read when the component upgrades to provide the innerText of the heading. If there is no `sr-text` attribute then the component defaults to "Jump to section". This attribute is to enable translations.
131
+
132
+
-`color`: Currently there are 2 options for the background color of the component; lightest or darkest.
133
+
134
+
-`offset`: This attribute determines the distance from the top of the browser window where the `pfe-jump-links-nav` should be attached. For instance `offset="600"` would mean that the component attaches at 600px from the top of the viewport. If this variable has not been set, it calculates the height of the pfe-navigation plus any sticky horizontal navigation
84
135
85
-
-`sr-text`: This attribute is read when the component upgrades to provide the innerText of the heading. If there is no `sr-text` attribute then the component defaults to "Jump to section". This attribute is to enable translations and internationalization.
136
+
### `pfe-jump-links-panel`
86
137
87
138
-`offset`: This attribute determines the distance from the top of the browser window to trigger a switch from one link being active to the next. For instance `offset="600"` would mean that threshold flips at 600px from the top. The default is set at 200, and if you desire 200px then you can leave this attribute off. The `offset` attribute should be placed on `pfe-jump-links-panel`. There is a css solution to control the offset, however the attribute value takes precedence over css. To read more about a css solution see below.
0 commit comments