@citizenplane/pimp 18.16.2 → 18.16.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/dist/components/CpButtonToggle.vue.d.ts +2 -0
- package/dist/components/CpButtonToggle.vue.d.ts.map +1 -1
- package/dist/pimp.es.js +14 -7
- package/dist/pimp.umd.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/CpButtonToggle.vue +39 -14
- package/src/stories/CpButtonToggle.stories.ts +26 -0
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
>
|
|
11
11
|
<span class="cpToggleButton__leading">
|
|
12
12
|
<slot name="leading">
|
|
13
|
-
<cp-icon size="
|
|
13
|
+
<cp-icon :size="dynamicIconSize" :type="leadingIcon" />
|
|
14
14
|
</slot>
|
|
15
15
|
</span>
|
|
16
16
|
<span v-if="showLabel" class="cpToggleButton__label">
|
|
@@ -29,6 +29,7 @@ interface Props {
|
|
|
29
29
|
isSelected?: boolean
|
|
30
30
|
label?: string
|
|
31
31
|
leadingIcon?: string
|
|
32
|
+
size?: 'sm' | 'md' | 'lg'
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -36,6 +37,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
36
37
|
disabled: false,
|
|
37
38
|
label: '',
|
|
38
39
|
leadingIcon: 'dashed-circle',
|
|
40
|
+
size: 'md',
|
|
39
41
|
})
|
|
40
42
|
|
|
41
43
|
const emit = defineEmits<{
|
|
@@ -46,13 +48,25 @@ const slots = useSlots()
|
|
|
46
48
|
|
|
47
49
|
const showLabel = computed(() => !!props.label || !!slots.default)
|
|
48
50
|
|
|
49
|
-
const dynamicClasses = computed(() =>
|
|
50
|
-
|
|
51
|
-
}
|
|
51
|
+
const dynamicClasses = computed(() => {
|
|
52
|
+
return {
|
|
53
|
+
[`cpToggleButton--${props.size}`]: true,
|
|
54
|
+
'cpToggleButton--isSelected': props.isSelected,
|
|
55
|
+
}
|
|
56
|
+
})
|
|
52
57
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
const dynamicIconSize = computed(() => {
|
|
59
|
+
switch (props.size) {
|
|
60
|
+
case 'lg':
|
|
61
|
+
return '20'
|
|
62
|
+
case 'md':
|
|
63
|
+
case 'sm':
|
|
64
|
+
default:
|
|
65
|
+
return '16'
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const handleClick = (event: MouseEvent) => emit('click', event)
|
|
56
70
|
</script>
|
|
57
71
|
|
|
58
72
|
<style lang="scss">
|
|
@@ -60,7 +74,6 @@ const handleClick = (event: MouseEvent) => {
|
|
|
60
74
|
display: inline-flex;
|
|
61
75
|
align-items: center;
|
|
62
76
|
justify-content: center;
|
|
63
|
-
padding: var(--cp-spacing-lg);
|
|
64
77
|
border-radius: var(--cp-radius-md);
|
|
65
78
|
background-color: var(--cp-background-primary);
|
|
66
79
|
box-shadow:
|
|
@@ -71,8 +84,7 @@ const handleClick = (event: MouseEvent) => {
|
|
|
71
84
|
transition:
|
|
72
85
|
background-color 100ms ease-out,
|
|
73
86
|
box-shadow 100ms ease-out,
|
|
74
|
-
color 100ms ease-out
|
|
75
|
-
transform 100ms ease;
|
|
87
|
+
color 100ms ease-out;
|
|
76
88
|
|
|
77
89
|
&:focus-visible {
|
|
78
90
|
box-shadow:
|
|
@@ -97,10 +109,6 @@ const handleClick = (event: MouseEvent) => {
|
|
|
97
109
|
color: var(--cp-text-secondary-hover);
|
|
98
110
|
}
|
|
99
111
|
|
|
100
|
-
&:active:not(:disabled) {
|
|
101
|
-
transform: scale3d(0.97, 0.97, 1);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
112
|
&__leading {
|
|
105
113
|
display: flex;
|
|
106
114
|
align-items: center;
|
|
@@ -117,6 +125,23 @@ const handleClick = (event: MouseEvent) => {
|
|
|
117
125
|
pointer-events: none;
|
|
118
126
|
}
|
|
119
127
|
|
|
128
|
+
&--sm {
|
|
129
|
+
padding: var(--cp-spacing-sm-md) var(--cp-spacing-md);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&--md {
|
|
133
|
+
padding: var(--cp-dimensions-2_5) var(--cp-spacing-lg);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&--lg {
|
|
137
|
+
padding: var(--cp-spacing-lg) var(--cp-spacing-xl);
|
|
138
|
+
|
|
139
|
+
.cpToggleButton__label {
|
|
140
|
+
font-size: var(--cp-text-size-md);
|
|
141
|
+
line-height: var(--cp-line-height-md);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
120
145
|
&--isSelected:not(:disabled) {
|
|
121
146
|
background-color: var(--cp-background-accent-secondary);
|
|
122
147
|
box-shadow:
|
|
@@ -6,10 +6,17 @@ import CpSwitch from '@/components/CpSwitch.vue'
|
|
|
6
6
|
|
|
7
7
|
import { docCellStyle, docLabelStyle, docRowWrapStyle } from '@/stories/documentationStyles'
|
|
8
8
|
|
|
9
|
+
const buttonToggleSizes = ['sm', 'md', 'lg'] as const
|
|
10
|
+
|
|
9
11
|
const meta = {
|
|
10
12
|
title: 'Atoms/CpButtonToggle',
|
|
11
13
|
component: CpButtonToggle,
|
|
12
14
|
argTypes: {
|
|
15
|
+
size: {
|
|
16
|
+
control: 'select',
|
|
17
|
+
options: buttonToggleSizes,
|
|
18
|
+
description: 'The size of the toggle button.',
|
|
19
|
+
},
|
|
13
20
|
isSelected: {
|
|
14
21
|
control: 'boolean',
|
|
15
22
|
description: 'Whether the toggle button is selected.',
|
|
@@ -48,10 +55,29 @@ export const Default: Story = {
|
|
|
48
55
|
isSelected: false,
|
|
49
56
|
disabled: false,
|
|
50
57
|
leadingIcon: 'dashed-circle',
|
|
58
|
+
size: 'md',
|
|
51
59
|
},
|
|
52
60
|
render: defaultRender,
|
|
53
61
|
}
|
|
54
62
|
|
|
63
|
+
export const Sizes: Story = {
|
|
64
|
+
parameters: { controls: { disable: true } },
|
|
65
|
+
render: () => ({
|
|
66
|
+
components: { CpButtonToggle },
|
|
67
|
+
setup() {
|
|
68
|
+
return { buttonToggleSizes, docCellStyle, docLabelStyle, docRowWrapStyle }
|
|
69
|
+
},
|
|
70
|
+
template: `
|
|
71
|
+
<div :style="docRowWrapStyle">
|
|
72
|
+
<div v-for="size in buttonToggleSizes" :key="size" :style="docCellStyle">
|
|
73
|
+
<span :style="docLabelStyle">{{ size }}</span>
|
|
74
|
+
<CpButtonToggle label="Title" :size="size" />
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
`,
|
|
78
|
+
}),
|
|
79
|
+
}
|
|
80
|
+
|
|
55
81
|
export const States: Story = {
|
|
56
82
|
parameters: { controls: { disable: true } },
|
|
57
83
|
render: () => ({
|