Skip to content

Commit 0f0ba4b

Browse files
authored
Merge pull request #319 from bartek-sek/SYL-4182/2-0-info-box
SYL-4182: 2.0 info box
2 parents 1632488 + 35c8379 commit 0f0ba4b

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

config/packages/sylius_ui.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ sylius_ui:
55
after_menu:
66
template: "Blocks/_infoBox.html.twig"
77
priority: 12
8+
new_version_box:
9+
template: "Blocks/_newVersionBox.html.twig"
10+
priority: 11
811
sylius.shop.layout.head:
912
blocks:
1013
analistics:
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<style>
2+
.version-warning {
3+
position: fixed!important;
4+
top: 30px;
5+
left: 20px;
6+
right: 20px;
7+
text-align: center;
8+
z-index: 1000;
9+
}
10+
</style>
11+
12+
<div class="ui container version-warning">
13+
<div data-js-version-warning class="ui warning message">
14+
<i class="close icon" data-js-version-warning-close></i>
15+
<div class="header">
16+
Warning
17+
</div>
18+
<p>This demo is based on Sylius 1.x. We strongly encourage you to check <a href="https://v2.demo.sylius.com/en_US/">the latest Sylius 2.0 demo</a> and upgrade your applications!</p>
19+
</div>
20+
</div>
21+
22+
<script type="text/javascript">
23+
class VersionWarning {
24+
constructor() {
25+
this.setupTime = localStorage.getItem('setupTime');
26+
this.warningBox = document.querySelector('[data-js-version-warning]');
27+
this.warningClose = document.querySelector('[data-js-version-warning-close]');
28+
this.hours = 1;
29+
30+
this.checkTime();
31+
32+
this.warningClose.addEventListener('click', this.saveTime.bind(this));
33+
}
34+
35+
checkTime() {
36+
const now = new Date().getTime();
37+
38+
if (this.setupTime !== null) {
39+
if (now - this.setupTime < this.hours*60*60*1000) {
40+
this.warningBox.classList.add('hidden');
41+
}
42+
}
43+
}
44+
45+
saveTime() {
46+
const now = new Date().getTime();
47+
48+
localStorage.setItem('setupTime', now);
49+
}
50+
}
51+
52+
const versionWarning = new VersionWarning();
53+
</script>

0 commit comments

Comments
 (0)