Skip to content

Commit 13a4654

Browse files
enstyledtobiasahlinactions-user
authored
Marketing: add link components (#1807)
* Initial setup for marketing links * Create short-pugs-press.md * Rename .mktg-link to .link-mktg * Update the link underline style * Update the usage examples * Clean up the SCSS * Add animated octicon-chevrow * Add underline-pale variant * Improve docs * Lint ignore the use of currentColor * Reduce the examples, refactor the chevrow animation * Refactor the octicon chevrow positioning and sizing * Less absolute positioning * Update the docs * Document link colors * Define underline offset with ems * Update marketing-links.md * Update chevrow position animation * Rename underline-pale to link-emphasis-mktg * Fix stylelint errors * Reduce the :active state chevrow position * Fix stylelint-disable comments * Obey the stylelint! * Rename octicon-chevrow to link-arrow-mktg * Extract the animated arrow as utility * Stylelint auto-fixes * Remove markdown leftover * Fix positioning in marketing buttons and links * Stylelint ignore marketing button line-height * Stylelint auto-fixes * Expand the arrow-target-mktg selector to cover btn-mktg and link-mktg Co-authored-by: Tobias Ahlin <[email protected]> * Update the btn-mktg line height * Revert the btn-mktg padding changes * Remove stylelint ignore rule * Expand the changelog * Improve the link-emphasis-mktg docs * Add prefers-reduced-motion media queries * Stylelint disable max-nesting-depth Co-authored-by: Tobias Ahlin <[email protected]> Co-authored-by: Actions Auto Build <[email protected]>
1 parent 4abb1af commit 13a4654

File tree

8 files changed

+219
-0
lines changed

8 files changed

+219
-0
lines changed

.changeset/short-pugs-press.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@primer/css": minor
3+
---
4+
5+
Marketing: Add link components
6+
Marketing: Add animated arrow utility
7+
Marketing: Document button components with arrows

docs/content/components/marketing-buttons.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,41 @@ Marketing buttons can be set to three different sizes:
4343
<button class="btn-mktg btn-subtle-mktg btn-large-mktg mr-3" type="button">Contact us</button>
4444
<button class="btn-mktg btn-signup-mktg btn-large-mktg" type="button">Sign up</button>
4545
```
46+
47+
## Animated arrow symbol
48+
49+
Marketing buttons can include an animated arrow symbol, by adding a class `arrow-target-mktg` and including the SVG symbol:
50+
51+
```html live
52+
<button class="btn-mktg arrow-target-mktg mr-3" type="button">
53+
Get started
54+
<svg xmlns="http://www.w3.org/2000/svg" class="octicon arrow-symbol-mktg" width="16" height="16" viewBox="0 0 16 16" fill="none">
55+
<path fill="currentColor" d="M7.28033 3.21967C6.98744 2.92678 6.51256 2.92678 6.21967 3.21967C5.92678 3.51256 5.92678 3.98744 6.21967 4.28033L7.28033 3.21967ZM11 8L11.5303 8.53033C11.8232 8.23744 11.8232 7.76256 11.5303 7.46967L11 8ZM6.21967 11.7197C5.92678 12.0126 5.92678 12.4874 6.21967 12.7803C6.51256 13.0732 6.98744 13.0732 7.28033 12.7803L6.21967 11.7197ZM6.21967 4.28033L10.4697 8.53033L11.5303 7.46967L7.28033 3.21967L6.21967 4.28033ZM10.4697 7.46967L6.21967 11.7197L7.28033 12.7803L11.5303 8.53033L10.4697 7.46967Z"></path>
56+
<path stroke="currentColor" d="M1.75 8H11" stroke-width="1.5" stroke-linecap="round"></path>
57+
</svg>
58+
</button>
59+
60+
<button class="btn-mktg arrow-target-mktg btn-muted-mktg mr-3" type="button">
61+
Learn more
62+
<svg xmlns="http://www.w3.org/2000/svg" class="octicon arrow-symbol-mktg" width="16" height="16" viewBox="0 0 16 16" fill="none">
63+
<path fill="currentColor" d="M7.28033 3.21967C6.98744 2.92678 6.51256 2.92678 6.21967 3.21967C5.92678 3.51256 5.92678 3.98744 6.21967 4.28033L7.28033 3.21967ZM11 8L11.5303 8.53033C11.8232 8.23744 11.8232 7.76256 11.5303 7.46967L11 8ZM6.21967 11.7197C5.92678 12.0126 5.92678 12.4874 6.21967 12.7803C6.51256 13.0732 6.98744 13.0732 7.28033 12.7803L6.21967 11.7197ZM6.21967 4.28033L10.4697 8.53033L11.5303 7.46967L7.28033 3.21967L6.21967 4.28033ZM10.4697 7.46967L6.21967 11.7197L7.28033 12.7803L11.5303 8.53033L10.4697 7.46967Z"></path>
64+
<path stroke="currentColor" d="M1.75 8H11" stroke-width="1.5" stroke-linecap="round"></path>
65+
</svg>
66+
</button>
67+
68+
<button class="btn-mktg arrow-target-mktg btn-subtle-mktg mr-3" type="button">
69+
Contact us
70+
<svg xmlns="http://www.w3.org/2000/svg" class="octicon arrow-symbol-mktg" width="16" height="16" viewBox="0 0 16 16" fill="none">
71+
<path fill="currentColor" d="M7.28033 3.21967C6.98744 2.92678 6.51256 2.92678 6.21967 3.21967C5.92678 3.51256 5.92678 3.98744 6.21967 4.28033L7.28033 3.21967ZM11 8L11.5303 8.53033C11.8232 8.23744 11.8232 7.76256 11.5303 7.46967L11 8ZM6.21967 11.7197C5.92678 12.0126 5.92678 12.4874 6.21967 12.7803C6.51256 13.0732 6.98744 13.0732 7.28033 12.7803L6.21967 11.7197ZM6.21967 4.28033L10.4697 8.53033L11.5303 7.46967L7.28033 3.21967L6.21967 4.28033ZM10.4697 7.46967L6.21967 11.7197L7.28033 12.7803L11.5303 8.53033L10.4697 7.46967Z"></path>
72+
<path stroke="currentColor" d="M1.75 8H11" stroke-width="1.5" stroke-linecap="round"></path>
73+
</svg>
74+
</button>
75+
76+
<button class="btn-mktg arrow-target-mktg btn-signup-mktg" type="button">
77+
Sign up
78+
<svg xmlns="http://www.w3.org/2000/svg" class="octicon arrow-symbol-mktg" width="16" height="16" viewBox="0 0 16 16" fill="none">
79+
<path fill="currentColor" d="M7.28033 3.21967C6.98744 2.92678 6.51256 2.92678 6.21967 3.21967C5.92678 3.51256 5.92678 3.98744 6.21967 4.28033L7.28033 3.21967ZM11 8L11.5303 8.53033C11.8232 8.23744 11.8232 7.76256 11.5303 7.46967L11 8ZM6.21967 11.7197C5.92678 12.0126 5.92678 12.4874 6.21967 12.7803C6.51256 13.0732 6.98744 13.0732 7.28033 12.7803L6.21967 11.7197ZM6.21967 4.28033L10.4697 8.53033L11.5303 7.46967L7.28033 3.21967L6.21967 4.28033ZM10.4697 7.46967L6.21967 11.7197L7.28033 12.7803L11.5303 8.53033L10.4697 7.46967Z"></path>
80+
<path stroke="currentColor" d="M1.75 8H11" stroke-width="1.5" stroke-linecap="round"></path>
81+
</svg>
82+
</button>
83+
```
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Marketing links
3+
path: components/marketing-links
4+
status: Beta
5+
source: 'https://github.com/primer/css/tree/main/src/marketing/links'
6+
bundle: marketing-links
7+
---
8+
9+
Marketing links can be produced by combining the base class `link-mktg` with a set of modifier classes to control the size and color.
10+
11+
12+
## Link sizes
13+
14+
The marketing link size is defined with utility classes and come in large (`.f3-mktg`) and small (`.f4-mktg`):
15+
16+
```html live
17+
<a href="#" class="link-mktg arrow-target-mktg text-semibold f3-mktg">
18+
Call to action
19+
20+
<svg xmlns="http://www.w3.org/2000/svg" class="octicon arrow-symbol-mktg" width="16" height="16" viewBox="0 0 16 16" fill="none">
21+
<path fill="currentColor" d="M7.28033 3.21967C6.98744 2.92678 6.51256 2.92678 6.21967 3.21967C5.92678 3.51256 5.92678 3.98744 6.21967 4.28033L7.28033 3.21967ZM11 8L11.5303 8.53033C11.8232 8.23744 11.8232 7.76256 11.5303 7.46967L11 8ZM6.21967 11.7197C5.92678 12.0126 5.92678 12.4874 6.21967 12.7803C6.51256 13.0732 6.98744 13.0732 7.28033 12.7803L6.21967 11.7197ZM6.21967 4.28033L10.4697 8.53033L11.5303 7.46967L7.28033 3.21967L6.21967 4.28033ZM10.4697 7.46967L6.21967 11.7197L7.28033 12.7803L11.5303 8.53033L10.4697 7.46967Z"></path>
22+
<path stroke="currentColor" d="M1.75 8H11" stroke-width="1.5" stroke-linecap="round"></path>
23+
</svg>
24+
</a>
25+
```
26+
27+
```html live
28+
<a href="#" class="link-mktg arrow-target-mktg text-semibold f4-mktg">
29+
Call to action
30+
31+
<svg xmlns="http://www.w3.org/2000/svg" class="octicon arrow-symbol-mktg" width="16" height="16" viewBox="0 0 16 16" fill="none">
32+
<path fill="currentColor" d="M7.28033 3.21967C6.98744 2.92678 6.51256 2.92678 6.21967 3.21967C5.92678 3.51256 5.92678 3.98744 6.21967 4.28033L7.28033 3.21967ZM11 8L11.5303 8.53033C11.8232 8.23744 11.8232 7.76256 11.5303 7.46967L11 8ZM6.21967 11.7197C5.92678 12.0126 5.92678 12.4874 6.21967 12.7803C6.51256 13.0732 6.98744 13.0732 7.28033 12.7803L6.21967 11.7197ZM6.21967 4.28033L10.4697 8.53033L11.5303 7.46967L7.28033 3.21967L6.21967 4.28033ZM10.4697 7.46967L6.21967 11.7197L7.28033 12.7803L11.5303 8.53033L10.4697 7.46967Z"></path>
33+
<path stroke="currentColor" d="M1.75 8H11" stroke-width="1.5" stroke-linecap="round"></path>
34+
</svg>
35+
</a>
36+
```
37+
38+
## Link with emphasis
39+
40+
Add class `link-emphasis-mktg` to the link, to give it a pale underline, that will fill up on hover.
41+
42+
```html live
43+
<a href="#" class="link-mktg arrow-target-mktg link-emphasis-mktg text-semibold f3-mktg">
44+
Call to action
45+
46+
<svg xmlns="http://www.w3.org/2000/svg" class="octicon arrow-symbol-mktg" width="16" height="16" viewBox="0 0 16 16" fill="none">
47+
<path fill="currentColor" d="M7.28033 3.21967C6.98744 2.92678 6.51256 2.92678 6.21967 3.21967C5.92678 3.51256 5.92678 3.98744 6.21967 4.28033L7.28033 3.21967ZM11 8L11.5303 8.53033C11.8232 8.23744 11.8232 7.76256 11.5303 7.46967L11 8ZM6.21967 11.7197C5.92678 12.0126 5.92678 12.4874 6.21967 12.7803C6.51256 13.0732 6.98744 13.0732 7.28033 12.7803L6.21967 11.7197ZM6.21967 4.28033L10.4697 8.53033L11.5303 7.46967L7.28033 3.21967L6.21967 4.28033ZM10.4697 7.46967L6.21967 11.7197L7.28033 12.7803L11.5303 8.53033L10.4697 7.46967Z"></path>
48+
<path stroke="currentColor" d="M1.75 8H11" stroke-width="1.5" stroke-linecap="round"></path>
49+
</svg>
50+
</a>
51+
```
52+
53+
54+
## Link colors
55+
56+
The link color is controlled with the [Primer color classes](/utilities/colors), while the symbol and underline styling will follow:
57+
58+
```html live
59+
<a href="#" class="link-mktg arrow-target-mktg text-semibold f3-mktg color-fg-default mr-4">
60+
Call to action
61+
62+
<svg xmlns="http://www.w3.org/2000/svg" class="octicon arrow-symbol-mktg" width="16" height="16" viewBox="0 0 16 16" fill="none">
63+
<path fill="currentColor" d="M7.28033 3.21967C6.98744 2.92678 6.51256 2.92678 6.21967 3.21967C5.92678 3.51256 5.92678 3.98744 6.21967 4.28033L7.28033 3.21967ZM11 8L11.5303 8.53033C11.8232 8.23744 11.8232 7.76256 11.5303 7.46967L11 8ZM6.21967 11.7197C5.92678 12.0126 5.92678 12.4874 6.21967 12.7803C6.51256 13.0732 6.98744 13.0732 7.28033 12.7803L6.21967 11.7197ZM6.21967 4.28033L10.4697 8.53033L11.5303 7.46967L7.28033 3.21967L6.21967 4.28033ZM10.4697 7.46967L6.21967 11.7197L7.28033 12.7803L11.5303 8.53033L10.4697 7.46967Z"></path>
64+
<path stroke="currentColor" d="M1.75 8H11" stroke-width="1.5" stroke-linecap="round"></path>
65+
</svg>
66+
</a>
67+
68+
<a href="#" class="link-mktg arrow-target-mktg link-emphasis-mktg text-semibold f4-mktg color-fg-default">
69+
Call to action
70+
71+
<svg xmlns="http://www.w3.org/2000/svg" class="octicon arrow-symbol-mktg" width="16" height="16" viewBox="0 0 16 16" fill="none">
72+
<path fill="currentColor" d="M7.28033 3.21967C6.98744 2.92678 6.51256 2.92678 6.21967 3.21967C5.92678 3.51256 5.92678 3.98744 6.21967 4.28033L7.28033 3.21967ZM11 8L11.5303 8.53033C11.8232 8.23744 11.8232 7.76256 11.5303 7.46967L11 8ZM6.21967 11.7197C5.92678 12.0126 5.92678 12.4874 6.21967 12.7803C6.51256 13.0732 6.98744 13.0732 7.28033 12.7803L6.21967 11.7197ZM6.21967 4.28033L10.4697 8.53033L11.5303 7.46967L7.28033 3.21967L6.21967 4.28033ZM10.4697 7.46967L6.21967 11.7197L7.28033 12.7803L11.5303 8.53033L10.4697 7.46967Z"></path>
73+
<path stroke="currentColor" d="M1.75 8H11" stroke-width="1.5" stroke-linecap="round"></path>
74+
</svg>
75+
</a>
76+
```

docs/src/@primer/gatsby-theme-doctocat/nav.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
url: /components/markdown
9494
- title: Marketing buttons
9595
url: /components/marketing-buttons
96+
- title: Marketing links
97+
url: /components/marketing-links
9698
- title: Navigation
9799
url: /components/navigation
98100
- title: Pagination

src/marketing/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
// marketing specific css modules
1212
@import './type/index.scss';
1313
@import './buttons/index.scss';
14+
@import './links/index.scss';
1415
@import './utilities/index.scss';

src/marketing/links/index.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// support files
2+
@import '../support/index.scss';
3+
@import './link.scss';

src/marketing/links/link.scss

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.link-mktg {
2+
position: relative;
3+
display: inline-block;
4+
5+
&:hover {
6+
text-decoration: none;
7+
}
8+
9+
&:active {
10+
outline: none;
11+
}
12+
13+
&::after,
14+
&.link-emphasis-mktg::before {
15+
position: absolute;
16+
bottom: -0.15em;
17+
left: 0;
18+
width: calc(100% - 1em);
19+
height: 2px;
20+
pointer-events: none;
21+
content: '';
22+
// stylelint-disable-next-line primer/colors
23+
background-color: currentColor;
24+
transform: scaleX(0);
25+
transform-origin: 0 0;
26+
27+
@media screen and (prefers-reduced-motion: no-preference) {
28+
transition: transform 0.3s ease;
29+
}
30+
}
31+
32+
&.link-emphasis-mktg::before {
33+
opacity: 0.2;
34+
transform: scaleX(1);
35+
}
36+
37+
&:hover,
38+
&:focus,
39+
&:active {
40+
&::after {
41+
transform: scaleX(1);
42+
}
43+
}
44+
45+
&.arrow-target-mktg {
46+
.arrow-symbol-mktg {
47+
margin-left: -$em-spacer-3;
48+
}
49+
}
50+
}

src/marketing/utilities/animations.scss

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,45 @@
77
transform: scale3d(1.025, 1.025, 1.025);
88
}
99
}
10+
11+
// Animated arrow symbol, used in marketing links, buttons, etc.
12+
.btn-mktg,
13+
.link-mktg,
14+
.arrow-target-mktg {
15+
.octicon {
16+
width: 1em;
17+
height: 1em;
18+
}
19+
20+
.arrow-symbol-mktg {
21+
transition: transform 0.2s;
22+
transform: translateX(0);
23+
24+
// stylelint-disable-next-line selector-max-type
25+
path:last-child {
26+
stroke-dasharray: 10;
27+
stroke-dashoffset: 10;
28+
transition: stroke-dashoffset 0.2s;
29+
}
30+
}
31+
32+
@media screen and (prefers-reduced-motion: no-preference) {
33+
&:hover,
34+
&:focus {
35+
.arrow-symbol-mktg {
36+
transform: translateX(4px);
37+
38+
// stylelint-disable-next-line selector-max-type, selector-max-specificity, max-nesting-depth
39+
path:last-child {
40+
stroke-dashoffset: 20;
41+
}
42+
}
43+
}
44+
45+
&:active {
46+
.arrow-symbol-mktg {
47+
transform: translateX(6px);
48+
}
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)