-
Notifications
You must be signed in to change notification settings - Fork 64
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
Breadcrumbs Types #700
Breadcrumbs Types #700
Changes from 5 commits
81b3170
2b79ba0
2386d0c
2dc0352
441fdf7
ccec72f
cc6fc60
9e3d89a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// @ts-nocheck | ||
import { tokens } from '@equinor/eds-tokens' | ||
|
||
const { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
// @ts-nocheck | ||
import React, { forwardRef, useState, Fragment } from 'react' | ||
import PropTypes from 'prop-types' | ||
import styled from 'styled-components' | ||
import { breadcrumbs as tokens } from './Breadcrumbs.tokens' | ||
import { Typography } from '../Typography' | ||
|
@@ -38,13 +36,20 @@ const Collapsed = styled(Typography)` | |
text-decoration: none; | ||
` | ||
|
||
export const Breadcrumbs = forwardRef(function Breadcrumbs( | ||
{ className, children, collapse, ...rest }, | ||
type Props = { | ||
/* | ||
* Collapses the list of breadcrumbs so that only the first | ||
* and last breadcrumb will be shown, with an ellipsis in between. | ||
*/ | ||
collapse?: boolean | ||
} & JSX.IntrinsicElements['nav'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also something we do differently from component to component… There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mimarz and I discussed this yesterday, if I remember correctly the difference was that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
export const Breadcrumbs = forwardRef<HTMLElement, Props>(function Breadcrumbs( | ||
{ children, collapse, ...rest }, | ||
ref, | ||
) { | ||
const props = { | ||
...rest, | ||
className, | ||
ref, | ||
} | ||
|
||
|
@@ -103,20 +108,3 @@ export const Breadcrumbs = forwardRef(function Breadcrumbs( | |
}) | ||
|
||
Breadcrumbs.displayName = 'eds-breadcrumbs' | ||
|
||
Breadcrumbs.propTypes = { | ||
/* | ||
* Collapses the list of breadcrumbs so that only the first | ||
* and last breadcrumb will be shown, with an ellipsis in between. | ||
*/ | ||
collapse: PropTypes.bool, | ||
// Breadcrumbs children | ||
children: PropTypes.node.isRequired, | ||
/** @ignore */ | ||
className: PropTypes.string, | ||
} | ||
|
||
Breadcrumbs.defaultProps = { | ||
className: '', | ||
collapse: false, | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Breadcrumbs as BaseComponent } from './Breadcrumbs' | ||
import { Breadcrumb } from './Breadcrumb' | ||
|
||
type BreadcrumbsTypes = typeof BaseComponent & { | ||
Breadcrumb: typeof Breadcrumb | ||
} | ||
|
||
const Breadcrumbs = BaseComponent as BreadcrumbsTypes | ||
|
||
Breadcrumbs.Breadcrumb = Breadcrumb | ||
|
||
export { Breadcrumbs } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pick
is one of those things I didn’t know about, that we should probably use in more components…There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend having a look at the Typescript utility types :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's pretty neat! 😄 @mimarz also taught me
Omit<Type, Keys>
from Typescript Utility Types where you can removeKeys
fromType
and re-use it