Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) O3-2901: Add a page header to the home page #186

Merged
merged 28 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
34ac8f9
home page header
arodidev Feb 27, 2024
d37a0ec
Update translations file
arodidev Feb 27, 2024
a9f7c8a
cleanup
arodidev Feb 27, 2024
1ac66bc
load header via extension
arodidev Feb 28, 2024
23104a2
loaded header via extension
arodidev Feb 28, 2024
de7456c
Merge branch 'adding-header-to-homepage' of https://github.com/arodid…
arodidev Feb 28, 2024
e29cac0
remove tertiary files
arodidev Feb 28, 2024
f35a74a
Merge branch 'adding-header-to-homepage' of https://github.com/arodid…
arodidev Feb 29, 2024
301f188
removed tertiary files commited
arodidev Feb 29, 2024
4eeeb65
removed extra committed files
arodidev Feb 29, 2024
c2de7e9
cleanup
arodidev Feb 29, 2024
634ff0c
Merge branch 'adding-header-to-homepage' of https://github.com/arodid…
arodidev Feb 29, 2024
1add09a
yarn.lock
arodidev Feb 29, 2024
fcca606
PR reviews
arodidev Feb 29, 2024
ef35d02
cleanup
arodidev Mar 1, 2024
b9c9d0e
PR review resolutions
arodidev Mar 5, 2024
489ad06
updated translations
arodidev Mar 5, 2024
c2110da
Update packages/esm-home-app/src/homepage-header-date/homepage-header…
arodidev Mar 21, 2024
80b6b50
PR reviews
arodidev Mar 21, 2024
67753b4
translations and cleanup
arodidev Mar 21, 2024
d3c6214
Merge branch 'main' into adding-header-to-homepage
arodidev Apr 3, 2024
aba4da2
PR review resolutions
arodidev Apr 3, 2024
04273c2
Merge branch 'openmrs:main' into adding-header-to-homepage
arodidev Apr 4, 2024
3d59aba
Merge branch 'openmrs:main' into adding-header-to-homepage
arodidev Apr 4, 2024
cb972c6
reinstate RTL style overrides
arodidev Apr 16, 2024
9702c0e
translations
arodidev Apr 16, 2024
9a10002
Name changes
arodidev Apr 16, 2024
333f9ec
Useful tweaks
denniskigen Apr 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
denniskigen marked this conversation as resolved.
Show resolved Hide resolved
import { Calendar } from '@carbon/react/icons';
import styles from './homepage-header-date.scss';
import { formatDate } from '@openmrs/esm-framework';

