@popsure/dirty-swan 0.41.19-alpha → 0.42.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/dist/cjs/index.js +31 -28
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/card/index.d.ts +5 -4
- package/dist/cjs/lib/components/card/index.stories.d.ts +4 -3
- package/dist/cjs/lib/index.d.ts +2 -2
- package/dist/esm/components/card/index.js +30 -27
- package/dist/esm/components/card/index.js.map +1 -1
- package/dist/esm/components/card/index.stories.js +10 -4
- package/dist/esm/components/card/index.stories.js.map +1 -1
- package/dist/esm/components/icon/icons/Info.js +2 -2
- package/dist/esm/components/icon/icons/Info.js.map +1 -1
- package/dist/esm/components/icon/icons.stories.js +1 -1
- package/dist/esm/components/icon/index.stories.js +1 -1
- package/dist/esm/{index-e506c4ca.js → index-03b0133a.js} +3 -3
- package/dist/esm/{index-e506c4ca.js.map → index-03b0133a.js.map} +1 -1
- package/dist/esm/lib/components/card/index.d.ts +5 -4
- package/dist/esm/lib/components/card/index.stories.d.ts +4 -3
- package/dist/esm/lib/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/lib/components/card/index.stories.tsx +29 -8
- package/src/lib/components/card/index.tsx +91 -90
- package/src/lib/components/card/style.module.scss +1 -0
- package/src/lib/index.tsx +1 -2
|
@@ -4,10 +4,10 @@ import { ChevronRightIcon } from '../icon';
|
|
|
4
4
|
|
|
5
5
|
import styles from './style.module.scss';
|
|
6
6
|
|
|
7
|
-
const CardDefault = '
|
|
7
|
+
const CardDefault = 'section' as const
|
|
8
8
|
type CardDefaultAsType = typeof CardDefault;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
type CardOwnProps<E extends ElementType = CardDefaultAsType> = {
|
|
11
11
|
as?: E;
|
|
12
12
|
children?: ReactNode;
|
|
13
13
|
classNames?: {
|
|
@@ -33,7 +33,11 @@ export interface CardProps<E extends ElementType = CardDefaultAsType> {
|
|
|
33
33
|
showActionIcon?: boolean;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
export type CardProps<E extends ElementType = CardDefaultAsType> = CardOwnProps<E> &
|
|
37
|
+
Omit<React.ComponentProps<E>, keyof CardOwnProps<E>>
|
|
38
|
+
|
|
39
|
+
const Card = <E extends ElementType = CardDefaultAsType>({
|
|
40
|
+
as,
|
|
37
41
|
children,
|
|
38
42
|
classNames,
|
|
39
43
|
density = 'balanced',
|
|
@@ -46,114 +50,111 @@ const CardContent = <E extends React.ElementType = CardDefaultAsType>({
|
|
|
46
50
|
actionIcon,
|
|
47
51
|
title,
|
|
48
52
|
titleVariant = 'large',
|
|
49
|
-
showActionIcon
|
|
53
|
+
showActionIcon,
|
|
54
|
+
...rest
|
|
50
55
|
}: CardProps<E>) => {
|
|
51
56
|
const hideActionIcon = typeof actionIcon !== 'undefined' && !actionIcon;
|
|
52
|
-
|
|
57
|
+
const propsWithActionIcon = onClick || rest?.href || rest.to;
|
|
58
|
+
const cardDefaultTag = onClick ? 'button' : CardDefault;
|
|
59
|
+
const Tag = as || cardDefaultTag;
|
|
60
|
+
|
|
53
61
|
return (
|
|
54
|
-
<
|
|
62
|
+
<Tag
|
|
55
63
|
className={classNamesUtil(
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
classNames?.buttonWrapper,
|
|
65
|
+
' d-flex w100 br8 ai-stretch',
|
|
58
66
|
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}[density],
|
|
63
|
-
classNames?.wrapper
|
|
67
|
+
'c-pointer': propsWithActionIcon,
|
|
68
|
+
[styles.button]: propsWithActionIcon
|
|
69
|
+
},
|
|
64
70
|
)}
|
|
71
|
+
{...onClick && {
|
|
72
|
+
onClick,
|
|
73
|
+
type: "button"
|
|
74
|
+
}}
|
|
75
|
+
{...rest}
|
|
65
76
|
>
|
|
66
|
-
<div
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{icon}
|
|
77
|
-
</div>
|
|
77
|
+
<div
|
|
78
|
+
className={classNamesUtil(
|
|
79
|
+
'd-flex fd-column jc-center br8 bg-white w100 ta-left',
|
|
80
|
+
{ 'bs-sm': dropShadow },
|
|
81
|
+
{
|
|
82
|
+
compact: 'p16',
|
|
83
|
+
balanced: 'p24',
|
|
84
|
+
spacious: 'p32',
|
|
85
|
+
}[density],
|
|
86
|
+
classNames?.wrapper
|
|
78
87
|
)}
|
|
88
|
+
>
|
|
89
|
+
<div className="d-flex w100">
|
|
90
|
+
{icon && (
|
|
91
|
+
<div
|
|
92
|
+
className={classNamesUtil(
|
|
93
|
+
`d-flex ai-center tc-primary-500`,
|
|
94
|
+
styles.icon,
|
|
95
|
+
styles[`icon${density}`],
|
|
96
|
+
classNames?.icon
|
|
97
|
+
)}
|
|
98
|
+
>
|
|
99
|
+
{icon}
|
|
100
|
+
</div>
|
|
101
|
+
)}
|
|
79
102
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
103
|
+
<div className="d-flex jc-between w100">
|
|
104
|
+
<div className="d-flex jc-center gap8 fd-column tc-grey-900 w100">
|
|
105
|
+
{label && (
|
|
106
|
+
<h3 className={classNamesUtil('p-p--small', classNames?.label)}>
|
|
107
|
+
{label}
|
|
108
|
+
</h3>
|
|
109
|
+
)}
|
|
87
110
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
111
|
+
{title && (
|
|
112
|
+
<h2
|
|
113
|
+
className={classNamesUtil(
|
|
114
|
+
classNames?.title,
|
|
115
|
+
{
|
|
116
|
+
large: 'p-h3',
|
|
117
|
+
medium: 'p-h4',
|
|
118
|
+
small: 'p-p',
|
|
119
|
+
}[titleVariant]
|
|
120
|
+
)}
|
|
121
|
+
>
|
|
122
|
+
{title}
|
|
123
|
+
</h2>
|
|
124
|
+
)}
|
|
102
125
|
|
|
103
|
-
|
|
126
|
+
{description && (
|
|
127
|
+
<div
|
|
128
|
+
className={classNamesUtil(
|
|
129
|
+
'tc-grey-600',
|
|
130
|
+
classNames?.description,
|
|
131
|
+
descriptionVariant === 'small' ? 'p-p--small' : 'p-p'
|
|
132
|
+
)}
|
|
133
|
+
>
|
|
134
|
+
{description}
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
{(showActionIcon || (propsWithActionIcon && !hideActionIcon)) && (
|
|
104
140
|
<div
|
|
105
141
|
className={classNamesUtil(
|
|
106
|
-
|
|
107
|
-
classNames?.
|
|
108
|
-
|
|
142
|
+
styles.actionIcon,
|
|
143
|
+
classNames?.actionIcon,
|
|
144
|
+
styles[`actionIcon${density}`],
|
|
145
|
+
'd-flex ai-center'
|
|
109
146
|
)}
|
|
110
147
|
>
|
|
111
|
-
{
|
|
148
|
+
{actionIcon || <ChevronRightIcon size={24} />}
|
|
112
149
|
</div>
|
|
113
150
|
)}
|
|
114
151
|
</div>
|
|
115
|
-
|
|
116
|
-
{(showActionIcon || (onClick && !hideActionIcon)) && (
|
|
117
|
-
<div
|
|
118
|
-
className={classNamesUtil(
|
|
119
|
-
styles.actionIcon,
|
|
120
|
-
classNames?.actionIcon,
|
|
121
|
-
styles[`actionIcon${density}`],
|
|
122
|
-
'd-flex ai-center'
|
|
123
|
-
)}
|
|
124
|
-
>
|
|
125
|
-
{actionIcon || <ChevronRightIcon size={24} />}
|
|
126
|
-
</div>
|
|
127
|
-
)}
|
|
128
152
|
</div>
|
|
129
|
-
</div>
|
|
130
153
|
|
|
131
|
-
|
|
132
|
-
|
|
154
|
+
{children && <div className={classNames?.children}>{children}</div>}
|
|
155
|
+
</div>
|
|
156
|
+
</Tag>
|
|
133
157
|
);
|
|
134
158
|
};
|
|
135
159
|
|
|
136
|
-
const Card = <E extends React.ElementType = CardDefaultAsType>(props: CardProps<E>) => {
|
|
137
|
-
const { as, onClick } = props;
|
|
138
|
-
const Tag = as || 'button';
|
|
139
|
-
|
|
140
|
-
if (onClick || as) {
|
|
141
|
-
return (
|
|
142
|
-
<Tag
|
|
143
|
-
className={classNamesUtil(
|
|
144
|
-
'c-pointer d-flex w100 br8 ai-stretch',
|
|
145
|
-
styles.button,
|
|
146
|
-
props.classNames?.buttonWrapper
|
|
147
|
-
)}
|
|
148
|
-
onClick={onClick}
|
|
149
|
-
{...onClick && { type: "button" }}
|
|
150
|
-
>
|
|
151
|
-
<CardContent {...props} />
|
|
152
|
-
</Tag>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return <CardContent {...props} />;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
160
|
export { Card };
|
package/src/lib/index.tsx
CHANGED
|
@@ -27,9 +27,8 @@ import {
|
|
|
27
27
|
CardWithTopIcon,
|
|
28
28
|
InfoCard,
|
|
29
29
|
CardButton,
|
|
30
|
-
CardProps,
|
|
31
30
|
} from './components/cards';
|
|
32
|
-
import { Card } from './components/card';
|
|
31
|
+
import { Card, CardProps } from './components/card';
|
|
33
32
|
import { Button } from './components/button';
|
|
34
33
|
import { AutoSuggestMultiSelect } from './components/input/autoSuggestMultiSelect';
|
|
35
34
|
import Chip from './components/chip';
|