Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
bierett committed Dec 19, 2023
1 parent 0672db8 commit 74dd769
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/packages/toc/Toc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface TocProps extends CommonComponentProps {
/**
* Properties for the embedded tool component.
*/
toolConfig?: ToolConfig;
toolsConfig?: ToolsConfig;

/**
* Defines whether the basemap switcher is shown in the toc.
Expand All @@ -50,7 +50,7 @@ export interface TocProps extends CommonComponentProps {
/**
* Props supported by the {@link Tools} component.
*/
export interface ToolConfig {
export interface ToolsConfig {
/**
* Optional property to show the `hide all layers` entry.
* Defaults to `true`.
Expand All @@ -69,7 +69,7 @@ export const Toc: FC<TocProps> = (props: TocProps) => {
const {
mapId,
showTools = false,
toolConfig,
toolsConfig,
showBasemapSwitcher = true,
basemapSwitcherProps
} = props;
Expand Down Expand Up @@ -116,7 +116,7 @@ export const Toc: FC<TocProps> = (props: TocProps) => {
})}
</Text>
<Spacer />
{showTools && <Tools mapId={mapId} {...toolConfig} />}
{showTools && <Tools mapId={mapId} {...toolsConfig} />}
</Flex>
</SectionHeading>
}
Expand Down
4 changes: 2 additions & 2 deletions src/packages/toc/Tools.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ it("Should successfully hide all layers in toc", async () => {

await findTools();

const itemButton = await screen.findByLabelText("hideAllLayers");
const itemButton = await screen.findByLabelText("tools.hideAllLayers");
expect(itemButton.tagName).toBe("BUTTON");

expect(operationalLayers.length).toBe(2);
Expand All @@ -88,7 +88,7 @@ it("Should successfully hide all layers in toc", async () => {

async function findTools() {
const tocDiv = await screen.findByTestId("toc");
return tocDiv.querySelector(".tools");
return tocDiv.querySelector(".toc-tools");
}

async function findMenu() {
Expand Down
12 changes: 6 additions & 6 deletions src/packages/toc/Tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { FC } from "react";
import { FiMoreVertical } from "react-icons/fi";
import { useIntl } from "open-pioneer:react-hooks";
import { MapModel, SublayersCollection, useMapModel } from "@open-pioneer/map";
import { ToolConfig } from "./Toc";
import { ToolsConfig } from "./Toc";

export const Tools: FC<{ mapId: string } & ToolConfig> = (props) => {
export const Tools: FC<{ mapId: string } & ToolsConfig> = (props) => {
const intl = useIntl();
const { mapId, showHideAllLayers = true } = props;
const { map } = useMapModel(mapId);
Expand All @@ -24,11 +24,11 @@ export const Tools: FC<{ mapId: string } & ToolConfig> = (props) => {

return (
!noEntry && (
<Box className="tools">
<Box className="toc-tools">
<Menu placement="bottom-start">
<Button
as={MenuButton}
className="tools-button"
className="toc-tools-button"
aria-label={intl.formatMessage({ id: "toolsLabel" })}
borderRadius="full"
iconSpacing={0}
Expand All @@ -39,12 +39,12 @@ export const Tools: FC<{ mapId: string } & ToolConfig> = (props) => {
<Portal>
<MenuList className="tools-menu">
<MenuItem
aria-label={intl.formatMessage({ id: "hideAllLayers" })}
aria-label={intl.formatMessage({ id: "tools.hideAllLayers" })}
onClick={() => {
hideAllLayers(map);
}}
>
{intl.formatMessage({ id: "hideAllLayers" })}
{intl.formatMessage({ id: "tools.hideAllLayers" })}
</MenuItem>
</MenuList>
</Portal>
Expand Down
8 changes: 4 additions & 4 deletions src/packages/toc/__snapshots__/Tools.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

exports[`Should successfully create a toc with default tool component 1`] = `
<div
class="tools css-0"
class="toc-tools css-0"
data-theme="light"
>
<button
aria-controls="menu-list-:r3:"
aria-expanded="false"
aria-haspopup="menu"
aria-label="toolsLabel"
class="chakra-menu__menu-button chakra-button tools-button css-yfj65e"
class="chakra-menu__menu-button chakra-button toc-tools-button css-yfj65e"
data-theme="light"
id="menu-button-:r3:"
type="button"
Expand Down Expand Up @@ -69,7 +69,7 @@ exports[`Should successfully create a toc with default tool component 2`] = `
tabindex="-1"
>
<button
aria-label="hideAllLayers"
aria-label="tools.hideAllLayers"
class="chakra-menu__menuitem css-18esm8n"
data-index="0"
data-theme="light"
Expand All @@ -78,7 +78,7 @@ exports[`Should successfully create a toc with default tool component 2`] = `
tabindex="-1"
type="button"
>
hideAllLayers
tools.hideAllLayers
</button>
</div>
`;
4 changes: 2 additions & 2 deletions src/packages/toc/i18n/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ messages:
missingLayers: "Es sind keine Layer vorhanden."
error: "Beim Erstellen des Karteninhalts ist ein Fehler aufgetreten."
toolsLabel: "Kartenwerkzeuge"
hideAllLayers: "Alle Karteninhalte ausblenden"
collapseGroups: "Gruppen einklappen"
tools:
hideAllLayers: "Alle Karteninhalte ausblenden"
4 changes: 2 additions & 2 deletions src/packages/toc/i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ messages:
missingLayers: "There are no layers to display."
error: "Error while creating map content."
toolsLabel: "Map tools"
hideAllLayers: "Hide all layers"
collapseGroups: "Collapse groups"
tools:
hideAllLayers: "Hide all layers"
2 changes: 1 addition & 1 deletion src/packages/toc/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)
// SPDX-License-Identifier: Apache-2.0
export { Toc, type TocProps, type ToolConfig } from "./Toc";
export { Toc, type TocProps, type ToolsConfig } from "./Toc";

0 comments on commit 74dd769

Please sign in to comment.