@citizenplane/pimp 12.0.3 → 13.0.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": "12.0.3",
3
+ "version": "13.0.0",
4
4
  "scripts": {
5
5
  "dev": "storybook dev -p 8080",
6
6
  "build-storybook": "storybook build --output-dir ./docs",
@@ -4,10 +4,10 @@
4
4
  class="cpLoader"
5
5
  :class="dynamicClasses"
6
6
  enable-background="new 0 0 40 40"
7
- :height="sizeAttrs.height"
7
+ :height="40"
8
8
  version="1.1"
9
9
  viewBox="0 0 40 40"
10
- :width="sizeAttrs.width"
10
+ :width="40"
11
11
  x="0px"
12
12
  xml:space="preserve"
13
13
  xmlns="http://www.w3.org/2000/svg"
@@ -25,7 +25,7 @@
25
25
  <animateTransform
26
26
  attributeName="transform"
27
27
  attributeType="xml"
28
- dur="0.5s"
28
+ :dur="formatedDuration"
29
29
  from="0 20 20"
30
30
  repeatCount="indefinite"
31
31
  to="360 20 20"
@@ -41,23 +41,22 @@ import { computed } from 'vue'
41
41
  import { Colors } from '@/constants'
42
42
  import { capitalizeFirstLetter } from '@/helpers'
43
43
 
44
+ type LoaderColor = Extract<Colors, 'neutral' | 'accent' | 'error' | 'warning' | 'success'>
45
+ type LoaderSize = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl'
46
+
44
47
  interface Props {
45
- color?: Colors
46
- size?: number | string
48
+ color?: LoaderColor
49
+ duration?: number
50
+ size?: LoaderSize
47
51
  }
48
52
 
49
- const props = withDefaults(defineProps<Props>(), { color: 'accent', size: 24 })
53
+ const props = withDefaults(defineProps<Props>(), { color: 'accent', duration: 700, size: 'sm' })
50
54
 
51
- const capitalizedColor = computed(() => capitalizeFirstLetter(props.color))
55
+ const formatedDuration = computed(() => `${props.duration}ms`)
52
56
 
53
57
  const dynamicClasses = computed(() => {
54
- return [`cpLoader--is${capitalizedColor.value}`, `cpLoader--${props.size}`]
58
+ return [`cpLoader--is${capitalizeFirstLetter(props.color)}`, `cpLoader--${props.size}`]
55
59
  })
56
-
57
- const sizeAttrs = computed(() => ({
58
- height: props.size,
59
- width: props.size,
60
- }))
61
60
  </script>
62
61
 
63
62
  <style lang="scss">
@@ -74,12 +73,36 @@ const sizeAttrs = computed(() => ({
74
73
  @include cp-loader-themed('Warning', var(--cp-foreground-warning-secondary));
75
74
  @include cp-loader-themed('Success', var(--cp-foreground-success-secondary));
76
75
 
77
- @include cp-loader-themed('Blue', var(--cp-foreground-blue-secondary));
78
- @include cp-loader-themed('Yellow', var(--cp-utility-yellow-300));
76
+ &--2xs {
77
+ @include mx.square-sizing(16);
78
+ }
79
+
80
+ &--xs {
81
+ @include mx.square-sizing(20);
82
+ }
83
+
84
+ &--sm {
85
+ @include mx.square-sizing(24);
86
+ }
87
+
88
+ &--md {
89
+ @include mx.square-sizing(32);
90
+ }
91
+
92
+ &--lg {
93
+ @include mx.square-sizing(40);
94
+ }
95
+
96
+ &--xl {
97
+ @include mx.square-sizing(48);
98
+ }
99
+
100
+ &--2xl {
101
+ @include mx.square-sizing(64);
102
+ }
79
103
 
80
- @include cp-loader-themed('Purple', var(--cp-text-accent-primary)); // TODO: Should be replace by ACCENT
81
- @include cp-loader-themed('Green', var(--cp-text-success-primary)); // TODO: Should be replace by SUCCESS
82
- @include cp-loader-themed('Orange', var(--cp-text-warning-primary)); // TODO: Should be replace by WARNING
83
- @include cp-loader-themed('Red', var(--cp-text-error-primary)); // TODO: Should be replace by ERROR
104
+ &--3xl {
105
+ @include mx.square-sizing(96);
106
+ }
84
107
  }
85
108
  </style>
@@ -7,14 +7,19 @@ const meta = {
7
7
  component: CpLoader,
8
8
  argTypes: {
9
9
  size: {
10
- control: 'number',
10
+ control: 'select',
11
+ options: ['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'],
11
12
  description: 'Size of the loader in pixels',
12
13
  },
13
14
  color: {
14
15
  control: 'select',
15
- options: ['neutral', 'accent', 'error', 'warning', 'success', 'blue', 'yellow'],
16
+ options: ['neutral', 'accent', 'error', 'warning', 'success'],
16
17
  description: 'The color variant of the loader',
17
18
  },
19
+ duration: {
20
+ control: 'number',
21
+ description: 'The duration of the loader in ms (700ms by default)',
22
+ },
18
23
  },
19
24
  } satisfies Meta<typeof CpLoader>
20
25