-
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.
feat: ✨ added an update banner and button (#12)
feat(script): ✨ updated user scripts to make the update button work (#12)
- Loading branch information
1 parent
1bd5353
commit 357c569
Showing
6 changed files
with
125 additions
and
2 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
51 changes: 51 additions & 0 deletions
51
src/components/tj-jira-panel/components/update-banner/tj-update-banner.css
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,51 @@ | ||
.updateContainer { | ||
width: 200px; | ||
border: 1px solid rgb(195, 195, 195); | ||
border-radius: 8px; | ||
overflow: hidden; | ||
font-size: 14px; | ||
|
||
&:hover { | ||
border: 0; | ||
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
&:hover .updateContent { | ||
max-height: 100px; | ||
transition: 0.5s ease-in; | ||
padding: 8px; | ||
} | ||
} | ||
|
||
.updateHeader { | ||
text-align: center; | ||
border-radius: 8px 8px 0 0; | ||
padding: 4px 0; | ||
background: #f8f8f8; | ||
font-weight: normal; | ||
margin: 0; | ||
} | ||
|
||
.updateContent { | ||
max-height: 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
transition: 0.5s ease-out; | ||
gap: 8px; | ||
} | ||
|
||
.updateContent a.releaseNotesLink { | ||
color: var(--primary-color); | ||
} | ||
|
||
.updateButton { | ||
background: var(--accent-color); | ||
width: fit-content; | ||
color: white; | ||
border: none; | ||
border-radius: 4px; | ||
padding: 4px 8px; | ||
cursor: pointer; | ||
width: 100%; | ||
} |
48 changes: 48 additions & 0 deletions
48
src/components/tj-jira-panel/components/update-banner/tj-update-banner.tsx
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,48 @@ | ||
import { Component, State, h } from '@stencil/core'; | ||
|
||
import { version } from '@root/package.json'; | ||
|
||
@Component({ | ||
tag: 'tj-update-banner', | ||
styleUrl: 'tj-update-banner.css', | ||
scoped: true, | ||
}) | ||
export class TJUpdateBanner { | ||
@State() latestVersion: string; | ||
|
||
async componentWillLoad() { | ||
if (!localStorage.getItem('tj_version')) { | ||
localStorage.setItem('tj_version', version); | ||
} | ||
const response = await fetch( | ||
`https://cdn.jsdelivr.net/npm/@ens-davids/tj-jira-panel/package.json?bypassDiskCache=${Date.now()}`, | ||
); | ||
const data = await response.json(); | ||
this.latestVersion = data.version; | ||
} | ||
|
||
updateAndRefresh = async () => { | ||
localStorage.setItem('tj_version', this.latestVersion); | ||
window.location.reload(); | ||
}; | ||
|
||
render() { | ||
return version !== this.latestVersion ? ( | ||
<div class="updateContainer"> | ||
<h4 class="updateHeader">New TJI Version Available</h4> | ||
<div class="updateContent"> | ||
<a | ||
class="releaseNotesLink" | ||
href={`https://github.com/davids-ensemble/tj-jira-panel/releases/tag/v2.2.0`} | ||
target="_blank" | ||
> | ||
See release notes | ||
</a> | ||
<button class="updateButton" onClick={this.updateAndRefresh}> | ||
Update and Refresh | ||
</button> | ||
</div> | ||
</div> | ||
) : null; | ||
} | ||
} |
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