-
-
Notifications
You must be signed in to change notification settings - Fork 957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API for React Wrapper #49
Comments
Probably want to have a single driver instance for the app/page. Potential solution could be to create a HOC called
Then, when you use the |
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>
);
}
} |
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 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 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. |
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 What do you think? |
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. |
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... |
I've got this to work so far, only supporting the highlight api.
Also this is based on writing it externally, but I'm open to ideas on how it should be bundled. It could either be a separate package, or exported from this one. i.e any of:
import {DriverReactWrapper as Driver} from 'driver.js'
import Driver from 'driver.js/react'
import Driver from 'driver.js.react'
For the most simple use case, I was thinking:
This works fine- I've set up a create-react-app to test it, with below replacing the
App.js
.It would also be good if the
driver.js
supported something like driver.highlight(element), so you could pass in a dom element as an argument instead of a selector. I don't think it would be very hard to achieve with how the code is currently.The text was updated successfully, but these errors were encountered: