-
Notifications
You must be signed in to change notification settings - Fork 98
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
feat(Link)!: the "href" property is required #1270
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
|
||
import {block} from '../utils/cn'; | ||
|
||
const b = block('breadcrumbs'); | ||
|
||
export function BreadcrumbsButton(props: { | ||
title: string; | ||
onClick: React.MouseEventHandler<HTMLElement>; | ||
children: React.ReactNode; | ||
}) { | ||
return <button {...props} type="button" className={b('switcher', {more: true})} />; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,24 +110,21 @@ LANDING_BLOCK--> | |
|
||
## Href | ||
|
||
The `href` property is optional. If it is skipped, the `Link` will behave like a `Button`. | ||
The `href` property is required. | ||
|
||
<!--LANDING_BLOCK | ||
<ExampleBlock | ||
code={` | ||
<Link href="#">Link with href</Link> | ||
<Link>Link without href</Link> | ||
`}> | ||
<UIKit.Link href="#">Link with href</UIKit.Link> | ||
<UIKit.Link>Link without href</UIKit.Link> | ||
</ExampleBlock> | ||
LANDING_BLOCK--> | ||
|
||
<!--GITHUB_BLOCK--> | ||
|
||
```tsx | ||
<Link href="#">Link with href</Link> | ||
<Link>Link without href</Link> | ||
``` | ||
|
||
<!--/GITHUB_BLOCK--> | ||
|
@@ -140,17 +137,17 @@ A `Link` can be used both as an independent text element and as part of the text | |
<ExampleBlock | ||
code={` | ||
<Text> | ||
<Link>what roles are active in the service</Link> | ||
<Link href="#">what roles are active in the service</Link> | ||
</Text> | ||
<Text> | ||
Currently, this role can only be assigned to a <Link>folder</Link> or <Link>cloud</Link> | ||
Currently, this role can only be assigned to a <Link href="#">folder</Link> or <Link href="#">cloud</Link> | ||
</Text> | ||
`}> | ||
<UIKit.Text> | ||
<UIKit.Link>what roles are active in the service</UIKit.Link> | ||
<UIKit.Link href="#">what roles are active in the service</UIKit.Link> | ||
</UIKit.Text> | ||
<UIKit.Text> | ||
Currently, this role can only be assigned to a <UIKit.Link>folder</UIKit.Link> or <UIKit.Link>cloud</UIKit.Link> | ||
Currently, this role can only be assigned to a <UIKit.Link href="#">folder</UIKit.Link> or <UIKit.Link href="#">cloud</UIKit.Link> | ||
</UIKit.Text> | ||
</ExampleBlock> | ||
LANDING_BLOCK--> | ||
|
@@ -159,32 +156,32 @@ LANDING_BLOCK--> | |
|
||
```tsx | ||
<Text> | ||
<Link>What roles are available in the service</Link> | ||
<Link href="#">What roles are available in the service</Link> | ||
</Text> | ||
<Text> | ||
Currently, this role can only be assigned to a <Link>folder</Link> or <Link>cloud</Link> | ||
Currently, this role can only be assigned to a <Link href="#">folder</Link> or <Link href="#">cloud</Link> | ||
</Text> | ||
``` | ||
|
||
<!--/GITHUB_BLOCK--> | ||
|
||
## Properties | ||
|
||
| Name | Description | Type | Default | | ||
| :--------- | :----------------------------------------- | :--------------------------------------------------------------------------: | :--------: | | ||
| view | Link appearance | `"normal" \| "primary" \| "secondary"` | `"normal"` | | ||
| visitable | Display `:visitable` CSS state | `boolean \| undefined` | | ||
| href | HTML `href` attribute | `string \| undefined` | | ||
| target | HTML `target` attribute | `string \| undefined` | | ||
| rel | HTML `rel` attribute | `string \| undefined` | | ||
| title | HTML `title` attribute | `string \| undefined` | | ||
| children | Link content | `React.ReactNode` | | ||
| extraProps | Any additional props | `Record \| undefined` | | ||
| onClick | `click` event handler | `React.MouseEventHandler<HTMLAnchorElement \| HTMLSpanElement> \| undefined` | | ||
| onFocus | `focus` event handler | `React.FocusEventHandler<HTMLAnchorElement \| HTMLSpanElement> \| undefined` | | ||
| onBlur | `blur` event handler | `React.FocusEventHandler<HTMLAnchorElement \| HTMLSpanElement> \| undefined` | | ||
| id | HTML `id` attribute | `string \| undefined` | | ||
| style | HTML `style` attribute | `React.CSSProperties \| undefined` | | ||
| className | HTML `class` attribute | `string \| undefined` | | ||
| qa | HTML `data-qa` attribute, used for testing | `string \| undefined` | | ||
| ref | React ref to Link DOM node | `React.ForwardedRef<HTMLElement> \| undefined` | | ||
| Name | Description | Type | Default | | ||
| :--------- | :----------------------------------------- | :-------------------------------------------------------: | :--------: | | ||
| view | Link appearance | `"normal" \| "primary" \| "secondary"` | `"normal"` | | ||
| visitable | Display `:visitable` CSS state | `boolean \| undefined` | | ||
| href | HTML `href` attribute | `string \| undefined` | | ||
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. table formatting broke 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. |
||
| target | HTML `target` attribute | `string \| undefined` | | ||
| rel | HTML `rel` attribute | `string \| undefined` | | ||
| title | HTML `title` attribute | `string \| undefined` | | ||
| children | Link content | `React.ReactNode` | | ||
| extraProps | Any additional props | `Record \| undefined` | | ||
| onClick | `click` event handler | `React.MouseEventHandler<HTMLAnchorElement> \| undefined` | | ||
| onFocus | `focus` event handler | `React.FocusEventHandler<HTMLAnchorElement> \| undefined` | | ||
| onBlur | `blur` event handler | `React.FocusEventHandler<HTMLAnchorElement> \| undefined` | | ||
| id | HTML `id` attribute | `string \| undefined` | | ||
| style | HTML `style` attribute | `React.CSSProperties \| undefined` | | ||
| className | HTML `class` attribute | `string \| undefined` | | ||
| qa | HTML `data-qa` attribute, used for testing | `string \| undefined` | | ||
| ref | React ref to Link DOM node | `React.ForwardedRef<HTMLAnchorElement> \| undefined` | |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Isn't the same as before?
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 was types product, became types sum. Its more powerful way for union declaration.
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.
I mean there is no difference,
href
is optional anyway. What's the point of this change?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.
Oh, I figure out, why it wasn't obvious to use this kind of approach. Lost it while rebasing, it should have been:
So, we describe 2 categories of breadcrumb items: the one is like regular anchor(and should have the href prop), the two is like button, that should have some action(action prop).
So, if user want to create Breadcrumb, that is not like regular link, he will be forced(by typescript) to specify the action prop.
And if the developer(of uikit) needs to add a new behavior for only one of the types of breadcrumb item(e.g. the target attribute for anchor), then he modifies only LinkBreadcrumbsItem and any time in the code he will know, that he works with certain type of item(due to the href prop check).