export const HomepageHeaderDate = () => {
return (
<React.Fragment>
<Calendar size={16} />
<span className={styles.value}>{formatDate(new Date(), { mode: 'standard' })}</span>
</React.Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.value{
margin-left: 0.25rem
}
arodidev marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Location } from '@carbon/react/icons';
import { ConfigObject, useConfig, useSession } from '@openmrs/esm-framework';
import { DatePicker, DatePickerInput } from '@carbon/react';
import dayjs from 'dayjs';
import styles from './homepage-header.scss';
import HomepageIllustration from './homepage-illustration.component';
import { HomepageHeaderDate } from '../homepage-header-date/homepage-header-date.component';

interface HomepageHeaderProps {
dashboardTitle: string;
}

const HomepageHeader: React.FC<HomepageHeaderProps> = ({ dashboardTitle }) => {
const { t } = useTranslation();
const session = useSession();
const location = session?.sessionLocation?.display;
denniskigen marked this conversation as resolved.
Show resolved Hide resolved
const config = useConfig() as ConfigObject;
denniskigen marked this conversation as resolved.
Show resolved Hide resolved

return (
<div className={styles.header} role="banner">
<div className={styles['left-justified-items']}>
<HomepageIllustration />
<div className={styles['page-labels']}>
<p>{t('home', config.appNameLabel)}</p>
<p className={styles['page-name']}>{dashboardTitle}</p>
</div>
</div>
<div className={styles['right-justified-items']}>
<div className={styles['date-and-location']}>
<Location size={16} />
<span className={styles.value}>{location}</span>
<span className={styles.middot}>&middot;</span>
<HomepageHeaderDate />
</div>
</div>
</div>
);
};

export default HomepageHeader;
85 changes: 85 additions & 0 deletions packages/esm-home-app/src/homepage-header/homepage-header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
@use '@carbon/colors';
@use '@carbon/layout';
@use '@carbon/type';
@import '~@openmrs/esm-styleguide/src/vars';

.header {
@include type.type-style('body-compact-02');
color: $text-02;
height: layout.$spacing-12;
background-color: $ui-02;
border-bottom: 1px solid $ui-03;
display: flex;
justify-content: space-between;
}

.left-justified-items {
display: flex;
flex-direction: row;
align-items: center;
cursor: pointer;
}

.right-justified-items {
@include type.type-style('body-compact-02');
color: $text-02;
margin: 1rem;
}

.page-name {
@include type.type-style('heading-04');
}

.page-labels {
margin: 1rem 0;

p:first-of-type {
margin-bottom: 0.25rem;
}
}

.date-and-location {
display: flex;
justify-content: flex-end;
align-items: center;
}

.dropdownContainer {
display: flex;
justify-content: flex-end;
}

.value {
margin-left: 0.25rem;
}

.middot {
margin: 0 0.5rem;
}

.view {
@include type.type-style('label-01');
}

.datePicker {
background-color: transparent;
width: 10rem;
border: none;

&>input {
color: colors.$blue-10;
}
}

// Overriding styles for RTL support
html[dir='rtl'] {
.date-and-location {
&>svg {
order: -1;
}

&>span:nth-child(2) {
order: -2;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';

const HomepageIllustration: React.FC = () => {
return (
<svg width="92" height="94" viewBox="0 0 92 94" xmlns="http://www.w3.org/2000/svg">
<title>Homepage illustration</title>
denniskigen marked this conversation as resolved.
Show resolved Hide resolved
<g fill="none" fillRule="evenodd">
<path fill="#FFF" d="M0 0h92v94H0z" />
<path
d="M40 32c.84-.602 1.12-1.797 1-3 .12-5.005-3.96-9-9-9s-9.12 3.995-9 9c-.12 3.572 2.1 6.706 5 8-6.76 1.741-12 7.91-12 15v15h28V32h-4zM76 67V52c0-7.09-5.24-13.278-12-15 2.9-1.294 5.12-4.428 5-8 .12-5.005-3.96-9-9-9s-9.12 3.995-9 9c-.12 1.203.14 2.398 1 3h-4v35h28z"
fill="#CEE6E5"
/>
<path
d="M32 75V60.312c0-7.402 5.24-13.59 12.3-15.216-3.2-1.39-5.42-4.523-5.42-8.166 0-4.935 4.08-8.93 9.12-8.93 5.04 0 9.12 3.995 9.12 8.93 0 3.642-2.22 6.776-5.42 8.166C58.76 46.741 64 52.91 64 60.313V75"
fill="#7BBCB9"
/>
</g>
</svg>
);
};

export default HomepageIllustration;
2 changes: 2 additions & 0 deletions packages/esm-home-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const homeWidgetDbLink = getSyncLifecycle(createDashboardLink(dashboardMe

export const homeWidgetDashboard = getSyncLifecycle(homeWidgetDashboardComponent, options);

export const homePageHeader = getAsyncLifecycle(() => import('./homepage-header/homepage-header.component'), options);

export function startupApp() {
defineConfigSchema(moduleName, esmHomeSchema);
// t('Home', 'Home');
Expand Down
5 changes: 5 additions & 0 deletions packages/esm-home-app/src/openmrs-esm-home-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ export const esmHomeSchema = {
_validators: [validators.isUrlWithTemplateParameters(['patientUuid'])],
},
},
appNameLabel: {
denniskigen marked this conversation as resolved.
Show resolved Hide resolved
_type: Type.String,
_default: 'Home',
_description: 'The name of the frontend app which is appended to the app header.',
},
};
7 changes: 7 additions & 0 deletions packages/esm-home-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
"online": true,
"offline": true
},
{
"name": "home-page-header",
"slot": "home-dashboard-slot",
denniskigen marked this conversation as resolved.
Show resolved Hide resolved
"component": "homePageHeader",
"online": true,
"offline": true
},
{
"name": "home-widget-dashboard",
"slot": "home-dashboard-slot",
Expand Down
1 change: 1 addition & 0 deletions packages/esm-home-app/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"home": "",
pirupius marked this conversation as resolved.
Show resolved Hide resolved
"Home": "Home"
}
Loading