-
Notifications
You must be signed in to change notification settings - Fork 8.2k
/
category.js
36 lines (29 loc) · 998 Bytes
/
category.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import HashtagTypeBase from "./base";
import { inject as service } from "@ember/service";
export default class CategoryHashtagType extends HashtagTypeBase {
@service site;
get type() {
return "category";
}
get preloadedData() {
return this.site.categories || [];
}
generateColorCssClasses(category) {
const generatedCssClasses = [];
const backgroundGradient = [`var(--category-${category.id}-color) 50%`];
if (category.parentCategory) {
backgroundGradient.push(
`var(--category-${category.parentCategory.id}-color) 50%`
);
} else {
backgroundGradient.push(`var(--category-${category.id}-color) 50%`);
}
generatedCssClasses.push(`.hashtag-color--category-${category.id} {
background: linear-gradient(90deg, ${backgroundGradient.join(", ")});
}`);
return generatedCssClasses;
}
generateIconHTML(hashtag) {
return `<span class="hashtag-category-badge hashtag-color--${this.type}-${hashtag.id}"></span>`;
}
}