@citizenplane/pimp 18.9.21 → 18.9.22

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": "18.9.21",
3
+ "version": "18.9.22",
4
4
  "scripts": {
5
5
  "dev": "storybook dev -p 8081",
6
6
  "build-storybook": "storybook build --output-dir ./docs",
@@ -4,9 +4,10 @@
4
4
  :can-backdrop-close="canBackdropClose"
5
5
  :can-swipe-close="canSwipeClose"
6
6
  :duration="animationDuration"
7
- expand-on-content-drag
7
+ :expand-on-content-drag="expandOnContentDrag"
8
8
  :swipe-close-threshold="swipeCloseThreshold"
9
9
  teleport-defer
10
+ :snap-points="resolvedSnapPoints"
10
11
  @closed="onBottomSheetClosed"
11
12
  @opened="onBottomSheetOpened"
12
13
  >
@@ -24,7 +25,7 @@
24
25
 
25
26
  <script setup lang="ts">
26
27
  import VueBottomSheet from '@douxcode/vue-spring-bottom-sheet'
27
- import { useTemplateRef, watch } from 'vue'
28
+ import { computed, useTemplateRef, watch } from 'vue'
28
29
 
29
30
  interface Emits {
30
31
  (e: 'close' | 'open'): void
@@ -34,13 +35,19 @@ interface Props {
34
35
  animationDuration?: number
35
36
  canBackdropClose?: boolean
36
37
  canSwipeClose?: boolean
38
+ expandOnContentDrag?: boolean
39
+ halfAndExpand?: boolean
37
40
  preventClose?: boolean
41
+ snapPoints?: Array<number | `${number}%`>
38
42
  swipeCloseThreshold?: string
39
43
  }
40
44
 
41
45
  const props = withDefaults(defineProps<Props>(), {
42
46
  animationDuration: 300,
43
- swipeCloseThreshold: '20%',
47
+ expandOnContentDrag: true,
48
+ halfAndExpand: false,
49
+ snapPoints: () => [],
50
+ swipeCloseThreshold: '40%',
44
51
  })
45
52
 
46
53
  const emit = defineEmits<Emits>()
@@ -48,6 +55,11 @@ const emit = defineEmits<Emits>()
48
55
  const bottomSheetRef = useTemplateRef('bottomSheetRef')
49
56
  const isVisibleModel = defineModel<boolean>()
50
57
 
58
+ const resolvedSnapPoints = computed((): Array<number | `${number}%`> | undefined => {
59
+ if (props.snapPoints?.length) return props.snapPoints
60
+ return props.halfAndExpand ? ([`${50}%`, `${100}%`] as Array<number | `${number}%`>) : undefined
61
+ })
62
+
51
63
  // Set right before syncing a self-close down to the model, so the resulting
52
64
  // watch trigger doesn't re-issue a close() the underlying sheet already ran.
53
65
  let skipNextToggle = false
@@ -44,6 +44,8 @@ import { Breakpoints } from '@/constants/layout'
44
44
  interface Props {
45
45
  breakpoint?: number
46
46
  class?: string
47
+ expandOnContentDrag?: boolean
48
+ halfAndExpand?: boolean
47
49
  isClosableOnClickOutside?: boolean
48
50
  maxWidth?: number | undefined
49
51
  preventClose?: boolean
@@ -83,7 +85,9 @@ const dynamicComponentProps = computed(() => {
83
85
  contentClass: props.class,
84
86
  canBackdropClose: !props.preventClose,
85
87
  canSwipeClose: !props.preventClose,
88
+ expandOnContentDrag: props.expandOnContentDrag,
86
89
  preventClose: props.preventClose,
90
+ halfAndExpand: props.halfAndExpand,
87
91
  }
88
92
  }
89
93
 
@@ -66,6 +66,30 @@ export const Default: Story = {
66
66
  >
67
67
  <template #header><strong>Header slot</strong></template>
68
68
  <p>This is the default slot content. You can put any content here.</p>
69
+ <p>This is the default slot content. You can put any content here.</p>
70
+ <p>This is the default slot content. You can put any content here.</p>
71
+ <p>This is the default slot content. You can put any content here.</p>
72
+ <p>This is the default slot content. You can put any content here.</p>
73
+ <p>This is the default slot content. You can put any content here.</p>
74
+ <p>This is the default slot content. You can put any content here.</p>
75
+ <p>This is the default slot content. You can put any content here.</p>
76
+ <p>This is the default slot content. You can put any content here.</p>
77
+ <p>This is the default slot content. You can put any content here.</p>
78
+ <p>This is the default slot content. You can put any content here.</p>
79
+ <p>This is the default slot content. You can put any content here.</p>
80
+ <p>This is the default slot content. You can put any content here.</p>
81
+ <p>This is the default slot content. You can put any content here.</p>
82
+ <p>This is the default slot content. You can put any content here.</p>
83
+ <p>This is the default slot content. You can put any content here.</p>
84
+ <p>This is the default slot content. You can put any content here.</p>
85
+ <p>This is the default slot content. You can put any content here.</p>
86
+ <p>This is the default slot content. You can put any content here.</p>
87
+ <p>This is the default slot content. You can put any content here.</p>
88
+ <p>This is the default slot content. You can put any content here.</p>
89
+ <p>This is the default slot content. You can put any content here.</p>
90
+ <p>This is the default slot content. You can put any content here.</p>
91
+ <p>This is the default slot content. You can put any content here.</p>
92
+ <p>This is the default slot content. You can put any content here.</p>
69
93
  <template #footer>
70
94
  <CpButton @click="isVisible = false">Close</CpButton>
71
95
  </template>