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
Cleanup Datatable / withComponents pattern #2126
Conversation
To provide an example of local replacement this code could replace the table by a grid of items for example: |
I didn't really follow everything but overall it seems like a good idea. I agree making Datatable a bit more verbose is fine if it makes it easier to customize it. Another thing to remember is that we can sometimes use class components to extract a component's logic into a method, and then only override the |
Can you elaborate what you mean by overriding the |
No I just meant that in, for example, the
could be refactored as this:
This way if you want to replace Basically anything we have more than JSX code in the |
dca0505
to
f8f08fb
Compare
Okay I get what you meant. I've just fixed the last commits and tested the code, it works as expected both with and without Material UI, I think we can merge. I'll come back at the DataTable later when I will be on a new project |
Let me add my view on this. I think using class components in which the The approach described by Sacha is a good option for now, it makes things work really well and it keeps stuff at one place so it's easy to maintain for now, while we don't define that many components. And we should keep using this to make logic replaceable too. In the end, I want to be able to switch from bootstrap, to bulma, to material-ui, or ant-design with just two-lines: meteor remove vulcan-ui-bootstrap
meteor add vulcan-ui-antd and ideally it would work out of the box (modulo the custom css / colors / settings / whatever the ui lib requires). So IMO, the initial approach of Eric is good. Even better if we add the method splitting explained by Sacha. It's hard work at the core of Vulcan, but if we do the hardwork at the core of the framework, then no one else has to do it. And that's how the framework will shine and gain momentum. PS: on a more meta note, I want to say that I love working with Vulcan (hence with all its community), and there is so much I want to do to improve it. |
@eric-burel sounds good, feel free to merge this when you have time. @Apollinaire thanks for the meta note! I also love this community :) |
I'll merge for now, I'll stay reachable next week monday or tuesday if this provokes any bug on the Datatable. |
Done so far:
split the visual component of DataTable. It makes it quite verbose, with many small components, but it will make maintaining libs such as
vulcan:material-ui
far easier (@ErikDakoda).Basically this way the only components that needs to be replaced to change the frontend lib now contain zero logic. So we can avoid discrepancies between UI libs every time we update Vulcan.
expose a
withComponents
HOC that fetch the globalComponents
object, merge it with a localcomponents
prop if its present (orformComponent
until we cleanup the Forms again), and pass aComponents
prop.Again this makes the core component implementation verbose (see Datatable), but cleaner. Also, the logic of the datatable could be reused with very different designs.
expose
mergeWithComponents
too (less useful though)This is quite experimental, I'd like to get some feedback on this. I did not observe regressions with Vulcan material-ui for the moment (I added components but did not change existing one that much).
Note that I don't really expect end users to use such features, as they concerns only components that tends to be very reusable (SmartForm, Datatable) and thus should tolerate advanced customization.