Closed olizilla closed 4 years ago
Also, it's worth noting that pulling components into a shared library can harm the dev experience if means you often have to npm link
the component library into your app so you can fix the shared components to work in your new use-case. I learn towards avoiding making overly generic components in favour of sharing good composable basic ones. If a component ends up with numerous props to customise it, and internal logic to deal with the variety, splitting it out into 2 simpler components is usually easier to reason about.
Worth considering
Hi all, I’m Gilad and I’m a core maintainer at Bit. I will happily shed some light on Bit’s sorcery :slightly_smiling_face: I think it can be a useful solution to this problem. For example, here’s an example of what Grommet are in the process of doing with Bit: https://bit.dev/grommet.
As you can see, every component can now be reused in other projects and even developed from multiple projects at the same time while changes can be synced. All the components are available in the collection and can be shared, discovered and playd with. This will not require any refactoring for the library. You can learn more here: https://docs.bit.dev/whybit/for-libs.html. Alternatively you can even save the need for the library altogether and just share components from different places into one collection.
What do you think? I’d love to help
Thanks @GiladShoham we're testing Bit out! @cwaring @fsdiogo can you add your feedback here as you go?
The learning curve seems quite low as the commands are all Git-like 👍
In a few minutes we had a collection with a few components, imported them from Bit and they worked out-of-the-box in our apps, so that is awesome 👌✨
A pain point we experienced is when we have dependencies higher up in the tree: we're using Tachyons and others and importing them in a global CSS file. So, to make our components "stylezed" in Bit, we've got to import those libs in each component on our collection (AFAIK). Is there a way to import a dependency globally to our collection?
I'm happy to see that you find Bit easy to use :) It's humbling to see an awesome team liking it!
We are working right now on the ability to add dependencies globally. So you can add Tachyons as a dependency to all components (or a subset...). It is part of the overrides feature (that is already merged). I expect it to be available in the next couple of weeks.
I can update you on its availability here if you'd like.
Awesome! Please do @GiladShoham!
Storybook is getting docs n blocks n mdx - https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a
Any update on tachyons (&c) support, @GiladShoham? Thanks!
@ericronne and I kicked around some ideas on this today and concluded that Bit neatly helps us achieve the goals we have for the first version of our component library. So I'm going to run an extended test based on ipfs-webui
soon 👌
@fsdiogo @olizilla @ericronne @cwaring I'm happy to hear you find Bit useful for your project :)
We've just published a new version for Bit (14.1.0). It supports a new workflow for manipulating Bit's automated dependency definition. It allows forcing a dependency to all components, even if they don't explicitly require it.
I'll assume that you are already tracking the styles component, and name it styles-component
.
Edit the workspace configuration and add the overrides
key. Note that you can set it for specific components or groups of components.
{
"bit": {
"overrides": {
"*": { // Add the css-component as dependency to all workspace components
"dependencies": {
"@bit/css-component": "+" // bit defines the version automatically, as defined in the workspace
}
},
"utils/*": { // if there are some components that don't need the dependency, you can use the override to remove dependencies
"dependencies": {
"@bit/css-component": "-"
}
}
}
}
}
You can read a bit more about it here.
If you need any help, you can open an issue in the main git repo, comment to this thread, or say 'hi' on gitter.
Thank you @GiladShoham, this looks ideal. I'll test it out and let you know how we get on :)
Closing in favor of https://github.com/ipfs/ipfs-gui/issues/29 (and linking to this issue inside it as well, so work isn't lost).
We want to reuse our UI componets across at least ipfs-webui, ipfs-desktop, ipfs-share-files. We want to define the patterns we have to creating our presentational components, in terms of component styling, and overrides, and i18n and bundling locale dictionaries when the componet is used in an app.
We believe we want a shared component library. A dev experience of
would be nice, epecially if it could automagically sort out adding the additional i18n keys to the bundle.
Prior art:
Puzzle pieces:
tx
for pulling locale dictionaries from transifexNext steps:
Starting from the gui-team principles... take a look at https://github.com/ipfs-shipyard/ipld-explorer-components
to start with, but it has the problem that if
ma4
is the default, and the caller tries to applyma2
as an override it will not work as the class will end up with both in its class list, and then its down to document order in the css file as to which one wins, in this example, the defaultma4
occurs afterma2
so it does not apply. I think we can figure out a neat solution to that tho.t
function and call that with i18n key names that they need. Alternatives are to create props for each label that appears in the component, and then write a container that maps those props to i18n keys. This could be neat if we use thepath/to/the/Component.fooLabel
as the key. In general you want to make it easy to have sensible defaults and possible to override them when the compent is used in a different setting. It's worth highlighting that really atomic components like<Button>
should not have any awareness of i18n, as their text will change with every use case, but something like a<DeleteButtonWithConfirmation/>
might benefit from sharing good default explanation text, that would need localising.