lmc-eu / spirit-design-system

Design system built by Alma Career (former LMC)
https://spirit.design
MIT License
23 stars 1 forks source link

React Tabs: Allow `items` prop to dynamically define tabs #365

Open literat opened 2 years ago

literat commented 2 years ago

Inspiration came from https://react-spectrum.adobe.com/react-spectrum/Tabs.html#content where are tabs created based on a defined object. Maybe we can simplify API to do so only using <Tabs items={items} />.

adamkudrna commented 2 years ago

I remember we also had it this way in RUI. Or to be precise, we had used the object definition in the app, but we changed it to TabItem because (maybe?) the code was easier to read and work with. Maybe we had done something wrong before but I just want to note I have already done the exactly opposite change 🙂. I only wish I could remember the reason 😞.

Originally we had this:

-Tabs.propTypes = {
-  children: PropTypes.node.isRequired,
-  id: PropTypes.string.isRequired,
-  tabs: PropTypes.arrayOf(PropTypes.shape({
-    icon: PropTypes.node,
-    id: PropTypes.string.isRequired,
-    isActive: PropTypes.bool,
-    link: PropTypes.string.isRequired,
-    title: PropTypes.string.isRequired,
-  })).isRequired,
-};

Then we moved Tabs to RUI:

https://github.com/react-ui-org/react-ui/pull/291