Skip to content

Commit

Permalink
Merge pull request #1172 from navikt/bytt-ut-gamalt-ekspanderbart-panel
Browse files Browse the repository at this point in the history
Bytt ut gamalt ekspanderbart panel med ExpancionCard
  • Loading branch information
ingfo authored Jan 13, 2025
2 parents 61ff2db + 57968d7 commit 8419dc8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 238 deletions.
27 changes: 1 addition & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
"nav-frontend-chevron": "1.0.30",
"nav-frontend-chevron-style": "^1.0.4",
"nav-frontend-core": "^6.0.1",
"nav-frontend-ekspanderbartpanel": "4.0.4",
"nav-frontend-ekspanderbartpanel-style": "2.0.2",
"nav-frontend-grid-style": "1.0.3",
"nav-frontend-ikoner-assets": "^3.0.1",
"nav-frontend-js-utils": "^1.0.20",
Expand Down
49 changes: 21 additions & 28 deletions src/components/ekspandertbart-panel/metrikk-ekspanderbartpanel.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
import React, {PropsWithChildren, useState} from 'react';
import Ekspanderbartpanel from 'nav-frontend-ekspanderbartpanel';
import {logEvent} from '../../utils/frontend-logger';
import {finnSideNavn} from '../../middleware/metrics-middleware';
import hiddenIf from '../hidden-if/hidden-if';
import '../toolbar/toolbar.css';
import classNames from 'classnames';
import {EkspanderbartpanelBaseProps} from 'nav-frontend-ekspanderbartpanel/lib/ekspanderbartpanel-base';
import {PropsWithChildren, useState} from 'react';
import {ExpansionCard} from '@navikt/ds-react';
import {trackAmplitude} from '../../amplitude/amplitude';

interface MetrikkEkspanderbartpanelProps extends EkspanderbartpanelBaseProps {
lamellNavn: string;
interface Props {
tittel: string;
}

function MetrikkEkspanderbartpanel({
lamellNavn,
tittel,
className,
children
}: PropsWithChildren<MetrikkEkspanderbartpanelProps>) {
export function MetrikkEkspanderbartpanel({tittel, children}: PropsWithChildren<Props>) {
const [isApen, setIsApen] = useState(true);

const handleOnClick = () => {
setIsApen(prevState => !prevState);
logEvent('portefolje.metrikker.lamell', {
navn: lamellNavn,
apen: !isApen,
sideNavn: finnSideNavn()
trackAmplitude({
name: isApen ? 'accordion lukket' : 'accordion åpnet',
data: {
tekst: tittel
}
});

setIsApen(prevState => !prevState);
};

return (
<div className={classNames('portefolje__ekspanderbarpanel', className)}>
<Ekspanderbartpanel tittel={tittel} border={true} onClick={handleOnClick} apen={isApen} role="button">
{children}
</Ekspanderbartpanel>
</div>
<ExpansionCard aria-labelledby="expancion-card-title" size="small" open={isApen}>
<ExpansionCard.Header onClick={handleOnClick}>
<ExpansionCard.Title id="expancion-card-title" size="small">
{tittel}
</ExpansionCard.Title>
</ExpansionCard.Header>
<ExpansionCard.Content>{children}</ExpansionCard.Content>
</ExpansionCard>
);
}

export default hiddenIf(MetrikkEkspanderbartpanel);
1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import ReactDOM from 'react-dom';
import Application from './application';
import 'nav-frontend-chevron-style/dist/main.css';
import 'nav-frontend-ekspanderbartpanel-style/dist/main.css';
import 'nav-frontend-grid-style/dist/main.css';
import 'nav-frontend-lenker-style/dist/main.css';
import 'nav-frontend-paneler-style/dist/main.css';
Expand Down
179 changes: 0 additions & 179 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -835,177 +835,6 @@ GRID
transition: height 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.ekspanderbartPanel {
position: relative;
background: white;
border-radius: 0.25rem;
}

.ekspanderbartPanel:hover,
.ekspanderbartPanel--hover {
box-shadow: #a0a0a0 0 2px 1px 0;
}

.ekspanderbartPanel:focus,
.ekspanderbartPanel--focus {
box-shadow: 0 0 0 3px #00347d;
outline: none;
}

.ekspanderbartPanel__hode {
display: block;
padding: 1rem 1rem 1rem 1rem;
border-radius: 4px;
background: transparent;
border: 0;
text-align: left;
width: 100%;
margin-bottom: 0;
}

.ekspanderbartPanel__hode .ekspanderbartPanel__tittel {
font-family: 'Source Sans Pro', Arial, sans-serif;
font-size: 1.25rem;
line-height: 1.5625rem;
font-weight: 600;
color: #262626;
}

.ekspanderbartPanel__hode:hover,
.ekspanderbartPanel__hode--hover {
cursor: pointer;
}

.ekspanderbartPanel__hode:hover .ekspanderbartPanel__tittel,
.ekspanderbartPanel__hode--hover .ekspanderbartPanel__tittel {
text-decoration: underline;
color: #0067c5;
}

.ekspanderbartPanel__hode:focus,
.ekspanderbartPanel__hode--focus {
box-shadow: 0 0 0 3px #00347d;
outline: none;
}

.ekspanderbartPanel__flex-wrapper {
display: flex;
align-items: center;
justify-content: space-between;
}

.ekspanderbartPanel__innhold {
padding: 1rem;
padding-top: 0.5rem;
}

.ekspanderbartPanel--lukket .ekspanderbartPanel__indikator {
display: inline-block;
flex-shrink: 0;
height: 2px;
line-height: 2px;
width: 20px;
position: relative;
text-align: center;
transition: 200ms transform;
vertical-align: middle;
}

.ekspanderbartPanel--lukket .ekspanderbartPanel__indikator::before,
.ekspanderbartPanel--lukket .ekspanderbartPanel__indikator::after {
transition: 200ms transform;
border-radius: 10px;
}

.ekspanderbartPanel--lukket .ekspanderbartPanel__indikator::before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 50%;
background: currentColor;

transform: translateX(2px) rotate(45deg);
}

.ekspanderbartPanel--lukket .ekspanderbartPanel__indikator::after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 100%;
width: 50%;
background: currentColor;

transform: translateX(-2px) rotate(-45deg);
}

.ekspanderbartPanel--border {
border: 1px solid #6a6a6a;
}

.ekspanderbartPanel--border:hover,
.ekspanderbartPanel--border.panel-interaktiv-mixin--hover {
border: 1px solid #0067c5;
}

.ekspanderbartPanel--border.ekspanderbartPanel--apen {
border: 1px solid #6a6a6a;
}

.ekspanderbartPanel--apen > .ekspanderbartPanel__hode {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}

.ekspanderbartPanel--apen .ekspanderbartPanel__innhold {
border-top-left-radius: 0;
border-top-right-radius: 0;
}

.ekspanderbartPanel--apen > .ekspanderbartPanel__hode .ekspanderbartPanel__indikator {
display: inline-block;
flex-shrink: 0;
height: 2px;
line-height: 2px;
width: 20px;
position: relative;
text-align: center;
transition: 200ms transform;
vertical-align: middle;
}

.ekspanderbartPanel--apen > .ekspanderbartPanel__hode .ekspanderbartPanel__indikator::before,
.ekspanderbartPanel--apen > .ekspanderbartPanel__hode .ekspanderbartPanel__indikator::after {
transition: 200ms transform;
border-radius: 10px;
}

.ekspanderbartPanel--apen > .ekspanderbartPanel__hode .ekspanderbartPanel__indikator::before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 50%;
background: currentColor;

transform: translateX(2px) rotate(-45deg);
}

.ekspanderbartPanel--apen > .ekspanderbartPanel__hode .ekspanderbartPanel__indikator::after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 100%;
width: 50%;
background: currentColor;

transform: translateX(-2px) rotate(45deg);
}

