-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) O3-3774: Add implementation for the Nav Group (#1116)
* Add nav group extension * Update docs * clean up * Remove unnecessary components * update docs * clean up * update t * define feature name for nav group * update docs * make group title translatable * update docs * tweak title translation and slot name * update api docs * register the global nav group extension * update docs * clean up * PR reviews * Update docs * Move nav group to primary-navigation-app --------- Co-authored-by: Ian <[email protected]>
- Loading branch information
1 parent
0e40c94
commit 4a39d52
Showing
7 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/apps/esm-primary-navigation-app/src/components/nav-group/nav-group.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Accordion, AccordionItem } from '@carbon/react'; | ||
import { ExtensionSlot, useConfig, Type } from '@openmrs/esm-framework'; | ||
|
||
export const navGroupFeatureName = 'Nav Group'; | ||
|
||
export const navGroupConfigSchema = { | ||
title: { | ||
_type: Type.String, | ||
_description: 'The title of the nav group.', | ||
_default: 'My Group', | ||
}, | ||
slotName: { | ||
_type: Type.String, | ||
_description: 'The name of the slot to create, which links can be added to.', | ||
}, | ||
isExpanded: { | ||
_type: Type.Boolean, | ||
_description: 'The boolean to determine whether the nav group is expanded or not.', | ||
_default: false, | ||
}, | ||
}; | ||
|
||
export interface NavGroupConfig { | ||
title: string; | ||
slotName: string; | ||
isExpanded?: boolean; | ||
} | ||
|
||
interface NavGroupProps { | ||
basePath?: string; | ||
} | ||
|
||
export function NavGroup({ basePath }: NavGroupProps) { | ||
const { t } = useTranslation(); | ||
const { title, isExpanded, slotName } = useConfig<NavGroupConfig>(); | ||
|
||
return ( | ||
<Accordion> | ||
<AccordionItem open={isExpanded} title={t(title)}> | ||
<ExtensionSlot name={slotName ?? `nav-group-${title}`} state={{ basePath }} /> | ||
</AccordionItem> | ||
</Accordion> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters