Skip to content

Commit

Permalink
retrofits NodePositionProvider and withNodePosition from @trbl/react-…
Browse files Browse the repository at this point in the history
…node-position, creates JumplistNode component and maintains nodes in context, #5 and #7
  • Loading branch information
jacobsfletch committed Dec 12, 2019
1 parent 2c208d4 commit d2df4cf
Show file tree
Hide file tree
Showing 17 changed files with 475 additions and 15,369 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules
.DS_Store
.DS_Store
yarn-error.log
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,22 @@ $ yarn add @trbl/react-jumplist

```jsx
import React from 'react';
import { JumplistProvider, Jumplist } from '@trbl/react-jumplist';
import { JumplistProvider, JumplistNav, JumplistNode } from '@trbl/react-jumplist';

const App = () => {
return (
<JumplistProvider>
<Jumplist
<JumplistNav
list={[
{
clickableNode: <p>Click to jump<p>,
targetId: 'jump-target',
clickableNode: <p>...<p>,
targetID: 'yourID',
}
]}
/>
<div id="jump-target" />
<JumplistNode id="yourID">
...
</JumplistNode>
</JumplistProvider>
)
}
Expand All @@ -53,8 +55,11 @@ $ open http://localhost:3000

All available props can be found via the references below:

- [Jumplist](/src/Jumplist/README.md)
- [JumplistContext](/src/JumplistContext/README.md)
- [JumplistNav](/src/JumplistNav/README.md)
- [JumplistNode](/src/JumplistNode/README.md)
- [JumplistProvider](/src/JumplistProvider/README.md)
- [withJumplistContext](/src/withJumplistContext/README.md)

## License

Expand Down
28 changes: 16 additions & 12 deletions demo/App.demo.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import React, { Fragment } from 'react';
import React from 'react';
import { JumplistProvider } from '../src'; // swap '../src' for '../dist/build.bundle' to demo production build
import JumplistDemo from './Jumplist.demo';

const AppDemo = () => {
return (
<Fragment>
<style
dangerouslySetInnerHTML={{ __html: `
.demo__jumplist__item--is-in-frame::after {
content: ' is in frame';
}
` }}
<JumplistProvider
classPrefix="demo"
frameOffset={100}
>
<JumplistDemo />
<div
style={{
position: 'fixed',
top: '100px',
right: '100px',
bottom: '100px',
left: '100px',
outline: 'dashed rgba(0, 0, 0, .15) 2px',
}}
/>
<JumplistProvider classPrefix="demo">
<JumplistDemo />
</JumplistProvider>
</Fragment>
</JumplistProvider>
);
};

Expand Down
92 changes: 62 additions & 30 deletions demo/Jumplist.demo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Fragment } from 'react';
import { Jumplist } from '../src'; // swap '../src' for '../dist/build.bundle' to test production
import { JumplistNav, JumplistNode } from '../src'; // swap '../src' for '../dist/build.bundle' to test production

const formatClickableNode = string => (
<li
Expand All @@ -15,31 +15,38 @@ const formatClickableNode = string => (
const JumplistDemo = () => {
return (
<Fragment>
<div style={{ position: 'fixed', zIndex: '1', backgroundColor: 'white' }}>
<style
dangerouslySetInnerHTML={{ __html: `
.demo__jumplist-nav__item--is-in-frame::after {
content: ' is in frame';
}
` }}
/>
<div style={{ position: 'fixed', zIndex: '1' }}>
<code>
<pre>
classPrefix: demo
classPrefix: demo,
<br />
htmlElement: div
htmlElement: div,
<br />
threshold: 0
threshold: 0,
<br />
vOffset: -100
vOffset: -100,
<br />
hOffset: -100
hOffset: -100,
<br />
{'list: {'}
<br />
&emsp; object
&emsp; object
<br />
&emsp; object
&emsp; object
<br />
&emsp; onject
&emsp; onject
<br />
{'}'}
</pre>
</code>
<Jumplist
<JumplistNav
id="demo-id"
vScrollOffset={-100}
hScrollOffset={-100}
Expand All @@ -57,64 +64,89 @@ const JumplistDemo = () => {
list={[
{
clickableNode: formatClickableNode('Jump to whitesmoke'),
targetId: 'whitesmoke',
targetID: 'whitesmoke',
},
{
clickableNode: formatClickableNode('Jump to gainsboro'),
targetId: 'gainsboro',
targetID: 'gainsboro',
},
{
clickableNode: formatClickableNode('Jump to silver'),
targetId: 'silver',
targetID: 'silver',
},
{
clickableNode: formatClickableNode('Jump to gray'),
targetId: 'gray',
targetID: 'gray',
},
{
clickableNode: formatClickableNode('Jump to lightblue'),
targetId: 'lightblue',
targetID: 'lightblue',
},
{
clickableNode: formatClickableNode('Jump to blue'),
targetId: 'blue',
targetID: 'blue',
},
]}
/>
</div>
<div style={{ display: 'flex' }}>
<div
className="vertical-overflow"
style={{ width: '150vw', flexShrink: '0' }}
style={{
width: '150vw', flexShrink: '0',
}}
>
<div
<JumplistNode
id="whitesmoke"
style={{ height: '500px', backgroundColor: 'whitesmoke', marginBottom: '10px' }}
style={{
height: '500px',
backgroundColor: 'whitesmoke',
marginBottom: '10px',
}}
/>
<div
<JumplistNode
id="gainsboro"
style={{ height: '250px', backgroundColor: 'gainsboro', marginBottom: '10px' }}
style={{
height: '250px',
backgroundColor: 'gainsboro',
marginBottom: '10px',
}}
/>
<div
<JumplistNode
id="silver"
style={{ height: '1500px', backgroundColor: 'silver', marginBottom: '10px' }}
style={{
height: '1500px',
backgroundColor: 'silver',
marginBottom: '10px',
}}
/>
<div
<JumplistNode
id="gray"
style={{ height: '2000px', backgroundColor: 'gray' }}
style={{
height: '2000px',
backgroundColor: 'gray',
}}
/>
</div>
<div
className="horizontal-overflow"
style={{ flexShrink: '0' }}
>
<div
<JumplistNode
id="lightblue"
style={{ height: '1000px', width: '125vw', backgroundColor: 'lightblue', display: 'inline-block' }}
style={{ height: '1000px',
width: '125vw',
backgroundColor: 'lightblue',
display: 'inline-block',
}}
/>
<div
<JumplistNode
id="blue"
style={{ height: '1000px', width: '500px', backgroundColor: 'blue', display: 'inline-block' }}
style={{ height: '1000px',
width: '500px',
backgroundColor: 'blue',
display: 'inline-block',
}}
/>
</div>
</div>
Expand Down
29 changes: 21 additions & 8 deletions dist/build.bundle.js

Large diffs are not rendered by default.

Loading

0 comments on commit d2df4cf

Please sign in to comment.