-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
116 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { ChangelogTag } from "./ChangelogTopic"; | ||
|
||
class ChangelogTagFactory | ||
{ | ||
constructor() { | ||
this.tagPurpleFilledTemplate = this.initTag("#changelog-tag-purple-filled"); | ||
this.tagPurpleTemplate = this.initTag("#changelog-tag-purple"); | ||
this.tagBlueTemplate = this.initTag("#changelog-tag-blue"); | ||
this.tagYelowTemplate = this.initTag("#changelog-tag-yellow"); | ||
} | ||
|
||
/** | ||
* | ||
* @param {string} id | ||
* @returns {HTMLDivElement} | ||
*/ | ||
initTag(id) { | ||
/** @type {HTMLDivElement} */ | ||
const tag = document.querySelector(id); | ||
|
||
/** @type {HTMLDivElement} */ | ||
const tagTemplate = tag.cloneNode(true); | ||
tagTemplate.id = ""; | ||
|
||
const tagPlaceholder = document.createElement("div"); | ||
tagPlaceholder.className = "changelog-tag-placeholder"; | ||
tag.replaceWith(tagPlaceholder); | ||
|
||
return tagTemplate; | ||
} | ||
|
||
/** | ||
* @param {ChangelogTag[]} tags | ||
* @returns {HTMLDivElement?} | ||
*/ | ||
getTopicTag(tags) { | ||
if (tags.includes("new-feature")) { | ||
const listItemTag = this.tagPurpleFilledTemplate.cloneNode(true); | ||
listItemTag.innerHTML = `🎉 New feature`; | ||
return listItemTag; | ||
} | ||
else if (tags.includes("feature-update")) { | ||
const listItemTag = this.tagPurpleTemplate.cloneNode(true); | ||
listItemTag.innerHTML = 'Feature update'; | ||
return listItemTag; | ||
} | ||
else if (tags.includes("step-update")) { | ||
const listItemTag = this.tagBlueTemplate.cloneNode(true); | ||
listItemTag.innerHTML = 'Step update'; | ||
return listItemTag; | ||
} | ||
else if (tags.includes("deprecation")) { | ||
const listItemTag = this.tagYelowTemplate.cloneNode(true); | ||
listItemTag.innerHTML = 'Deprecation'; | ||
return listItemTag; | ||
} | ||
return null; | ||
} | ||
} | ||
|
||
export default ChangelogTagFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters