Skip to content

Commit 87d8d5b

Browse files
feat(@clayui/card): add disabled state for high-level components
1 parent d0a2e36 commit 87d8d5b

File tree

7 files changed

+392
-15
lines changed

7 files changed

+392
-15
lines changed

packages/clay-card/src/CardWithHorizontal.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import ClayCard from './Card';
1414

1515
interface IProps {
1616
actions?: React.ComponentProps<typeof ClayDropDownWithItems>['items'];
17+
18+
/**
19+
* Flag to indicate that all interactions on the card will be disabled.
20+
*/
21+
disabled?: boolean;
22+
1723
/**
1824
* Path or URL to item
1925
*/
@@ -47,6 +53,7 @@ interface IProps {
4753

4854
export const ClayCardWithHorizontal: React.FunctionComponent<IProps> = ({
4955
actions,
56+
disabled,
5057
href,
5158
onSelectChange,
5259
selected = false,
@@ -64,7 +71,11 @@ export const ClayCardWithHorizontal: React.FunctionComponent<IProps> = ({
6471
</div>
6572

6673
<div className="autofit-col autofit-col-expand autofit-col-gutters">
67-
<ClayCard.Description displayType="title" href={href}>
74+
<ClayCard.Description
75+
disabled={disabled}
76+
displayType="title"
77+
href={href}
78+
>
6879
{title}
6980
</ClayCard.Description>
7081
</div>
@@ -75,7 +86,10 @@ export const ClayCardWithHorizontal: React.FunctionComponent<IProps> = ({
7586
items={actions}
7687
spritemap={spritemap}
7788
trigger={
78-
<button className="component-action">
89+
<button
90+
className="component-action"
91+
disabled={disabled}
92+
>
7993
<ClayIcon
8094
spritemap={spritemap}
8195
symbol="ellipsis-v"
@@ -94,8 +108,7 @@ export const ClayCardWithHorizontal: React.FunctionComponent<IProps> = ({
94108
{onSelectChange && (
95109
<ClayCheckbox
96110
checked={selected}
97-
disabled={false}
98-
indeterminate={false}
111+
disabled={disabled}
99112
onChange={() => onSelectChange(!selected)}
100113
>
101114
{content}

packages/clay-card/src/CardWithInfo.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ interface IProps {
2525
*/
2626
description?: React.ReactText;
2727

28+
/**
29+
* Flag to indicate that all interactions on the card will be disabled.
30+
*/
31+
disabled?: boolean;
32+
2833
/**
2934
* Flag to indicate if `aspect-ratio-item-flush` class should be
3035
* applied to the image.
@@ -91,6 +96,7 @@ interface IProps {
9196
export const ClayCardWithInfo: React.FunctionComponent<IProps> = ({
9297
actions,
9398
description,
99+
disabled,
94100
flushHorizontal,
95101
flushVertical,
96102
href,
@@ -150,8 +156,7 @@ export const ClayCardWithInfo: React.FunctionComponent<IProps> = ({
150156
{onSelectChange && (
151157
<ClayCheckbox
152158
checked={selected}
153-
disabled={false}
154-
indeterminate={false}
159+
disabled={disabled}
155160
onChange={() => onSelectChange(!selected)}
156161
>
157162
{headerContent}
@@ -163,7 +168,11 @@ export const ClayCardWithInfo: React.FunctionComponent<IProps> = ({
163168
<ClayCard.Body>
164169
<ClayCard.Row>
165170
<div className="autofit-col autofit-col-expand">
166-
<ClayCard.Description displayType="title" href={href}>
171+
<ClayCard.Description
172+
disabled={disabled}
173+
displayType="title"
174+
href={href}
175+
>
167176
{title}
168177
</ClayCard.Description>
169178

@@ -188,7 +197,10 @@ export const ClayCardWithInfo: React.FunctionComponent<IProps> = ({
188197
items={actions}
189198
spritemap={spritemap}
190199
trigger={
191-
<button className="component-action">
200+
<button
201+
className="component-action"
202+
disabled={disabled}
203+
>
192204
<ClayIcon
193205
spritemap={spritemap}
194206
symbol="ellipsis-v"

packages/clay-card/src/CardWithUser.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ interface IProps {
2424
*/
2525
description: string;
2626

27+
/**
28+
* Flag to indicate that all interactions on the card will be disabled.
29+
*/
30+
disabled?: boolean;
31+
2732
/**
2833
* Path or URL to user
2934
*/
@@ -70,6 +75,7 @@ interface IProps {
7075
export const ClayCardWithUser: React.FunctionComponent<IProps> = ({
7176
actions,
7277
description,
78+
disabled,
7379
href,
7480
labels,
7581
name,
@@ -106,8 +112,7 @@ export const ClayCardWithUser: React.FunctionComponent<IProps> = ({
106112
{onSelectChange && (
107113
<ClayCheckbox
108114
checked={selected}
109-
disabled={false}
110-
indeterminate={false}
115+
disabled={disabled}
111116
onChange={() => onSelectChange(!selected)}
112117
>
113118
{content}
@@ -120,7 +125,11 @@ export const ClayCardWithUser: React.FunctionComponent<IProps> = ({
120125
<ClayCard.Body>
121126
<ClayCard.Row>
122127
<div className="autofit-col autofit-col-expand">
123-
<ClayCard.Description displayType="title" href={href}>
128+
<ClayCard.Description
129+
disabled={disabled}
130+
displayType="title"
131+
href={href}
132+
>
124133
{name}
125134
</ClayCard.Description>
126135
<ClayCard.Description displayType="subtitle">
@@ -143,7 +152,10 @@ export const ClayCardWithUser: React.FunctionComponent<IProps> = ({
143152
items={actions}
144153
spritemap={spritemap}
145154
trigger={
146-
<button className="component-action">
155+
<button
156+
className="component-action"
157+
disabled={disabled}
158+
>
147159
<ClayIcon
148160
spritemap={spritemap}
149161
symbol="ellipsis-v"

packages/clay-card/src/Description.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ interface ICardDescriptionProps
1818
*/
1919
displayType: CardDescriptionDisplayType;
2020

21+
/**
22+
* Flag to indicate if href will be disabled.
23+
*/
24+
disabled?: boolean;
25+
2126
/**
2227
* Path or URL
2328
*/
@@ -38,13 +43,14 @@ const CARD_TYPE_ELEMENTS = {
3843
const ClayCardDescription: React.FunctionComponent<ICardDescriptionProps> = ({
3944
children,
4045
className,
46+
disabled,
4147
displayType,
4248
href,
4349
truncate = true,
4450
...otherProps
4551
}: ICardDescriptionProps) => {
4652
const OuterTag = CARD_TYPE_ELEMENTS[displayType];
47-
const InnerTag = href ? 'a' : 'span';
53+
const InnerTag = href && !disabled ? 'a' : 'span';
4854

4955
return (
5056
<OuterTag

0 commit comments

Comments
 (0)