Skip to content

Commit c0f373b

Browse files
committed
convert article component to class
1 parent 6172a09 commit c0f373b

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
root: true,
3+
parser: 'babel-eslint',
34
parserOptions: {
45
ecmaVersion: 2018,
56
sourceType: 'module'

app/components/deprecation-article.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
import Component from '@ember/component';
2-
import { computed } from '@ember/object';
1+
import Component from '@glimmer/component';
2+
import { tracked } from '@glimmer/tracking';
3+
import { computed, get } from '@ember/object';
34
import { inject as service } from '@ember/service';
4-
import $ from 'jquery';
5-
6-
export default Component.extend({
7-
prism: service(),
8-
renderIdOrUntil: true,
9-
idForTitle: computed('model.title', function() {
10-
return `toc_${this.get('model.title')}`;
11-
}),
12-
idForUntil: computed('model.until', function() {
13-
return `toc_until-${this.get('model.until')}`;
14-
}),
15-
16-
didRender() {
5+
6+
export default class DeprecationArticle extends Component {
7+
@service prism;
8+
9+
@tracked renderIdOrUntil = true;
10+
11+
@computed('model.title')
12+
get idForTitle() {
13+
return `toc_${get(this, 'model.title')}`;
14+
}
15+
16+
@computed('model.until')
17+
get idForUntil() {
18+
return `toc_until-${get(this, 'model.until')}`;
19+
}
20+
21+
setupCodeSnippets() {
1722
let nodeList = document.querySelectorAll('pre:not(.no-line-numbers) > code');
1823

1924
if (nodeList) {
@@ -54,12 +59,9 @@ export default Component.extend({
5459
}
5560
wrapperDiv.style.position = 'relative';
5661

57-
// code.parentNode.classList.add(ext);
5862
code.parentNode.parentNode.appendChild(wrapperDiv);
5963
wrapperDiv.appendChild(code.parentNode);
6064

61-
// this.$(code.parentNode).wrap(`<div class="filename ${ext}" style="position: relative;"></div>`);
62-
6365
if (filename) {
6466
let span = document.createElement('span');
6567
span.innerHTML = filename;
@@ -71,12 +73,14 @@ export default Component.extend({
7173
});
7274
}
7375

74-
this.$(".anchorable-toc").each(function () {
76+
document.querySelectorAll(".anchorable-toc").forEach(function (anchorable) {
7577
let currentToc = $(this);
7678

79+
let link = document.createElement('a');
7780
currentToc.wrap(`<a class="bg-none toc-anchor" href="#${currentToc.attr('id')}"></a>`)
81+
7882
})
7983

8084
this.prism.highlight();
8185
}
82-
});
86+
}

app/templates/components/deprecation-article.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<div class="padding-vertical-small bg-light-muted rounded-sm">
2-
<h3 class="anchorable-toc" id="{{id-for-deprecation model.id}}">{{model.title}}</h3>
1+
<div class="padding-vertical-small bg-light-muted rounded-sm" {{did-insert this.setupCodeSnippets}}>
2+
<h3 class="anchorable-toc" id="{{id-for-deprecation this.args.model.id}}">{{this.args.model.title}}</h3>
33
<p class="em">
44
{{#if renderIdOrUntil}}
55
<div><span class="bold">until: </span>{{model.until}}</div>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"devDependencies": {
2222
"@ember/jquery": "^1.1.0",
2323
"@ember/optional-features": "^1.3.0",
24+
"@ember/render-modifiers": "^1.0.2",
2425
"@sinonjs/fake-timers": "^6.0.1",
2526
"algoliasearch": "^3.35.1",
2627
"broccoli-asset-rev": "^3.0.0",

0 commit comments

Comments
 (0)