facebookincubator / infima

A UI framework that provides websites with the minimal CSS and JS needed to get started with building a modern responsive beautiful website
https://infima.dev
MIT License
408 stars 55 forks source link

Question about adding JavaScript to components #309

Closed frankieali closed 3 months ago

frankieali commented 3 months ago

I've been reviewing the project's source and running yarn start to check out the demo file and yarn website:start to check out the docusaurus build. I see that several components have JavaScript that goes with them, and it works well in the demo file, but it doesn't seem like that JavaScript makes it into the docusaurus build. I was wonder if/how you would package JavaScript with a theme component? I'm asking because I was interested in developing some 3rd party components using the --ifm- variables. However, some components I'd like to add, such as a modal and tooltips, would require a slight bit of JavaScript. I'm wondering how this could be done. Would I have to make a plug-in package to go with the theme package?

slorber commented 3 months ago

The JS files used in Infima are here for documentation purpose/demo only and are never used by Docusaurus.

I'd advise not use Infima in third-party packages. I plan to make Infima disappear, and make it an implementation detail of the Docusaurus classic theme later. Depending on it is likely to break in unexpected ways in the future because we do breaking changes on implementation details.

If you want to provide themed components to Docusaurus users, you'd rather create a regular npm package with React code. React 19 (Docusaurus v4, soon) is going to make it much easier to share CSS alongside your components.