@citizenplane/pimp 9.15.1 → 9.15.2

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": "9.15.1",
3
+ "version": "9.15.2",
4
4
  "scripts": {
5
5
  "dev": "storybook dev -p 8080",
6
6
  "build-storybook": "storybook build --output-dir ./docs",
@@ -37,7 +37,7 @@
37
37
  </cp-button>
38
38
  </div>
39
39
  <div
40
- v-if="displayTimer(message.life)"
40
+ v-if="displayTimer(message)"
41
41
  aria-hidden="true"
42
42
  class="cpToast__timer"
43
43
  role="presentation"
@@ -50,15 +50,15 @@
50
50
 
51
51
  <script setup lang="ts">
52
52
  import Toast from 'primevue/toast'
53
- import { defineProps, withDefaults } from 'vue'
54
53
 
55
54
  import { CpToastTypes } from '@/constants/CpToastTypes'
56
55
 
57
56
  import { capitalizeFirstLetter } from '@/helpers'
58
57
 
59
- interface Props {
58
+ interface Message {
60
59
  detail?: string
61
60
  hideTimer?: boolean
61
+ life?: number
62
62
  primaryAction?: {
63
63
  label: string
64
64
  onClick: VoidFunction
@@ -71,14 +71,7 @@ interface Props {
71
71
  summary: string
72
72
  }
73
73
 
74
- const props = withDefaults(defineProps<Props>(), {
75
- hideTimer: false,
76
- primaryAction: undefined,
77
- secondaryAction: undefined,
78
- detail: '',
79
- })
80
-
81
- const displayTimer = (life: number) => !props.hideTimer && life !== undefined
74
+ const displayTimer = (message: Message) => !message.hideTimer && message.life !== undefined
82
75
 
83
76
  const getDynamicClass = (severity: string) => `cpToast--is${capitalizeFirstLetter(severity)}`
84
77
 
@@ -110,12 +103,13 @@ const getButtonColor = (severity: string) => {
110
103
  }
111
104
  }
112
105
 
113
- const hasActions = (message: Props) => !!message.primaryAction || !!message.secondaryAction
106
+ const hasActions = (message: Message) => !!message.primaryAction || !!message.secondaryAction
114
107
 
115
108
  const getTimerBarStyle = (life: number) => ({ animationDuration: `${life}ms` })
116
109
  </script>
117
110
 
118
111
  <style lang="scss">
112
+ .p-toast-message-move,
119
113
  .p-toast-message-enter-active {
120
114
  transition:
121
115
  transform 400ms fn.v(easing-elastic),
@@ -136,7 +130,7 @@ const getTimerBarStyle = (life: number) => ({ animationDuration: `${life}ms` })
136
130
  z-index: -1;
137
131
  }
138
132
 
139
- .cpToasts div[role='alert']:not(:only-child).p-toast-message-leave-active {
133
+ .cpToasts .p-toast-message-leave-active:not(:only-child) {
140
134
  position: absolute;
141
135
  }
142
136
 
@@ -144,6 +138,13 @@ const getTimerBarStyle = (life: number) => ({ animationDuration: `${life}ms` })
144
138
  transform: translate3d(-50%, 0, 0);
145
139
  }
146
140
 
141
+ .cpToasts[data-p^='bottom'] {
142
+ .p-toast-message-enter-from,
143
+ .p-toast-message-leave-to {
144
+ transform: translate3d(0, fn.px-to-rem(30), 0) scale3d(0.75, 0.75, 1);
145
+ }
146
+ }
147
+
147
148
  .cpToasts > div {
148
149
  display: flex;
149
150
  flex-direction: column;
@@ -1,4 +1,5 @@
1
1
  import { useToast } from 'primevue/usetoast'
2
+ import { ref } from 'vue'
2
3
 
3
4
  import type { Meta, StoryObj } from '@storybook/vue3'
4
5
 
@@ -131,22 +132,28 @@ export const WithTimer: Story = {
131
132
  setup() {
132
133
  const toast = useToast()
133
134
 
135
+ const hideTimer = ref(false)
136
+
134
137
  const notifyWithTimer = () => {
135
138
  toast.add({
136
139
  severity: CpToastTypes.INFO,
137
140
  summary: "Hello i'm a cpToast with a timer !",
138
141
  detail: 'This is a cpToast description.',
139
142
  life: 2500,
143
+ hideTimer: !hideTimer.value,
140
144
  })
141
145
  }
142
146
 
143
- return { args, notifyWithTimer }
147
+ return { args, notifyWithTimer, hideTimer }
144
148
  },
145
149
  template: `
146
150
  <div style="padding: 16px;">
147
151
  <CpToast v-bind="args" />
148
152
 
149
153
  <cp-button @click="notifyWithTimer">Show toast with timer</cp-button>
154
+ <div style="margin-top: 24px">
155
+ <cp-switch v-model="hideTimer" label="Show timer bar ?"</cp-switch>
156
+ </div>
150
157
  </div>
151
158
  `,
152
159
  }),