@citizenplane/pimp 8.5.6 → 8.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": "8.5.6",
3
+ "version": "8.6.0",
4
4
  "scripts": {
5
5
  "dev": "vite --host",
6
6
  "build": "vite build",
@@ -1,7 +1,9 @@
1
1
  <template>
2
2
  <div v-if="isDisplayed" class="cpAlert" :class="`cpAlert--${intent}`">
3
3
  <div class="cpAlert__icon">
4
- <cp-icon :type="alertIcon" />
4
+ <slot name="icon">
5
+ <cp-icon :type="alertIcon" />
6
+ </slot>
5
7
  </div>
6
8
  <div class="cpAlert__body">
7
9
  <cp-heading v-if="title" heading-level="h4" :size="400" class="cpAlert__title">{{ title }}</cp-heading>
@@ -13,51 +15,45 @@
13
15
  </div>
14
16
  </template>
15
17
 
16
- <script>
18
+ <script setup>
19
+ import { ref, computed, useSlots } from 'vue'
20
+
17
21
  import { Intent } from '@/utils/constants'
18
22
 
19
- export default {
20
- props: {
21
- intent: {
22
- type: String,
23
- required: true,
24
- default: Intent.INFO.value,
25
- validator(value) {
26
- const intentValues = Object.values(Intent).map((item) => item.value)
27
- return intentValues.includes(value)
28
- },
29
- },
30
- title: {
31
- type: String,
32
- required: false,
33
- default: '',
34
- },
35
- isClosable: {
36
- type: Boolean,
37
- required: false,
38
- default: false,
23
+ const props = defineProps({
24
+ intent: {
25
+ type: String,
26
+ required: true,
27
+ default: Intent.INFO.value,
28
+ validator(value) {
29
+ const intentValues = Object.values(Intent).map((item) => item.value)
30
+ return intentValues.includes(value)
39
31
  },
40
32
  },
41
- data() {
42
- return {
43
- isDisplayed: true,
44
- }
45
- },
46
- computed: {
47
- alertIcon() {
48
- const intentValues = Object.values(Intent)
49
- return intentValues.find((intentItem) => intentItem.value === this.intent).icon
50
- },
51
- hasContent() {
52
- return !!this.$slots['default']
53
- },
33
+ title: {
34
+ type: String,
35
+ required: false,
36
+ default: '',
54
37
  },
55
- methods: {
56
- dismissAlert() {
57
- this.isDisplayed = false
58
- },
38
+ isClosable: {
39
+ type: Boolean,
40
+ required: false,
41
+ default: false,
59
42
  },
60
- }
43
+ })
44
+
45
+ const slots = useSlots()
46
+
47
+ const isDisplayed = ref(true)
48
+
49
+ const alertIcon = computed(() => {
50
+ const intentValues = Object.values(Intent)
51
+ return intentValues.find((intentItem) => intentItem.value === props.intent).icon
52
+ })
53
+
54
+ const hasContent = computed(() => !!slots.default)
55
+
56
+ const dismissAlert = () => (isDisplayed.value = false)
61
57
  </script>
62
58
 
63
59
  <style lang="scss">