.begrensetbredde {
max-width: 35rem;
}
Expand Down Expand Up @@ -1091,14 +920,6 @@ GRID
margin-bottom: 0.5rem;
}

.veilarbportefoljeflatefs .ekspanderbartPanel__innhold {
padding: 0.5rem 1rem 1rem;
}

.veilarbportefoljeflatefs .ekspanderbartPanel--apen .ReactCollapse--collapse {
overflow: initial !important;
}

.veilarbportefoljeflatefs .side-storrelse {
margin: 0 auto;
padding: 0 var(--side-padding-x-akse);
Expand Down
4 changes: 2 additions & 2 deletions src/veiledere/veiledere-side.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {useSetEnhetIUrl} from '../hooks/portefolje/use-set-enhet-i-url';
import {useSetLocalStorageOnUnmount} from '../hooks/portefolje/use-set-local-storage-on-unmount';
import FilteringVeiledergrupper from '../filtrering/filtrering-veileder-grupper/filtrering-veiledergrupper';
import {useFetchStatustallForVeileder} from '../hooks/portefolje/use-fetch-statustall';
import MetrikkEkspanderbartpanel from '../components/ekspandertbart-panel/metrikk-ekspanderbartpanel';
import {MetrikkEkspanderbartpanel} from '../components/ekspandertbart-panel/metrikk-ekspanderbartpanel';
import {oppdaterKolonneAlternativer, OversiktType} from '../ducks/ui/listevisning';
import LagredeFilterUIController from '../filtrering/lagrede-filter-controller';
import {Panel} from '@navikt/ds-react';
Expand Down Expand Up @@ -76,7 +76,7 @@ function VeiledereSide() {
<Panel className="sok-veileder" role="search">
<FiltreringVeiledere endreFiltervalg={doEndreFiltervalg} filtervalg={filtervalg} />
</Panel>
<MetrikkEkspanderbartpanel lamellNavn="veiledergrupper" tittel="Veiledergrupper">
<MetrikkEkspanderbartpanel tittel="Veiledergrupper">
<FilteringVeiledergrupper oversiktType={OversiktType.veilederOversikt} />
</MetrikkEkspanderbartpanel>
</div>
Expand Down

0 comments on commit 8419dc8

Please sign in to comment.