@citizenplane/pimp 8.20.4 → 8.22.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.
Files changed (140) hide show
  1. package/README.md +23 -2
  2. package/dist/IconAccompaniedMinorEach-DVJcuHj0.js +18 -0
  3. package/dist/IconAccompaniedMinorNone-BXf4n4ou.js +19 -0
  4. package/dist/IconAccompaniedMinorOne-CNdC-xeI.js +18 -0
  5. package/dist/IconAddReceipt-BFz16BpE.js +22 -0
  6. package/dist/IconAirportTerminal-CVkKwFXB.js +23 -0
  7. package/dist/IconArrival-C3UZ0X3K.js +23 -0
  8. package/dist/IconBroadcast-C0PyG0ON.js +20 -0
  9. package/dist/IconCabinBag-Dbfd3eU9.js +20 -0
  10. package/dist/IconCheckedBaggage--V-SlEA8.js +18 -0
  11. package/dist/IconCheckedBaggage20-qxIkw6m1.js +20 -0
  12. package/dist/IconCheckedBaggage30-BvMLcDVK.js +20 -0
  13. package/dist/IconChild-DQa4WqLv.js +21 -0
  14. package/dist/IconContact-CpjzDGE9.js +20 -0
  15. package/dist/IconDeparture-BgVq_dTQ.js +23 -0
  16. package/dist/IconDistribution-BbcHTmnJ.js +20 -0
  17. package/dist/IconDistributionClosed-BKSkMVr_.js +20 -0
  18. package/dist/IconDistributionExclusivePair-B4sktgJ5.js +18 -0
  19. package/dist/IconDistributionSided-DYDvAPYA.js +31 -0
  20. package/dist/IconDistributionSupplySided-Kj6qqifp.js +31 -0
  21. package/dist/IconDynamicContent-DvIytfat.js +21 -0
  22. package/dist/IconFares-DV3aFH6m.js +18 -0
  23. package/dist/IconFaresOutlined-DYEOkY_L.js +23 -0
  24. package/dist/IconFemale-D2Mfa1QV.js +33 -0
  25. package/dist/IconFindConversation-8wEIdKQV.js +24 -0
  26. package/dist/IconFire-pBaXc12G.js +22 -0
  27. package/dist/IconFlight-C5C7PmQR.js +23 -0
  28. package/dist/IconFlightReturn-BHKIKmJU.js +18 -0
  29. package/dist/IconHandHeart-WBIMaQuQ.js +21 -0
  30. package/dist/IconHistory-yZOWejhP.js +19 -0
  31. package/dist/IconHourGlass-CqyVtXKn.js +31 -0
  32. package/dist/IconIdCard-C1LVMNO2.js +22 -0
  33. package/dist/IconInfant-jlx5bYg6.js +18 -0
  34. package/dist/IconMale-DBRDgP6y.js +21 -0
  35. package/dist/IconMultiSegments-BNeLi2v7.js +18 -0
  36. package/dist/IconNoRefund-CnYqcTPx.js +18 -0
  37. package/dist/IconNotion-k-88gdS4.js +18 -0
  38. package/dist/IconOffline-sxl4gIDa.js +20 -0
  39. package/dist/IconPaid-DerAlBSC.js +23 -0
  40. package/dist/IconPassport-CrcNh_qG.js +22 -0
  41. package/dist/IconPayout-CS6i4g1R.js +20 -0
  42. package/dist/IconReceipt-DW0CutDY.js +25 -0
  43. package/dist/IconRecurrence-VbfPoDYR.js +24 -0
  44. package/dist/IconRefund-CXSRbRLD.js +19 -0
  45. package/dist/IconRoundTrip-Bt9-qnbY.js +20 -0
  46. package/dist/IconRouteNoStop-DL8Y30wj.js +18 -0
  47. package/dist/IconRouteOneStop-CTEyyVWa.js +18 -0
  48. package/dist/IconScheduleChange-Cfbc6YaK.js +19 -0
  49. package/dist/IconSeatEmpty-DXRMdLkb.js +25 -0
  50. package/dist/IconSeatSold-BEe-3cEz.js +22 -0
  51. package/dist/IconSeatTotal-IpvEJlaf.js +22 -0
  52. package/dist/IconTemplate-DzowVaSP.js +23 -0
  53. package/dist/IconTicket-o3P0xLEU.js +22 -0
  54. package/dist/IconTimer-DlMeU4t-.js +23 -0
  55. package/dist/IconTrafficControl-B1knXbCR.js +24 -0
  56. package/dist/index-CNDZl4Ol.js +15377 -0
  57. package/dist/pimp.es.js +2 -15377
  58. package/dist/pimp.umd.js +3 -3
  59. package/dist/style.css +1 -1
  60. package/package.json +12 -5
  61. package/src/README.md +1 -6
  62. package/src/assets/styles/base/_base.scss +3 -2
  63. package/src/assets/styles/helpers/_mixins.scss +1 -1
  64. package/src/assets/styles/utilities/_index.scss +1 -1
  65. package/src/assets/styles/variables/_colors.scss +16 -16
  66. package/src/components/atomic-elements/CpBadge.vue +82 -138
  67. package/src/components/feedback-indicators/CpToaster.vue +7 -2
  68. package/src/components/helpers-utilities/TransitionExpand.vue +0 -6
  69. package/src/components/icons/IconAccompaniedMinorEach.vue +30 -0
  70. package/src/components/icons/IconAccompaniedMinorNone.vue +10 -0
  71. package/src/components/icons/IconAccompaniedMinorOne.vue +22 -0
  72. package/src/components/icons/IconAddReceipt.vue +17 -0
  73. package/src/components/icons/IconAirportTerminal.vue +10 -0
  74. package/src/components/icons/IconArrival.vue +18 -0
  75. package/src/components/icons/IconBroadcast.vue +35 -0
  76. package/src/components/icons/IconCabinBag.vue +36 -0
  77. package/src/components/icons/IconCheckedBaggage.vue +11 -0
  78. package/src/components/icons/IconCheckedBaggage20.vue +36 -0
  79. package/src/components/icons/IconCheckedBaggage30.vue +39 -0
  80. package/src/components/icons/IconChild.vue +16 -0
  81. package/src/components/icons/IconContact.vue +15 -0
  82. package/src/components/icons/IconDeparture.vue +18 -0
  83. package/src/components/icons/IconDistribution.vue +19 -0
  84. package/src/components/icons/IconDistributionClosed.vue +30 -0
  85. package/src/components/icons/IconDistributionExclusivePair.vue +7 -0
  86. package/src/components/icons/IconDistributionSided.vue +24 -0
  87. package/src/components/icons/IconDistributionSupplySided.vue +24 -0
  88. package/src/components/icons/IconDynamicContent.vue +18 -0
  89. package/src/components/icons/IconFares.vue +7 -0
  90. package/src/components/icons/IconFaresOutlined.vue +24 -0
  91. package/src/components/icons/IconFemale.vue +20 -0
  92. package/src/components/icons/IconFindConversation.vue +21 -0
  93. package/src/components/icons/IconFire.vue +9 -0
  94. package/src/components/icons/IconFlight.vue +16 -0
  95. package/src/components/icons/IconFlightReturn.vue +7 -0
  96. package/src/components/icons/IconHandHeart.vue +18 -0
  97. package/src/components/icons/IconHistory.vue +10 -0
  98. package/src/components/icons/IconHourGlass.vue +25 -0
  99. package/src/components/icons/IconIdCard.vue +17 -0
  100. package/src/components/icons/IconInfant.vue +22 -0
  101. package/src/components/icons/IconMale.vue +8 -0
  102. package/src/components/icons/IconMultiSegments.vue +7 -0
  103. package/src/components/icons/IconNoRefund.vue +19 -0
  104. package/src/components/icons/IconNotion.vue +7 -0
  105. package/src/components/icons/IconOffline.vue +25 -0
  106. package/src/components/icons/IconPaid.vue +18 -0
  107. package/src/components/icons/IconPassport.vue +21 -0
  108. package/src/components/icons/IconPayout.vue +15 -0
  109. package/src/components/icons/IconReceipt.vue +20 -0
  110. package/src/components/icons/IconRecurrence.vue +15 -0
  111. package/src/components/icons/IconRefund.vue +10 -0
  112. package/src/components/icons/IconRoundTrip.vue +15 -0
  113. package/src/components/icons/IconRouteNoStop.vue +7 -0
  114. package/src/components/icons/IconRouteOneStop.vue +7 -0
  115. package/src/components/icons/IconScheduleChange.vue +31 -0
  116. package/src/components/icons/IconSeatEmpty.vue +22 -0
  117. package/src/components/icons/IconSeatSold.vue +21 -0
  118. package/src/components/icons/IconSeatTotal.vue +27 -0
  119. package/src/components/icons/IconTemplate.vue +18 -0
  120. package/src/components/icons/IconTicket.vue +23 -0
  121. package/src/components/icons/IconTimer.vue +12 -0
  122. package/src/components/icons/IconTrafficControl.vue +11 -0
  123. package/src/components/{index.js → index.ts} +1 -3
  124. package/src/components/inputs/CpInput.vue +2 -2
  125. package/src/components/lists-and-table/CpTable.vue +4 -2
  126. package/src/components/selects/CpSelectMenu.vue +6 -2
  127. package/src/components/visual/CpIcon.vue +76 -62
  128. package/src/constants/{index.js → index.ts} +1 -0
  129. package/src/constants/src/CpCustomIcons.ts +69 -0
  130. package/src/constants/src/colors/{ToggleColors.js → ToggleColors.ts} +1 -1
  131. package/src/libs/CoreDatepicker.vue +4 -1
  132. package/src/stories/CpBadge.stories.ts +80 -90
  133. package/src/stories/CpIcon.stories.ts +60 -27
  134. package/src/stories/CpSelectMenu.stories.ts +1 -1
  135. package/tsconfig.json +14 -0
  136. package/src/components/atomic-elements/CpBadgeNew.vue +0 -145
  137. package/src/stories/CpBadgeNew.stories.ts +0 -148
  138. /package/src/constants/src/{CpTableConfig.js → CpTableConfig.ts} +0 -0
  139. /package/src/constants/src/{Position.js → Position.ts} +0 -0
  140. /package/src/constants/src/colors/{Colors.js → Colors.ts} +0 -0
