Closed darkterminal closed 1 year ago
If you would like to continue contributing to open source and would like to do it with an awesome inclusive community, you should join our GitHub Organisation - we help and encourage each other to contribute to open source little and often :neckbeard:. Any questions let us know.
This one is insaaaaane! ⚡️👀 Congratulations !
The Backstory about your JavaScript Metaphor
As I embarked upon the realm of crafting a Next.js project infused with TypeScript, I encountered a profound necessity—a central sidebar menu configuration that would bestow upon us a realm of consistency and scalability. Our noble objective was to fashion a malleable menu system, one that could gracefully accommodate updates and bespoke alterations across an array of pages and components. With TypeScript as our steadfast companion, we sought to harness its formidable power of static typing, thereby fortifying our code with unwavering reliability and unwaning maintainability. Armed with meticulous planning and ingenious design, we embarked upon a grand odyssey—a quest to forge a central sidebar menu configuration, an embodiment of harmonized navigation, and a guarantee of a sublime user experience throughout our illustrious endeavor.
The JavaScript Story!
As we are well aware, when treading the realms of TypeScript, it is incumbent upon us to fashion meticulous definitions. These exquisite artifacts bestow upon us the power to discern errors swiftly during the development process and promptly rectify them.
I am embarking on a project utilizing Next.js App Router and Shadcn-UI. This endeavor marks a new and momentous chapter in my career as a Software Freestyle Engineer.
The Abstract Definition
In the vein of crafting a research journal, I am compelled to fashion an abstract that shall subsequently unfold into a captivating phenomenon of eloquent prose, adorned with a hint of narcissistic flair.
The following code presents a comprehensive definition of TypeScript interfaces and React component prop types for a sidebar component.
The
SubmenuItems
interface delineates the composition of submenu items within the sidebar. It encompasses two properties:label
, denoting the label for the submenu item, andlink
, representing the associated URL link.The
NavItems
interface outlines the structure of navigation items within the sidebar. It encompasses properties such aslabel
for the navigation item label,icon
for the corresponding React element depicting the item's icon,link
for the associated URL link,isParent
to indicate the presence of submenus, and an optionalsubMenu
property of typeSubmenuItems[]
, which facilitates the definition of an array of submenu items.The
SidebarProps
interface extends the HTML attributes of adiv
element and introduces amenus
property of typeNavItems[]
. This property allows for the definition of an array of navigation items to be passed as props to the sidebar component.In essence, this code provides a structured approach to defining types and props required for a sidebar component, promoting seamless utilization and type-checking within a React application.
A Central Sidebar Configuration
The provided code establishes an arrangement for the sidebar navigation menu within a dashboard or application through the definition of an array named
sideMenu
, having a type ofNavItems[]
.Each element within the
sideMenu
array represents a distinct menu item within the sidebar. These elements possess properties such aslabel
for the menu item's label,icon
for associating an icon with the menu item (utilizing theIcons
component),link
for the corresponding URL link, andisParent
to signify whether the menu item contains submenus.The code initializes the
sideMenu
array with various menu items. For instance, "Master Data" serves as a top-level item without an icon. Additionally, other items such as "Master Korcam," "Master Kordes," and so forth, are equipped with icons sourced from theIcons
component, along with their respective links.Furthermore, there exists a "Settings" menu item adorned with the "settings" icon, and
isParent
is set to true, indicating the presence of submenus. The submenus themselves are defined within thesubMenu
property as an array of objects comprisinglabel
andlink
properties.All in all, this code establishes the configuration for a sidebar menu, encompassing an array of menu items complete with labels, icons, links, and submenus. This configuration can be employed to render the sidebar navigation within a React application.
The Sidebar Component
Once we have abstracted our imagination and begun unraveling it into a journey towards the dream we desire—an exquisite center of command for the sidebar menu in our application—it is now time to execute our intentions and bring forth the creation of the sidebar menu component.
The sidebar menu component will dynamically process and categorize the menus defined in
config/sideMenu.tsx
. Isn't this truly impressive? We simply need to define the menus we wish to display on the sidebar within a single configuration file.Here is an illustration showcasing the transformation from the realm of imagination to the realization of our previous endeavors.
[Imagine -> Plan -> Create -> Achieve]
This journey exemplifies the power of imagination and execution in bringing ideas to fruition.
[The Graph - 001] - Sidebar Menu Title & Sidebar Menu Items
[The Graph - 002] - Nested Menu in Sidebar Navigation
The Live Version of Our Imagination
The Last Freestyle Improvisation
As is my custom, I always strive to innovate upon existing foundations while staying true to my own character as a Software Freestyle Engineer.
The default button component provided by Shadcn-UI may not fully satisfy the imaginative requirements we envision. However, with a few modifications, we can transform it into something truly remarkable.
And I awoke from a profoundly beautiful dream, only to discover that the dream had indeed become a reality.
A JavaScript demo/repos link
No response
PayPal Link for Donation (JavaScript Storyteller)
No response