Skip to content

Commit

Permalink
Merge pull request #105 from trussworks/em-title-component-#83
Browse files Browse the repository at this point in the history
Add title component
  • Loading branch information
eamahanna authored May 1, 2020
2 parents 86b0413 + 4c0efe4 commit ee10946
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
7 changes: 2 additions & 5 deletions src/components/Title/Title.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ Source: https://designsystem.digital.gov/components/header/
},
}

const testTitle = 'Test Title'
const testLink = '#testLinkOne'
const testTitle = <a href="#testlink">Project Title</a>

export const defaultTitle = (): React.ReactElement => (
<Title title={testTitle} link={testLink}></Title>
)
export const defaultTitle = (): React.ReactElement => <Title>{testTitle}</Title>
7 changes: 1 addition & 6 deletions src/components/Title/Title.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import { render } from '@testing-library/react'

import { Title } from './Title'

const testTitle = 'Test Title'
const testLink = '#testLinkOne'

describe('Title component', () => {
it('renders without errors', () => {
const { queryByText } = render(
<Title title={testTitle} link={testLink}></Title>
)
const { queryByText } = render(<Title>Test Title</Title>)
expect(queryByText('Test Title')).toBeInTheDocument()
})
})
16 changes: 8 additions & 8 deletions src/components/Title/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import React from 'react'
import classnames from 'classnames'

interface TitleProps {
title: React.ReactNode
link?: string
children: React.ReactNode
}

export const Title = ({ title, link }: TitleProps): React.ReactElement => {
const classes = classnames('usa-logo')
export const Title = (
props: TitleProps & React.HTMLAttributes<HTMLDivElement>
): React.ReactElement => {
const { className, children, ...divProps } = props
const classes = classnames('usa-logo', className)

return (
<div className={classes}>
<em className="usa-logo__text">
<a href={link}>{title}</a>
</em>
<div className={classes} {...divProps}>
<em className="usa-logo__text">{children}</em>
</div>
)
}
Expand Down

0 comments on commit ee10946

Please sign in to comment.