-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ffe-cards-react): groupcard, fjernet nopadding og oppdatert utse…
…ende BREAKING CHANGE: dfd
- Loading branch information
1 parent
d3af154
commit f30ee76
Showing
5 changed files
with
92 additions
and
13 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
38 changes: 38 additions & 0 deletions
38
packages/ffe-cards-react/src/GroupCard/GroupCardFooter.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,38 @@ | ||
import React, { ElementType, ForwardedRef } from 'react'; | ||
import classNames from 'classnames'; | ||
import { CardName, Subtext, Text, Title, WithCardAction } from '../components'; | ||
import { CardRenderProps, ComponentAsPropParams } from '../types'; | ||
import { fixedForwardRef } from '../fixedForwardRef'; | ||
|
||
export type GroupCardFooterProps<As extends ElementType = 'div'> = Omit< | ||
ComponentAsPropParams<As>, | ||
'children' | ||
> & { | ||
children: | ||
| React.ReactNode | ||
| ((cardRenderProps: CardRenderProps) => React.ReactNode); | ||
}; | ||
|
||
function GroupCardFooterWithForwardRef<As extends ElementType>( | ||
props: GroupCardFooterProps<As>, | ||
ref: ForwardedRef<any>, | ||
) { | ||
const { className, children, ...rest } = props; | ||
|
||
return ( | ||
<WithCardAction | ||
baseClassName="ffe-group-card__footer" | ||
className={classNames('ffe-group-card__footer', className, {})} | ||
{...(rest as Record<string, unknown>)} | ||
ref={ref} | ||
> | ||
{({ CardAction }) => | ||
typeof children === 'function' | ||
? children({ Text, Subtext, Title, CardName, CardAction }) | ||
: children | ||
} | ||
</WithCardAction> | ||
); | ||
} | ||
|
||
export const GroupCardFooter = fixedForwardRef(GroupCardFooterWithForwardRef); |
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,42 @@ | ||
import React, { ElementType, ForwardedRef } from 'react'; | ||
import classNames from 'classnames'; | ||
import { CardName, Subtext, Text, Title, WithCardAction } from '../components'; | ||
import { CardRenderProps, ComponentAsPropParams } from '../types'; | ||
import { fixedForwardRef } from '../fixedForwardRef'; | ||
|
||
export type GroupCardTitleProps<As extends ElementType = 'div'> = Omit< | ||
ComponentAsPropParams<As>, | ||
'children' | ||
> & { | ||
/** Visible border underneath title*/ | ||
noSeparator?: boolean; | ||
children: | ||
| React.ReactNode | ||
| ((cardRenderProps: CardRenderProps) => React.ReactNode); | ||
}; | ||
|
||
function GroupCardTitleWithForwardRef<As extends ElementType>( | ||
props: GroupCardTitleProps<As>, | ||
ref: ForwardedRef<any>, | ||
) { | ||
const { className, noSeparator = false, children, ...rest } = props; | ||
|
||
return ( | ||
<WithCardAction | ||
baseClassName="ffe-group-card__title" | ||
className={classNames('ffe-group-card__title', className, { | ||
'ffe-group-card__element--no-separator': noSeparator, | ||
})} | ||
{...(rest as Record<string, unknown>)} | ||
ref={ref} | ||
> | ||
{({ CardAction }) => | ||
typeof children === 'function' | ||
? children({ Text, Subtext, Title, CardName, CardAction }) | ||
: children | ||
} | ||
</WithCardAction> | ||
); | ||
} | ||
|
||
export const GroupCardTitle = fixedForwardRef(GroupCardTitleWithForwardRef); |
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