@@ -8,151 +8,141 @@ const meta = {
8
8
  argTypes: {
9
9
  color: {
10
10
  control: 'select',
11
- options: ['neutral', 'blue', 'green', 'red', 'orange', 'purple', 'teal', 'pink', 'yellow'],
11
+ options: ['gray', 'blue', 'green', 'red', 'orange', 'purple', 'pink', 'yellow'],
12
12
  description: 'The color variant of the badge',
13
13
  },
14
- isSolid: {
15
- control: 'boolean',
16
- description: 'Whether the badge has a solid background',
14
+ size: {
15
+ control: 'select',
16
+ options: ['sm', 'md'],
17
+ description: 'The size of the badge',
17
18
  },
18
- isPlain: {
19
+ isStroked: {
19
20
  control: 'boolean',
20
- description: 'Whether the badge has a plain style (no dot)',
21
+ description: 'Whether the badge has a stroked border',
21
22
  },
22
- isClearable: {
23
- control: 'boolean',
24
- description: 'Whether the badge can be cleared',
23
+ leadingIcon: {
24
+ control: 'select',
25
+ options: ['check', 'arrow-right', 'arrow-left', 'arrow-up', 'arrow-down'],
26
+ description: 'Type of leading icon (if any)',
25
27
  },
26
- icon: {
28
+ trailingIcon: {
27
29
  control: 'select',
28
- options: ['arrow-left', 'arrow-right', 'arrow-up', 'arrow-down', 'check'],
29
- description: 'The icon to display in the badge',
30
+ options: ['check', 'arrow-right', 'arrow-left', 'arrow-up', 'arrow-down'],
31
+ description: 'Type of trailing icon (if any)',
32
+ },
33
+ label: {
34
+ control: 'text',
35
+ description: 'The label text',
30
36
  },
31
- onClear: { action: 'cleared' },
32
37
  },
33
38
  } satisfies Meta<typeof CpBadge>
34
39
 
35
40
  export default meta
41
+
36
42
  type Story = StoryObj<typeof meta>
37
43
 
38
44
  export const Default: Story = {
39
45
  args: {
40
- color: 'neutral',
41
- isSolid: false,
42
- isPlain: false,
43
- isClearable: false,
44
- icon: '',
46
+ color: 'gray',
47
+ size: 'md',
48
+ isStroked: false,
49
+ leadingIcon: '',
50
+ trailingIcon: '',
51
+ label: 'Badge',
45
52
  },
46
53
  render: (args) => ({
47
54
  components: { CpBadge },
48
55
  setup() {
49
56
  return { args }
50
57
  },
51
- template: '<CpBadge v-bind="args">Badge</CpBadge>',
58
+ template: '<CpBadge v-bind="args" />',
52
59
  }),
53
60
  }
54
61
 
55
62
  export const WithColors: Story = {
56
- render: (args) => ({
63
+ render: () => ({
57
64
  components: { CpBadge },
58
- setup() {
59
- return { args }
60
- },
61
65
  template: `
62
66
  <div style="display: flex; gap: 8px; flex-wrap: wrap;">
63
- <CpBadge color="neutral">Neutral</CpBadge>
64
- <CpBadge color="blue">Blue</CpBadge>
65
- <CpBadge color="green">Green</CpBadge>
66
- <CpBadge color="red">Red</CpBadge>
67
- <CpBadge color="orange">Orange</CpBadge>
68
- <CpBadge color="purple">Purple</CpBadge>
69
- <CpBadge color="teal">Teal</CpBadge>
70
- <CpBadge color="pink">Pink</CpBadge>
71
- <CpBadge color="yellow">Yellow</CpBadge>
67
+ <CpBadge color="gray" label="Gray" />
68
+ <CpBadge color="blue" label="Blue" />
69
+ <CpBadge color="green" label="Green" />
70
+ <CpBadge color="red" label="Red" />
71
+ <CpBadge color="orange" label="Orange" />
72
+ <CpBadge color="purple" label="Purple" />
73
+ <CpBadge color="pink" label="Pink" />
74
+ <CpBadge color="yellow" label="Yellow" />
72
75
  </div>
73
76
  `,
74
77
  }),
75
78
  }
76
79
 
77
- export const Solid: Story = {
78
- render: (args) => ({
80
+ export const WithSizes: Story = {
81
+ render: () => ({
79
82
  components: { CpBadge },
80
- setup() {
81
- return { args }
82
- },
83
83
  template: `
84
- <div style="display: flex; gap: 8px; flex-wrap: wrap;">
85
- <CpBadge color="neutral" is-solid>Neutral</CpBadge>
86
- <CpBadge color="blue" is-solid>Blue</CpBadge>
87
- <CpBadge color="green" is-solid>Green</CpBadge>
88
- <CpBadge color="red" is-solid>Red</CpBadge>
89
- <CpBadge color="orange" is-solid>Orange</CpBadge>
90
- <CpBadge color="purple" is-solid>Purple</CpBadge>
91
- <CpBadge color="teal" is-solid>Teal</CpBadge>
92
- <CpBadge color="pink" is-solid>Pink</CpBadge>
93
- <CpBadge color="yellow" is-solid>Yellow</CpBadge>
84
+ <div style="display: flex; gap: 8px; align-items: center;">
85
+ <CpBadge size="sm" label="Small" />
86
+ <CpBadge size="md" label="Medium" />
94
87
  </div>
95
88
  `,
96
89
  }),
97
90
  }
98
91
 
99
- export const WithIcon: Story = {
100
- args: {
101
- color: 'blue',
102
- icon: 'check',
103
- },
104
- render: (args) => ({
92
+ export const IsStroked: Story = {
93
+ render: () => ({
105
94
  components: { CpBadge },
106
- setup() {
107
- return { args }
108
- },
109
- template: '<CpBadge v-bind="args">With Icon</CpBadge>',
95
+ template: `
96
+ <div style="display: flex; gap: 8px; flex-wrap: wrap;">
97
+ <CpBadge color="blue" isStroked label="Stroked" />
98
+ <CpBadge color="green" isStroked label="Stroked" />
99
+ <CpBadge color="red" isStroked label="Stroked" />
100
+ </div>
101
+ `,
110
102
  }),
111
103
  }
112
104
 
113
- export const Clearable: Story = {
114
- args: {
115
- color: 'blue',
116
- isClearable: true,
117
- },
118
- render: (args) => ({
105
+ export const WithIcons: Story = {
106
+ render: () => ({
119
107
  components: { CpBadge },
120
- setup() {
121
- return { args }
122
- },
123
- template: '<CpBadge v-bind="args">Clearable Badge</CpBadge>',
108
+ template: `
109
+ <div style="display: flex; gap: 8px; align-items: center;">
110
+ <CpBadge color="blue" leading-icon="check" label="Leading Icon" />
111
+ <CpBadge color="green" trailing-icon="arrow-right" label="Trailing Icon" />
112
+ <CpBadge color="red" leading-icon="check" trailing-icon="arrow-right" label="Both Icons" />
113
+ </div>
114
+ `,
124
115
  }),
125
116
  }
126
117
 
127
- export const Plain: Story = {
128
- args: {
129
- color: 'green',
130
- isPlain: true,
131
- },
132
- render: (args) => ({
118
+ export const IsClearable: Story = {
119
+ render: () => ({
133
120
  components: { CpBadge },
134
- setup() {
135
- return { args }
136
- },
137
- template: '<CpBadge v-bind="args">Plain Badge</CpBadge>',
121
+ template: `
122
+ <div style="display: flex; gap: 8px; align-items: center;">
123
+ <CpBadge color="blue" isClearable label="Clearable" />
124
+ <CpBadge color="green" isClearable label="Clearable" />
125
+ <CpBadge color="red" isClearable label="Clearable" />
126
+ </div>
127
+ `,
138
128
  }),
139
129
  }
140
130
 
141
- export const AllVariants: Story = {
142
- render: (args) => ({
131
+ export const WithSlot: Story = {
132
+ render: () => ({
143
133
  components: { CpBadge },
144
- setup() {
145
- return { args }
146
- },
147
134
  template: `
148
- <div style="display: flex; gap: 8px; flex-wrap: wrap;">
149
- <CpBadge color="blue">Default</CpBadge>
150
- <CpBadge color="blue" is-solid>Solid</CpBadge>
151
- <CpBadge color="blue" is-plain>Plain</CpBadge>
152
- <CpBadge color="blue" is-clearable>Clearable</CpBadge>
153
- <CpBadge color="blue" icon="check">With Icon</CpBadge>
154
- <CpBadge color="blue" is-solid is-clearable>Solid Clearable</CpBadge>
155
- </div>
135
+ <CpBadge color="purple">
136
+ <template #leading-icon>
137
+ <span style="font-size: 16px; margin-right: 4px;">🌟</span>
138
+ </template>
139
+ <div>
140
+ Custom div inside default slot
141
+ </div>
142
+ <template #trailing-icon>
143
+ <span style="font-size: 16px; margin-left: 4px;">🚀</span>
144
+ </template>
145
+ </CpBadge>
156
146
  `,
157
147
  }),
158
148
  }
@@ -1,5 +1,30 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3'
2
2
  import CpIcon from '@/components/visual/CpIcon.vue'
3
+ import { CustomCpIcons } from '@/constants'
4
+
5
+ const iconsOptions = [
6
+ ...Object.keys(CustomCpIcons),
7
+ 'activity',
8
+ 'alert-circle',
9
+ 'arrow-down',
10
+ 'arrow-left',
11
+ 'arrow-right',
12
+ 'arrow-up',
13
+ 'bell',
14
+ 'calendar',
15
+ 'check',
16
+ 'check-circle',
17
+ 'chevron-down',
18
+ 'chevron-left',
19
+ 'chevron-right',
20
+ 'chevron-up',
21
+ 'edit',
22
+ 'home',
23
+ 'search',
24
+ 'settings',
25
+ 'user',
26
+ 'x',
27
+ ].sort()
3
28
 
4
29
  const meta = {
5
30
  title: 'CpIcon',
@@ -7,28 +32,7 @@ const meta = {
7
32
  argTypes: {
8
33
  type: {
9
34
  control: 'select',
10
- options: [
11
- 'activity',
12
- 'alert-circle',
13
- 'arrow-down',
14
- 'arrow-left',
15
- 'arrow-right',
16
- 'arrow-up',
17
- 'bell',
18
- 'calendar',
19
- 'check',
20
- 'check-circle',
21
- 'chevron-down',
22
- 'chevron-left',
23
- 'chevron-right',
24
- 'chevron-up',
25
- 'edit',
26
- 'home',
27
- 'search',
28
- 'settings',
29
- 'user',
30
- 'x',
31
- ],
35
+ options: iconsOptions,
32
36
  description: 'Type of icon to display',
33
37
  },
34
38
  size: {
@@ -39,6 +43,13 @@ const meta = {
39
43
  control: 'text',
40
44
  description: 'HTML tag to use for the icon wrapper',
41
45
  },
46
+ weight: {
47
+ control: 'number',
48
+ description: 'Weight for specific icons like checked-baggage',
49
+ table: {
50
+ defaultValue: { summary: 0 },
51
+ },
52
+ },
42
53
  },
43
54
  } satisfies Meta<typeof CpIcon>
44
55
 
@@ -65,14 +76,36 @@ export const Default: Story = {
65
76
  }
66
77
 
67
78
  export const DifferentSizes: Story = {
68
- render: () => ({
79
+ args: {
80
+ type: 'check',
81
+ },
82
+ render: (args) => ({
69
83
  components: { CpIcon },
84
+ setup() {
85
+ return { args }
86
+ },
70
87
  template: `
71
88
  <div style="padding: 20px; display: flex; align-items: center; gap: 16px;">
72
- <CpIcon type="check" size="16" />
73
- <CpIcon type="check" size="24" />
74
- <CpIcon type="check" size="32" />
75
- <CpIcon type="check" size="48" />
89
+ <CpIcon v-bind="{ ...args, size: 16 }" />
90
+ <CpIcon v-bind="{ ...args, size: 24 }" />
91
+ <CpIcon v-bind="{ ...args, size: 32 }" />
92
+ <CpIcon v-bind="{ ...args, size: 48 }" />
93
+ </div>
94
+ `,
95
+ }),
96
+ }
97
+
98
+ export const AllIcons: Story = {
99
+ render: () => ({
100
+ components: { CpIcon },
101
+ setup() {
102
+ return { icons: iconsOptions }
103
+ },
104
+ template: `
105
+ <div style="padding: 20px; display: grid; grid-template-columns: repeat(4, minmax(100px, 3fr)); gap: 16px;">
106
+ <div v-for="icon in icons" style="display: flex;align-items: center;justify-content: center;border: 1px solid #eee;border-radius: 4px;padding: 2px 0;">
107
+ <CpIcon :key="icon" :type="icon" />
108
+ </div>
76
109
  </div>
77
110
  `,
78
111
  }),
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3'
2
- import { computed, ref } from 'vue'
2
+ import { ref } from 'vue'
3
3
  import CpSelectMenu from '@/components/selects/CpSelectMenu.vue'
4
4
 
5
5
  const meta = {
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "isolatedModules": true,
4
+ "strict": true,
5
+ "jsx": "preserve",
6
+ "jsxImportSource": "vue",
7
+ "baseUrl": ".",
8
+ "paths": {
9
+ "@/*": ["./src/*"]
10
+ }
11
+ },
12
+ "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
13
+ "exclude": ["node_modules", "storybook-static", "dist", "build"]
14
+ }
@@ -1,145 +0,0 @@
1
- <template>
2
- <div class="cpBadgeNew" :class="componentDynamicClasses">
3
- <slot name="leading-icon">
4
- <cp-icon v-if="leadingIcon" :type="leadingIcon" class="cpBadgeNew__icon" />
5
- </slot>
6
-
7
- <span class="cpBadgeNew__label">
8
- <slot>{{ label }}</slot>
9
- </span>
10
-
11
- <slot v-if="!isClearable" name="trailing-icon">
12
- <cp-icon v-if="trailingIcon" :type="trailingIcon" class="cpBadgeNew__icon" />
13
- </slot>
14
-
15
- <button v-if="isClearable" class="cpBadgeNew__clear" @click="onClear">
16
- <cp-icon type="x" class="cpBadgeNew__icon" />
17
- </button>
18
- </div>
19
- </template>
20
-
21
- <script setup>
22
- import { computed } from 'vue'
23
-
24
- import { Colors } from '@/constants'
25
-
26
- import { Sizes } from '@/utils/constants'
27
-
28
- import { capitalizeFirstLetter } from '@/helpers'
29
-
30
- const props = defineProps({
31
- color: {
32
- type: String,
33
- default: Colors.GRAY,
34
- validator: (value) => Object.values(Colors).includes(value),
35
- },
36
- size: {
37
- type: String,
38
- required: false,
39
- default: Sizes.MD,
40
- validator(value) {
41
- return Object.values(Sizes).includes(value)
42
- },
43
- },
44
- label: {
45
- type: String,
46
- default: '',
47
- },
48
- leadingIcon: {
49
- type: String,
50
- default: '',
51
- },
52
- trailingIcon: {
53
- type: String,
54
- default: '',
55
- },
56
- isStroked: {
57
- type: Boolean,
58
- default: false,
59
- },
60
- isClearable: {
61
- type: Boolean,
62
- default: false,
63
- },
64
- })
65
-
66
- const componentDynamicClasses = computed(() => {
67
- return [
68
- `cpBadgeNew--${props.size}`,
69
- `cpBadgeNew--is${capitalizeFirstLetter(props.color)}`,
70
- { 'cpBadgeNew--isStroked': props.isStroked },
71
- { 'cpBadgeNew--isClearable': props.isClearable },
72
- ]
73
- })
74
- </script>
75
-
76
- <style lang="scss">
77
- @mixin cp-badge-new-themed($className, $color, $bg-color, $outline-color) {
78
- &--is#{$className} {
79
- color: $color;
80
- background-color: $bg-color;
81
- outline-color: $outline-color;
82
-
83
- .cpBadgeNew__clear:hover,
84
- .cpBadgeNew__clear:focus-visible {
85
- background-color: $color;
86
- }
87
- }
88
- }
89
-
90
- .cpBadgeNew {
91
- display: inline-flex;
92
- padding: sp.$space-sm sp.$space;
93
- align-items: center;
94
- border-radius: fn.px-to-rem(8);
95
- background-color: colors.$neutral-dark-5;
96
- font-size: fn.px-to-em(14);
97
- color: colors.$neutral-dark;
98
- gap: sp.$space-sm;
99
-
100
- &--isStroked {
101
- outline: 1px solid currentColor;
102
- }
103
-
104
- @include cp-badge-new-themed('Blue', colors.$blue, colors.$blue-100, colors.$blue-200);
105
- @include cp-badge-new-themed('Gray', colors.$astronaut, colors.$gray-5, colors.$gray-4);
106
- @include cp-badge-new-themed('Green', colors.$green, colors.$green-100, colors.$green-200);
107
- @include cp-badge-new-themed('Orange', colors.$orange, colors.$orange-100, colors.$orange-200);
108
- @include cp-badge-new-themed('Pink', colors.$pink, colors.$pink-100, colors.$pink-200);
109
- @include cp-badge-new-themed('Purple', colors.$purple, colors.$purple-100, colors.$purple-200);
110
- @include cp-badge-new-themed('Red', colors.$red, colors.$red-100, colors.$red-200);
111
- @include cp-badge-new-themed('Yellow', colors.$yellow-500, colors.$yellow-100, colors.$yellow-200);
112
-
113
- &--sm {
114
- font-size: fn.px-to-em(12);
115
-
116
- .cpBadgeNew__label {
117
- line-height: fn.px-to-rem(16);
118
- }
119
- }
120
-
121
- &__icon {
122
- width: fn.px-to-rem(16);
123
- height: fn.px-to-rem(16);
124
- aspect-ratio: 1/1;
125
- }
126
-
127
- &__label {
128
- line-height: fn.px-to-rem(20);
129
- }
130
-
131
- &__clear {
132
- display: flex;
133
- align-items: center;
134
- justify-content: center;
135
- padding: sp.$space-xs;
136
- border-radius: 50%;
137
- color: inherit;
138
-
139
- &:hover,
140
- &:focus-visible {
141
- color: colors.$neutral-light;
142
- }
143
- }
144
- }
145
- </style>
@@ -1,148 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/vue3'
2
-
3
- import CpBadgeNew from '@/components/atomic-elements/CpBadgeNew.vue'
4
-
5
- const meta = {
6
- title: 'CpBadgeNew',
7
- component: CpBadgeNew,
8
- argTypes: {
9
- color: {
10
- control: 'select',
11
- options: ['gray', 'blue', 'green', 'red', 'orange', 'purple', 'pink', 'yellow'],
12
- description: 'The color variant of the badge',
13
- },
14
- size: {
15
- control: 'select',
16
- options: ['sm', 'md'],
17
- description: 'The size of the badge',
18
- },
19
- isStroked: {
20
- control: 'boolean',
21
- description: 'Whether the badge has a stroked border',
22
- },
23
- leadingIcon: {
24
- control: 'select',
25
- options: ['check', 'arrow-right', 'arrow-left', 'arrow-up', 'arrow-down'],
26
- description: 'Type of leading icon (if any)',
27
- },
28
- trailingIcon: {
29
- control: 'select',
30
- options: ['check', 'arrow-right', 'arrow-left', 'arrow-up', 'arrow-down'],
31
- description: 'Type of trailing icon (if any)',
32
- },
33
- label: {
34
- control: 'text',
35
- description: 'The label text',
36
- },
37
- },
38
- } satisfies Meta<typeof CpBadgeNew>
39
-
40
- export default meta
41
-
42
- type Story = StoryObj<typeof meta>
43
-
44
- export const Default: Story = {
45
- args: {
46
- color: 'gray',
47
- size: 'md',
48
- isStroked: false,
49
- leadingIcon: '',
50
- trailingIcon: '',
51
- label: 'Badge',
52
- },
53
- render: (args) => ({
54
- components: { CpBadgeNew },
55
- setup() {
56
- return { args }
57
- },
58
- template: '<CpBadgeNew v-bind="args" />',
59
- }),
60
- }
61
-
62
- export const WithColors: Story = {
63
- render: () => ({
64
- components: { CpBadgeNew },
65
- template: `
66
- <div style="display: flex; gap: 8px; flex-wrap: wrap;">
67
- <CpBadgeNew color="gray" label="Gray" />
68
- <CpBadgeNew color="blue" label="Blue" />
69
- <CpBadgeNew color="green" label="Green" />
70
- <CpBadgeNew color="red" label="Red" />
71
- <CpBadgeNew color="orange" label="Orange" />
72
- <CpBadgeNew color="purple" label="Purple" />
73
- <CpBadgeNew color="pink" label="Pink" />
74
- <CpBadgeNew color="yellow" label="Yellow" />
75
- </div>
76
- `,
77
- }),
78
- }
79
-
80
- export const WithSizes: Story = {
81
- render: () => ({
82
- components: { CpBadgeNew },
83
- template: `
84
- <div style="display: flex; gap: 8px; align-items: center;">
85
- <CpBadgeNew size="sm" label="Small" />
86
- <CpBadgeNew size="md" label="Medium" />
87
- </div>
88
- `,
89
- }),
90
- }
91
-
92
- export const IsStroked: Story = {
93
- render: () => ({
94
- components: { CpBadgeNew },
95
- template: `
96
- <div style="display: flex; gap: 8px; flex-wrap: wrap;">
97
- <CpBadgeNew color="blue" isStroked label="Stroked" />
98
- <CpBadgeNew color="green" isStroked label="Stroked" />
99
- <CpBadgeNew color="red" isStroked label="Stroked" />
100
- </div>
101
- `,
102
- }),
103
- }
104
-
105
- export const WithIcons: Story = {
106
- render: () => ({
107
- components: { CpBadgeNew },
108
- template: `
109
- <div style="display: flex; gap: 8px; align-items: center;">
110
- <CpBadgeNew color="blue" leading-icon="check" label="Leading Icon" />
111
- <CpBadgeNew color="green" trailing-icon="arrow-right" label="Trailing Icon" />
112
- <CpBadgeNew color="red" leading-icon="check" trailing-icon="arrow-right" label="Both Icons" />
113
- </div>
114
- `,
115
- }),
116
- }
117
-
118
- export const IsClearable: Story = {
119
- render: () => ({
120
- components: { CpBadgeNew },
121
- template: `
122
- <div style="display: flex; gap: 8px; align-items: center;">
123
- <CpBadgeNew color="blue" isClearable label="Clearable" />
124
- <CpBadgeNew color="green" isClearable label="Clearable" />
125
- <CpBadgeNew color="red" isClearable label="Clearable" />
126
- </div>
127
- `,
128
- }),
129
- }
130
-
131
- export const WithSlot: Story = {
132
- render: () => ({
133
- components: { CpBadgeNew },
134
- template: `
135
- <CpBadgeNew color="purple">
136
- <template #leading-icon>
137
- <span style="font-size: 16px; margin-right: 4px;">🌟</span>
138
- </template>
139
- <div>
140
- Custom div inside default slot
141
- </div>
142
- <template #trailing-icon>
143
- <span style="font-size: 16px; margin-left: 4px;">🚀</span>
144
- </template>
145
- </CpBadgeNew>
146
- `,
147
- }),
148
- }
File without changes