Skip to content

Commit 4937d34

Browse files
authored
Merge pull request #887 from lukasnys/anchor-redesign
API docs redesign anchor
2 parents ef4d2e1 + 62a632f commit 4937d34

File tree

6 files changed

+30
-41
lines changed

6 files changed

+30
-41
lines changed

app/components/class-field-description.hbs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<section class='{{@type}}'>
2-
{{!-- TODO: Fix this link for a11y --}}
3-
<h3 class='class-field-description--link' data-anchor='{{@field.name}}' role='link' {{on 'click' (fn this.updateAnchor @field.name)}}>
4-
<a class='anchor' {{!-- template-lint-disable link-href-attributes --}}>
5-
{{svg-jar 'fa-link' class='class-field-description--link-hover' width='20px' height='20px'}}
6-
</a>
2+
<h3 data-anchor='{{@field.name}}'>
73
<span class='{{@type}}-name'>{{@field.name}}</span>
84
{{#if @field.params}}
95
<span class='args'>
@@ -19,6 +15,10 @@
1915
{{#if @field.deprecated}}
2016
<span class='access'>deprecated</span>
2117
{{/if}}
18+
{{!-- TODO: Fix this link for a11y --}}
19+
<a class='class-field-description--link' data-test-anchor="{{@field.name}}" role='link' {{on 'click' (fn this.updateAnchor @field.name)}} {{!-- template-lint-disable link-href-attributes --}}>
20+
{{svg-jar 'link' width='20px' height='20px'}}
21+
</a>
2222
</h3>
2323
{{#if @model.module}}
2424
<div class='attributes'>

app/styles/app.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@ li.toc-heading:first-child {
9090
margin-top: 0;
9191
}
9292

93+
a.class-field-description--link {
94+
margin-left: 12px;
95+
vertical-align: middle;
96+
background: none;
97+
cursor: pointer;
98+
}
99+
100+
a.class-field-description--link svg {
101+
height: 18px;
102+
fill: var(--color-gray-600);
103+
transform: rotate(45deg);
104+
vertical-align: middle;
105+
}
106+
107+
a.class-field-description--link:hover svg {
108+
fill: var(--color-brand);
109+
}
110+
93111
@media (min-width: 845px) {
94112
.es-header {
95113
padding: 0 var(--spacing-4);

public/assets/images/fa-link.svg

Lines changed: 0 additions & 5 deletions
This file was deleted.

public/assets/images/link.svg

Lines changed: 3 additions & 0 deletions
Loading

tests/acceptance/anchors-test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ module('Acceptance | Creating Anchors', function (hooks) {
1111
await click(element);
1212
assert.equal(
1313
currentURL(),
14-
`/ember/1.0/classes/Container/properties?anchor=${element.innerText.trim()}`
14+
`/ember/1.0/classes/Container/properties?anchor=${element.getAttribute(
15+
'data-test-anchor'
16+
)}`
1517
);
1618
});
1719
});

tests/integration/components/class-field-description-test.js

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
import EmberObject from '@ember/object';
33
import { module, test } from 'qunit';
44
import { setupRenderingTest } from 'ember-qunit';
5-
import {
6-
render,
7-
click,
8-
findAll,
9-
find,
10-
triggerEvent,
11-
} from '@ember/test-helpers';
5+
import { render, click, findAll, find } from '@ember/test-helpers';
126
import hbs from 'htmlbars-inline-precompile';
137

148
module('Integration | Component | class field description', function (hooks) {
@@ -37,29 +31,6 @@ module('Integration | Component | class field description', function (hooks) {
3731
assert.dom(findAll('.args')[0]).hasText('(param1, param2, param3)');
3832
});
3933

40-
test('On hover -- the link icon shows up', async function (assert) {
41-
this.set('type', 'method');
42-
this.set(
43-
'field',
44-
EmberObject.create({
45-
access: 'public',
46-
deprecated: true,
47-
name: 'concat',
48-
description: 'concatenates',
49-
params: [{ name: 'param1' }, { name: 'param2' }, { name: 'param3' }],
50-
})
51-
);
52-
53-
await render(
54-
hbs`<ClassFieldDescription @type={{this.type}} @field={{this.field}}/>`
55-
);
56-
57-
await triggerEvent('.class-field-description--link', 'mouseenter');
58-
assert
59-
.dom('.class-field-description--link-hover')
60-
.exists('The link icon appears when hovering on the method text');
61-
});
62-
6334
test('it calls the provided action on link-click with the field name as an arg', async function (assert) {
6435
this.set('updateAnchor', (name) => {
6536
assert.equal(

0 commit comments

Comments
 (0)