@everchron/ec-shards 7.4.16 → 7.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everchron/ec-shards",
3
- "version": "7.4.16",
3
+ "version": "7.5.0",
4
4
  "private": false,
5
5
  "description": "Everchron Shards UI Library",
6
6
  "repository": "https://github.com/everchron/ec-shards.git",
@@ -0,0 +1,174 @@
1
+ <template>
2
+ <div
3
+ v-if="show"
4
+ class="ecs-banner"
5
+ :class="[type, fixed]"
6
+ role="alert"
7
+ >
8
+ <slot></slot>
9
+ <button
10
+ v-if="dismissable"
11
+ @click="dismiss"
12
+ :style="dismissButtonStyle"
13
+ class="close"
14
+ aria-label="Dismiss"
15
+ >
16
+ <ecs-icon type="close" size="20" />
17
+ <ecs-focus-ring />
18
+ </button>
19
+ </div>
20
+ </template>
21
+
22
+ <script>
23
+ import EcsIcon from '../icon/icon'
24
+ import EcsFocusRing from '../mixins/focus-ring'
25
+
26
+ export default {
27
+ components: { EcsIcon, EcsFocusRing },
28
+
29
+ props: {
30
+ /** The alert variant, which defines it's background color. */
31
+ type: {
32
+ type: String,
33
+ validator: v => ['success', 'info', 'error', 'warning', 'important'].includes(v),
34
+ default: 'warning'
35
+ },
36
+ /** When set to true, a close button is displayed which allows the user to dismiss the alert. */
37
+ dismissable: {
38
+ type: Boolean,
39
+ default: false
40
+ },
41
+ /** If true, the alert will have no rounded corners and no margins. This is usefull when the alert directly touches other UI elements. */
42
+ fixed: {
43
+ type: Boolean,
44
+ default: true
45
+ }
46
+ },
47
+
48
+ data() {
49
+ return {
50
+ dismissed: false
51
+ }
52
+ },
53
+
54
+ computed: {
55
+ show() {
56
+ return !this.dismissed
57
+ },
58
+
59
+ // Returns color and background color for the dismiss button. Based on the type prop.
60
+ // Refactor me with css variables.
61
+ dismissButtonStyle() {
62
+ switch (this.type) {
63
+ case 'success':
64
+ return {
65
+ color: '#004925',
66
+ backgroundColor: '#76E2AD'
67
+ }
68
+ case 'info':
69
+ return {
70
+ color: '#2A2D3D',
71
+ backgroundColor: '#A1A6B0'
72
+ }
73
+ case 'error':
74
+ return {
75
+ color: '#940014',
76
+ backgroundColor: '#FF99A6'
77
+ }
78
+ case 'warning':
79
+ return {
80
+ color: '#664B29',
81
+ backgroundColor: '#F1B251'
82
+ }
83
+ case 'important':
84
+ return {
85
+ color: '#003992',
86
+ backgroundColor: '#6BAFFF'
87
+ }
88
+ }
89
+ }
90
+ },
91
+
92
+ methods: {
93
+ dismiss() {
94
+ this.dismissed = true;
95
+ /** Emitted when the banner has been dismissed manually by the user. */
96
+ this.$emit('dismiss');
97
+ }
98
+ }
99
+ }
100
+ </script>
101
+
102
+ <style lang="scss" scoped>
103
+ @import "../../tokens/build/scss/tokens.scss";
104
+
105
+ .ecs-banner {
106
+ position: relative;
107
+ font-size: $type-scale-2-font-size;
108
+ line-height: $type-scale-2-line-height;
109
+ font-weight: $font-weight-medium;
110
+ text-align: center;
111
+ color: #FFF;
112
+ padding: 6px $spacing-20;
113
+
114
+ &.fixed {
115
+ position: fixed;
116
+ bottom: 0;
117
+ left: 0;
118
+ right: 0;
119
+ z-index: 9;
120
+ }
121
+
122
+ a{
123
+ text-decoration: underline;
124
+ color: #FFF;
125
+ }
126
+
127
+ &.info {
128
+ background-color: $color-gray-10;
129
+ }
130
+
131
+ &.error {
132
+ background-color: $color-red-10;
133
+ }
134
+
135
+ &.success {
136
+ background-color: $color-green-10;
137
+ }
138
+
139
+ &.warning {
140
+ background-color: $color-yellow-10;
141
+ }
142
+
143
+ &.important {
144
+ background-color: $color-blue-10;
145
+ }
146
+ }
147
+
148
+ .close {
149
+ position: absolute;
150
+ top: $spacing-5;
151
+ right: $spacing-5;
152
+ width: $spacing-25;
153
+ height: $spacing-25;
154
+ border-radius: $border-radius-medium;
155
+ color: inherit;
156
+ cursor: pointer;
157
+ padding: 0;
158
+ transition: .12s;
159
+
160
+ &:hover {
161
+ filter: brightness(1.2);
162
+ }
163
+
164
+ &:focus-visible {
165
+ z-index: 1;
166
+ outline: none;
167
+
168
+ .ecs-focus-ring {
169
+ display: block;
170
+ }
171
+ }
172
+ }
173
+
174
+ </style>
@@ -6,6 +6,7 @@ import EcsAlert from "./alert/alert.vue"
6
6
  import EcsActionToolbar from "./action-toolbar/action-toolbar.vue"
7
7
  import EcsAudio from "./audio/audio.vue"
8
8
  import EcsAvatar from "./avatar/avatar.vue"
9
+ import EcsBanner from "./banner/banner.vue"
9
10
  import EcsBreadcrumb from "./breadcrumb/breadcrumb.vue"
10
11
  import EcsBreadcrumbButton from "./breadcrumb-button/breadcrumb-button.vue"
11
12
  import EcsBreadcrumbTitle from "./breadcrumb-title/breadcrumb-title.vue"
@@ -144,6 +145,7 @@ const Components = {
144
145
  EcsActionToolbar,
145
146
  EcsAudio,
146
147
  EcsAvatar,
148
+ EcsBanner,
147
149
  EcsBreadcrumb,
148
150
  EcsBreadcrumbButton,
149
151
  EcsBreadcrumbTitle,
@@ -0,0 +1,17 @@
1
+ import EcsBanner from '@components/banner/banner';
2
+
3
+ export default {
4
+ title: 'Feedback/Banner',
5
+ component: EcsBanner
6
+ };
7
+
8
+ export const types = () => ({
9
+ components: { EcsBanner },
10
+ template: `<div>
11
+ <ecs-banner type="success" dismissable>This is a success <a href="#">alert</a> — check it out!</ecs-banner>
12
+ <ecs-banner type="info" dismissable>This is an info alert — check it out!</ecs-banner>
13
+ <ecs-banner type="error" dismissable>This is an error alert — check it out!</ecs-banner>
14
+ <ecs-banner type="warning" dismissable>This is a warning alert — check it out!</ecs-banner>
15
+ <ecs-banner type="important" dismissable>This is an important alert — check it out!</ecs-banner>
16
+ </div>`,
17
+ });