-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented scorecard legend view
- Loading branch information
Showing
12 changed files
with
176 additions
and
43 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
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
27 changes: 27 additions & 0 deletions
27
...c/modules/Main/components/ScorecardViewPage/ScorecardLegendsView/ScorecardLegendsView.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,27 @@ | ||
import { ArrowLegendsView } from "./components/ArrowLegendView"; | ||
import { ScorecardConfig } from "@hisptz/dhis2-analytics"; | ||
import { LegendView } from "./components/LegendView"; | ||
|
||
export function ScorecardLegendsView({ config }: { config: ScorecardConfig }) { | ||
const legendDefinitions = config.legendDefinitions; | ||
|
||
return ( | ||
<div | ||
style={{ gap: 16, padding: "0 16px" }} | ||
className="row align-items-center space-between" | ||
> | ||
<div | ||
style={{ | ||
display: "grid", | ||
gap: 8, | ||
gridTemplateColumns: `repeat(${legendDefinitions.length}, auto)`, | ||
}} | ||
> | ||
{legendDefinitions.map((item) => ( | ||
<LegendView legend={item} key={item.id} /> | ||
))} | ||
</div> | ||
<ArrowLegendsView /> | ||
</div> | ||
); | ||
} |
27 changes: 27 additions & 0 deletions
27
...les/Main/components/ScorecardViewPage/ScorecardLegendsView/components/ArrowLegendView.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,27 @@ | ||
import { IconArrowDown24, IconArrowUp24 } from "@dhis2/ui"; | ||
import i18n from "@dhis2/d2-i18n"; | ||
import { useScorecardState } from "../../state/state"; | ||
|
||
export function ArrowLegendsView(props: any) { | ||
const [state] = useScorecardState(); | ||
const showArrows = state.options.arrows; | ||
|
||
if (!showArrows) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div | ||
style={{ gap: 16, display: "grid", gridTemplateColumns: "1fr 1fr" }} | ||
> | ||
<div style={{ gap: 8 }} className="row align-items-center"> | ||
<IconArrowUp24 /> | ||
{i18n.t("Increased from last period")} | ||
</div> | ||
<div style={{ gap: 8 }} className="row align-items-center"> | ||
<IconArrowDown24 /> | ||
{i18n.t("Decreased from last period")} | ||
</div> | ||
</div> | ||
); | ||
} |
23 changes: 23 additions & 0 deletions
23
.../modules/Main/components/ScorecardViewPage/ScorecardLegendsView/components/LegendView.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,23 @@ | ||
import { LegendDefinition } from "@hisptz/dhis2-analytics"; | ||
|
||
export interface LegendViewProps { | ||
legend: LegendDefinition; | ||
} | ||
|
||
export function LegendView({ legend }: LegendViewProps) { | ||
const { color, name, id } = legend; | ||
return ( | ||
<div key={id} className="row align-items-center"> | ||
<div | ||
style={{ | ||
width: 60, | ||
height: 25, | ||
background: color, | ||
border: "1px solid rgb(232, 237, 242)", | ||
padding: 16, | ||
}} | ||
/> | ||
<p style={{ paddingLeft: 8, marginRight: 8 }}>{name}</p> | ||
</div> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/app/src/modules/Main/components/ScorecardViewPage/ScorecardLegendsView/index.ts
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 @@ | ||
export * from "./ScorecardLegendsView"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2933,15 +2933,15 @@ | |
dependencies: | ||
"@hapi/hoek" "^9.0.0" | ||
|
||
"@hisptz/dhis2-analytics@^2.0.16": | ||
version "2.0.16" | ||
resolved "https://registry.yarnpkg.com/@hisptz/dhis2-analytics/-/dhis2-analytics-2.0.16.tgz#063e3bbc48cdad98ba6bee5a7c10b07aa7c97b31" | ||
integrity sha512-dwa73O/W/N+qXbSM0ariEMPeie08cpvpXZvH6/mPUtSj4W5rKJVzBtCu6oWhfDEQS29hthjFZNktL/zyysfiBQ== | ||
"@hisptz/dhis2-analytics@^2.0.17": | ||
version "2.0.17" | ||
resolved "https://registry.yarnpkg.com/@hisptz/dhis2-analytics/-/dhis2-analytics-2.0.17.tgz#cf5f24ca8ac2050b0626534df8ef31bb2ed8519e" | ||
integrity sha512-rekZp29fQsul2rJhIu1ILaZ+mMwJoT8eRCY6ZJaIgjG2oMSPJ++XaIY2yWLiNNinQwLokWBvp7GGO6kIMkJZTw== | ||
dependencies: | ||
"@dhis2/multi-calendar-dates" "^1.2.3" | ||
"@dnd-kit/core" "^6.1.0" | ||
"@dnd-kit/utilities" "^3.2.2" | ||
"@hisptz/dhis2-ui" "2.0.13" | ||
"@hisptz/dhis2-ui" "2.0.14" | ||
"@hisptz/dhis2-utils" "2.0.5" | ||
"@react-leaflet/core" "^2.1.0" | ||
"@tanstack/react-table" "^8.19.3" | ||
|
@@ -2962,12 +2962,11 @@ | |
screenfull "^6.0.2" | ||
zod "^3.23.8" | ||
|
||
"@hisptz/dhis2-analytics@^2.0.17": | ||
version "2.0.17" | ||
resolved "https://registry.yarnpkg.com/@hisptz/dhis2-analytics/-/dhis2-analytics-2.0.17.tgz#cf5f24ca8ac2050b0626534df8ef31bb2ed8519e" | ||
integrity sha512-rekZp29fQsul2rJhIu1ILaZ+mMwJoT8eRCY6ZJaIgjG2oMSPJ++XaIY2yWLiNNinQwLokWBvp7GGO6kIMkJZTw== | ||
"@hisptz/dhis2-analytics@^2.0.18": | ||
version "2.0.18" | ||
resolved "https://registry.yarnpkg.com/@hisptz/dhis2-analytics/-/dhis2-analytics-2.0.18.tgz#b4ee2dd12119a4f60e2275f620195fb9eadf5b4c" | ||
integrity sha512-v/rDP/XQ1zTdsKgN0gMys6BQt4llfxJm354IndLioojxD5hd8OPv0kVVgxq4rxTvYr+88vPrmLoqZUOdLGkvYQ== | ||
dependencies: | ||
"@dhis2/multi-calendar-dates" "^1.2.3" | ||
"@dnd-kit/core" "^6.1.0" | ||
"@dnd-kit/utilities" "^3.2.2" | ||
"@hisptz/dhis2-ui" "2.0.14" | ||
|
@@ -2991,25 +2990,6 @@ | |
screenfull "^6.0.2" | ||
zod "^3.23.8" | ||
|
||
"@hisptz/[email protected]": | ||
version "2.0.13" | ||
resolved "https://registry.yarnpkg.com/@hisptz/dhis2-ui/-/dhis2-ui-2.0.13.tgz#c9ee3ff9ab54324b447bb6c9cd7fe3a04cbe522d" | ||
integrity sha512-qlapKYJSr3Yxgw7wz0VhVLKxzoPz8C9pYs3qLFg8zVSIZ9Cdfm+frQ27UCRzJaSH2WiSFkp6WyFXA+jvnJkFdg== | ||
dependencies: | ||
"@hisptz/dhis2-utils" "2.0.5" | ||
classnames "^2.5.1" | ||
dexie "^3.2.3" | ||
jodit-react "^1.3.39" | ||
lodash "^4.17.21" | ||
luxon "^3.4.4" | ||
react-circular-progressbar "^2.1.0" | ||
react-collapsible "^2.10.0" | ||
react-color "^2.19.3" | ||
react-hook-form "^7.51.5" | ||
recoil "^0.7.7" | ||
styled-components "^6.1.8" | ||
usehooks-ts "^2.9.2" | ||
|
||
"@hisptz/[email protected]", "@hisptz/dhis2-ui@^2.0.14": | ||
version "2.0.14" | ||
resolved "https://registry.yarnpkg.com/@hisptz/dhis2-ui/-/dhis2-ui-2.0.14.tgz#acf1f0af8383c0d3a6fdfa555a97d23dc6e17cb3" | ||
|