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