Skip to content

Commit bc2e0e4

Browse files
authored
Merge pull request #493 from ember-learn/anchor-styling
Move header anchor styling into styleguide
2 parents d7ba17a + dc33a0a commit bc2e0e4

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

addon/styles/addon.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@import 'icon.css';
1515
@import 'sidebar-container.css';
1616
@import 'well.css';
17+
@import 'header-anchor';
1718

1819
/* Helpers */
1920
@import 'helpers/index.css';

addon/styles/header-anchor.css

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
h1 > a,
2+
h2 > a,
3+
h3 > a,
4+
h4 > a,
5+
h5 > a,
6+
h6 > a {
7+
margin-left: 12px;
8+
vertical-align: middle;
9+
}
10+
11+
main h1 > a:link,
12+
main h2 > a:link,
13+
main h3 > a:link,
14+
main h4 > a:link,
15+
main h5 > a:link,
16+
main h6 > a:link {
17+
background: none;
18+
}
19+
20+
h1 > a > svg,
21+
h2 > a > svg,
22+
h3 > a > svg,
23+
h4 > a > svg,
24+
h5 > a > svg,
25+
h6 > a > svg {
26+
height: 18px;
27+
fill: var(--color-gray-600);
28+
transform: rotate(45deg);
29+
}
30+
31+
h1 > a:hover > svg,
32+
h2 > a:hover > svg,
33+
h3 > a:hover > svg,
34+
h4 > a:hover > svg,
35+
h5 > a:hover > svg,
36+
h6 > a:hover > svg {
37+
fill: var(--color-brand);
38+
}

docs/concepts/header-anchor.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Header anchor
2+
3+
In our documentation we want to be able to link to specific headers, that's why we introduce this pattern. The `<h>` includes the `<a>` that includes the link `<svg>`. This removes the link underline default styling from all `<a>`s wrapped in `<h>`-elements and rotates all `svg`s by 45 degrees if they are wrapped in both.
4+
5+
```html
6+
<h2 id="toc_multiple-dynamic-segments">
7+
Multiple Dynamic Segments
8+
<a href="#multiple-dynamic-segments">
9+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
10+
<path
11+
d="M326.61 185.4c59.75 59.8 58.93 155.69.36 214.58-.1.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.7 59.26-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.1-37.1c9.85-9.85 26.8-3.3 27.3 10.6a184.27 184.27 0 0 0 9.7 52.72 16.1 16.1 0 0 1-3.8 16.61l-13.08 13.1c-28.02 28.02-28.9 73.65-1.15 101.95 28.02 28.58 74.08 28.75 102.32.51l67.2-67.19a71.98 71.98 0 0 0-10.34-110.4 16.04 16.04 0 0 1-6.95-12.6 39.83 39.83 0 0 1 11.7-29.81l21.06-21.06a16.06 16.06 0 0 1 20.58-1.73 152.48 152.48 0 0 1 20.52 17.2zM467.55 44.44c-59.26-59.26-155.7-59.27-214.96 0l-67.2 67.2-.36.37c-58.57 58.9-59.39 154.78.36 214.59a152.45 152.45 0 0 0 20.52 17.2 16.07 16.07 0 0 0 20.58-1.74l21.06-21.05a39.83 39.83 0 0 0 11.7-29.8 16.04 16.04 0 0 0-6.95-12.61 71.98 71.98 0 0 1-10.34-110.4l67.2-67.2c28.23-28.23 74.3-28.06 102.32.52 27.75 28.3 26.87 73.93-1.15 101.96l-13.1 13.09a16.1 16.1 0 0 0-3.77 16.6c5.86 17.2 9.04 35 9.69 52.73.5 13.9 17.45 20.44 27.29 10.6l37.1-37.1c59.28-59.26 59.28-155.7 0-214.96z"></path>
12+
</svg>
13+
</a>
14+
</h2>
15+
```

0 commit comments

Comments
 (0)