-
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, oppdatert utseende
- Loading branch information
1 parent
6121548
commit 5e2659c
Showing
5 changed files
with
103 additions
and
2 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
42 changes: 42 additions & 0 deletions
42
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,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 GroupCardFooterProps<As extends ElementType = 'div'> = Omit< | ||
ComponentAsPropParams<As>, | ||
'children' | ||
> & { | ||
/** No padding on the element */ | ||
noPadding?: boolean; | ||
children: | ||
| React.ReactNode | ||
| ((cardRenderProps: CardRenderProps) => React.ReactNode); | ||
}; | ||
|
||
function GroupCardFooterWithForwardRef<As extends ElementType>( | ||
props: GroupCardFooterProps<As>, | ||
ref: ForwardedRef<any>, | ||
) { | ||
const { className, noPadding = false, children, ...rest } = props; | ||
|
||
return ( | ||
<WithCardAction | ||
baseClassName="ffe-group-card__footer" | ||
className={classNames('ffe-group-card__footer', className, { | ||
'ffe-group-card__element--no-padding': noPadding, | ||
})} | ||
{...(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,51 @@ | ||
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' | ||
> & { | ||
/** No padding on the element */ | ||
noPadding?: boolean; | ||
/** 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, | ||
noPadding = false, | ||
noSeparator = false, | ||
children, | ||
...rest | ||
} = props; | ||
|
||
return ( | ||
<WithCardAction | ||
baseClassName="ffe-group-card__title" | ||
className={classNames('ffe-group-card__title', className, { | ||
'ffe-group-card__element--no-padding': noPadding, | ||
'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