@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.
@@ -4,10 +4,10 @@ import { ChevronRightIcon } from '../icon';
4
4
 
5
5
  import styles from './style.module.scss';
6
6
 
7
- const CardDefault = 'button' as const
7
+ const CardDefault = 'section' as const
8
8
  type CardDefaultAsType = typeof CardDefault;
9
9
 
10
- export interface CardProps<E extends ElementType = CardDefaultAsType> {
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
- const CardContent = <E extends React.ElementType = CardDefaultAsType>({
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
- <section
62
+ <Tag
55
63
  className={classNamesUtil(
56
- 'd-flex fd-column jc-center br8 bg-white w100 ta-left',
57
- { 'bs-sm': dropShadow },
64
+ classNames?.buttonWrapper,
65
+ ' d-flex w100 br8 ai-stretch',
58
66
  {
59
- compact: 'p16',
60
- balanced: 'p24',
61
- spacious: 'p32',
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 className="d-flex w100">
67
- {icon && (
68
- <div
69
- className={classNamesUtil(
70
- `d-flex ai-center tc-primary-500`,
71
- styles.icon,
72
- styles[`icon${density}`],
73
- classNames?.icon
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
- <div className="d-flex jc-between w100">
81
- <div className="d-flex jc-center gap8 fd-column tc-grey-900 w100">
82
- {label && (
83
- <h3 className={classNamesUtil('p-p--small', classNames?.label)}>
84
- {label}
85
- </h3>
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
- {title && (
89
- <h2
90
- className={classNamesUtil(
91
- classNames?.title,
92
- {
93
- large: 'p-h3',
94
- medium: 'p-h4',
95
- small: 'p-p',
96
- }[titleVariant]
97
- )}
98
- >
99
- {title}
100
- </h2>
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
- {description && (
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
- 'tc-grey-600',
107
- classNames?.description,
108
- descriptionVariant === 'small' ? 'p-p--small' : 'p-p'
142
+ styles.actionIcon,
143
+ classNames?.actionIcon,
144
+ styles[`actionIcon${density}`],
145
+ 'd-flex ai-center'
109
146
  )}
110
147
  >
111
- {description}
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
- {children && <div className={classNames?.children}>{children}</div>}
132
- </section>
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 };
@@ -5,6 +5,7 @@
5
5
  color: $ds-grey-900;
6
6
  outline: 1px solid transparent;
7
7
  transition: all 0.2s ease-in-out;
8
+ text-decoration: none;
8
9
 
9
10
  &:hover {
10
11
  outline: 1px solid $ds-primary-500;
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';