Debian Codegraph @

resources/lib/codex/mixins/link.less

raw
1 // Link Styles
2 //
3 // Per ADR 04, Codex Links are implemented as a re-usable Less mixin rather
4 // than a Vue.js component. Users who wish to apply the Codex Link styles to
5 // elements on a page should call the mixin inside of the relevant selector in
6 // their own stylesheets. Variants (underlined links, red links) can be accessed
7 // by adding the appropriate modifier class (.is-underlined and .is-red-link,
8 // respectively).
9 //
10 // Code that needs to customize these modifier classes or otherwise customize the
11 // selectors used for these modifiers can use the following sub-mixins:
12 // - cdx-mixin-link-base(): base link styles
13 // - cdx-mixin-link-underlined(): underlined link (-base must also be applied)
14 // - cdx-mixin-link-red(): red link (-base must also be applied)
15 //
16 // Example usage:
17 //
18 // .my-link-class {
19 // .cdx-mixin-link-base();
20 //
21 // &.custom-underlined-class {
22 // .cdx-mixin-link-underlined();
23 // }
24 //
25 // &.custom-red-link-class {
26 // .cdx-mixin-link-red();
27 // }
28 // }
29 //
30 // Link styles can be used inside of other Vue components, or anywhere that Less
31 // is available; JS is not required.
32
33 .cdx-mixin-link-base() {
34 color: @color-progressive;
35 border-radius: @border-radius-base;
36 text-decoration: @text-decoration-none;
37
38 &:visited {
39 color: @color-visited;
40
41 &:hover {
42 color: @color-visited;
43 }
44 }
45
46 &:hover {
47 color: @color-progressive--hover;
48 text-decoration: @text-decoration-underline;
49 }
50
51 &:active {
52 color: @color-progressive--active;
53 text-decoration: @text-decoration-underline;
54 }
55
56 &:focus-visible {
57 outline: @border-style-base @border-width-thick @outline-color-progressive--focus;
58 }
59
60 @supports not selector( :focus-visible ) {
61 &:focus {
62 outline: @border-style-base @border-width-thick @outline-color-progressive--focus;
63 }
64 }
65
66 // Style external link icon.
67 // HACK: Make sure this doesn't apply to placeholder icons in TypeaheadSearch (T372420).
68 .cdx-icon:not( .cdx-thumbnail__placeholder__icon--vue ):last-child {
69 // Note, `@min-size-icon-x-small` & `@size-icon-small` are an approximation in our current
70 // 16/14 base font theme environment.
71 // We're faking it to make it, `@min-size-icon-x-small` is `12px` in both themes,
72 // `@size-icon-small` is `1em`, achieving the desired size.
73 min-width: @min-size-icon-x-small;
74 min-height: @min-size-icon-x-small;
75 width: @size-icon-small;
76 height: @size-icon-small;
77 padding-left: @spacing-25;
78 vertical-align: middle;
79 }
80 }
81
82 .cdx-mixin-link-underlined() {
83 text-decoration: @text-decoration-underline;
84 }
85
86 .cdx-mixin-link-red() {
87 color: @color-link-red;
88
89 &:visited {
90 color: @color-link-red--visited;
91
92 &:hover {
93 color: @color-link-red--visited;
94 }
95 }
96
97 &:hover {
98 color: @color-link-red--hover;
99 text-decoration: @text-decoration-underline;
100 }
101
102 &:active {
103 color: @color-link-red--active;
104 text-decoration: @text-decoration-underline;
105 }
106
107 &:focus {
108 outline-color: @outline-color-progressive--focus;
109 }
110 }
111
112 .cdx-mixin-link() {
113 .cdx-mixin-link-base();
114
115 // stylelint-disable-next-line selector-class-pattern
116 &.is-underlined {
117 .cdx-mixin-link-underlined();
118 }
119
120 // stylelint-disable-next-line selector-class-pattern
121 &.is-red-link {
122 .cdx-mixin-link-red();
123 }
124 }