Skip to content

Commit

Permalink
(feat) O3-4362 add Location Picker to the top nav
Browse files Browse the repository at this point in the history
  • Loading branch information
chibongho committed Feb 24, 2025
1 parent 7fec697 commit 0aaf0b8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HeaderGlobalAction } from '@carbon/react';
import { LocationIcon, navigate, useSession } from '@openmrs/esm-framework';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Button, SwitcherItem } from '@carbon/react';
import { LocationIcon, navigate, useSession } from '@openmrs/esm-framework';
import styles from './change-location-link.scss';

const ChangeLocationLink: React.FC = () => {
Expand All @@ -18,15 +18,14 @@ const ChangeLocationLink: React.FC = () => {
};

return (
<SwitcherItem aria-label="Change Location" className={styles.panelItemContainer}>
<div>
<LocationIcon size={20} />
<p>{currentLocation}</p>
</div>
<Button kind="ghost" onClick={changeLocation}>
{t('change', 'Change')}
</Button>
</SwitcherItem>
<HeaderGlobalAction
aria-label={t('changeLocation', 'Change location')}
className={styles.changeLocationButton}
onClick={changeLocation}
>
<LocationIcon size={16} />
<span className={styles.currentLocationText}>{currentLocation}</span>
</HeaderGlobalAction>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use '@carbon/layout';
@import '~@openmrs/esm-styleguide/src/vars';
@import '../root.scss';

Expand All @@ -11,3 +12,15 @@
display: flex;
align-items: center;
}

.changeLocationButton {
width: fit-content;
background-color: transparent;
color: white;
font-size: 14px;
padding: layout.$spacing-04 !important; // this gets unset in rtl language without !important
}

.currentLocationText {
padding-inline-start: layout.$spacing-03;
}
2 changes: 1 addition & 1 deletion packages/apps/esm-login-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
{
"name": "location-changer",
"slot": "user-panel-slot",
"slot": "top-nav-info-slot",
"component": "changeLocationLink",
"online": true,
"offline": true,
Expand Down
1 change: 1 addition & 0 deletions packages/apps/esm-login-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"builtWith": "Built with",
"cancel": "Cancel",
"change": "Change",
"changeLocation": "Change location",
"changePassword": "Change password",
"changingPassword": "Changing password",
"confirmPassword": "Confirm new password",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const HeaderItems: React.FC = () => {
<Logo />
</div>
</ConfigurableLink>
<ExtensionSlot className={styles.dividerOverride} name="top-nav-info-slot" />
<div className={styles.divider} />
<ExtensionSlot name="top-nav-info-slot" />
<HeaderGlobalBar className={styles.headerGlobalBar}>
<ExtensionSlot name="top-nav-actions-slot" className={styles.topNavActionsSlot} />
<ExtensionSlot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@
height: layout.$spacing-09;
width: layout.$spacing-09;
padding: layout.$spacing-04;
margin-right: layout.$spacing-02;
margin-inline-end: layout.$spacing-02;
}

.spacedLogo {
margin-left: layout.$spacing-05;
margin-inline-start: layout.$spacing-05;
}

.divider {
width: 1px;
height: 24px;
background-color: rgba(244, 244, 244, 0.4);
margin-inline-start: layout.$spacing-04;
}

0 comments on commit 0aaf0b8

Please sign in to comment.