Currently, we export a single module that contains every single one of our components. It makes it impossible to treeshake Clarity, or even to write unit tests without compiling the whole library.
On top of that, the number of components we have is starting to be too much for a flat structure, so we need to reorganize the project.
Here is the proposed folder structure for clarity-angular/ (which I just realized is poorly named, since it also contains the source for clarity-ui).
โโ animations (needs a rewrite from scratch)
โโ close
โโ conditional
โ โโ if-active
โ โโ if-expanded
โ โโ if-open
โ โโ ...
โโ loading
โโ scrolling-service (?)
button
โโ button-basic (?)
โโ button-group
โโ button-spinner
code
โโ example (?)
โโ syntax-highlight
colors (all CSS)
data
โโ datagrid
โ โโ (preserve structure for now)
โโ stack-view
โโ table
โโ tree-view
drag-drop
emphasis
โโ alert
โโ badge
โโ label
forms
โโ checkbox
โโ date
โโ input
โโ radio
โโ select
โโ time
โโ toggle
โโ ...
icons
layout
โโ card
โโ grid
โโ login
โโ main-container
โโ nav
โโ tabs
modal
โโ dialog (?)
popover
โโ common (private, do not re-export from PopoverModule)
โโ dropdown
โโ signpost
โโ tooltip
progress
โโ progress-bar
โโ spinner
typography
โโ list
wizard
(?) means the component is either not written yet, not decided on, or possibly not needed anymore.
Each folder declares an Angular module, so that each component can be imported individually by importing its corresponding module. Each folder that contains sub-folders declares a module that exports the corresponding sub-modules.
Of course, modules can depend on one another, but we have to make sure our own modules only import what's strictly necessary. For instance, TreeViewModule will not import all of FormsModule, but only CheckboxModule.
Note that there are a few constraints that we need to respect at all times:
SCSS files will follow their respective components, but note that contrary to Angular components, they can be at the root of a folder that contains sub-folders.
This should be done without breaking changes, which means our main index.ts and ClarityModule need to export the same classes and components as they did before the reorganization.
Thumbs up! For users to import certain components individually will be so nice, great!
Any thoughts on making scoped package (e.g. @clarity/angular) just like Angular is doing right now?
@imcotton: We considered it initially, but if I remember correctly there were some internal constraints at VMware that prevented us from doing so.
These constraints might not exist anymore, so I'll raise this with the team and see if it's now something we want to do.
Hi there ๐, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.
Most helpful comment
Thumbs up! For users to import certain components individually will be so nice, great!