diff --git a/frontend/src/components/CustomGlobalStyle.ts b/frontend/src/components/CustomGlobalStyle.ts index 73577d592..c7142d0c6 100644 --- a/frontend/src/components/CustomGlobalStyle.ts +++ b/frontend/src/components/CustomGlobalStyle.ts @@ -74,4 +74,8 @@ html { } } + h2 { + line-height: normal; + } + ` diff --git a/frontend/src/features/Dashboard/components/DashboardForm/Accordion.tsx b/frontend/src/features/Dashboard/components/DashboardForm/Accordion.tsx index cb0d73aea..339347e15 100644 --- a/frontend/src/features/Dashboard/components/DashboardForm/Accordion.tsx +++ b/frontend/src/features/Dashboard/components/DashboardForm/Accordion.tsx @@ -12,7 +12,11 @@ type AccordionProps = { export function Accordion({ children, headerButton, isExpanded, setExpandedAccordion, title }: AccordionProps) { return ( - + {title} {headerButton} @@ -25,7 +29,9 @@ export function Accordion({ children, headerButton, isExpanded, setExpandedAccor /> - {children} + + {children} + ) } @@ -48,7 +54,7 @@ const TitleContainer = styled.div` display: flex; gap: 16px; ` -const Title = styled.span` +const Title = styled.h2` font-size: 16px; font-weight: 500; ` diff --git a/frontend/src/features/Dashboard/components/DashboardForm/RegulatoryAreas/Panel.tsx b/frontend/src/features/Dashboard/components/DashboardForm/RegulatoryAreas/Panel.tsx index db8948b73..c61ef9556 100644 --- a/frontend/src/features/Dashboard/components/DashboardForm/RegulatoryAreas/Panel.tsx +++ b/frontend/src/features/Dashboard/components/DashboardForm/RegulatoryAreas/Panel.tsx @@ -15,7 +15,7 @@ import styled from 'styled-components' const FOUR_HOURS = 4 * 60 * 60 * 1000 -export function RegulatoryPanel({ $marginLeft, dashboardId }: { $marginLeft: number; dashboardId: number }) { +export function RegulatoryPanel({ className, dashboardId }: { className: string; dashboardId: number }) { const dispatch = useAppDispatch() const openPanel = useAppSelector(state => state.dashboard.dashboards?.[dashboardId]?.openPanel) @@ -38,7 +38,7 @@ export function RegulatoryPanel({ $marginLeft, dashboardId }: { $marginLeft: num } return ( - + {regulatoryMetadata ? ( <>
@@ -74,16 +74,12 @@ export function RegulatoryPanel({ $marginLeft, dashboardId }: { $marginLeft: num ) } -const Wrapper = styled.div<{ $isOpen: boolean; $marginLeft: number }>` +const Wrapper = styled.div<{ $isOpen: boolean }>` background-color: ${p => p.theme.color.white}; box-shadow: 0px 3px 5px #70778540; position: absolute; width: 400px; z-index: 1; - left: ${p => - `calc( - ${p.$marginLeft}px + 40px + 64px + 20px - )`}; // 40px is the padding, 64px is the width of the lsidebar, 20px is the margin ` const RegulatoryZoneName = styled.span` diff --git a/frontend/src/features/Dashboard/components/DashboardForm/RegulatoryAreas/index.tsx b/frontend/src/features/Dashboard/components/DashboardForm/RegulatoryAreas/index.tsx index 8e2440865..a39cbf385 100644 --- a/frontend/src/features/Dashboard/components/DashboardForm/RegulatoryAreas/index.tsx +++ b/frontend/src/features/Dashboard/components/DashboardForm/RegulatoryAreas/index.tsx @@ -3,31 +3,30 @@ import { LayerSelector } from '@features/layersSelector/utils/LayerSelector.styl import { useAppSelector } from '@hooks/useAppSelector' import { pluralize } from '@mtes-mct/monitor-ui' import { groupBy } from 'lodash' -import { useRef, useState } from 'react' +import { useState } from 'react' import styled from 'styled-components' import { ListLayerGroup } from './ListLayerGroup' import { RegulatoryPanel } from './Panel' import { Accordion } from '../Accordion' -import { SmallAccordion } from '../SmallAccordion' +import { SelectedAccordion } from '../SelectedAccordion' import type { RegulatoryLayerCompactFromAPI } from 'domain/entities/regulatory' type RegulatoriesAreasProps = { + columnWidth: number dashboardId: number isExpanded: boolean regulatoryAreas: RegulatoryLayerCompactFromAPI[] | undefined setExpandedAccordion: () => void } export function RegulatoryAreas({ + columnWidth, dashboardId, isExpanded, regulatoryAreas, setExpandedAccordion }: RegulatoriesAreasProps) { - const ref = useRef(null) - const width = ref.current?.clientWidth - const selectedLayerIds = useAppSelector( state => state.dashboard.dashboards?.[dashboardId]?.[Dashboard.Block.REGULATORY_AREAS] ) @@ -39,8 +38,8 @@ export function RegulatoryAreas({ const selectedRegulatoryAreasByLayerName = groupBy(selectedRegulatoryAreaIds, r => r.layer_name) return ( -
- +
+ - setExpandedSmallAccordion(!isExpandedSmallAccordion)} @@ -84,7 +83,7 @@ export function RegulatoryAreas({ /> ) })} - +
) } @@ -92,3 +91,9 @@ export function RegulatoryAreas({ const StyledLayerList = styled(LayerSelector.LayerList)` height: auto; ` +const StyledPanel = styled(RegulatoryPanel)<{ $marginLeft: number }>` + left: ${p => + `calc( + ${p.$marginLeft}px + 40px + 64px + )`}; // 40px is the padding, 64px is the width of the sidebar +` diff --git a/frontend/src/features/Dashboard/components/DashboardForm/SmallAccordion.tsx b/frontend/src/features/Dashboard/components/DashboardForm/SelectedAccordion.tsx similarity index 81% rename from frontend/src/features/Dashboard/components/DashboardForm/SmallAccordion.tsx rename to frontend/src/features/Dashboard/components/DashboardForm/SelectedAccordion.tsx index c3ce599f1..999518be1 100644 --- a/frontend/src/features/Dashboard/components/DashboardForm/SmallAccordion.tsx +++ b/frontend/src/features/Dashboard/components/DashboardForm/SelectedAccordion.tsx @@ -1,7 +1,7 @@ import { Accent, Icon, IconButton } from '@mtes-mct/monitor-ui' import styled from 'styled-components' -type AccordionProps = { +type SelectedAccordionProps = { children: React.ReactNode isExpanded: boolean isReadOnly?: boolean @@ -9,16 +9,20 @@ type AccordionProps = { title: string } -export function SmallAccordion({ +export function SelectedAccordion({ children, isExpanded, isReadOnly = false, setExpandedAccordion, title -}: AccordionProps) { +}: SelectedAccordionProps) { return ( - + {title} @@ -31,7 +35,9 @@ export function SmallAccordion({ /> )} - {children} + + {children} + ) } @@ -39,7 +45,6 @@ export function SmallAccordion({ const AccordionContainer = styled.div` background-color: ${p => p.theme.color.blueGray25}; box-shadow: 0px 3px 6px #70778540; - cursor: pointer; padding-bottom: 4px; ` const StyledIconButton = styled(IconButton)<{ $isExpanded: boolean }>` @@ -48,6 +53,7 @@ const StyledIconButton = styled(IconButton)<{ $isExpanded: boolean }>` ` const AccordionHeader = styled.header` color: ${p => p.theme.color.blueYonder}; + cursor: pointer; display: flex; font-weight: 500; justify-content: space-between; diff --git a/frontend/src/features/Dashboard/components/DashboardForm/index.tsx b/frontend/src/features/Dashboard/components/DashboardForm/index.tsx index 9e4da3899..d32dd4432 100644 --- a/frontend/src/features/Dashboard/components/DashboardForm/index.tsx +++ b/frontend/src/features/Dashboard/components/DashboardForm/index.tsx @@ -3,7 +3,7 @@ import { SideWindowContent } from '@features/SideWindow/style' import { useAppDispatch } from '@hooks/useAppDispatch' import { useAppSelector } from '@hooks/useAppSelector' import { Accent, Icon, IconButton } from '@mtes-mct/monitor-ui' -import { useState } from 'react' +import { useRef, useState } from 'react' import styled from 'styled-components' import { Accordion } from './Accordion' @@ -13,6 +13,9 @@ import { dashboardActions } from '../../slice' export function DashboardForm() { const extractedArea = useAppSelector(state => state.dashboard.extractedArea) + const firstColumnRef = useRef(null) + const firstColumnWidth = firstColumnRef.current?.clientWidth + const dispatch = useAppDispatch() const dashboardId = 1 // TODO replace with real value const [expandedAccordionFirstColumn, setExpandedAccordionFirstColumn] = useState( @@ -51,8 +54,9 @@ export function DashboardForm() { return ( - +