-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4681 from navikt/refactor/veilederflate-gjennomfo…
…ring-status Refactor/veilederflate gjennomforing status
- Loading branch information
Showing
15 changed files
with
138 additions
and
127 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
frontend/frontend-common/components/gjennomforing/GjennomforingStatusMedAarsakTag.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Tag } from "@navikt/ds-react"; | ||
import { TiltaksgjennomforingStatusDto } from "@mr/api-client"; | ||
import { useState } from "react"; | ||
import { variantAndName } from "./GjennomforingStatusTag"; | ||
|
||
interface Props { | ||
status: TiltaksgjennomforingStatusDto; | ||
} | ||
|
||
export function GjennomforingStatusMedAarsakTag({ status }: Props) { | ||
const [expandLabel, setExpandLabel] = useState<boolean>(false); | ||
|
||
const { variant, label } = variantAndName(status.status); | ||
const labelWithBeskrivelse = status.avbrutt?.beskrivelse | ||
? `${label} - ${status.avbrutt.beskrivelse}` | ||
: label; | ||
|
||
return ( | ||
<Tag | ||
style={{ | ||
maxWidth: "400px", | ||
}} | ||
size="small" | ||
onMouseEnter={() => setExpandLabel(true)} | ||
onMouseLeave={() => setExpandLabel(false)} | ||
aria-label={`Gjennomføringstatus: ${label}`} | ||
variant={variant} | ||
> | ||
{expandLabel ? labelWithBeskrivelse : truncate(labelWithBeskrivelse, 30)} | ||
</Tag> | ||
); | ||
} | ||
|
||
function truncate(text: string, maxLength: number): string { | ||
return text.length > maxLength ? `${text.substring(0, maxLength - 3)}...` : text; | ||
} |
34 changes: 34 additions & 0 deletions
34
frontend/frontend-common/components/gjennomforing/GjennomforingStatusTag.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Tag } from "@navikt/ds-react"; | ||
import { TiltaksgjennomforingStatus } from "@mr/api-client"; | ||
|
||
interface Props { | ||
status: TiltaksgjennomforingStatus; | ||
} | ||
|
||
export function GjennomforingStatusTag({ status }: Props) { | ||
const { variant, label } = variantAndName(status); | ||
|
||
return ( | ||
<Tag size="small" aria-label={`Gjennomføringstatus: ${label}`} variant={variant}> | ||
{label} | ||
</Tag> | ||
); | ||
} | ||
|
||
export function variantAndName(status: TiltaksgjennomforingStatus): { | ||
variant: "alt1" | "success" | "neutral" | "error"; | ||
label: string; | ||
} { | ||
switch (status) { | ||
case TiltaksgjennomforingStatus.GJENNOMFORES: | ||
return { variant: "success", label: "Gjennomføres" }; | ||
case TiltaksgjennomforingStatus.AVSLUTTET: | ||
return { variant: "neutral", label: "Avsluttet" }; | ||
case TiltaksgjennomforingStatus.AVBRUTT: | ||
return { variant: "error", label: "Avbrutt" }; | ||
case TiltaksgjennomforingStatus.AVLYST: | ||
return { variant: "error", label: "Avlyst" }; | ||
case TiltaksgjennomforingStatus.PLANLAGT: | ||
return { variant: "alt1", label: "Planlagt" }; | ||
} | ||
} |
57 changes: 0 additions & 57 deletions
57
frontend/frontend-common/components/tags/TiltaksgjennomforingStatusTag.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.