Skip to content

Commit

Permalink
Improve UI
Browse files Browse the repository at this point in the history
  • Loading branch information
anagperal committed Nov 7, 2024
1 parent adc486e commit c235383
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
9 changes: 6 additions & 3 deletions src/utils/tests.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { render, RenderResult } from "@testing-library/react";
import { SnackbarProvider } from "@eyeseetea/d2-ui-components";
import { ReactNode } from "react";
import { MemoryRouter } from "react-router-dom";
import { AppContext, AppContextState } from "../webapp/contexts/app-context";
import { getTestCompositionRoot } from "../CompositionRoot";
import { createAdminUser } from "../domain/entities/__tests__/userFixtures";
Expand Down Expand Up @@ -78,9 +79,11 @@ export function getReactComponent(children: ReactNode): RenderResult {
<MuiThemeProvider theme={muiTheme}>
<ThemeProvider theme={muiTheme}>
<OldMuiThemeProvider muiTheme={muiThemeLegacy}>
<AppContext.Provider value={context}>
<SnackbarProvider>{children}</SnackbarProvider>
</AppContext.Provider>
<MemoryRouter>
<AppContext.Provider value={context}>
<SnackbarProvider>{children}</SnackbarProvider>
</AppContext.Provider>
</MemoryRouter>
</OldMuiThemeProvider>
</ThemeProvider>
</MuiThemeProvider>
Expand Down
10 changes: 7 additions & 3 deletions src/webapp/components/im-team-hierarchy/IMTeamHierarchyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const IMTeamHierarchyView: React.FC<IMTeamHierarchyViewProps> = React.mem
return (
<IMTeamHierarchyViewContainer>
<ContentWrapper>
<SearchInput value={searchTerm} onChange={onSearchChange} />
<SearchInputContainer>
<SearchInput value={searchTerm} onChange={onSearchChange} />
</SearchInputContainer>
{isSelectable && searchTerm && selectedItemIds && selectedItemIds?.length > 0 ? (
<CountSelectionText>
{i18n.t(
Expand Down Expand Up @@ -103,12 +105,14 @@ const StyledIMTeamHierarchyView = styled(TreeViewMUI)`
const ContentWrapper = styled.div`
display: flex;
flex-direction: column;
/* gap: 8px; */
`;

const CountSelectionText = styled.span`
margin-block-start: 10px;
font-weight: 400;
font-size: 0.875rem;
color: ${props => props.theme.palette.common.grey900};
`;

const SearchInputContainer = styled.div`
margin-block-end: 10px;
`;
40 changes: 21 additions & 19 deletions src/webapp/components/layout/side-bar/SideBarContent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { List, ListItem, ListItemText } from "@material-ui/core";
import React, { useCallback } from "react";
import styled from "styled-components";
import { NavLink } from "react-router-dom";
import { NavLink, useLocation } from "react-router-dom";
import { AddCircleOutline } from "@material-ui/icons";
import i18n from "../../../../utils/i18n";
import { Button } from "../../button/Button";
Expand Down Expand Up @@ -46,6 +46,7 @@ export const SideBarContent: React.FC<SideBarContentProps> = React.memo(
({ children, hideOptions = false, showCreateEvent = false }) => {
const { goTo } = useRoutes();
const { getCurrentEventTracker } = useCurrentEventTracker();
const location = useLocation();

const goToCreateEvent = useCallback(() => {
goTo(RouteName.CREATE_FORM, { formType: "disease-outbreak-event" });
Expand All @@ -63,24 +64,25 @@ export const SideBarContent: React.FC<SideBarContentProps> = React.memo(
</CreateEventContainer>
) : (
<StyledList>
{DEFAULT_SIDEBAR_OPTIONS.map(({ text, value }) => (
<ListItem
button
key={text}
component={NavLink}
to={
value === RouteName.EVENT_TRACKER ||
value === RouteName.IM_TEAM_BUILDER
? routes[value].replace(
":id",
getCurrentEventTracker()?.id || ""
)
: routes[value]
}
>
<StyledText primary={i18n.t(text)} selected={false} />
</ListItem>
))}
{DEFAULT_SIDEBAR_OPTIONS.map(({ text, value }) => {
const route =
value === RouteName.EVENT_TRACKER ||
value === RouteName.IM_TEAM_BUILDER
? routes[value].replace(
":id",
getCurrentEventTracker()?.id || ""
)
: routes[value];

return (
<ListItem button key={text} component={NavLink} to={route}>
<StyledText
primary={i18n.t(text)}
selected={location?.pathname === route}
/>
</ListItem>
);
})}
</StyledList>
)}
</SideBarContainer>
Expand Down

0 comments on commit c235383

Please sign in to comment.