Skip to content

Commit 89f7309

Browse files
authored
Add a slot for modal banner (#1208)
* add temp gradient banner to whats new * Set up rounded corners on banner * Test of modal banner slot * Change test of banner slot to get testing to not complain about img 404 * Use variables in modal css
1 parent e5e1f47 commit 89f7309

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

src/assets/scss/_variables.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ $padding-file-drop-zone: 15px;
115115
$padding-modal-body: 40px;
116116
$padding-modal-header: 40px;
117117
$padding-modal-actions: 15px;
118+
$border-radius-modal: 6px;
119+
$padding-modal-top-actions-close: 16px;
118120

119121
// PageBody
120122
$margin-top-page-body: 20px;

src/components/modal.vue

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ may add the `in` class to the element, and the checkScroll() method may add the
2525
:aria-label="$t('action.close')" @click="hideIfCan">
2626
<span aria-hidden="true">&times;</span>
2727
</button>
28+
<div class="modal-banner"><slot name="banner"></slot></div>
2829
</div>
2930
<div class="modal-header">
3031
<h4 :id="titleId" class="modal-title"><slot name="title"></slot></h4>
@@ -250,12 +251,24 @@ const titleId = `modal-title${id}`;
250251
box-shadow: $box-shadow-panel-main;
251252
252253
.modal-top-actions {
253-
text-align: right;
254-
padding-right: 16px;
255-
padding-top: 16px;
254+
255+
.modal-banner {
256+
display: contents;
257+
width: 100%;
258+
padding: 0px;
259+
margin: 0px;
260+
261+
// Force child of banner (e.g. image) to have rounded corners
262+
&>* {
263+
border-top-left-radius: $border-radius-modal;
264+
border-top-right-radius: $border-radius-modal;
265+
}
266+
}
256267
257268
.close {
258-
float: none;
269+
position: absolute;
270+
top: $padding-modal-top-actions-close;
271+
right: $padding-modal-top-actions-close;
259272
color: $color-input;
260273
font-weight: normal;
261274
opacity: 1;
@@ -269,7 +282,7 @@ const titleId = `modal-title${id}`;
269282
.modal-header {
270283
border-bottom: 0px;
271284
color: $color-text;
272-
padding: 0px $padding-modal-header 20px $padding-modal-header;
285+
padding: $padding-modal-header $padding-modal-header 20px $padding-modal-header;
273286
274287
h4 {
275288
@include text-overflow-ellipsis;

src/components/whats-new.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ except according to the terms contained in the LICENSE file.
1111
-->
1212
<template>
1313
<modal :state="isVisible" backdrop :hideable="true" @hide="hideModal">
14+
<template #banner>
15+
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="150px">
16+
<defs>
17+
<linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="0%">
18+
<stop offset="0%" style="stop-color:#8d0050;stop-opacity:1"/>
19+
<stop offset="100%" style="stop-color:#f7f7f7;stop-opacity:1"/>
20+
</linearGradient>
21+
</defs>
22+
<rect width="100%" height="150" fill="url(#gradient)"/>
23+
</svg>
24+
</template>
1425
<template #title>{{ $t('title') }}</template>
1526
<template #body>
1627
<p class="modal-introduction">

test/components/modal.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ describe('Modal', () => {
3434
modal.get('.modal-body pre').text().should.equal('foo');
3535
});
3636

37+
it('uses the banner slot', () => {
38+
const modal = mountComponent({
39+
slots: {
40+
banner: { template: '<div class="test-banner">foo</div>' }
41+
}
42+
});
43+
modal.get('.modal-banner .test-banner').text().should.equal('foo');
44+
});
45+
3746
it('shows any alert', () => {
3847
mountComponent().findComponent(Alert).exists().should.be.true;
3948
});

0 commit comments

Comments
 (0)