Skip to content

Commit

Permalink
Merge pull request #1900 from BaseAdresseNationale/feat/adresse-v2-ca…
Browse files Browse the repository at this point in the history
…rto-ban-step3

Feat/adresse v2  - carto ban step3
  • Loading branch information
nkokla authored Dec 5, 2024
2 parents 503fefb + 86f5741 commit 137781d
Show file tree
Hide file tree
Showing 67 changed files with 1,515 additions and 819 deletions.
2 changes: 1 addition & 1 deletion .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NEXT_PUBLIC_CERTIFICAT_NUMEROTATION_ENABLED=0
ENABLE_HELMET=0

# Internal URL
NEXT_PUBLIC_URL_CARTOGRAPHY_BAN = '/carte-base-adresse-nationale'
NEXT_PUBLIC_URL_CARTOGRAPHY_BAN = /carte-base-adresse-nationale

# -----------------------------------------------
# --- Parametres URL Externe autre projet BAN ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,26 @@ export const AsideWrapper = styled.div<{
z-index: 9;
overflow-x: hidden;
overflow-y: auto;
scroll-behavior: smooth;
scroll-snap-type: y mandatory;
scroll-padding-top: 8rem;
font-size: 1rem;
pointer-events: none;
@media (hover: hover) {
&:hover,
&:focus-within,
&:active {
pointer-events: auto;
}
}
&::before {
${({ $isTypeInfo }) => !$isTypeInfo && css`content: ''`};
display: block;
height: calc(100% - 2.5rem);
height: 100%;
scroll-snap-align: start;
transition: height 0.5s ease;
${({ $isVisible }) => css`
height: ${$isVisible ? 'calc(100% - 2.5rem)' : '100%'};
`}
}
.body {
Expand All @@ -38,15 +45,21 @@ export const AsideWrapper = styled.div<{
max-height: 100%;
overflow-x: hidden;
overflow-y: auto;
box-shadow: 0 0 .5rem -0.125rem rgba(0, 0, 0, 0.7);
scroll-snap-align: start;
${({ $isTypeInfo }) => $isTypeInfo && css`
display: flex;
flex-flow: column nowrap;
justify-content: flex-end;
align-items: center;
padding-bottom: 4rem; `
scroll-snap-stop: always;
${({ $isTypeInfo }) => $isTypeInfo
? css`
display: flex;
flex-flow: column nowrap;
justify-content: flex-end;
align-items: center;
padding-bottom: 4rem;
`
: css`
background: var(--background-default-grey);
box-shadow: 0 0 .5rem -0.125rem rgba(0, 0, 0, 0.7);
`
}
}
Expand All @@ -58,9 +71,10 @@ export const AsideWrapper = styled.div<{
max-width: calc(25% + 2rem);
overflow: hidden;
transition: transform 0.5s ease;
pointer-events: none;
${({ $withTogglerButton }) => $withTogglerButton
? css`
? css`
width: calc(400px + 2rem);
max-width: calc(25% + 2rem);
`
Expand All @@ -81,22 +95,23 @@ export const AsideWrapper = styled.div<{
.body {
justify-content: flex-start;
height: 100%;
padding-bottom: 8rem;
overflow-x: hidden;
overflow-y: auto;
scroll-snap-type: x mandatory;
${({ $isTypeInfo }) => $isTypeInfo && css`padding-top: 4rem;`};
${({ $isTypeInfo }) => $isTypeInfo && css`padding-top: 8rem;`};
}
}
`

export const AsideTogglerButtonWrapper = styled.div`
height: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 2.5rem;
max-height: 2.5rem;
pointer-events: none;
&::after {
Expand Down Expand Up @@ -197,6 +212,11 @@ export const AsideWrapperTogglerButton = styled.button.attrs<{ $isOpen: boolean
}
`

export const AsideBody = styled.div`
background: var(--background-default-grey);
pointer-events: auto;
`

export const AsideFooter = styled.footer`
position: sticky;
z-index: 1;
Expand Down
59 changes: 43 additions & 16 deletions src/app/carte-base-adresse-nationale/components/Aside/Aside.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
import AsideHeader from './AsideHeader'

import {
AsideWrapper,
AsideTogglerButtonWrapper,
AsideWrapperTogglerButton,
AsideBody,
AsideFooter,
} from './Aside.styles'

interface AsideProps {
import type { MapBreadcrumbPath } from '../MapBreadcrumb'

interface AsideDefaultProps {
children: React.ReactNode
header?: React.ReactNode
footer?: React.ReactNode
path?: MapBreadcrumbPath
onClose?: () => void
onClickToggler?: (args: { isOpen: boolean, togglerButtonType: 'horizontal' | 'vertical' }) => void
isOpen?: boolean
isInfo?: boolean
}

function Aside({ children, footer, onClickToggler, isOpen = true, isInfo }: AsideProps) {
interface AsideProps extends AsideDefaultProps {
header: React.ReactNode
isInfo?: false
}
interface AsideInfoProps extends AsideDefaultProps {
header?: undefined | null
isInfo: true
}

function Aside({
children,
header,
footer,
path,
onClose,
onClickToggler,
isOpen = true,
isInfo,
}: AsideProps | AsideInfoProps) {
const withTogglerButton = Boolean(onClickToggler)

return (
Expand All @@ -25,18 +51,6 @@ function Aside({ children, footer, onClickToggler, isOpen = true, isInfo }: Asid
>
{withTogglerButton && (
<AsideTogglerButtonWrapper>
<AsideWrapperTogglerButton
className="ri-arrow-up-double-fill sm"
// TODO : Add onClick event for auto scroll to top on mobile
onClick={() => {
onClickToggler?.({
isOpen,
togglerButtonType: 'vertical',
})
}}
$isOpen={isOpen}
/>

<AsideWrapperTogglerButton
className="ri-arrow-right-double-fill md"
onClick={() => {
Expand All @@ -50,9 +64,22 @@ function Aside({ children, footer, onClickToggler, isOpen = true, isInfo }: Asid
</AsideTogglerButtonWrapper>
)}

<div className="body">
{children}
<div className="aside-body-wrapper ">
<div className="body">
{header && (
<AsideHeader path={path} onClose={onClose}>
{header}
</AsideHeader>
)}

{isInfo
? children
: children && (
<AsideBody>
{children}
</AsideBody>
)}
</div>
{footer && (
<AsideFooter>
{footer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import styled from 'styled-components'

export const AsideFooterWrapper = styled.div``
export const AsideFooterWrapper = styled.div`
font-size: 1rem;
`

export const ActionWrapper = styled.ul`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { useMemo } from 'react'

import Button, { ButtonProps } from '@codegouvfr/react-dsfr/Button'

import {
AsideFooterWrapper,
ActionWrapper,
ActionList,
} from './AsideFooter.styles'

interface AsideFooterAddressProps {
children?: React.ReactNode
actions?: {
label: ButtonProps['children']
onClick: ButtonProps['onClick']
iconId: ButtonProps['iconId']
priority?: ButtonProps['priority']
}[]
}

function AsideFooterDistrict({ children, actions }: AsideFooterAddressProps) {
const actionsButtons = useMemo(() => actions?.map(({ label, ...props }, index) => (
<ActionList key={index}>
<Button
{...props as ButtonProps}
>
{label}
</Button>
</ActionList>
)
), [actions])

return (
<AsideFooterWrapper>
{children}
{actions && actions.length > 0 && (
<ActionWrapper>
<ActionList>
{actionsButtons}
</ActionList>
</ActionWrapper>
)}
</AsideFooterWrapper>
)
}

export default AsideFooterDistrict
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
'use client'

import styled from 'styled-components'

export const AsideHeader = styled.div`
position: absolute;
display: flex;
flex-direction: column-reverse;
overflow: hidden;
width: 100%;
padding: 0 1rem 1rem;
font-size: 1rem;
transform: translateY(-100%);
scroll-snap-align: start;
scroll-snap-stop: always;
@media (min-width: ${({ theme }) => theme.breakpoints.md}) {
position: static;
padding: 8rem 1rem 1rem;
background: var(--background-default-grey);
margin: 0;
transform: none;
}
& * {
pointer-events: auto;
}
&::after {
content: '';
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: linear-gradient(0deg, var(--background-default-grey) 0%, rgba(0, 0, 0, 0) 100%);
background-repeat: no-repeat;
background-size: 100% 100%;
background-position: 100% center;
pointer-events: auto;
transform: translateY(0);
transition: transform 0.5s ease;
@media (min-width: ${({ theme }) => theme.breakpoints.md}) {
content: none;
}
}
`

export const AsideHeaderContent = styled.div`
position: relative;
display: flex;
justify-content: flex-start;
align-items: center;
gap: 1.25rem;
padding: 1rem;
margin-bottom: 1rem;
border-bottom: 4px solid var(--border-active-blue-france);
background-color: var(--background-default-grey);
@media (min-width: ${({ theme }) => theme.breakpoints.md}) {
padding: 1rem 0;
}
`

export const AsideHeaderCloseButtonWrapper = styled.div`
position: absolute;
top: 0;
right: 0;
z-index: 1;
pointer-events: auto;
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Button from '@codegouvfr/react-dsfr/Button'

import MapBreadcrumb from '../MapBreadcrumb'
import type { MapBreadcrumbPath } from '../MapBreadcrumb'

import {
AsideHeader as AsideHeaderStyle,
AsideHeaderContent,
AsideHeaderCloseButtonWrapper,
} from './AsideHeader.styles'

interface AsideHeaderProps {
path?: MapBreadcrumbPath
children?: React.ReactNode
onClose?: () => void
}

function AsideHeader({ path, children, onClose }: AsideHeaderProps) {
return (
<AsideHeaderStyle>
{path && <MapBreadcrumb path={path} />}
<AsideHeaderContent>
{onClose && (
<AsideHeaderCloseButtonWrapper>
<Button
iconId="ri-close-line"
priority="tertiary no outline"
size="small"
onClick={onClose}
title="Fermer"
/>
</AsideHeaderCloseButtonWrapper>
)}
{children}
</AsideHeaderContent>
</AsideHeaderStyle>
)
}

export default AsideHeader
Loading

0 comments on commit 137781d

Please sign in to comment.