@citizenplane/pimp 6.5.2 → 6.6.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": "@citizenplane/pimp",
3
- "version": "6.5.2",
3
+ "version": "6.6.0",
4
4
  "scripts": {
5
5
  "dev": "vue-cli-service serve",
6
6
  "lint": "vue-cli-service lint",
@@ -36,14 +36,8 @@
36
36
  "babel-jest": "^27.2.5",
37
37
  "eslint": "^6.2.1",
38
38
  "eslint-config-prettier": "^6.15.0",
39
- "eslint-config-standard": ">=16.0.3",
40
- "eslint-loader": "^4.0.2",
41
- "eslint-plugin-import": ">=2.25.2",
42
39
  "eslint-plugin-jest": ">=25.0.5",
43
- "eslint-plugin-node": ">=9.1.0",
44
40
  "eslint-plugin-prettier": "^3.4.1",
45
- "eslint-plugin-promise": ">=4.3.1",
46
- "eslint-plugin-standard": ">=5.0.0",
47
41
  "eslint-plugin-vue": "^7.19.1",
48
42
  "portal-vue": "^2.1.7",
49
43
  "prettier": "^2.4.1",
@@ -1,15 +1,23 @@
1
1
  <template>
2
2
  <div class="cpBadge" :class="computedClasses">
3
3
  <span class="cpBadge__label">{{ label }}</span>
4
+ <button v-if="isClearable" class="cpBadge__clear" type="button" @click="onClear">
5
+ <x-icon class="cpBadge__icon" />
6
+ </button>
4
7
  </div>
5
8
  </template>
6
9
 
7
10
  <script>
11
+ import { XIcon } from 'vue-feather-icons'
12
+
8
13
  import { capitalizeFirstLetter } from '@/helpers'
9
14
 
10
15
  const badgeColors = ['neutral', 'blue', 'green', 'red', 'orange', 'purple', 'teal', 'pink', 'yellow']
11
16
 
12
17
  export default {
18
+ components: {
19
+ XIcon,
20
+ },
13
21
  props: {
14
22
  color: {
15
23
  type: String,
@@ -25,12 +33,14 @@ export default {
25
33
  isSolid: {
26
34
  type: Boolean,
27
35
  default: false,
28
- required: false,
29
36
  },
30
37
  isPlain: {
31
38
  type: Boolean,
32
39
  default: false,
33
- required: false,
40
+ },
41
+ isClearable: {
42
+ type: Boolean,
43
+ default: false,
34
44
  },
35
45
  },
36
46
  computed: {
@@ -39,12 +49,20 @@ export default {
39
49
  },
40
50
  computedClasses() {
41
51
  return [
42
- this.isSolid ? 'cpBadge--isSolid' : '',
43
- this.isPlain ? 'cpBadge--isPlain' : '',
52
+ {
53
+ 'cpBadge--isSolid': this.isSolid,
54
+ 'cpBadge--isPlain': this.isPlain,
55
+ 'cpBadge--isClearable': this.isClearable,
56
+ },
44
57
  `cpBadge--is${this.capitalizedColor}`,
45
58
  ]
46
59
  },
47
60
  },
61
+ methods: {
62
+ onClear() {
63
+ this.$emit('on-clear')
64
+ },
65
+ },
48
66
  }
49
67
  </script>
50
68
 
@@ -60,68 +78,44 @@ export default {
60
78
 
61
79
  @mixin cp-badge-color-solid($color) {
62
80
  background-color: $color;
63
- color: $neutral-light;
64
81
 
65
- &:before {
66
- background-color: $neutral-light;
82
+ .cpBadge__clear:hover,
83
+ .cpBadge__clear:focus-visible {
84
+ color: $color;
67
85
  }
68
86
  }
69
87
 
70
88
  @mixin cp-badge-style($color, $className) {
71
89
  &--is#{$className} {
72
90
  @include cp-badge-color-default($color);
91
+
92
+ &:not(.cpBadge--isSolid) .cpBadge__clear:hover,
93
+ &:not(.cpBadge--isSolid) .cpBadge__clear:focus-visible {
94
+ background-color: $color;
95
+ }
73
96
  }
74
97
 
75
98
  &--is#{$className}#{&}--isSolid {
76
99
  @include cp-badge-color-solid($color);
77
100
  }
78
-
79
- &--is#{$className}#{&}--isPlain {
80
- &:before {
81
- content: none;
82
- }
83
- }
84
101
  }
85
102
 
86
103
  .cpBadge {
87
104
  display: inline-flex;
88
105
  align-items: center;
89
- padding: pxToRem(4) pxToRem(8);
106
+ padding-block: $space-sm;
90
107
  font-size: pxToEm(14);
91
- text-transform: capitalize;
92
108
  font-weight: 500;
93
109
  border-radius: pxToRem(1000);
94
110
 
95
- &::before {
96
- content: '';
97
- width: pxToRem(6);
98
- height: pxToRem(6);
99
- margin-right: pxToRem(6);
100
- border-radius: 100%;
101
- flex-shrink: 0;
102
- }
103
-
104
- &__label {
105
- flex: 1;
106
- @extend %u-text-ellipsis;
107
- }
108
-
109
111
  @include cp-badge-style($neutral-dark, 'Neutral');
110
-
111
112
  @include cp-badge-style($secondary-color, 'Blue');
112
-
113
113
  @include cp-badge-style($green-2, 'Green');
114
-
115
114
  @include cp-badge-style($red, 'Red');
116
-
117
115
  @include cp-badge-style($orange, 'Orange');
118
-
119
116
  @include cp-badge-style($purple, 'Purple');
120
-
121
117
  @include cp-badge-style($blue-1, 'Teal');
122
-
123
118
  @include cp-badge-style($pink, 'Pink');
124
-
125
119
  @include cp-badge-style($yellow, 'Yellow');
126
120
 
127
121
  &--isYellow#{&}--isSolid {
@@ -131,5 +125,56 @@ export default {
131
125
  background-color: darken($yellow, 20);
132
126
  }
133
127
  }
128
+
129
+ &--isSolid {
130
+ color: $neutral-light;
131
+
132
+ &:before {
133
+ background-color: $neutral-light;
134
+ }
135
+ }
136
+
137
+ &:not(&--isClearable) {
138
+ padding-inline: $space;
139
+ }
140
+
141
+ &--isClearable {
142
+ padding-left: $space;
143
+ padding-right: $space-sm;
144
+ }
145
+
146
+ &:not(&--isPlain)::before {
147
+ content: '';
148
+ width: pxToEm(6);
149
+ height: pxToEm(6);
150
+ margin-right: pxToRem(6);
151
+ border-radius: 100%;
152
+ flex-shrink: 0;
153
+ }
154
+
155
+ &__label {
156
+ @extend %u-text-ellipsis;
157
+ flex: 1;
158
+ min-width: 0;
159
+ }
160
+
161
+ &__clear {
162
+ margin-left: pxToRem(6);
163
+ padding: pxToRem(1);
164
+ border-radius: 100%;
165
+ color: inherit;
166
+
167
+ &:hover,
168
+ &:focus-visible {
169
+ background-color: $neutral-light;
170
+ color: $neutral-light;
171
+ }
172
+ }
173
+
174
+ &__icon {
175
+ width: pxToEm(16);
176
+ height: pxToEm(16);
177
+ stroke-width: pxToRem(3);
178
+ }
134
179
  }
135
180
  </style>
@@ -4,11 +4,14 @@
4
4
  <h3>Badge</h3>
5
5
  <div class="sectionAtomicElements__badges">
6
6
  <cp-badge
7
- v-for="{ color, label } in badgeList"
7
+ v-for="{ color, label, clear, plain, solid } in badgeList"
8
8
  :key="label"
9
9
  :color="color"
10
10
  :label="label"
11
11
  class="sectionAtomicElements__badge"
12
+ :is-clearable="clear"
13
+ :is-plain="plain"
14
+ :is-solid="solid"
12
15
  />
13
16
  </div>
14
17
  </div>
@@ -31,20 +34,29 @@ export default {
31
34
  },
32
35
  {
33
36
  color: 'green',
34
- label: 'Processed',
37
+ label: 'Green solid clearable',
38
+ solid: true,
39
+ clear: true,
35
40
  },
36
41
  {
37
42
  color: 'red',
38
- label: 'Aborted',
43
+ label: 'Red clearable',
44
+ clear: true,
39
45
  },
40
46
  {
41
47
  color: 'blue',
42
- label: 'In Progress',
48
+ label: 'Blue plain',
49
+ plain: true,
43
50
  },
44
51
  {
45
52
  color: 'purple',
46
53
  label: 'trial',
47
54
  },
55
+ {
56
+ color: 'yellow',
57
+ label: 'yellow solid',
58
+ solid: true,
59
+ },
48
60
  ],
49
61
  }
50
62
  },