@popsure/dirty-swan 0.41.18 → 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 -27
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/card/index.d.ts +8 -4
- package/dist/cjs/lib/components/card/index.stories.d.ts +13 -5
- package/dist/esm/components/card/index.js +30 -26
- package/dist/esm/components/card/index.js.map +1 -1
- package/dist/esm/components/card/index.stories.js +20 -13
- 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 +8 -4
- package/dist/esm/lib/components/card/index.stories.d.ts +13 -5
- package/package.json +1 -1
- package/src/lib/components/card/index.stories.tsx +36 -13
- package/src/lib/components/card/index.tsx +96 -90
- package/src/lib/components/card/style.module.scss +1 -0
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { 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
|
-
|
|
7
|
+
const CardDefault = 'section' as const
|
|
8
|
+
type CardDefaultAsType = typeof CardDefault;
|
|
9
|
+
|
|
10
|
+
type CardOwnProps<E extends ElementType = CardDefaultAsType> = {
|
|
11
|
+
as?: E;
|
|
8
12
|
children?: ReactNode;
|
|
9
13
|
classNames?: {
|
|
10
14
|
buttonWrapper?: string;
|
|
@@ -29,7 +33,11 @@ export interface CardProps {
|
|
|
29
33
|
showActionIcon?: boolean;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
|
|
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,
|
|
33
41
|
children,
|
|
34
42
|
classNames,
|
|
35
43
|
density = 'balanced',
|
|
@@ -42,113 +50,111 @@ const CardContent = ({
|
|
|
42
50
|
actionIcon,
|
|
43
51
|
title,
|
|
44
52
|
titleVariant = 'large',
|
|
45
|
-
showActionIcon
|
|
46
|
-
|
|
53
|
+
showActionIcon,
|
|
54
|
+
...rest
|
|
55
|
+
}: CardProps<E>) => {
|
|
47
56
|
const hideActionIcon = typeof actionIcon !== 'undefined' && !actionIcon;
|
|
48
|
-
|
|
57
|
+
const propsWithActionIcon = onClick || rest?.href || rest.to;
|
|
58
|
+
const cardDefaultTag = onClick ? 'button' : CardDefault;
|
|
59
|
+
const Tag = as || cardDefaultTag;
|
|
60
|
+
|
|
49
61
|
return (
|
|
50
|
-
<
|
|
62
|
+
<Tag
|
|
51
63
|
className={classNamesUtil(
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
classNames?.buttonWrapper,
|
|
65
|
+
' d-flex w100 br8 ai-stretch',
|
|
54
66
|
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}[density],
|
|
59
|
-
classNames?.wrapper
|
|
67
|
+
'c-pointer': propsWithActionIcon,
|
|
68
|
+
[styles.button]: propsWithActionIcon
|
|
69
|
+
},
|
|
60
70
|
)}
|
|
71
|
+
{...onClick && {
|
|
72
|
+
onClick,
|
|
73
|
+
type: "button"
|
|
74
|
+
}}
|
|
75
|
+
{...rest}
|
|
61
76
|
>
|
|
62
|
-
<div
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{icon}
|
|
73
|
-
</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
|
|
74
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
|
+
)}
|
|
75
102
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
)}
|
|
83
110
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
+
)}
|
|
98
125
|
|
|
99
|
-
|
|
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)) && (
|
|
100
140
|
<div
|
|
101
141
|
className={classNamesUtil(
|
|
102
|
-
|
|
103
|
-
classNames?.
|
|
104
|
-
|
|
142
|
+
styles.actionIcon,
|
|
143
|
+
classNames?.actionIcon,
|
|
144
|
+
styles[`actionIcon${density}`],
|
|
145
|
+
'd-flex ai-center'
|
|
105
146
|
)}
|
|
106
147
|
>
|
|
107
|
-
{
|
|
148
|
+
{actionIcon || <ChevronRightIcon size={24} />}
|
|
108
149
|
</div>
|
|
109
150
|
)}
|
|
110
151
|
</div>
|
|
111
|
-
|
|
112
|
-
{(showActionIcon || (onClick && !hideActionIcon)) && (
|
|
113
|
-
<div
|
|
114
|
-
className={classNamesUtil(
|
|
115
|
-
styles.actionIcon,
|
|
116
|
-
classNames?.actionIcon,
|
|
117
|
-
styles[`actionIcon${density}`],
|
|
118
|
-
'd-flex ai-center'
|
|
119
|
-
)}
|
|
120
|
-
>
|
|
121
|
-
{actionIcon || <ChevronRightIcon size={24} />}
|
|
122
|
-
</div>
|
|
123
|
-
)}
|
|
124
152
|
</div>
|
|
125
|
-
</div>
|
|
126
153
|
|
|
127
|
-
|
|
128
|
-
|
|
154
|
+
{children && <div className={classNames?.children}>{children}</div>}
|
|
155
|
+
</div>
|
|
156
|
+
</Tag>
|
|
129
157
|
);
|
|
130
158
|
};
|
|
131
159
|
|
|
132
|
-
const Card = (props: CardProps) => {
|
|
133
|
-
const { onClick } = props;
|
|
134
|
-
|
|
135
|
-
if (onClick) {
|
|
136
|
-
return (
|
|
137
|
-
<button
|
|
138
|
-
className={classNamesUtil(
|
|
139
|
-
'c-pointer d-flex w100 br8 ai-stretch',
|
|
140
|
-
styles.button,
|
|
141
|
-
props.classNames?.buttonWrapper
|
|
142
|
-
)}
|
|
143
|
-
onClick={onClick}
|
|
144
|
-
type="button"
|
|
145
|
-
>
|
|
146
|
-
<CardContent {...props} />
|
|
147
|
-
</button>
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return <CardContent {...props} />;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
160
|
export { Card };
|