mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
add OutboundLink (#504)
* feat(link): add OutboundLink * fix(outbound-link): forward Link events
This commit is contained in:
parent
3e926de49d
commit
251f986304
8 changed files with 85 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"total": 155,
|
||||
"total": 156,
|
||||
"components": [
|
||||
{
|
||||
"moduleName": "SkeletonText",
|
||||
|
@ -5083,6 +5083,21 @@
|
|||
"typedefs": [],
|
||||
"rest_props": { "type": "Element", "name": "div" }
|
||||
},
|
||||
{
|
||||
"moduleName": "OutboundLink",
|
||||
"filePath": "/src/Link/OutboundLink.svelte",
|
||||
"props": [],
|
||||
"slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }],
|
||||
"events": [
|
||||
{ "type": "forwarded", "name": "click", "element": "Link" },
|
||||
{ "type": "forwarded", "name": "mouseover", "element": "Link" },
|
||||
{ "type": "forwarded", "name": "mouseenter", "element": "Link" },
|
||||
{ "type": "forwarded", "name": "mouseleave", "element": "Link" }
|
||||
],
|
||||
"typedefs": [],
|
||||
"rest_props": { "type": "InlineComponent", "name": "Link" },
|
||||
"extends": { "interface": "LinkProps", "import": "\"./Link\"" }
|
||||
},
|
||||
{
|
||||
"moduleName": "ListItem",
|
||||
"filePath": "/src/ListItem/ListItem.svelte",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import { Link } from "carbon-components-svelte";
|
||||
import { Link, OutboundLink } from "carbon-components-svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
|
@ -9,14 +9,18 @@
|
|||
|
||||
### Target _blank
|
||||
|
||||
Setting `target` to `"_blank"` opens the link in a new tab.
|
||||
|
||||
If `target="_blank"`, the `Link` component will automatically set `rel="noopener noreferrer"` to guard against [potential cross-origin security exploits](https://web.dev/external-anchors-use-rel-noopener/).
|
||||
If setting `target` to `"_blank"`, the `Link` component will automatically set `rel="noopener noreferrer"` to guard against [potential cross-origin security exploits](https://web.dev/external-anchors-use-rel-noopener/).
|
||||
|
||||
You can override the `rel` attribute with a custom value.
|
||||
|
||||
<Link href="https://www.carbondesignsystem.com/" target="_blank">Carbon Design System</Link>
|
||||
|
||||
### Outbound link
|
||||
|
||||
An alternative to manually setting `target` to `"_blank"` is to use the `OutboundLink`.
|
||||
|
||||
<OutboundLink href="https://www.carbondesignsystem.com/">Carbon Design System</OutboundLink>
|
||||
|
||||
### Inline variant
|
||||
|
||||
<div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue