@gitlab/ui 50.0.1 → 50.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/components/base/broadcast_message/broadcast_message.js +25 -1
- package/dist/components/base/broadcast_message/constants.js +5 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +1 -1
- package/scss_to_js/scss_variables.js +1 -0
- package/scss_to_js/scss_variables.json +5 -0
- package/src/components/base/broadcast_message/broadcast_message.scss +19 -3
- package/src/components/base/broadcast_message/broadcast_message.spec.js +17 -7
- package/src/components/base/broadcast_message/broadcast_message.stories.js +31 -26
- package/src/components/base/broadcast_message/broadcast_message.vue +26 -1
- package/src/components/base/broadcast_message/constants.js +3 -0
- package/src/scss/variables.scss +1 -0
package/package.json
CHANGED
|
@@ -331,6 +331,7 @@ export const glDropdownWidthNarrow = '10rem'
|
|
|
331
331
|
export const glDropdownWidthWide = '25rem'
|
|
332
332
|
export const glMaxDropdownMaxHeight = '19.5rem'
|
|
333
333
|
export const glBroadcastMessageTextMaxWidth = '58.375rem'
|
|
334
|
+
export const glBroadcastMessageNotificationMaxWidth = '18.75rem'
|
|
334
335
|
export const glModalSmallWidth = '32rem'
|
|
335
336
|
export const glModalMediumWidth = '48rem'
|
|
336
337
|
export const glModalLargeWidth = '61.875rem'
|
|
@@ -1765,6 +1765,11 @@
|
|
|
1765
1765
|
"value": "px-to-rem(934px)",
|
|
1766
1766
|
"compiledValue": "58.375rem"
|
|
1767
1767
|
},
|
|
1768
|
+
{
|
|
1769
|
+
"name": "$gl-broadcast-message-notification-max-width",
|
|
1770
|
+
"value": "px-to-rem(300px)",
|
|
1771
|
+
"compiledValue": "18.75rem"
|
|
1772
|
+
},
|
|
1768
1773
|
{
|
|
1769
1774
|
"name": "$gl-modal-small-width",
|
|
1770
1775
|
"value": "px-to-rem(512px)",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
.gl-broadcast-message {
|
|
2
|
-
@include gl-text-contrast-light;
|
|
3
2
|
@include gl-display-flex;
|
|
4
3
|
@include gl-justify-content-space-between;
|
|
5
4
|
@include gl-align-items-flex-start;
|
|
@@ -8,8 +7,10 @@
|
|
|
8
7
|
@include gl-pl-5;
|
|
9
8
|
@include gl-pr-4;
|
|
10
9
|
@include gl-py-5;
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
|
|
11
|
+
&.indigo {
|
|
12
|
+
@include gl-bg-theme-indigo-700;
|
|
13
|
+
}
|
|
13
14
|
|
|
14
15
|
&.light-indigo {
|
|
15
16
|
@include gl-bg-theme-indigo-500;
|
|
@@ -47,6 +48,21 @@
|
|
|
47
48
|
@include gl-bg-gray-300;
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
&.banner {
|
|
52
|
+
@include gl-text-contrast-light;
|
|
53
|
+
@include gl-inset-border-b-1-gray-900;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&.notification {
|
|
57
|
+
@include gl-rounded-base;
|
|
58
|
+
@include gl-bg-white;
|
|
59
|
+
@include gl-border-solid;
|
|
60
|
+
@include gl-border-gray-100;
|
|
61
|
+
@include gl-border-1;
|
|
62
|
+
@include gl-shadow-x0-y2-b4-s0;
|
|
63
|
+
max-width: $gl-broadcast-message-notification-max-width;
|
|
64
|
+
}
|
|
65
|
+
|
|
50
66
|
&-content {
|
|
51
67
|
@include gl-display-flex;
|
|
52
68
|
@include gl-justify-content-center;
|
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
import GlBroadcastMessage from './broadcast_message.vue';
|
|
3
|
+
import { TYPE_NOTIFICATION } from './constants';
|
|
3
4
|
|
|
4
5
|
describe('Broadcast message component', () => {
|
|
5
6
|
let wrapper;
|
|
6
7
|
|
|
7
|
-
const createComponent = (
|
|
8
|
-
wrapper = shallowMount(GlBroadcastMessage,
|
|
8
|
+
const createComponent = (propsData = {}) => {
|
|
9
|
+
wrapper = shallowMount(GlBroadcastMessage, {
|
|
10
|
+
slots: { default: 'some message' },
|
|
11
|
+
propsData,
|
|
12
|
+
});
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
const findDismissButton = () => wrapper.findComponent({ ref: 'dismiss' });
|
|
12
16
|
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
createComponent({ slots: { default: 'some message' } });
|
|
15
|
-
});
|
|
16
|
-
|
|
17
17
|
it('clicking on dismiss button emits a dismiss event', () => {
|
|
18
|
+
createComponent();
|
|
18
19
|
findDismissButton().vm.$emit('click');
|
|
19
|
-
|
|
20
20
|
expect(wrapper.emitted('dismiss')).toHaveLength(1);
|
|
21
21
|
});
|
|
22
|
+
|
|
23
|
+
it('dismiss button does not appear when dismissible is false', () => {
|
|
24
|
+
createComponent({ dismissible: false });
|
|
25
|
+
expect(findDismissButton().exists()).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('dismiss button always appears for notification broadcast messages', () => {
|
|
29
|
+
createComponent({ dismissible: false, type: TYPE_NOTIFICATION });
|
|
30
|
+
expect(findDismissButton().exists()).toBe(true);
|
|
31
|
+
});
|
|
22
32
|
});
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import iconSpriteInfo from '@gitlab/svgs/dist/icons.json';
|
|
2
2
|
import { GlBroadcastMessage } from '../../../index';
|
|
3
3
|
import { colorThemes } from '../../../utils/constants';
|
|
4
|
+
import { TYPE_LIST, TYPE_NOTIFICATION } from './constants';
|
|
4
5
|
import readme from './broadcast_message.md';
|
|
5
6
|
|
|
6
7
|
const template = `
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
</
|
|
8
|
+
<gl-broadcast-message
|
|
9
|
+
:icon-name="iconName"
|
|
10
|
+
:dismissible="dismissible"
|
|
11
|
+
:dismiss-label="dismissLabel"
|
|
12
|
+
:theme="theme"
|
|
13
|
+
:type="type">
|
|
14
|
+
{{ text }}
|
|
15
|
+
</gl-broadcast-message>
|
|
15
16
|
`;
|
|
16
17
|
|
|
17
18
|
const defaultValue = (prop) => GlBroadcastMessage.props[prop].default;
|
|
@@ -19,45 +20,45 @@ const defaultValue = (prop) => GlBroadcastMessage.props[prop].default;
|
|
|
19
20
|
const generateProps = ({
|
|
20
21
|
text = 'Tuesday June 12th, at 14:30 UTC we will perform database maintenance that will require up to 1 minute of downtime.',
|
|
21
22
|
iconName = defaultValue('iconName'),
|
|
23
|
+
dismissible = defaultValue('dismissible'),
|
|
22
24
|
dismissLabel = defaultValue('dismissLabel'),
|
|
23
25
|
theme = defaultValue('theme'),
|
|
26
|
+
type = defaultValue('type'),
|
|
24
27
|
} = {}) => ({
|
|
25
28
|
text,
|
|
26
29
|
iconName,
|
|
30
|
+
dismissible,
|
|
27
31
|
dismissLabel,
|
|
28
32
|
theme,
|
|
33
|
+
type,
|
|
29
34
|
});
|
|
30
35
|
|
|
31
|
-
const
|
|
36
|
+
const DefaultStory = (args, { argTypes }) => ({
|
|
32
37
|
components: {
|
|
33
38
|
GlBroadcastMessage,
|
|
34
39
|
},
|
|
35
40
|
props: Object.keys(argTypes),
|
|
36
|
-
template
|
|
41
|
+
template: `<div>${template}</div>`,
|
|
37
42
|
});
|
|
38
|
-
export const Default =
|
|
43
|
+
export const Default = DefaultStory.bind({});
|
|
39
44
|
Default.args = generateProps();
|
|
40
45
|
|
|
46
|
+
const NotificationStory = (args, { argTypes }) => ({
|
|
47
|
+
components: {
|
|
48
|
+
GlBroadcastMessage,
|
|
49
|
+
},
|
|
50
|
+
props: Object.keys(argTypes),
|
|
51
|
+
template: `<div>${template}</div>`,
|
|
52
|
+
});
|
|
53
|
+
export const Notification = NotificationStory.bind({});
|
|
54
|
+
Notification.args = generateProps({ type: TYPE_NOTIFICATION });
|
|
55
|
+
|
|
41
56
|
const StackedStory = (args, { argTypes }) => ({
|
|
42
57
|
components: {
|
|
43
58
|
GlBroadcastMessage,
|
|
44
59
|
},
|
|
45
60
|
props: Object.keys(argTypes),
|
|
46
|
-
template:
|
|
47
|
-
<div>
|
|
48
|
-
<gl-broadcast-message
|
|
49
|
-
:icon-name="iconName"
|
|
50
|
-
:dismiss-label="dismissLabel"
|
|
51
|
-
:theme="theme">
|
|
52
|
-
{{ text }}
|
|
53
|
-
</gl-broadcast-message>
|
|
54
|
-
<gl-broadcast-message
|
|
55
|
-
:icon-name="iconName"
|
|
56
|
-
:dismiss-label="dismissLabel"
|
|
57
|
-
:theme="theme">
|
|
58
|
-
{{ text }}
|
|
59
|
-
</gl-broadcast-message>
|
|
60
|
-
</div>`,
|
|
61
|
+
template: `<div>${template}${template}</div>`,
|
|
61
62
|
});
|
|
62
63
|
export const Stacked = StackedStory.bind({});
|
|
63
64
|
Stacked.args = generateProps();
|
|
@@ -84,5 +85,9 @@ export default {
|
|
|
84
85
|
options: Object.keys(colorThemes),
|
|
85
86
|
control: 'select',
|
|
86
87
|
},
|
|
88
|
+
type: {
|
|
89
|
+
options: TYPE_LIST,
|
|
90
|
+
control: 'select',
|
|
91
|
+
},
|
|
87
92
|
},
|
|
88
93
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { colorThemes } from '../../../utils/constants';
|
|
3
3
|
import CloseButton from '../../shared_components/close_button/close_button.vue';
|
|
4
4
|
import GlIcon from '../icon/icon.vue';
|
|
5
|
+
import { TYPE_BANNER, TYPE_NOTIFICATION, TYPE_LIST } from './constants';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
components: {
|
|
@@ -17,6 +18,14 @@ export default {
|
|
|
17
18
|
required: false,
|
|
18
19
|
default: 'bullhorn',
|
|
19
20
|
},
|
|
21
|
+
/**
|
|
22
|
+
* Allow the broadcast message to be dismissed by a user.
|
|
23
|
+
*/
|
|
24
|
+
dismissible: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
required: false,
|
|
27
|
+
default: true,
|
|
28
|
+
},
|
|
20
29
|
/**
|
|
21
30
|
* The dismiss button's label, it is visible in mobile viewports and used for the button's aria-label attribute.
|
|
22
31
|
*/
|
|
@@ -34,6 +43,21 @@ export default {
|
|
|
34
43
|
default: Object.keys(colorThemes)[0],
|
|
35
44
|
validator: (value) => Object.keys(colorThemes).includes(value),
|
|
36
45
|
},
|
|
46
|
+
/**
|
|
47
|
+
* The base layout to use. `notification` type broadcast messages are not compatible
|
|
48
|
+
with the `dismissible` or `theme` props.
|
|
49
|
+
*/
|
|
50
|
+
type: {
|
|
51
|
+
type: String,
|
|
52
|
+
required: false,
|
|
53
|
+
default: TYPE_BANNER,
|
|
54
|
+
validator: (value) => TYPE_LIST.includes(value),
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
computed: {
|
|
58
|
+
showDismissButton() {
|
|
59
|
+
return this.dismissible || this.type === TYPE_NOTIFICATION;
|
|
60
|
+
},
|
|
37
61
|
},
|
|
38
62
|
methods: {
|
|
39
63
|
onDismiss() {
|
|
@@ -50,7 +74,7 @@ export default {
|
|
|
50
74
|
</script>
|
|
51
75
|
|
|
52
76
|
<template>
|
|
53
|
-
<div class="gl-broadcast-message" :class="theme" role="alert">
|
|
77
|
+
<div class="gl-broadcast-message" :class="`${theme} ${type}`" role="alert">
|
|
54
78
|
<div class="gl-broadcast-message-content">
|
|
55
79
|
<div class="gl-broadcast-message-icon gl-line-height-normal">
|
|
56
80
|
<gl-icon :name="iconName" />
|
|
@@ -61,6 +85,7 @@ export default {
|
|
|
61
85
|
</div>
|
|
62
86
|
</div>
|
|
63
87
|
<close-button
|
|
88
|
+
v-if="showDismissButton"
|
|
64
89
|
ref="dismiss"
|
|
65
90
|
class="gl-close-btn-color-inherit gl-broadcast-message-dismiss"
|
|
66
91
|
:label="dismissLabel"
|
package/src/scss/variables.scss
CHANGED
|
@@ -469,6 +469,7 @@ $gl-max-dropdown-max-height: px-to-rem(312px);
|
|
|
469
469
|
|
|
470
470
|
// Broadcast messages
|
|
471
471
|
$gl-broadcast-message-text-max-width: px-to-rem(934px);
|
|
472
|
+
$gl-broadcast-message-notification-max-width: px-to-rem(300px);
|
|
472
473
|
|
|
473
474
|
// Modal Widths
|
|
474
475
|
$gl-modal-small-width: px-to-rem(512px);
|