Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sizing of breadcrumbs to make breadcrumbs size appropriate #189

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/parliament-ui-components",
"version": "5.2.2",
"version": "5.2.3",
"description": "UI Components for Parliament projects",
"author": {
"name": "Simon Mac Donald",
Expand Down
92 changes: 26 additions & 66 deletions src/Breadcrumbs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,75 +11,35 @@
*/

/** @jsx jsx */
import { css, jsx } from '@emotion/react'
import { jsx } from '@emotion/react'
import PropTypes from 'prop-types'
import { Link as GatsbyLink } from 'gatsby'
import '@spectrum-css/breadcrumb'
import { Breadcrumbs, Item } from '@adobe/react-spectrum'

const Breadcrumbs = ({ selectedTopPage, selectedSubPages, ...props }) => (
<nav aria-label='Breadcrumb' role='navigation' {...props}>
<ul
className='spectrum-Breadcrumbs'
css={css`
display: block;
`}
>
<li className='spectrum-Breadcrumbs-item'>
<GatsbyLink
className='spectrum-Breadcrumbs-itemLink'
to={selectedTopPage?.path}
>
{selectedTopPage?.title}
</GatsbyLink>
<svg
className='spectrum-Icon spectrum-UIIcon-ChevronRightSmall spectrum-Breadcrumbs-itemSeparator'
focusable='false'
role='img'
aria-hidden='true'
>
<path
d='M7 5a.747.747 0 00-.22-.53L2.54.23a.75.75 0 10-1.06 1.06L5.19 5 1.48 8.71a.75.75 0 101.06 1.06l4.24-4.24A.747.747 0 007 5z'
className='spectrum-UIIcon--large'
/>
<path
d='M5.5 4a.747.747 0 00-.22-.53C4.703 2.862 3.242 1.5 2.04.23A.75.75 0 10.98 1.29L3.69 4 .98 6.71a.75.75 0 101.06 1.06l3.24-3.24A.747.747 0 005.5 4z'
className='spectrum-UIIcon--medium'
/>
</svg>
</li>
{selectedSubPages &&
selectedSubPages.map((page, index) => (
<li className='spectrum-Breadcrumbs-item' key={index}>
<GatsbyLink
className='spectrum-Breadcrumbs-itemLink'
to={page.path}
>
{page.title}
</GatsbyLink>
<svg
className='spectrum-Icon spectrum-UIIcon-ChevronRightSmall spectrum-Breadcrumbs-itemSeparator'
focusable='false'
role='img'
aria-hidden='true'
>
<path
d='M7 5a.747.747 0 00-.22-.53L2.54.23a.75.75 0 10-1.06 1.06L5.19 5 1.48 8.71a.75.75 0 101.06 1.06l4.24-4.24A.747.747 0 007 5z'
className='spectrum-UIIcon--large'
/>
<path
d='M5.5 4a.747.747 0 00-.22-.53C4.703 2.862 3.242 1.5 2.04.23A.75.75 0 10.98 1.29L3.69 4 .98 6.71a.75.75 0 101.06 1.06l3.24-3.24A.747.747 0 005.5 4z'
className='spectrum-UIIcon--medium'
/>
</svg>
</li>
))}
</ul>
</nav>
)
/**
* Parliament Breadcrumbs are deprecated. Please use the React Spectrum v3 Breadcrumbs instead.
* See the docs for details: https://react-spectrum.adobe.com/react-spectrum/Breadcrumbs.html.
*
* @deprecated
*/
const ParliamentBreadcrumbs = ({ breadcrumbsPages, ...props }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we've moved to using v3 Breadcrumbs, I'm not sure if having this component here is providing any value. I think we should deprecate it:

Suggested change
const ParliamentBreadcrumbs = ({ breadcrumbsPages, ...props }) => {
/**
* Parliament Breadcrumbs are deprecated. Please use the React Spectrum v3 Breadcrumbs instead.
* See the docs for details: https://react-spectrum.adobe.com/react-spectrum/Breadcrumbs.html.
*
* @deprecated
*/
const ParliamentBreadcrumbs = ({ breadcrumbsPages, ...props }) => {
console.warn('Parliament Breadcrumbs are deprecated. Please use the React Spectrum v3 Breadcrumbs instead. See the docs for details: https://react-spectrum.adobe.com/react-spectrum/Breadcrumbs.html');

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion!

console.warn(
'Parliament Breadcrumbs are deprecated. Please use the React Spectrum v3 Breadcrumbs instead. See the docs for details: https://react-spectrum.adobe.com/react-spectrum/Breadcrumbs.html'
)

return (
<Breadcrumbs size='M' {...props}>
{breadcrumbsPages.map((page) => (
<Item key={page.title}>
<GatsbyLink to={page.path}>{page.title}</GatsbyLink>
</Item>
))}
</Breadcrumbs>
)
}

Breadcrumbs.propTypes = {
selectedTopPage: PropTypes.object,
selectedSubPages: PropTypes.array
ParliamentBreadcrumbs.propTypes = {
breadcrumbsPages: PropTypes.array
}

export { Breadcrumbs }
export { ParliamentBreadcrumbs as Breadcrumbs }
10 changes: 9 additions & 1 deletion src/Breadcrumbs/test/Breadcrumbs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ import { Breadcrumbs } from '../index'

describe('<Breadcrumbs />', () => {
test('should render', () => {
const { getByTestId } = render(<Breadcrumbs data-testid='el' />)
const sampleBreadcrumbsPages = [
{
path: 'sample-path',
title: 'Sample page'
}
]
const { getByTestId } = render(
<Breadcrumbs breadcrumbsPages={sampleBreadcrumbsPages} data-testid='el' />
)
const el = getByTestId('el')

expect(el).toBeInTheDocument()
Expand Down