Skip to content

Commit

Permalink
Merge pull request #6 from selsa-inube/ja/1413/Adjust_and_export_inte…
Browse files Browse the repository at this point in the history
…rfaces

Adjust and export interfaces
  • Loading branch information
wfercanas committed Apr 1, 2024
2 parents 85e78a9 + 420a906 commit efe5c61
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
26 changes: 17 additions & 9 deletions src/Nav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ interface ILink {
path: string;
}

interface ISection {
interface INavSection {
name: string;
links: { [key: string]: ILink };
}

interface INavigation {
interface INavNavigation {
title: string;
sections: { [key: string]: ISection };
sections: { [key: string]: INavSection };
}

interface INav {
navigation: INavigation;
navigation: INavNavigation;
logoutPath: string;
logoutTitle: string;
}
Expand All @@ -55,7 +55,7 @@ const Links = (props: INavLink) => {
return <>{LinkElements} </>;
};

const MultiSections = ({ navigation }: Pick<INav, "navigation">) => {
const MultiSections = ({ navigation }: INav) => {
const sections = Object.keys(navigation.sections);

return (
Expand Down Expand Up @@ -87,7 +87,7 @@ const MultiSections = ({ navigation }: Pick<INav, "navigation">) => {
);
};

const OneSection = ({ navigation }: Pick<INav, "navigation">) => {
const OneSection = ({ navigation }: INav) => {
const section = Object.keys(navigation.sections).join();

return (
Expand Down Expand Up @@ -117,9 +117,17 @@ const Nav = (props: INav) => {
{navigation.title}
</Text>
{Object.keys(navigation.sections).length > 1 ? (
<MultiSections navigation={navigation} />
<MultiSections
navigation={navigation}
logoutPath={logoutPath}
logoutTitle={logoutTitle}
/>
) : (
<OneSection navigation={navigation} />
<OneSection
navigation={navigation}
logoutPath={logoutPath}
logoutTitle={logoutTitle}
/>
)}
<SeparatorLine />
<NavLink
Expand Down Expand Up @@ -148,4 +156,4 @@ const Nav = (props: INav) => {
};

export { Nav };
export type { INav, INavLink, ILink, ISection, INavigation };
export type { INav, INavLink, ILink, INavSection, INavNavigation };
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export { Nav } from "./Nav";
export { NavLink } from "./NavLink";
export type { INav, ILink, INavSection, INavNavigation } from "./Nav";
export type { INavLink } from "./NavLink";
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineConfig({
"react-dom",
"styled-components",
"react/jsx-runtime",
"react-icons",
"react-icons/md",
"react-router-dom",
"@inubekit/foundations",
"@inubekit/stack",
Expand Down

0 comments on commit efe5c61

Please sign in to comment.