Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
854ebd0
Add fake navbar to demo page; tidy demo CSS, shorten length of paragr…
starryeyez024 Jul 9, 2020
3d50fa1
Update elements/pfe-jump-links/demo/index.html
starryeyez024 Jul 10, 2020
49059ff
Merge branch 'master' into pfe-jump-links-demo
castastrophe Jul 20, 2020
e4b5a4e
Merge branch 'master' into pfe-jump-links-demo
castastrophe Jul 23, 2020
805d0ec
Update elements/pfe-jump-links/src/pfe-jump-links-nav.scss
starryeyez024 Jul 30, 2020
3b9fed2
added placeholder text to fix reported height and added click event f…
Djfaucette Aug 4, 2020
dc8e7f9
Merge branch 'master' into pfe-jump-links-demo
kylebuch8 Aug 4, 2020
bc63a69
close accordion fixes
kylebuch8 Aug 4, 2020
3023ed0
added teardown of event listeners in disconnected callback
Djfaucette Aug 4, 2020
e140bc7
modified attributes to be backwards compatible
Djfaucette Aug 5, 2020
2344165
fixed link colors in darkest variant
Djfaucette Aug 5, 2020
5178254
updated styling for darkest variant
Djfaucette Aug 5, 2020
5c38b75
found closer to spec light blue
Djfaucette Aug 5, 2020
e2a032c
updated report height function to report correct height and update on…
Djfaucette Aug 5, 2020
eb85fe6
WIP got the spacer working
Djfaucette Aug 12, 2020
bdb2ac4
Merge branch 'master' into pfe-jump-links-demo
Djfaucette Aug 12, 2020
c70f853
Merge branch 'pfe-jump-links-demo' of https://github.com/patternfly/p…
Djfaucette Aug 12, 2020
2941fa5
went bug smushing and won
Djfaucette Aug 12, 2020
5a801b8
added warning for using css values with units
Djfaucette Aug 12, 2020
b873def
got slotted css working
Djfaucette Aug 17, 2020
9fccf0d
Merge branch 'master' into pfe-jump-links-demo
Djfaucette Aug 17, 2020
7665ad7
removing duped code
Djfaucette Aug 17, 2020
7fddb27
remove interpolation from variable
starryeyez024 Oct 7, 2020
3d17e1a
silly change for a netlify re-deploy
Djfaucette Oct 19, 2020
eb11664
Merge branch 'master' into pfe-jump-links-demo
Djfaucette Oct 19, 2020
67ab5ce
edited css offset to match the spacer
Djfaucette Oct 19, 2020
81927ac
Merge branch 'master' into pfe-jump-links-demo
castastrophe Oct 20, 2020
9cd6eae
fixing up tests to pass with the new shadowroot
Djfaucette Oct 20, 2020
e58aac9
enhancing to be backwards compatible with old attr names
Djfaucette Oct 20, 2020
7c557fc
Branch was auto-updated with the latest.
github-actions[bot] Oct 20, 2020
47a3ae4
Branch was auto-updated with the latest.
github-actions[bot] Oct 21, 2020
91c7de9
added new css hooks to documentation
Djfaucette Oct 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ Many commands have an optional argument of space-separated component name(s), if
# Build and watch all components, run the server to preview demo pages
npm run dev



