Skip to content

Commit

Permalink
Improve ove styling
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeckem committed Jun 12, 2024
1 parent 1071096 commit 15223a9
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 26 deletions.
16 changes: 14 additions & 2 deletions src/packages/react-utils/TitledSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export interface TitledSectionProps {
*/
title?: string | ReactNode | undefined;

/**
* Properties for the automatically generated section heading.
*
* NOTE: This is only applied if `title` is a string.
*/
sectionHeadingProps?: SectionHeadingProps | undefined;

/**
* Children are rendered without any modifications.
*/
Expand Down Expand Up @@ -68,9 +75,14 @@ export interface TitledSectionProps {
* ```
*/
export function TitledSection(props: TitledSectionProps): JSX.Element {
const { title, children } = props;
const { title, sectionHeadingProps, children } = props;
const currentLevel = useContext(LevelContext);
const heading = typeof title === "string" ? <SectionHeading>{title}</SectionHeading> : title;
const heading =
typeof title === "string" ? (
<SectionHeading {...sectionHeadingProps}>{title}</SectionHeading>
) : (
title
);

return (
<>
Expand Down
1 change: 1 addition & 0 deletions src/samples/showcase/showcase-app/build.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { defineBuildConfig } from "@open-pioneer/build-support";

export default defineBuildConfig({
i18n: ["en", "de"],
styles: "./styles.scss",
services: {
MapConfigProviderImpl: {
provides: ["map.MapConfigProvider"],
Expand Down
31 changes: 14 additions & 17 deletions src/samples/showcase/showcase-app/demos/TocLegendDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ export function createTocAndLegendDemo({ intl, mapModel }: SharedDemoOptions): D
title: intl.formatMessage({ id: "demos.tocLegend.title" }),
createModel() {
function setDemoLayerVisible(visible: boolean = true): void {
const layer = mapModel.layers.getLayerById("verwaltungsgebiete") as Layer;
layer.setVisible(visible);
const layer1 = mapModel.layers.getLayerById("verwaltungsgebiete") as Layer;
layer1.setVisible(visible);

const layer2 = mapModel.layers.getLayerById("krankenhaus") as Layer;
layer2.setVisible(visible);
}
function resetDemoLayers(): void {
setDemoLayerVisible(false);
Expand Down Expand Up @@ -51,19 +54,16 @@ function TocLegendView() {
</SectionHeading>
}
>
{/*todo responsive design*/}
<Box overflowY="auto" maxHeight={200}>
<Toc
mapId={MAP_ID}
showTools={true}
basemapSwitcherProps={{
allowSelectingEmptyBasemap: true
}}
/>
</Box>
<Toc
mapId={MAP_ID}
showTools={true}
basemapSwitcherProps={{
allowSelectingEmptyBasemap: true
}}
/>
</TitledSection>
</Box>
<Box role="dialog" aria-labelledby={legendTitleId}>
<Box pt={2} role="dialog" aria-labelledby={legendTitleId}>
<TitledSection
title={
<SectionHeading id={legendTitleId} size="md" mb={2}>
Expand All @@ -73,10 +73,7 @@ function TocLegendView() {
</SectionHeading>
}
>
{/*todo responsive design*/}
<Box overflowY="auto" maxHeight={300}>
<Legend mapId={MAP_ID} showBaseLayers={true} />
</Box>
<Legend mapId={MAP_ID} showBaseLayers={true} />
</TitledSection>
</Box>
</>
Expand Down
4 changes: 3 additions & 1 deletion src/samples/showcase/showcase-app/i18n/de.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
messages:
header:
title: Component Showcase
# NOTE: 'description' supports arbitrary HTML!
ariaLabels:
map: "Karte. Mit den Pfeiltasten kannst du die Karte bewegen. Mit der Plus Taste hineinzoomen und mit der Minus Taste herauszoomen."
demos:
# NOTE: 'description' supports arbitrary HTML!
geolocation:
title: Geolocation
description: Diese Demo zeigt, wie das <code>Geolocation</code>-Tool verwendet werden kann, um die aktuelle Position des Geräts zu erhalten.
Expand Down
4 changes: 3 additions & 1 deletion src/samples/showcase/showcase-app/i18n/en.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
messages:
header:
title: Component Showcase
# NOTE: 'description' supports arbitrary HTML!
ariaLabels:
map: "Map. Use the arrow keys to move the map. Zoom in with the plus button and zoom out with the minus button."
demos:
# NOTE: 'description' supports arbitrary HTML!
geolocation:
title: Geolocation
description: This demo shows how to use the <code>Geolocation</code> tool to get the current position of the device.
Expand Down
15 changes: 15 additions & 0 deletions src/samples/showcase/showcase-app/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.map-anchor.main-map-anchor {
overflow-x: hidden;
overflow-y: auto;
}

.map-container:focus-visible {
border: 3px solid var(--chakra-colors-trails-500);
outline: none;
}

@media screen and (max-width: 48em) {
.map-anchor.main-map-anchor {
max-height: 45%;
}
}
20 changes: 15 additions & 5 deletions src/samples/showcase/showcase-app/ui/AppUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MapAnchor, MapContainer } from "@open-pioneer/map";
import { Notifier } from "@open-pioneer/notifier";
import { TitledSection } from "@open-pioneer/react-utils";
import { useReactiveSnapshot } from "@open-pioneer/reactivity";
import { useService } from "open-pioneer:react-hooks";
import { useIntl, useService } from "open-pioneer:react-hooks";
import { ReactNode } from "react";
import { MAP_ID } from "../MapConfigProviderImpl";
import { AppInitModel, AppStateReady } from "../model/AppInitModel";
Expand All @@ -31,6 +31,7 @@ export function AppUI() {
}

function AppContent(props: { state: AppStateReady }) {
const intl = useIntl();
const appModel = props.state.appModel;
const { currentDemo, currentDemoModel } = useReactiveSnapshot(
() => ({
Expand All @@ -53,12 +54,21 @@ function AppContent(props: { state: AppStateReady }) {
<MapContainer
mapId={MAP_ID}
role="main"
/* TODO: aria-label={intl.formatMessage({ id: "ariaLabel.map" })} */
aria-label={intl.formatMessage({ id: "ariaLabels.map" })}
>
<MapAnchor position="top-left" horizontalGap={10}>
<Box bgColor="whiteAlpha.800">
<TitledSection title={currentDemo.title}>
<MapAnchor
className="main-map-anchor"
position="top-left"
horizontalGap={10}
verticalGap={10}
>
<Box bgColor="white" borderRadius={10} p={2} maxW="500px">
<TitledSection
title={currentDemo.title}
sectionHeadingProps={{ size: "lg" }}
>
<Text
py={4}
dangerouslySetInnerHTML={{
__html: currentDemoModel.description
}}
Expand Down

0 comments on commit 15223a9

Please sign in to comment.