Skip to content

Commit acca4ef

Browse files
committed
feat: 🎸 update body.ejs and footer.ejs template
BREAKING CHANGE: 🧨 The JS part of playground was moved from body.ejs to footer.ejs template.
1 parent f08762a commit acca4ef

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

Diff for: packages/cli/src/merkurConfig.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ emitter.on(
262262
new RegExp('^https?://127\\.0\\.0\\.1(:[0-9]+)?$'),
263263
],
264264
methods: ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE', 'OPTIONS'],
265+
optionsSuccessStatus: 200,
265266
...merkurConfig.widgetServer?.cors?.options,
266267
},
267268
},

Diff for: packages/cli/src/templates/body.ejs

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
<% if(widgetProperties?.slot?.headline?.html){ %>
2-
<div class="<%= (widgetProperties?.slot?.headline?.containerSelector ?? 'headline-view').replace('.', '') %>">
2+
<div class="<%= (widgetProperties?.slot?.headline?.containerSelector ?? 'merkur-headline').replace('.', '') %>">
33
<%- widgetProperties?.slot?.headline?.html %>
44
</div>
55
<% } %>
6-
<div class="merkur-view"><%- html %></div>
7-
<script>
8-
window.addEventListener('load', function () {
9-
__merkur__.create(<%- escapeToJSON(widgetProperties) %>)
10-
.then(function (widget) {
11-
widget.containerSelector = '.merkur-view';
12-
if (widget?.slot?.headline && !widget?.slot?.headline?.containerSelector) {
13-
widget.slot.headline.containerSelector = '.headline-view';
14-
}
15-
16-
widget.mount();
17-
});
18-
});
19-
</script>
6+
<div class="<%= (widgetProperties?.containerSelector ?? 'merkur-main').replace('.', '') %>"><%- html %></div>

Diff for: packages/cli/src/templates/footer.ejs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script>
2+
window.addEventListener('load', function () {
3+
__merkur__.create(<%- escapeToJSON(widgetProperties) %>)
4+
.then(function (widget) {
5+
widget.containerSelector = widget.containerSelector ?? '.merkur-main';
6+
7+
if (widget.slot && Object.keys(widget.slot).length > 0) {
8+
Object.keys(widget.slot).forEach(function (slotName) {
9+
widget.slot[slotName].containerSelector = widget.slot[slotName].containerSelector ?? '.merkur-' + slotName;
10+
});
11+
}
12+
13+
// support for router plugin
14+
if (widget.router) {
15+
widget.on('@merkur/plugin-router.redirect', function (_, url) {
16+
var parsedUrl = new URL(url.url);
17+
window.location = parsedUrl.href;
18+
});
19+
}
20+
21+
// mount widget to DOM
22+
widget.mount();
23+
});
24+
});
25+
</script>

Diff for: packages/create-widget/template/src/style.css

+5-8
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,29 @@ button {
1515
margin: 0 auto;
1616
}
1717

18-
.merkur__page {
19-
}
20-
21-
.merkur__headline {
18+
.merkur-headline {
2219
background-color: #282c34;
2320
padding: 120px 10px 80px 10px;
2421
color: #a2a8b6;
2522
text-align: center;
2623
}
2724

28-
.merkur__headline a {
25+
.merkur-headline a {
2926
color: white;
3027
text-decoration: none;
3128
}
3229

33-
.merkur__headline h1 {
30+
.merkur-headline h1 {
3431
font-size: 60px;
3532
margin: 0 0 20px 0;
3633
}
3734

38-
.merkur__headline h2 {
35+
.merkur-headline h2 {
3936
margin: 0;
4037
line-height: 1.3;
4138
}
4239

43-
.merkur__headline h3 {
40+
.merkur-headline h3 {
4441
margin: 40px 0 16px 0;
4542
line-height: 1.3;
4643
}

0 commit comments

Comments
 (0)