# Run, watch, and build one or more component(s)
=======
# Build and watch on one or more components, run the server to preview demo pages
npm run dev [component-name(s)]
```
Expand Down
8 changes: 5 additions & 3 deletions elements/pfe-jump-links/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@


## Usage
This component is focused on reading content inside the <pfe-jump-links-panel> and updating a sidebar or horizontal nav with 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 nav, or have the nav build a DOM tree for you. Please note the shape of the DOM tree below. In order to support sub-section highlighting jump links must be very opinionated about the DOM tree.
This component is focused on reading content inside the <pfe-jump-links-panel> and updating a sidebar or horizontal 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 nav, or have the nav build a DOM tree for you. Please note the shape of the DOM tree below. In order to support sub-section highlighting jump links must be very opinionated about the DOM tree.

Inside of <pfe-jump-links-panel> add the class .pfe-jump-links-panel__section to tell the component to watch for when that section crosses the scroll threshold. If this section has sub-sections you 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 will match to the href attribute of the corresponding <a> tag.
Inside of <pfe-jump-links-panel> add the class .pfe-jump-links-panel__section to tell the component to watch for when that section crosses the scroll threshold. If this section has sub-sections you 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.

## Wiring up the nav
The panel and nav are wired up by a scrolltarget and id. On the panel add an attribute scrolltarget="foo". This will correspond to the nav's #id. Add the corresponding id to your nav like so id="foo". The last step is to match the <a> tag's href attribute to specific sections (just like we would with same page anchor links). See below for a simple example with three sections where section two has two sub-sections:
The panel and nav are wired up by a scrolltarget and id. On the panel add an attribute scrolltarget="foo". This will correspond to the nav's #id. Add the corresponding id to your nav like so 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:

```html
<pfe-jump-links-nav id="jumplinks1" default>
Expand Down Expand Up @@ -84,6 +84,8 @@ No extra roles or aria labels are required because we're using standard html tag

- `style="--pfe-jump-links-panel--offset: {integer};"`: You can control offset in your styling layer as well. This value can be set directly on the component inside a style attribute, e.g. `style="--pfe-jump-links-panel--offset: 100;"` or using the appropriate selector in another file. Please note that adding an attribute will take precedence over a css value. At the moment only integer values passed to this key are valid. No other values are supported. This means that passing "300px", "2rem","calc(100% - 12px)" will all result in JavaScript errors. You should pass a number that correlates to pixels. To read about the `pfe-c-offset` attribute, see above.

- `style="--pfe-jump-links-panel__section--spacer: {integer}{unit};"`: pfe-jump-links are built with native behavior in terms of anchor links and scroll. That means that clicking a nav link will adjust the viewport to show the top of that section aligned with the top of the browser. This native browser is undesirable in certain cases such as working with a "sticky" navigation bar or other elements placed outside of the normal document flow. The panel components inserts a "spacer" just before each section that can be manipulated with this custom property. Specify a unit along with an integer like so: `--pfe-jump-links-panel__section--spacer: 100px;`.

## Events
This component fires an event when a link is made active.

Expand Down
72 changes: 72 additions & 0 deletions elements/pfe-jump-links/demo/demo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
html {
background: #eee;
scroll-behavior: smooth;
}

:root{
--pfe-navigation--Height--actual: 55px;
--pfe-jump-links--nav-height: 62px;
--pfe-jump-links-panel__section--spacer: 117px;
--pfe-jump-links-panel--offset: 120px;
}

a.pfe-jump-links-nav__item {
/* Just in here for sanity knowing outside styles can't leak in */
color: orange !important;
}

.sticky {
position: sticky;
top: 55px;
}


/* SET OFFSET */
/* .special {
--pfe-jump-links-panel--offset: 100;
--pfe-jump-links__nav--offset: 100px;
}
@media(max-width: 992px) {
.special{
--pfe-jump-links-panel--offset: 60px;
--pfe-jump-links__nav--offset: 60px;
}
} */

/*
* Fixing the issue where the headers are under the stick nav
* https://stackoverflow.com/questions/4086107/fixed-page-header-overlaps-in-page-anchors
*/


/* FAKE NAV BAR */
#navbar {
position: fixed;
top: 0;
width: 100%;
overflow: hidden;
background-color: #333;
height: var(--pfe-navigation--Height--actual);
}

#navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/*
.pfe-jump-links__section--spacer {
content: '';
display: block;
position: relative;
width: 0;
margin-top: -64px;
height: 64px;
margin-top: calc( -1 * var(--pfe-jump-links-panel__section--spacer) );
height: var(--pfe-jump-links-panel__section--spacer);
} */

Loading