Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API docs redesign anchor #887

Merged
merged 9 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/components/class-field-description.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<section class='{{@type}}'>
{{!-- TODO: Fix this link for a11y --}}
<h3 class='class-field-description--link' data-anchor='{{@field.name}}' role='link' {{on 'click' (fn this.updateAnchor @field.name)}}>
<a class='anchor' {{!-- template-lint-disable link-href-attributes --}}>
{{svg-jar 'fa-link' class='class-field-description--link-hover' width='20px' height='20px'}}
</a>
<h3 data-anchor='{{@field.name}}'>
<span class='{{@type}}-name'>{{@field.name}}</span>
{{#if @field.params}}
<span class='args'>
Expand All @@ -19,6 +15,10 @@
{{#if @field.deprecated}}
<span class='access'>deprecated</span>
{{/if}}
{{!-- TODO: Fix this link for a11y --}}
<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 --}}>
{{svg-jar 'link' width='20px' height='20px'}}
</a>
</h3>
{{#if @model.module}}
<div class='attributes'>
Expand Down
18 changes: 18 additions & 0 deletions app/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ li.toc-heading:first-child {
margin-top: 0;
}

a.class-field-description--link {
margin-left: 12px;
vertical-align: middle;
background: none;
cursor: pointer;
}

a.class-field-description--link svg {
height: 18px;
fill: var(--color-gray-600);
transform: rotate(45deg);
vertical-align: middle;
}

a.class-field-description--link:hover svg {
fill: var(--color-brand);
}

@media (min-width: 845px) {
.es-header {
padding: 0 var(--spacing-4);
Expand Down
5 changes: 0 additions & 5 deletions public/assets/images/fa-link.svg

This file was deleted.

3 changes: 3 additions & 0 deletions public/assets/images/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion tests/acceptance/anchors-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ module('Acceptance | Creating Anchors', function (hooks) {
await click(element);
assert.equal(
currentURL(),
`/ember/1.0/classes/Container/properties?anchor=${element.innerText.trim()}`
`/ember/1.0/classes/Container/properties?anchor=${element.getAttribute(
'data-test-anchor'
)}`
);
});
});
31 changes: 1 addition & 30 deletions tests/integration/components/class-field-description-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
import EmberObject from '@ember/object';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import {
render,
click,
findAll,
find,
triggerEvent,
} from '@ember/test-helpers';
import { render, click, findAll, find } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

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

test('On hover -- the link icon shows up', async function (assert) {
this.set('type', 'method');
this.set(
'field',
EmberObject.create({
access: 'public',
deprecated: true,
name: 'concat',
description: 'concatenates',
params: [{ name: 'param1' }, { name: 'param2' }, { name: 'param3' }],
})
);

await render(
hbs`<ClassFieldDescription @type={{this.type}} @field={{this.field}}/>`
);

await triggerEvent('.class-field-description--link', 'mouseenter');
assert
.dom('.class-field-description--link-hover')
.exists('The link icon appears when hovering on the method text');
});

test('it calls the provided action on link-click with the field name as an arg', async function (assert) {
this.set('updateAnchor', (name) => {
assert.equal(
Expand Down