@citizenplane/pimp 16.0.2 → 16.0.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": "16.0.2",
3
+ "version": "16.0.3",
4
4
  "scripts": {
5
5
  "dev": "storybook dev -p 8081",
6
6
  "build-storybook": "storybook build --output-dir ./docs",
@@ -98,37 +98,39 @@ const emit = defineEmits<{
98
98
 
99
99
  const slots = useSlots()
100
100
 
101
- const colorProps = {
102
- neutral: {
103
- icon: 'dashed-circle',
104
- primaryActionAppearance: 'secondary',
105
- secondaryActionAppearance: 'tertiary',
106
- },
107
- accent: {
108
- icon: 'info',
109
- primaryActionAppearance: 'primary',
101
+ const colorProps = computed(() => {
102
+ const defaultProps = {
103
+ primaryActionAppearance: isExpanded.value ? 'primary' : 'secondary',
110
104
  secondaryActionAppearance: 'secondary',
111
- },
112
- success: {
113
- icon: 'check',
114
- primaryActionAppearance: 'primary',
115
- secondaryActionAppearance: 'secondary',
116
- },
117
- warning: {
118
- icon: 'alert-triangle',
119
- primaryActionAppearance: 'primary',
120
- secondaryActionAppearance: 'secondary',
121
- },
122
- error: {
123
- icon: 'x-octagon',
124
- primaryActionAppearance: 'primary',
125
- secondaryActionAppearance: 'secondary',
126
- },
127
- }
105
+ }
106
+ return {
107
+ neutral: {
108
+ icon: 'dashed-circle',
109
+ primaryActionAppearance: isExpanded.value ? 'secondary' : 'tertiary',
110
+ secondaryActionAppearance: 'tertiary',
111
+ },
112
+ accent: {
113
+ ...defaultProps,
114
+ icon: 'info',
115
+ },
116
+ success: {
117
+ ...defaultProps,
118
+ icon: 'check',
119
+ },
120
+ warning: {
121
+ ...defaultProps,
122
+ icon: 'alert-triangle',
123
+ },
124
+ error: {
125
+ ...defaultProps,
126
+ icon: 'x-octagon',
127
+ },
128
+ }
129
+ })
128
130
 
129
131
  const alertIcon = computed(() => {
130
132
  if (props.icon) return props.icon
131
- return colorProps[props.color].icon
133
+ return colorProps.value[props.color].icon
132
134
  })
133
135
 
134
136
  const isExpanded = computed(() => props.type === 'expanded')
@@ -136,9 +138,11 @@ const hasTitle = computed(() => !!props.title || !!slots.title)
136
138
  const hasContent = computed(() => isExpanded.value && (!!props.content || !!slots.default))
137
139
  const hasActions = computed(() => hasPrimaryAction.value || hasSecondaryAction.value)
138
140
  const hasPrimaryAction = computed(() => !!props.primaryActionLabel || !!slots['primary-action'])
139
- const hasSecondaryAction = computed(() => !!props.secondaryActionLabel || !!slots['secondary-action'])
140
- const primaryActionAppearance = computed(() => colorProps[props.color].primaryActionAppearance)
141
- const secondaryActionAppearance = computed(() => colorProps[props.color].secondaryActionAppearance)
141
+ const hasSecondaryAction = computed(
142
+ () => isExpanded.value && (!!props.secondaryActionLabel || !!slots['secondary-action']),
143
+ )
144
+ const primaryActionAppearance = computed(() => colorProps.value[props.color].primaryActionAppearance)
145
+ const secondaryActionAppearance = computed(() => colorProps.value[props.color].secondaryActionAppearance)
142
146
  const actionsSize = computed(() => (isExpanded.value ? 'sm' : 'xs'))
143
147
 
144
148
  const dynamicClasses = computed(() => [
@@ -197,6 +201,10 @@ const dynamicClasses = computed(() => [
197
201
  gap: var(--cp-spacing-md);
198
202
  }
199
203
 
204
+ &__close {
205
+ align-self: flex-start;
206
+ }
207
+
200
208
  &__title {
201
209
  font-size: var(--cp-text-size-sm);
202
210
  line-height: var(--cp-line-height-sm);
@@ -217,11 +217,11 @@ export const Documentation: Story = {
217
217
 
218
218
  export const Default: Story = {
219
219
  args: {
220
- color: 'accent',
220
+ color: 'neutral',
221
221
  type: 'expanded',
222
222
  title: 'Alert title',
223
223
  content: 'This is an informational alert message.',
224
- isClosable: true,
224
+ isClosable: false,
225
225
  icon: undefined,
226
226
  primaryActionLabel: undefined,
227
227
  secondaryActionLabel: undefined,