@aurodesignsystem-dev/auro-hyperlink 0.0.0-pr322.1 → 0.0.0-pr328.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -3
- package/custom-elements.json +64 -1799
- package/demo/a11y.html +3 -3
- package/demo/a11y.md +11 -9
- package/demo/api.html +2 -2
- package/demo/api.js +2 -1
- package/demo/api.md +311 -168
- package/demo/api.min.js +14 -1
- package/demo/auro-hyperlink.min.js +64 -52
- package/demo/index.html +2 -2
- package/demo/index.js +0 -2
- package/demo/index.md +23 -259
- package/demo/index.min.js +0 -31
- package/dist/{auro-hyperlink-isNf5eLk.js → auro-hyperlink-SowfvvPT.js} +4 -4
- package/dist/index.d.ts +227 -124
- package/dist/index.js +1 -1
- package/dist/registered.js +1 -1
- package/package.json +9 -5
package/demo/api.min.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { A as AuroHyperlink } from './auro-hyperlink.min.js';
|
|
2
2
|
|
|
3
|
+
function roleButtonExample() {
|
|
4
|
+
const roleButton = document.getElementById("roleButton");
|
|
5
|
+
const roleButtonOndark = document.getElementById("roleButton-ondark");
|
|
6
|
+
|
|
7
|
+
roleButton.addEventListener("click", () => {
|
|
8
|
+
alert("You clicked the role button!");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
roleButtonOndark.addEventListener("click", () => {
|
|
12
|
+
alert("You clicked the role button!");
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
3
16
|
AuroHyperlink.register();
|
|
4
17
|
|
|
5
18
|
function initHyperlinkApiExamples(initCount) {
|
|
@@ -7,7 +20,7 @@ function initHyperlinkApiExamples(initCount) {
|
|
|
7
20
|
initCount = initCount || 0;
|
|
8
21
|
|
|
9
22
|
try {
|
|
10
|
-
|
|
23
|
+
roleButtonExample();
|
|
11
24
|
} catch {
|
|
12
25
|
if (initCount <= 20) {
|
|
13
26
|
// setTimeout handles issue where content is sometimes loaded after the functions get called
|
|
@@ -602,11 +602,26 @@ class AuroElement extends i$2 {
|
|
|
602
602
|
// See LICENSE in the project root for license information.
|
|
603
603
|
|
|
604
604
|
|
|
605
|
-
// build the component class
|
|
606
605
|
class ComponentBase extends AuroElement {
|
|
607
606
|
constructor() {
|
|
608
607
|
super();
|
|
609
608
|
|
|
609
|
+
this._initializeDefaults();
|
|
610
|
+
|
|
611
|
+
/*
|
|
612
|
+
If the component requires a touch detection,
|
|
613
|
+
please use this function to determine if a user is
|
|
614
|
+
actively touching a device, versus detecting if
|
|
615
|
+
the device is touch enables or a handheld device.
|
|
616
|
+
|
|
617
|
+
Also uncomment the touch detection lib above
|
|
618
|
+
*/
|
|
619
|
+
this.addEventListener("touchstart", function () {
|
|
620
|
+
this.classList.add("is-touching");
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
_initializeDefaults() {
|
|
610
625
|
this.appearance = "default";
|
|
611
626
|
this.download = false;
|
|
612
627
|
this.ondark = false;
|
|
@@ -646,18 +661,6 @@ class ComponentBase extends AuroElement {
|
|
|
646
661
|
* @private
|
|
647
662
|
*/
|
|
648
663
|
this.runtimeUtils = new AuroLibraryRuntimeUtils();
|
|
649
|
-
|
|
650
|
-
/*
|
|
651
|
-
If the component requires a touch detection,
|
|
652
|
-
please use this function to determine if a user is
|
|
653
|
-
actively touching a device, versus detecting if
|
|
654
|
-
the device is touch enables or a handheld device.
|
|
655
|
-
|
|
656
|
-
Also uncomment the touch detection lib above
|
|
657
|
-
*/
|
|
658
|
-
this.addEventListener("touchstart", function () {
|
|
659
|
-
this.classList.add("is-touching");
|
|
660
|
-
});
|
|
661
664
|
}
|
|
662
665
|
|
|
663
666
|
// function to define props used within the scope of this component
|
|
@@ -667,79 +670,81 @@ class ComponentBase extends AuroElement {
|
|
|
667
670
|
|
|
668
671
|
/**
|
|
669
672
|
* Defines whether the component will be on lighter or darker backgrounds.
|
|
670
|
-
* @property {'default'
|
|
673
|
+
* @property {'default' | 'inverse'}
|
|
671
674
|
* @default 'default'
|
|
672
675
|
*/
|
|
673
676
|
appearance: {
|
|
674
677
|
type: String,
|
|
675
|
-
reflect: true
|
|
678
|
+
reflect: true
|
|
676
679
|
},
|
|
677
680
|
|
|
678
681
|
/**
|
|
679
|
-
*
|
|
682
|
+
* If true, the linked resource will be downloaded when the hyperlink is clicked.
|
|
680
683
|
*/
|
|
681
|
-
|
|
682
|
-
type:
|
|
683
|
-
reflect: true
|
|
684
|
+
download: {
|
|
685
|
+
type: Boolean,
|
|
686
|
+
reflect: true
|
|
684
687
|
},
|
|
685
688
|
|
|
686
689
|
/**
|
|
687
|
-
*
|
|
690
|
+
* If true and `type="cta"`, the hyperlink will have a fluid-width UI.
|
|
688
691
|
*/
|
|
689
|
-
|
|
690
|
-
type: String,
|
|
691
|
-
reflect: true,
|
|
692
|
-
},
|
|
692
|
+
fluid: { type: Boolean },
|
|
693
693
|
|
|
694
694
|
/**
|
|
695
|
-
* Defines
|
|
695
|
+
* Defines the URL of the linked page.
|
|
696
696
|
*/
|
|
697
|
-
|
|
697
|
+
href: {
|
|
698
698
|
type: String,
|
|
699
|
-
reflect: true
|
|
699
|
+
reflect: true
|
|
700
700
|
},
|
|
701
701
|
|
|
702
702
|
/**
|
|
703
|
-
*
|
|
703
|
+
* DEPRECATED - use `appearance="inverse"` instead.
|
|
704
704
|
*/
|
|
705
|
-
|
|
706
|
-
type: Boolean,
|
|
707
|
-
reflect: true,
|
|
708
|
-
},
|
|
705
|
+
ondark: { type: Boolean },
|
|
709
706
|
|
|
710
707
|
/**
|
|
711
|
-
*
|
|
708
|
+
* If true, sets `strict-origin-when-cross-origin` to control the referrer information sent with requests.
|
|
712
709
|
*/
|
|
713
|
-
|
|
710
|
+
referrerpolicy: {
|
|
711
|
+
type: Boolean,
|
|
712
|
+
reflect: true
|
|
713
|
+
},
|
|
714
714
|
|
|
715
715
|
/**
|
|
716
|
-
* Defines the
|
|
716
|
+
* Defines the relationship between the current document and the linked document. Visit [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/rel) for more information.
|
|
717
717
|
*/
|
|
718
|
-
|
|
718
|
+
rel: {
|
|
719
719
|
type: String,
|
|
720
|
-
reflect: true
|
|
720
|
+
reflect: true
|
|
721
721
|
},
|
|
722
722
|
|
|
723
723
|
/**
|
|
724
|
-
*
|
|
724
|
+
* Defines where to open the linked document.
|
|
725
725
|
*/
|
|
726
|
-
|
|
726
|
+
target: {
|
|
727
|
+
type: String,
|
|
728
|
+
reflect: true
|
|
729
|
+
},
|
|
727
730
|
|
|
728
731
|
/**
|
|
729
|
-
*
|
|
732
|
+
* Defines the type of hyperlink.
|
|
733
|
+
* @type {'nav' | 'cta'}
|
|
730
734
|
*/
|
|
731
|
-
|
|
732
|
-
type:
|
|
733
|
-
reflect: true
|
|
735
|
+
type: {
|
|
736
|
+
type: String,
|
|
737
|
+
reflect: true
|
|
734
738
|
},
|
|
735
739
|
|
|
736
740
|
/**
|
|
737
|
-
* Sets button variant option
|
|
738
|
-
* @
|
|
741
|
+
* Sets button variant option when using `type="cta"`.
|
|
742
|
+
* @type {'primary' | 'secondary' | 'tertiary' | 'ghost' | 'flat'}
|
|
743
|
+
* @default 'primary'
|
|
739
744
|
*/
|
|
740
745
|
variant: {
|
|
741
746
|
type: String,
|
|
742
|
-
reflect: true
|
|
747
|
+
reflect: true
|
|
743
748
|
},
|
|
744
749
|
};
|
|
745
750
|
}
|
|
@@ -1106,15 +1111,17 @@ class l{generateElementName(t,e){let o=t;return o+="-",o+=e.replace(/[.]/g,"_"),
|
|
|
1106
1111
|
var styles = i$5`a.auro-button{text-decoration:none}
|
|
1107
1112
|
`;
|
|
1108
1113
|
|
|
1109
|
-
// Copyright (c)
|
|
1114
|
+
// Copyright (c) 2026 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1110
1115
|
// See LICENSE in the project root for license information.
|
|
1111
1116
|
|
|
1112
1117
|
|
|
1113
|
-
|
|
1118
|
+
/**
|
|
1119
|
+
* @internal
|
|
1120
|
+
*/
|
|
1114
1121
|
class AuroHyperlinkButton extends T {
|
|
1115
1122
|
/**
|
|
1116
1123
|
* This will register this element with the browser.
|
|
1117
|
-
* @param {string} [name="auro-hyperlink-button"] - The name of element that you want to register
|
|
1124
|
+
* @param {string} [name="auro-hyperlink-button"] - The name of the element that you want to register.
|
|
1118
1125
|
*
|
|
1119
1126
|
* @example
|
|
1120
1127
|
* AuroHyperlinkButton.register("custom-hyperlink-button") // this will register this element to <custom-hyperlink-button/>
|
|
@@ -1150,9 +1157,14 @@ var tokensCss = i$5`:host(:not([type=cta])){--ds-auro-hyperlink-default-color-de
|
|
|
1150
1157
|
|
|
1151
1158
|
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
1152
1159
|
/**
|
|
1153
|
-
*
|
|
1160
|
+
* The `auro-hyperlink` element wraps an HTML `<a>` element, providing additional styling and behavior.
|
|
1161
|
+
* @customElement auro-hyperlink
|
|
1154
1162
|
*
|
|
1155
|
-
* @
|
|
1163
|
+
* @forcePrivate {'layout'}
|
|
1164
|
+
*
|
|
1165
|
+
* "Role" property needs to stay in this jsdocs block to avoid conflicts with testing framework.
|
|
1166
|
+
* @property {string} role - Defines ARIA roles; currently supports `button` for extended experiences.
|
|
1167
|
+
*
|
|
1156
1168
|
* @csspart link - Allows styling to be applied to the `a` element.
|
|
1157
1169
|
* @csspart targetIcon - Allows styling to be applied to the icon that appears next to the hyperlink.
|
|
1158
1170
|
*/
|
|
@@ -1222,7 +1234,7 @@ class AuroHyperlink extends ComponentBase {
|
|
|
1222
1234
|
|
|
1223
1235
|
/**
|
|
1224
1236
|
* This will register this element with the browser.
|
|
1225
|
-
* @param {string} [name="auro-hyperlink"] - The name of element that you want to register
|
|
1237
|
+
* @param {string} [name="auro-hyperlink"] - The name of the element that you want to register.
|
|
1226
1238
|
*
|
|
1227
1239
|
* @example
|
|
1228
1240
|
* AuroHyperlink.register("custom-hyperlink") // this will register this element to <custom-hyperlink/>
|
package/demo/index.html
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
<script defer type="module" src="./index.min.js"></script>
|
|
52
52
|
|
|
53
53
|
<!-- If additional elements are needed for the demo, add them here. -->
|
|
54
|
-
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest
|
|
55
|
-
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-icon@latest
|
|
54
|
+
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/+esm" type="module"></script>
|
|
55
|
+
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-icon@latest/+esm" type="module"></script>
|
|
56
56
|
</body>
|
|
57
57
|
</html>
|
package/demo/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { roleButtonExample } from "../apiExamples/roleButton";
|
|
2
1
|
import { AuroHyperlink } from "../src/index";
|
|
3
2
|
|
|
4
3
|
AuroHyperlink.register();
|
|
@@ -9,7 +8,6 @@ function initHyperlinkIndexExamples(initCount) {
|
|
|
9
8
|
initCount = initCount || 0;
|
|
10
9
|
|
|
11
10
|
try {
|
|
12
|
-
roleButtonExample();
|
|
13
11
|
} catch {
|
|
14
12
|
if (initCount <= 20) {
|
|
15
13
|
// setTimeout handles issue where content is sometimes loaded after the functions get called
|
package/demo/index.md
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
<style>
|
|
2
|
-
.exampleWrapper--ondark {
|
|
3
|
-
color: var(--ds-color-text-primary-inverse);
|
|
4
|
-
}
|
|
5
|
-
</style>
|
|
6
1
|
<!--
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
THIS PAGE'S CONTENT SHOULD BE KEPT MINIMAL.
|
|
3
|
+
ONLY ADD EXAMPLES THAT ARE TRULY NECESSARY FOR THE INDEX PAGE — THE BASIC EXAMPLE IS USUALLY ENOUGH.
|
|
4
|
+
ALL OTHER EXAMPLES SHOULD GO IN THE API DOCUMENTATION.
|
|
9
5
|
-->
|
|
10
6
|
|
|
11
|
-
# Hyperlink
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
# Hyperlink
|
|
8
|
+
|
|
9
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/description.md) -->
|
|
10
|
+
<!-- The below content is automatically added from ./../docs/partials/description.md -->
|
|
11
|
+
The `<auro-hyperlink>` element is a wrapper element for an HTML `<a>` element containing styling and behavior.
|
|
12
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
14
13
|
|
|
15
|
-
##
|
|
14
|
+
## Use Cases
|
|
15
|
+
|
|
16
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/useCases.md) -->
|
|
17
|
+
<!-- The below content is automatically added from ./../docs/partials/useCases.md -->
|
|
18
|
+
The `<auro-hyperlink>` elements should be used in situations where users may:
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
* stand-alone link element for navigation
|
|
21
|
+
* inline link element for navigation
|
|
22
|
+
* optional role as button when hyperlink UI is needed for submit action
|
|
23
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
24
|
+
|
|
25
|
+
## Example(s)
|
|
18
26
|
|
|
19
|
-
|
|
27
|
+
### Basic
|
|
28
|
+
|
|
29
|
+
<div class="exampleWrapper">
|
|
20
30
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/basic.html) -->
|
|
21
31
|
<!-- The below content is automatically added from ./../apiExamples/basic.html -->
|
|
22
32
|
<auro-hyperlink>No href supplied</auro-hyperlink><br>
|
|
23
33
|
Welcome to <auro-hyperlink href="https://www.alaskaair.com">Alaska Airlines</auro-hyperlink>.
|
|
24
34
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
25
35
|
</div>
|
|
26
|
-
<div class="exampleWrapper--ondark" aria-hidden>
|
|
27
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/basic-inverseAppearance.html) -->
|
|
28
|
-
<!-- The below content is automatically added from ./../apiExamples/basic-inverseAppearance.html -->
|
|
29
|
-
<auro-hyperlink appearance="inverse">No href supplied</auro-hyperlink><br>
|
|
30
|
-
Welcome to <auro-hyperlink appearance="inverse" href="https://www.alaskaair.com">Alaska Airlines</auro-hyperlink>.
|
|
31
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
32
|
-
</div>
|
|
33
36
|
<auro-accordion alignRight>
|
|
34
37
|
<span slot="trigger">See code</span>
|
|
35
38
|
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/basic.html) -->
|
|
@@ -39,244 +42,5 @@ If the `href` attribute is not added, the hyperlink element will render back sim
|
|
|
39
42
|
<auro-hyperlink>No href supplied</auro-hyperlink><br>
|
|
40
43
|
Welcome to <auro-hyperlink href="https://www.alaskaair.com">Alaska Airlines</auro-hyperlink>.
|
|
41
44
|
```
|
|
42
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
43
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/basic-inverseAppearance.html) -->
|
|
44
|
-
<!-- The below code snippet is automatically added from ./../apiExamples/basic-inverseAppearance.html -->
|
|
45
|
-
|
|
46
|
-
```html
|
|
47
|
-
<auro-hyperlink appearance="inverse">No href supplied</auro-hyperlink><br>
|
|
48
|
-
Welcome to <auro-hyperlink appearance="inverse" href="https://www.alaskaair.com">Alaska Airlines</auro-hyperlink>.
|
|
49
|
-
```
|
|
50
45
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
51
|
-
</auro-accordion>
|
|
52
|
-
|
|
53
|
-
## Navigation pattern example
|
|
54
|
-
|
|
55
|
-
Auro's hyperlink element can be used in many creative ways in combination with other elements for easy-to-manage UI solutions. This example uses the `auro-hyperlink` with the `auro-icon` elements with a little CSS to create a pretty popular nav style UI.
|
|
56
|
-
|
|
57
|
-
The `auro-icon` element comes with some pre-defined opinions, but these are easily overwritten by binding CSS directly to the custom element itself. Remember to also use the `customColor` attribute with `auro-icon` so that the SVG will inherit the link and hover colors of the hyperlink.
|
|
58
|
-
|
|
59
|
-
<div class="exampleWrapper" style="display: flex; justify-content: space-between;">
|
|
60
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/navPattern.html) -->
|
|
61
|
-
<!-- The below content is automatically added from ./../apiExamples/navPattern.html -->
|
|
62
|
-
<auro-hyperlink href="/last" type="nav">
|
|
63
|
-
<auro-icon category="interface" name="chevron-left" customColor style="line-height: 1"></auro-icon>
|
|
64
|
-
Click here to go back
|
|
65
|
-
</auro-hyperlink>
|
|
66
|
-
<auro-hyperlink href="/next" type="nav">
|
|
67
|
-
Click here to go forward
|
|
68
|
-
<auro-icon category="interface" name="chevron-right" customColor style="line-height: 1"></auro-icon>
|
|
69
|
-
</auro-hyperlink>
|
|
70
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
71
|
-
</div>
|
|
72
|
-
<div class="exampleWrapper--ondark" style="display: flex; justify-content: space-between;">
|
|
73
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/navPattern-inverseAppearance.html) -->
|
|
74
|
-
<!-- The below content is automatically added from ./../apiExamples/navPattern-inverseAppearance.html -->
|
|
75
|
-
<auro-hyperlink appearance="inverse" href="/last" type="nav">
|
|
76
|
-
<auro-icon appearance="inverse" category="interface" name="chevron-left" customColor style="line-height: 1"></auro-icon>
|
|
77
|
-
Click here to go back
|
|
78
|
-
</auro-hyperlink>
|
|
79
|
-
<auro-hyperlink appearance="inverse" href="/next" type="nav">
|
|
80
|
-
Click here to go forward
|
|
81
|
-
<auro-icon appearance="inverse" category="interface" name="chevron-right" customColor style="line-height: 1"></auro-icon>
|
|
82
|
-
</auro-hyperlink>
|
|
83
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
84
|
-
</div>
|
|
85
|
-
<auro-accordion alignRight>
|
|
86
|
-
<span slot="trigger">See code</span>
|
|
87
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/navPattern.html) -->
|
|
88
|
-
<!-- The below code snippet is automatically added from ./../apiExamples/navPattern.html -->
|
|
89
|
-
|
|
90
|
-
```html
|
|
91
|
-
<auro-hyperlink href="/last" type="nav">
|
|
92
|
-
<auro-icon category="interface" name="chevron-left" customColor style="line-height: 1"></auro-icon>
|
|
93
|
-
Click here to go back
|
|
94
|
-
</auro-hyperlink>
|
|
95
|
-
<auro-hyperlink href="/next" type="nav">
|
|
96
|
-
Click here to go forward
|
|
97
|
-
<auro-icon category="interface" name="chevron-right" customColor style="line-height: 1"></auro-icon>
|
|
98
|
-
</auro-hyperlink>
|
|
99
|
-
```
|
|
100
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
101
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/navPattern-inverseAppearance.html) -->
|
|
102
|
-
<!-- The below code snippet is automatically added from ./../apiExamples/navPattern-inverseAppearance.html -->
|
|
103
|
-
|
|
104
|
-
```html
|
|
105
|
-
<auro-hyperlink appearance="inverse" href="/last" type="nav">
|
|
106
|
-
<auro-icon appearance="inverse" category="interface" name="chevron-left" customColor style="line-height: 1"></auro-icon>
|
|
107
|
-
Click here to go back
|
|
108
|
-
</auro-hyperlink>
|
|
109
|
-
<auro-hyperlink appearance="inverse" href="/next" type="nav">
|
|
110
|
-
Click here to go forward
|
|
111
|
-
<auro-icon appearance="inverse" category="interface" name="chevron-right" customColor style="line-height: 1"></auro-icon>
|
|
112
|
-
</auro-hyperlink>
|
|
113
|
-
```
|
|
114
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
115
|
-
</auro-accordion>
|
|
116
|
-
|
|
117
|
-
## Using role="button"
|
|
118
|
-
|
|
119
|
-
Aside from the standard hyperlink use-case, the `auro-hyperlink` element is intended to be used for button situations as illustrated below. Assuming the role of button, `auro-hyperlink` also will track the `aria-pressed` state.
|
|
120
|
-
|
|
121
|
-
**Note:** Any `href` will be ignored when using `role="button"`. A click-event must be passed to the element as illustrated in the example below.
|
|
122
|
-
|
|
123
|
-
**Accessibility:** Review the code examples, the user of this element are responsible for keyboard support when using `role="button"`.
|
|
124
|
-
|
|
125
|
-
<div class="exampleWrapper">
|
|
126
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/roleButton.html) -->
|
|
127
|
-
<!-- The below content is automatically added from ./../apiExamples/roleButton.html -->
|
|
128
|
-
<auro-hyperlink href="http://www.alaskaair.com" role="button" id="roleButton">Cancel button</auro-hyperlink>
|
|
129
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
130
|
-
</div>
|
|
131
|
-
<div class="exampleWrapper--ondark">
|
|
132
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/roleButton-inverseAppearance.html) -->
|
|
133
|
-
<!-- The below content is automatically added from ./../apiExamples/roleButton-inverseAppearance.html -->
|
|
134
|
-
<auro-hyperlink appearance="inverse" href="http://www.alaskaair.com" role="button" id="roleButton-ondark">Cancel button</auro-hyperlink>
|
|
135
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
136
|
-
</div>
|
|
137
|
-
<auro-accordion alignRight>
|
|
138
|
-
<span slot="trigger">See code</span>
|
|
139
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/roleButton.html) -->
|
|
140
|
-
<!-- The below code snippet is automatically added from ./../apiExamples/roleButton.html -->
|
|
141
|
-
|
|
142
|
-
```html
|
|
143
|
-
<auro-hyperlink href="http://www.alaskaair.com" role="button" id="roleButton">Cancel button</auro-hyperlink>
|
|
144
|
-
```
|
|
145
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
146
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/roleButton-inverseAppearance.html) -->
|
|
147
|
-
<!-- The below code snippet is automatically added from ./../apiExamples/roleButton-inverseAppearance.html -->
|
|
148
|
-
|
|
149
|
-
```html
|
|
150
|
-
<auro-hyperlink appearance="inverse" href="http://www.alaskaair.com" role="button" id="roleButton-ondark">Cancel button</auro-hyperlink>
|
|
151
|
-
```
|
|
152
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
153
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/roleButton.js) -->
|
|
154
|
-
<!-- The below code snippet is automatically added from ./../apiExamples/roleButton.js -->
|
|
155
|
-
|
|
156
|
-
```js
|
|
157
|
-
export function roleButtonExample() {
|
|
158
|
-
const roleButton = document.getElementById("roleButton");
|
|
159
|
-
const roleButtonOndark = document.getElementById("roleButton-ondark");
|
|
160
|
-
|
|
161
|
-
roleButton.addEventListener("click", () => {
|
|
162
|
-
alert("You clicked the role button!");
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
roleButtonOndark.addEventListener("click", () => {
|
|
166
|
-
alert("You clicked the role button!");
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
171
|
-
</auro-accordion>
|
|
172
|
-
|
|
173
|
-
## Unsupported types
|
|
174
|
-
|
|
175
|
-
Not all URL types are supported for security reasons. Two common types that are worth mentioning are `javaScript:` and `data:`.
|
|
176
|
-
|
|
177
|
-
The following examples illustrate the use of `<auro-hyperlink>` with either no `href`, `javaScript:` or `data:` protocols being used. Note that `javascript` returns a shadowDOM as simple text. Using an unsupported protocol like `data:`, the protocol is removed from the provided `href` value.
|
|
178
|
-
|
|
179
|
-
<div class="exampleWrapper">
|
|
180
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/nonSupported.html) -->
|
|
181
|
-
<!-- The below content is automatically added from ./../apiExamples/nonSupported.html -->
|
|
182
|
-
<p>
|
|
183
|
-
<auro-hyperlink>No href supplied</auro-hyperlink>
|
|
184
|
-
</p>
|
|
185
|
-
<p>
|
|
186
|
-
<auro-hyperlink href="javascript:;">JavaScript not supported</auro-hyperlink>
|
|
187
|
-
</p>
|
|
188
|
-
<p>
|
|
189
|
-
<auro-hyperlink href="data:text/plain;charset=utf-8,Hello%20World!">Data type not supported</auro-hyperlink>
|
|
190
|
-
</p>
|
|
191
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
192
|
-
</div>
|
|
193
|
-
<auro-accordion alignRight>
|
|
194
|
-
<span slot="trigger">See code</span>
|
|
195
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/nonSupported.html) -->
|
|
196
|
-
<!-- The below code snippet is automatically added from ./../apiExamples/nonSupported.html -->
|
|
197
|
-
|
|
198
|
-
```html
|
|
199
|
-
<p>
|
|
200
|
-
<auro-hyperlink>No href supplied</auro-hyperlink>
|
|
201
|
-
</p>
|
|
202
|
-
<p>
|
|
203
|
-
<auro-hyperlink href="javascript:;">JavaScript not supported</auro-hyperlink>
|
|
204
|
-
</p>
|
|
205
|
-
<p>
|
|
206
|
-
<auro-hyperlink href="data:text/plain;charset=utf-8,Hello%20World!">Data type not supported</auro-hyperlink>
|
|
207
|
-
</p>
|
|
208
|
-
```
|
|
209
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
210
|
-
</auro-accordion>
|
|
211
|
-
|
|
212
|
-
## Typography
|
|
213
|
-
|
|
214
|
-
The `auro-hyperlink` component is designed to work with the typography classes provided by the Auro Design System.
|
|
215
|
-
|
|
216
|
-
The component will automatically inherit the typography styles from the parent element, allowing for consistent text styling across your application. Classes can also be applied directly onto the `auro-hyperlink` component.
|
|
217
|
-
|
|
218
|
-
<div class="exampleWrapper">
|
|
219
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/typography.html) -->
|
|
220
|
-
<!-- The below content is automatically added from ./../apiExamples/typography.html -->
|
|
221
|
-
<div class="body-xs">
|
|
222
|
-
Welcome to <auro-hyperlink href="https://www.alaskaair.com">Alaska Airlines</auro-hyperlink>.
|
|
223
|
-
</div>
|
|
224
|
-
<div class="body-default">
|
|
225
|
-
Welcome to <auro-hyperlink href="https://www.alaskaair.com">Alaska Airlines</auro-hyperlink>.
|
|
226
|
-
</div>
|
|
227
|
-
<div class="body-lg">
|
|
228
|
-
Welcome to <auro-hyperlink href="https://www.alaskaair.com">Alaska Airlines</auro-hyperlink>.
|
|
229
|
-
</div>
|
|
230
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
231
|
-
</div>
|
|
232
|
-
<auro-accordion alignRight>
|
|
233
|
-
<span slot="trigger">See code</span>
|
|
234
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/typography.html) -->
|
|
235
|
-
<!-- The below code snippet is automatically added from ./../apiExamples/typography.html -->
|
|
236
|
-
|
|
237
|
-
```html
|
|
238
|
-
<div class="body-xs">
|
|
239
|
-
Welcome to <auro-hyperlink href="https://www.alaskaair.com">Alaska Airlines</auro-hyperlink>.
|
|
240
|
-
</div>
|
|
241
|
-
<div class="body-default">
|
|
242
|
-
Welcome to <auro-hyperlink href="https://www.alaskaair.com">Alaska Airlines</auro-hyperlink>.
|
|
243
|
-
</div>
|
|
244
|
-
<div class="body-lg">
|
|
245
|
-
Welcome to <auro-hyperlink href="https://www.alaskaair.com">Alaska Airlines</auro-hyperlink>.
|
|
246
|
-
</div>
|
|
247
|
-
```
|
|
248
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
249
|
-
</auro-accordion>
|
|
250
|
-
|
|
251
|
-
## Recommended Use and Version Control
|
|
252
|
-
|
|
253
|
-
There are two important parts of every Auro component. The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes">class</a> and the custom element. The class is exported and then used as part of defining the Web Component. When importing this component as described in the <a href="#install">install</a> section, the class is imported and the `auro-hyperlink` custom element is defined automatically.
|
|
254
|
-
|
|
255
|
-
To protect from versioning conflicts with other instances of the component being loaded, it is recommended to use our `AuroHyperlink.register(name)` method and pass in a unique name.
|
|
256
|
-
|
|
257
|
-
```js
|
|
258
|
-
import { AuroHyperlink } from '@aurodesignsystem/auro-hyperlink/class';
|
|
259
|
-
|
|
260
|
-
AuroHyperlink.register('custom-hyperlink');
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
This will create a new custom element that you can use in your HTML that will function identically to the `<auro-hyperlink>` element.
|
|
264
|
-
|
|
265
|
-
<div class="exampleWrapper exampleWrapper--flex">
|
|
266
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/custom.html) -->
|
|
267
|
-
<!-- The below content is automatically added from ./../apiExamples/custom.html -->
|
|
268
|
-
<custom-hyperlink>No href supplied</custom-hyperlink><br>
|
|
269
|
-
Welcome to <custom-hyperlink href="https://www.alaskaair.com">Alaska Airlines</custom-hyperlink>.
|
|
270
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
271
|
-
</div>
|
|
272
|
-
<auro-accordion alignRight>
|
|
273
|
-
<span slot="trigger">See code</span>
|
|
274
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/custom.html) -->
|
|
275
|
-
<!-- The below code snippet is automatically added from ./../apiExamples/custom.html -->
|
|
276
|
-
|
|
277
|
-
```html
|
|
278
|
-
<custom-hyperlink>No href supplied</custom-hyperlink><br>
|
|
279
|
-
Welcome to <custom-hyperlink href="https://www.alaskaair.com">Alaska Airlines</custom-hyperlink>.
|
|
280
|
-
```
|
|
281
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
282
46
|
</auro-accordion>
|
package/demo/index.min.js
CHANGED
|
@@ -1,35 +1,4 @@
|
|
|
1
1
|
import { A as AuroHyperlink } from './auro-hyperlink.min.js';
|
|
2
2
|
|
|
3
|
-
function roleButtonExample() {
|
|
4
|
-
const roleButton = document.getElementById("roleButton");
|
|
5
|
-
const roleButtonOndark = document.getElementById("roleButton-ondark");
|
|
6
|
-
|
|
7
|
-
roleButton.addEventListener("click", () => {
|
|
8
|
-
alert("You clicked the role button!");
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
roleButtonOndark.addEventListener("click", () => {
|
|
12
|
-
alert("You clicked the role button!");
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
3
|
AuroHyperlink.register();
|
|
17
4
|
AuroHyperlink.register("custom-hyperlink");
|
|
18
|
-
|
|
19
|
-
function initHyperlinkIndexExamples(initCount) {
|
|
20
|
-
// biome-ignore lint: no-unused-vars
|
|
21
|
-
initCount = initCount || 0;
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
roleButtonExample();
|
|
25
|
-
} catch {
|
|
26
|
-
if (initCount <= 20) {
|
|
27
|
-
// setTimeout handles issue where content is sometimes loaded after the functions get called
|
|
28
|
-
setTimeout(() => {
|
|
29
|
-
initHyperlinkIndexExamples(initCount + 1);
|
|
30
|
-
}, 100);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
initHyperlinkIndexExamples();
|