-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(window-start): check if window start is a function before executi…
…ng (#6) * fix(window-start): check if window start is a function before executing * fix(window.start): check if window is not undefined * fix(badges): badges children can be anything * fix(reactNode): delete useless importation * fix(badge): children is not optionnal * fix(window.dsfr): start condition earlier * fix(window.start): check if start is a function
- Loading branch information
Showing
4 changed files
with
145 additions
and
70 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
import { useId } from 'react'; | ||
import classNames from 'classnames'; | ||
import { getChildrenOfType } from '../../utils/children'; | ||
import { Merge } from '../../types/polymophic'; | ||
import { Badge } from './Badge'; | ||
import { useId } from "react"; | ||
import classNames from "classnames"; | ||
import { getChildrenOfType } from "../../utils/children"; | ||
import { Merge } from "../../types/polymophic"; | ||
import { Badge } from "./Badge"; | ||
|
||
type BadgeGroupBaseProps = { | ||
className?: string; | ||
} | ||
children?: React.ReactNode; | ||
}; | ||
|
||
export type BadgeGroupProps = Merge<React.HTMLAttributes<HTMLUListElement>, BadgeGroupBaseProps>; | ||
export type BadgeGroupProps = Merge< | ||
React.HTMLAttributes<HTMLUListElement>, | ||
BadgeGroupBaseProps | ||
>; | ||
|
||
export const BadgeGroup: React.FC<BadgeGroupProps> = ({ | ||
children, | ||
className, | ||
...props | ||
}: React.HTMLAttributes<HTMLUListElement>) => { | ||
const id = useId(); | ||
const _classes = classNames('fr-badges-group', className); | ||
const _classes = classNames("fr-badges-group", className); | ||
return ( | ||
<ul className={_classes} {...props}> | ||
{getChildrenOfType(children, Badge).map((child, index) => <li key={`${id}-${index}`}>{child}</li>)} | ||
{getChildrenOfType(children, Badge).map((child, index) => ( | ||
<li key={`${id}-${index}`}>{child}</li> | ||
))} | ||
</ul> | ||
); | ||
}; |
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