@citizenplane/pimp 18.13.1 → 18.13.3

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.13.1",
3
+ "version": "18.13.3",
4
4
  "scripts": {
5
5
  "dev": "storybook dev -p 8081",
6
6
  "build-storybook": "storybook build --output-dir ./docs",
@@ -1,9 +1,11 @@
1
1
  <template>
2
- <label class="cpCheckbox" :class="computedClasses" :for="checkboxUniqueId">
2
+ <label class="cpCheckbox" :class="dynamicCheckboxClasses" :for="checkboxUniqueId">
3
3
  <div class="cpCheckbox__wrapper">
4
4
  <input
5
5
  :id="checkboxUniqueId"
6
6
  ref="inputRef"
7
+ class="cpCheckbox__input"
8
+ :class="dynamicInputClasses"
7
9
  :autofocus="autofocus"
8
10
  :checked="isChecked"
9
11
  :disabled="isDisabled"
@@ -16,7 +18,7 @@
16
18
  </div>
17
19
  <div class="cpCheckbox__content">
18
20
  <slot>
19
- <span v-if="checkboxLabel" class="cpCheckbox__label">
21
+ <span v-if="checkboxLabel" class="cpCheckbox__label" :class="dynamicLabelClasses">
20
22
  {{ checkboxLabel }}
21
23
  </span>
22
24
  </slot>
@@ -48,6 +50,7 @@ export interface Props {
48
50
  isDisabled?: boolean
49
51
  modelValue?: boolean | unknown[]
50
52
  reverseLabel?: boolean
53
+ size?: 'md' | 'lg'
51
54
  }
52
55
 
53
56
  const props = withDefaults(defineProps<Props>(), {
@@ -57,6 +60,7 @@ const props = withDefaults(defineProps<Props>(), {
57
60
  groupName: '',
58
61
  color: 'accent',
59
62
  helper: '',
63
+ size: 'md',
60
64
  })
61
65
 
62
66
  const emit = defineEmits<EmitType>()
@@ -96,7 +100,7 @@ const hasDefaultSlot = computed(() => !!slots.default)
96
100
 
97
101
  const isEmpty = computed(() => !hasDefaultSlot.value && !props.checkboxLabel)
98
102
 
99
- const computedClasses = computed(() => {
103
+ const dynamicCheckboxClasses = computed(() => {
100
104
  return [
101
105
  {
102
106
  'cpCheckbox--isEmpty': isEmpty.value,
@@ -105,9 +109,14 @@ const computedClasses = computed(() => {
105
109
  'cpCheckbox--isIndeterminate': props.indeterminate,
106
110
  },
107
111
  `cpCheckbox--is${capitalizedColor.value}`,
112
+ `cpCheckbox--${props.size}`,
108
113
  ]
109
114
  })
110
115
 
116
+ const dynamicLabelClasses = computed(() => [ `cpCheckbox__label--${props.size}` ])
117
+
118
+ const dynamicInputClasses = computed(() => [ `cpCheckbox__input--${props.size}` ])
119
+
111
120
  const onChange = () => {
112
121
  if (Array.isArray(props.modelValue)) {
113
122
  const currentValues = [...props.modelValue]
@@ -172,10 +181,14 @@ const onChange = () => {
172
181
  'Purple'
173
182
  ); // TODO: Should be replace by ACCENT
174
183
 
175
- &:not(&--isEmpty) {
184
+ &--md:not(.cpCheckbox--isEmpty) {
176
185
  gap: var(--cp-spacing-md);
177
186
  }
178
187
 
188
+ &--lg:not(.cpCheckbox--isEmpty) {
189
+ gap: var(--cp-spacing-lg);
190
+ }
191
+
179
192
  &__wrapper {
180
193
  display: flex;
181
194
  flex-shrink: 0;
@@ -184,9 +197,7 @@ const onChange = () => {
184
197
  padding: var(--cp-spacing-sm);
185
198
  }
186
199
 
187
- input {
188
- width: var(--cp-dimensions-4);
189
- height: var(--cp-dimensions-4);
200
+ &__input {
190
201
  flex-shrink: 0;
191
202
  border: var(--cp-dimensions-0_25) solid var(--cp-border-soft);
192
203
  border-radius: var(--cp-radius-sm);
@@ -237,16 +248,43 @@ const onChange = () => {
237
248
  &:active:not(:disabled) {
238
249
  transform: scale(0.8);
239
250
  }
251
+
252
+ &--md {
253
+ width: var(--cp-dimensions-4);
254
+ height: var(--cp-dimensions-4);
255
+ border-radius: var(--cp-radius-sm);
256
+ }
257
+
258
+ &--lg {
259
+ width: var(--cp-dimensions-5);
260
+ height: var(--cp-dimensions-5);
261
+ border-radius: var(--cp-radius-sm-md);
262
+ }
240
263
  }
241
264
 
242
265
  &__label,
243
266
  &__helper {
244
267
  display: block;
268
+ }
269
+
270
+ &__helper {
245
271
  line-height: var(--cp-line-height-md);
246
272
  }
247
273
 
274
+
248
275
  &__label {
249
276
  font-weight: 500;
277
+ padding-block: var(--cp-spacing-xs);
278
+
279
+ &--md {
280
+ font-size: var(--cp-text-size-sm);
281
+ line-height: var(--cp-line-height-sm);
282
+ }
283
+
284
+ &--lg {
285
+ font-size: var(--cp-text-size-md);
286
+ line-height: var(--cp-line-height-md);
287
+ }
250
288
 
251
289
  &::first-letter {
252
290
  text-transform: capitalize;
@@ -116,6 +116,7 @@ interface Emits {
116
116
 
117
117
  interface Props {
118
118
  appendTo?: string | HTMLElement
119
+ disableBlurReset?: boolean
119
120
  disabled?: boolean
120
121
  emptyMessage?: string
121
122
  errorMessage?: string
@@ -144,6 +145,7 @@ const props = withDefaults(defineProps<Props>(), {
144
145
  name: '',
145
146
  placeholder: '',
146
147
  optionLabel: 'name',
148
+ disableBlurReset: false,
147
149
  trackBy: undefined,
148
150
  emptyMessage: 'No results found',
149
151
  errorMessage: '',
@@ -248,6 +250,7 @@ const handleOverlayShown = () => emit('overlayShown')
248
250
  const handleOverlayHidden = () => emit('overlayHidden')
249
251
 
250
252
  const handleBlur = () => {
253
+ if (props.disableBlurReset) return
251
254
  if (props.multiple) {
252
255
  const inputElement = getInputElement()
253
256
  if (inputElement) inputElement.value = ''
@@ -52,6 +52,11 @@ const meta = {
52
52
  control: 'boolean',
53
53
  description: 'Whether the checkbox is in an indeterminate state',
54
54
  },
55
+ size: {
56
+ control: 'select',
57
+ options: ['md', 'lg'],
58
+ description: 'Size variant of the checkbox',
59
+ },
55
60
  },
56
61
  } satisfies Meta<typeof CpCheckbox>
57
62