Comments (6)
Probably want to have a single driver instance for the app/page.
Potential solution could be to create a HOC called withDriver
, and wrap a component high up in the tree, which will pass down a driver instance as a prop.
withDriver(Root)
Then, when you use the DriverWrapper
, you pass a reference to the driver instance which can be passed through the props down the tree.
from driver.js.
Hey, while this looks good, I was thinking about a little different implementation to keep it simple and more generic for any use-case. We export a single component with which user provides all the options and then we subscribe to the lifecycle hooks of the component and manipulate the driver:
Below is the example to give you a better idea
import Driver from 'react-driver';
export class App extends React.Component {
render: function () {
return (
<div className="app">
<Driver
ref="driver"
start={true} // boolean for when you want to start it
steps={[arrayOfSteps]} // this would be the array of step definitions
highlight={element} // or you can pass this to highlight single element
animate={true}
opacity={0.75}
...
/>
<YourComponents .../>
</div>
);
}
}
from driver.js.
Hmmm. How would you envision accessing the elements for the highlight/steps? For the highlight, It may be better to pass a reference to the driver down the tree to wherever you want to highlight - or even something like highlight: (element) => this.driver.highlight(element)
. We could even make it smarter and allow the wrapper's highlight to accept a component as the argument, and use ReactDOM.findDomNode()
to get a reference to the DOM element.
Additionally, I'm not sure how you would come up with an array of steps here without deeply knowing how the tree looks further into <YourComponents...>
which kind of breaks the idea of encapsulation, unless I'm misunderstanding your suggestion.
BTW string refs are considered legacy, https://reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs, so I'd avoid using them.
from driver.js.
How would you envision accessing the elements for the highlight/steps?
We don't need to access them in the wrapper, Driver would do that for us; you just need to pass the query selectors. I was thinking that the wrapper won't have anything react
ish, it will just be a super simple single component using Driver behind the scenes the same way that we use it normally; except instead of initializing the Driver
directly etc, we will do it through the wrapper. The component will just expose the options as attributes and proxy them over to the instance of Driver
that it will create internally.
What do you think?
from driver.js.
Using the query selectors isn't a very react-y way of doing this - But I'm still not sure on the best way to do steps without it. It's hard because the very concept of steps breaks encapsulation in any case. I might write up a quick wrapper that only supports highlight for now, and you can see what you think. Will post it here when I'm done.
from driver.js.
https://github.com/James-E-Adams/react-driver.js
I still need to solve an issue with parcel/how I'm exporting the module though...
from driver.js.
Related Issues (20)
- How to add image in popover HOT 1
- 'Unable to preventDefault inside passive event listener invocation.' Console Error When Hooking into Lifecycle Methods
- Purely programmatic step?
- Add onOverlayClicked callback
- Can ‘getConfig("animate")’ be replaced with ‘isAnimatedTour’ ?
- Can ‘getConfig("animate")’ be replaced with ‘isAnimatedTour’ ?
- Is there a way to make the overlay mask fixed to an element area instead of the entire body? HOT 1
- (Re) Support the feature to move next on click outside the element
- Can the position of a popover be fixed?
- Can this work with Canvas elements? HOT 2
- How can I make the popup display while the project can be clicked normally?
- How can I customize a popover and button using MUI?
- Step positions are erratic HOT 1
- Missing data
- [Suggestion] Add disableActiveInteraction to Drive Step Configuration.
- Skip step for missing element
- [Feature Request] Expose step index in DOM HOT 1
- Hide "previous" button on step 1 HOT 1
- [Bug] Methods hasNextStep and hasPreviousStep do not return boolean HOT 1
- [Feature Request] Lifecycle events HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from driver.js.