From 2b2fabce39f7216efc4b23f40e88943d994df8f5 Mon Sep 17 00:00:00 2001 From: Pedro Vitor Date: Mon, 8 Jan 2024 17:36:48 -0300 Subject: [PATCH 01/26] feat: adds hamburguer menu sections --- dist/index.d.mts | 3 +++ src/utils/context/libraryContext.tsx | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dist/index.d.mts b/dist/index.d.mts index ed02716..bd734d8 100644 --- a/dist/index.d.mts +++ b/dist/index.d.mts @@ -87,6 +87,7 @@ interface Props extends Partial { isPreview: boolean; /** The section currently selected. */ sectionSelected: string; + hamburguerMenuSections: Section[][]; /** The portal language. The default is english. */ locale?: 'en' | 'pt' | 'es'; } @@ -113,6 +114,8 @@ type ContextType = { closeSidebarElements: (parentsArray: string[]) => void; sidebarSections: Section[][]; setSidebarSections: Dispatch>; + hamburguerSections: Section[][]; + setHamburguerSections: Dispatch>; locale: 'en' | 'pt' | 'es'; }; type ActiveItem = { diff --git a/src/utils/context/libraryContext.tsx b/src/utils/context/libraryContext.tsx index 1a62000..8a4171f 100644 --- a/src/utils/context/libraryContext.tsx +++ b/src/utils/context/libraryContext.tsx @@ -15,8 +15,12 @@ interface Props extends Partial { isPreview: boolean /** The section currently selected. */ sectionSelected: string + /** The sections to be used on the hamburguer menu */ + hamburguerMenuSections: Section[][] /** The portal language. The default is english. */ locale?: 'en' | 'pt' | 'es' + + } export type ContextType = { @@ -44,6 +48,8 @@ export type ContextType = { closeSidebarElements: (parentsArray: string[]) => void sidebarSections: Section[][] setSidebarSections: Dispatch> + hamburguerSections: Section[][] + setHamburguerSections: Dispatch> locale: 'en' | 'pt' | 'es' } @@ -80,6 +86,8 @@ export const LibraryContext = createContext({ closeSidebarElements: () => undefined, sidebarSections: [], setSidebarSections: () => undefined, + hamburguerSections: [], + setHamburguerSections: () => undefined, locale: 'en', }) @@ -100,8 +108,10 @@ const LibraryContextProvider = ({ children, ...props }: Props) => { const [sidebarDataMaster, setSidebarDataMaster] = useState(props.fallback) const [isEditorPreview, setIsEditorPreview] = useState(props.isPreview) const [sidebarSections, setSidebarSections] = useState(props.sections) + const [hamburguerSections, setHamburguerSections] = useState(props.hamburguerMenuSections) const locale = 'en' - + + console.log("abacate mal"); useEffect(() => { setSidebarDataMaster(props.fallback) }, [props.fallback]) @@ -200,6 +210,8 @@ const LibraryContextProvider = ({ children, ...props }: Props) => { setSidebarDataMaster, sidebarSections, setSidebarSections, + hamburguerSections, + setHamburguerSections, locale, ...props, }} From 2b5cec4586d48b14c01e22fa443b2498ba0b1310 Mon Sep 17 00:00:00 2001 From: Pedro Vitor Date: Tue, 9 Jan 2024 10:39:01 -0300 Subject: [PATCH 02/26] fix: removing test log --- src/utils/context/libraryContext.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/context/libraryContext.tsx b/src/utils/context/libraryContext.tsx index 8a4171f..5b28cc8 100644 --- a/src/utils/context/libraryContext.tsx +++ b/src/utils/context/libraryContext.tsx @@ -111,7 +111,6 @@ const LibraryContextProvider = ({ children, ...props }: Props) => { const [hamburguerSections, setHamburguerSections] = useState(props.hamburguerMenuSections) const locale = 'en' - console.log("abacate mal"); useEffect(() => { setSidebarDataMaster(props.fallback) }, [props.fallback]) From d968801b75f5a440850c4e8b1658ee5d3deba2f7 Mon Sep 17 00:00:00 2001 From: Pedro Vitor Date: Tue, 9 Jan 2024 10:59:04 -0300 Subject: [PATCH 03/26] refactor: hamburguer menu props comment --- dist/index.d.mts | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/index.d.mts b/dist/index.d.mts index bd734d8..418fa5e 100644 --- a/dist/index.d.mts +++ b/dist/index.d.mts @@ -87,6 +87,7 @@ interface Props extends Partial { isPreview: boolean; /** The section currently selected. */ sectionSelected: string; + /** The sections to be used on the hamburguer menu */ hamburguerMenuSections: Section[][]; /** The portal language. The default is english. */ locale?: 'en' | 'pt' | 'es'; From 48681d0aa18a666cbee140ff02f497d050a3881a Mon Sep 17 00:00:00 2001 From: Pedro Vitor Date: Tue, 9 Jan 2024 11:24:46 -0300 Subject: [PATCH 04/26] fix: adds hamburguer menu fallback to storybook --- src/utils/storybook-constants.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/utils/storybook-constants.tsx b/src/utils/storybook-constants.tsx index 9bbdab5..9272663 100644 --- a/src/utils/storybook-constants.tsx +++ b/src/utils/storybook-constants.tsx @@ -22,6 +22,25 @@ export const sections = [ ], ] +export const hamburguerSections = [ + [ + { + Icon: APIGuidesIcon, + title: 'Guides', + description: 'Guides description', + link: '#', + }, + ], + [ + { + Icon: APIReferenceIcon, + title: 'Reference', + description: 'Reference description', + link: '#', + }, + ], +] + export const navigationLocale = [ { documentation: 'Guides', @@ -95,6 +114,7 @@ export const exampleContextProps = { isPreview: false, sectionSelected: '', fallback: navigation, + hamburguerMenuSections: hamburguerSections } export const exampleContextPropsLocale = { From 74f704fa7dd8e5aef23d40e77194a5b7920e8c09 Mon Sep 17 00:00:00 2001 From: Pedro Vitor Date: Tue, 9 Jan 2024 16:12:38 -0300 Subject: [PATCH 05/26] feat: changes from sidebar sections to hamburguer menu sections --- src/lib/hamburger-menu/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/hamburger-menu/index.tsx b/src/lib/hamburger-menu/index.tsx index 603a17f..910bbe0 100644 --- a/src/lib/hamburger-menu/index.tsx +++ b/src/lib/hamburger-menu/index.tsx @@ -29,6 +29,8 @@ const HamburgerMenu = ({ parentsArray = [] }: HamburgerMenuProps) => { setActiveSectionName, setSidebarSectionHidden, sidebarSections, + hamburguerSections, + setHamburguerSections } = context updateOpenPage({ parentsArray, context }) @@ -42,7 +44,7 @@ const HamburgerMenu = ({ parentsArray = [] }: HamburgerMenuProps) => { - {sidebarSections.map((section, id) => ( + {hamburguerSections.map((section, id) => ( 0 From 27e047c775805845cdf34a151aad2f0beb9246e6 Mon Sep 17 00:00:00 2001 From: Pedro Vitor Date: Fri, 12 Jan 2024 16:13:56 -0300 Subject: [PATCH 06/26] feat: manages iconcarent if is a document --- src/lib/hamburger-menu/index.tsx | 45 ++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/lib/hamburger-menu/index.tsx b/src/lib/hamburger-menu/index.tsx index 910bbe0..31d00e8 100644 --- a/src/lib/hamburger-menu/index.tsx +++ b/src/lib/hamburger-menu/index.tsx @@ -30,9 +30,18 @@ const HamburgerMenu = ({ parentsArray = [] }: HamburgerMenuProps) => { setSidebarSectionHidden, sidebarSections, hamburguerSections, - setHamburguerSections + setHamburguerSections, } = context + const isDocument = (sections: any, title: string) => { + let isDoc = false + if (Array.isArray(sections)) { + isDoc = sections.find((section) => section.document === title) + } + + return isDoc + } + updateOpenPage({ parentsArray, context }) return ( @@ -57,22 +66,24 @@ const HamburgerMenu = ({ parentsArray = [] }: HamburgerMenuProps) => { {section.map((card) => ( -