-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IS-1959: Migrate referat to react hook form (#1499)
- Loading branch information
1 parent
f86a453
commit c258add
Showing
25 changed files
with
651 additions
and
965 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { ReactNode, useEffect, useState } from "react"; | ||
import { ExpansionCard } from "@navikt/ds-react"; | ||
|
||
interface Props { | ||
ariaLabel: string; | ||
heading: ReactNode; | ||
children: ReactNode; | ||
hasError?: boolean; | ||
} | ||
|
||
export const ExpansionCardFormField = ({ | ||
ariaLabel, | ||
heading, | ||
children, | ||
hasError, | ||
}: Props) => { | ||
const [open, setOpen] = useState(false); | ||
useEffect(() => { | ||
if (hasError) { | ||
setOpen(true); | ||
} | ||
}, [hasError]); | ||
|
||
return ( | ||
<ExpansionCard | ||
aria-label={ariaLabel} | ||
size="small" | ||
open={open} | ||
onToggle={() => setOpen(!open)} | ||
> | ||
<ExpansionCard.Header>{heading}</ExpansionCard.Header> | ||
<ExpansionCard.Content>{children}</ExpansionCard.Content> | ||
</ExpansionCard> | ||
); | ||
}; |
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.