mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-09-01 02:10:57 -07:00
create a LinkTypeWrapper (#709)
- AboutCard requires both internal and external links - LinkTypeWrapper allows the component to specify link type - add tests
This commit is contained in:
parent
a532b652b4
commit
58f4102d6f
6 changed files with 154 additions and 26 deletions
|
@ -1,15 +1,17 @@
|
|||
import React from 'react';
|
||||
import {Grid} from '@trussworks/react-uswds';
|
||||
import LinkTypeWrapper from '../LinkTypeWrapper';
|
||||
|
||||
// the "body" section is the child object to allow for html versus just text
|
||||
interface AboutCardProps {
|
||||
imgSrc: string;
|
||||
header: string;
|
||||
size?: 'small' | 'large';
|
||||
actionText?: string;
|
||||
actionUrl?: string;
|
||||
actionOpenInNewTab?: boolean;
|
||||
linkText?: string;
|
||||
url?: string;
|
||||
openUrlNewTab?: boolean;
|
||||
className?: string;
|
||||
internal?:boolean;
|
||||
}
|
||||
|
||||
const AboutCard = (props: React.PropsWithChildren<AboutCardProps>) => {
|
||||
|
@ -54,16 +56,13 @@ const AboutCard = (props: React.PropsWithChildren<AboutCardProps>) => {
|
|||
<h3>{props.header}</h3>
|
||||
<p>{props.children}</p>
|
||||
<div className={'j40-aboutcard-sm-link'}>
|
||||
{props.actionOpenInNewTab ?
|
||||
<a
|
||||
className={'j40-aboutcard-link'}
|
||||
href={props.actionUrl}
|
||||
target="_blank"
|
||||
rel="noreferrer">{props.actionText}</a> :
|
||||
<a
|
||||
className={'j40-aboutcard-link'}
|
||||
href={props.actionUrl}>{props.actionText}</a>
|
||||
}
|
||||
<LinkTypeWrapper
|
||||
linkText={props.linkText}
|
||||
internal={props.internal}
|
||||
url={props.url}
|
||||
openUrlNewTab={props.openUrlNewTab}
|
||||
className={'j40-aboutcard-link'}
|
||||
/>
|
||||
</div>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
|
|
@ -39,10 +39,7 @@ exports[`rendering of the AboutCard checks if component renders 1`] = `
|
|||
>
|
||||
<a
|
||||
class="j40-aboutcard-link"
|
||||
href="#"
|
||||
>
|
||||
Test Action
|
||||
</a>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue