@citizenplane/pimp 8.33.0 → 9.0.1

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.
@@ -8,13 +8,14 @@ const meta = {
8
8
  title: 'CpSwitch',
9
9
  component: CpSwitch,
10
10
  argTypes: {
11
- modelValue: {
11
+ autofocus: {
12
12
  control: 'boolean',
13
- description: 'The switch state',
13
+ description: 'Whether to autofocus the switch',
14
14
  },
15
- label: {
16
- control: 'text',
17
- description: 'Label text for the switch',
15
+ color: {
16
+ control: 'select',
17
+ options: ['blue', 'purple'],
18
+ description: 'Color variant of the switch',
18
19
  },
19
20
  disabled: {
20
21
  control: 'boolean',
@@ -24,18 +25,29 @@ const meta = {
24
25
  control: 'text',
25
26
  description: 'Name attribute for the switch',
26
27
  },
27
- color: {
28
- control: 'select',
29
- options: ['blue', 'purple'],
30
- description: 'Color variant of the switch',
28
+ helper: {
29
+ control: 'text',
30
+ description: 'Helper text to display below the label',
31
+ },
32
+ isRequired: {
33
+ control: 'boolean',
34
+ description: 'Whether the switch is required',
35
+ },
36
+ label: {
37
+ control: 'text',
38
+ description: 'Label text for the switch',
39
+ },
40
+ modelValue: {
41
+ control: 'boolean',
42
+ description: 'The switch state',
31
43
  },
32
44
  reverseLabel: {
33
45
  control: 'boolean',
34
46
  description: 'Whether to show label before the switch',
35
47
  },
36
- autofocus: {
37
- control: 'boolean',
38
- description: 'Whether to autofocus the switch',
48
+ tooltip: {
49
+ control: 'text',
50
+ description: 'Tooltip text to display',
39
51
  },
40
52
  },
41
53
  } satisfies Meta<typeof CpSwitch>
@@ -45,11 +57,14 @@ type Story = StoryObj<typeof meta>
45
57
 
46
58
  export const Default: Story = {
47
59
  args: {
48
- label: 'Switch Label',
60
+ label: 'Label',
61
+ helper: '',
49
62
  disabled: false,
50
63
  color: 'purple',
51
64
  reverseLabel: false,
52
65
  autofocus: false,
66
+ isRequired: true,
67
+ tooltip: '',
53
68
  },
54
69
  render: (args) => ({
55
70
  components: { CpSwitch },
@@ -83,6 +98,28 @@ export const DisabledChecked: Story = {
83
98
  },
84
99
  }
85
100
 
101
+ export const Required: Story = {
102
+ args: {
103
+ ...Default.args,
104
+ isRequired: true,
105
+ },
106
+ render: (args) => ({
107
+ components: { CpSwitch },
108
+ setup() {
109
+ const value = ref(false)
110
+ return { args, value }
111
+ },
112
+ template: `
113
+ <div style="padding: 20px;">
114
+ <CpSwitch
115
+ v-model="value"
116
+ v-bind="args"
117
+ />
118
+ </div>
119
+ `,
120
+ }),
121
+ }
122
+
86
123
  export const Reversed: Story = {
87
124
  args: {
88
125
  ...Default.args,
@@ -105,6 +142,73 @@ export const Reversed: Story = {
105
142
  }),
106
143
  }
107
144
 
145
+ export const WithHelper: Story = {
146
+ args: {
147
+ ...Default.args,
148
+ helper: 'This is a helper text that provides additional information',
149
+ },
150
+ render: (args) => ({
151
+ components: { CpSwitch },
152
+ setup() {
153
+ const value = ref(false)
154
+ return { args, value }
155
+ },
156
+ template: `
157
+ <div style="padding: 20px;">
158
+ <CpSwitch
159
+ v-model="value"
160
+ v-bind="args"
161
+ />
162
+ </div>
163
+ `,
164
+ }),
165
+ }
166
+
167
+ export const WithTooltip: Story = {
168
+ args: {
169
+ ...Default.args,
170
+ tooltip: 'This is a tooltip text',
171
+ },
172
+ render: (args) => ({
173
+ components: { CpSwitch },
174
+ setup() {
175
+ const value = ref(false)
176
+ return { args, value }
177
+ },
178
+ template: `
179
+ <div style="padding: 20px;">
180
+ <CpSwitch
181
+ v-model="value"
182
+ v-bind="args"
183
+ />
184
+ </div>
185
+ `,
186
+ }),
187
+ }
188
+
189
+ export const WithHelperAndTooltip: Story = {
190
+ args: {
191
+ ...Default.args,
192
+ helper: 'This is a helper text that provides additional information',
193
+ tooltip: 'This is a tooltip text',
194
+ },
195
+ render: (args) => ({
196
+ components: { CpSwitch },
197
+ setup() {
198
+ const value = ref(false)
199
+ return { args, value }
200
+ },
201
+ template: `
202
+ <div style="padding: 20px;">
203
+ <CpSwitch
204
+ v-model="value"
205
+ v-bind="args"
206
+ />
207
+ </div>
208
+ `,
209
+ }),
210
+ }
211
+
108
212
  export const SwitchGroup: Story = {
109
213
  render: () => ({
110
214
  components: { CpSwitch },
@@ -132,6 +236,12 @@ export const SwitchGroup: Story = {
132
236
  v-model="switches.switch3"
133
237
  label="Third Switch"
134
238
  group-name="switch-group"
239
+ disabled
240
+ />
241
+ <CpSwitch
242
+ v-model="switches.switch4"
243
+ label="Fourth Switch"
244
+ group-name="switch-group"
135
245
  />
136
246
  </div>
137
247
  `,