@indico-data/design-system 2.14.0 → 2.15.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/lib/index.css +47 -0
- package/lib/index.d.ts +64 -55
- package/lib/index.esm.css +47 -0
- package/lib/index.esm.js +7 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -1
- package/lib/src/components/card/Card.d.ts +10 -0
- package/lib/src/components/card/Card.stories.d.ts +6 -0
- package/lib/src/components/card/__tests__/Card.test.d.ts +1 -0
- package/lib/src/components/card/index.d.ts +1 -0
- package/lib/src/components/index.d.ts +1 -0
- package/lib/src/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/card/Card.mdx +14 -0
- package/src/components/card/Card.stories.tsx +97 -0
- package/src/components/card/Card.tsx +33 -0
- package/src/components/card/__tests__/Card.test.tsx +26 -0
- package/src/components/card/index.ts +1 -0
- package/src/components/card/styles/Card.scss +44 -0
- package/src/components/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/styles/index.scss +1 -0
- package/src/styles/variables/_dropshadows.scss +5 -0
- package/src/styles/variables/index.scss +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Card } from './Card';
|
package/lib/src/index.d.ts
CHANGED
|
@@ -16,3 +16,4 @@ export { PasswordInput } from './components/forms/passwordInput';
|
|
|
16
16
|
export { Select as SelectInput } from './components/forms/select';
|
|
17
17
|
export { Form } from './components/forms/form';
|
|
18
18
|
export { Skeleton } from './components/skeleton';
|
|
19
|
+
export { Card } from './components/card';
|
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Canvas, Meta, Controls, Story } from '@storybook/blocks';
|
|
2
|
+
import * as Card from './Card.stories';
|
|
3
|
+
|
|
4
|
+
<Meta title="Layout/Card" name="Card" of={Card} />
|
|
5
|
+
|
|
6
|
+
# Card
|
|
7
|
+
|
|
8
|
+
The Card component is a container that can be used to display content in a structured way. It can be used to display images, text, or even other components. The Card component mainly serves as a wrapper for your content.
|
|
9
|
+
|
|
10
|
+
<Canvas of={Card.Default} />
|
|
11
|
+
|
|
12
|
+
### The following props are available for the Card component:
|
|
13
|
+
|
|
14
|
+
<Controls of={Card.Default} />
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Card } from './Card';
|
|
3
|
+
import { Button } from '../button';
|
|
4
|
+
import { Col, Container, Row } from '../grid';
|
|
5
|
+
|
|
6
|
+
const meta: Meta = {
|
|
7
|
+
title: 'Layout/Card',
|
|
8
|
+
component: Card,
|
|
9
|
+
argTypes: {
|
|
10
|
+
title: {
|
|
11
|
+
control: 'text',
|
|
12
|
+
description: 'The title of the card',
|
|
13
|
+
table: {
|
|
14
|
+
category: 'Props',
|
|
15
|
+
type: {
|
|
16
|
+
summary: 'string',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultValue: { summary: '' },
|
|
20
|
+
},
|
|
21
|
+
subtitle: {
|
|
22
|
+
control: 'text',
|
|
23
|
+
description: 'The subtitle of the card',
|
|
24
|
+
table: {
|
|
25
|
+
category: 'Props',
|
|
26
|
+
type: {
|
|
27
|
+
summary: 'string',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
defaultValue: { summary: '' },
|
|
31
|
+
},
|
|
32
|
+
hasBoxShadow: {
|
|
33
|
+
control: 'boolean',
|
|
34
|
+
description: 'Adds a box shadow to the card',
|
|
35
|
+
table: {
|
|
36
|
+
category: 'Props',
|
|
37
|
+
type: {
|
|
38
|
+
summary: 'boolean',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
defaultValue: { summary: false },
|
|
42
|
+
},
|
|
43
|
+
className: {
|
|
44
|
+
control: 'text',
|
|
45
|
+
description: 'Additional classes for the card component',
|
|
46
|
+
table: {
|
|
47
|
+
category: 'Props',
|
|
48
|
+
type: {
|
|
49
|
+
summary: 'string',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
children: {
|
|
54
|
+
control: false,
|
|
55
|
+
description: 'The content of the card',
|
|
56
|
+
table: {
|
|
57
|
+
category: 'Props',
|
|
58
|
+
type: {
|
|
59
|
+
summary: 'React.ReactNode',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default meta;
|
|
67
|
+
|
|
68
|
+
type Story = StoryObj<typeof Card>;
|
|
69
|
+
|
|
70
|
+
export const Default: Story = {
|
|
71
|
+
args: {
|
|
72
|
+
title: 'Adventurer Class: Bard',
|
|
73
|
+
subtitle: 'Champion of the lute and song',
|
|
74
|
+
hasBoxShadow: true,
|
|
75
|
+
className: '',
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
render: (args) => {
|
|
79
|
+
return (
|
|
80
|
+
<Container>
|
|
81
|
+
<Row>
|
|
82
|
+
<Col sm={4}>
|
|
83
|
+
<Card {...args}>
|
|
84
|
+
<hr />A versatile and charismatic character class known for their magical abilities,
|
|
85
|
+
musical talents, and wide array of skills. Bards are often seen as
|
|
86
|
+
jacks-of-all-trades, able to adapt to various situations and roles within a party.
|
|
87
|
+
<hr />
|
|
88
|
+
<Button color="secondary" ariaLabel="Learn More" onClick={() => alert('Learn More')}>
|
|
89
|
+
Learn More
|
|
90
|
+
</Button>
|
|
91
|
+
</Card>
|
|
92
|
+
</Col>
|
|
93
|
+
</Row>
|
|
94
|
+
</Container>
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames'; // Assuming you have this utility
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
title?: string;
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
hasBoxShadow?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const Card: React.FC<Props> = ({
|
|
13
|
+
className = '',
|
|
14
|
+
children,
|
|
15
|
+
title,
|
|
16
|
+
subtitle,
|
|
17
|
+
hasBoxShadow = false,
|
|
18
|
+
...rest
|
|
19
|
+
}) => {
|
|
20
|
+
const cardClasses = classNames('card', { 'card--box-shadow': hasBoxShadow }, className);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className={cardClasses} {...rest}>
|
|
24
|
+
{(title || subtitle) && (
|
|
25
|
+
<div className="card__header">
|
|
26
|
+
{title && <h2>{title}</h2>}
|
|
27
|
+
{subtitle && <p>{subtitle}</p>}
|
|
28
|
+
</div>
|
|
29
|
+
)}
|
|
30
|
+
<div className="card__content">{children}</div>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { Card } from '@/components/card/Card';
|
|
3
|
+
|
|
4
|
+
describe('Card', () => {
|
|
5
|
+
it('Renders the title for the card if one exists', () => {
|
|
6
|
+
render(
|
|
7
|
+
<Card title="Title" data-testid="Card">
|
|
8
|
+
Text
|
|
9
|
+
</Card>,
|
|
10
|
+
);
|
|
11
|
+
expect(screen.getByTestId('Card')).toHaveTextContent('Title');
|
|
12
|
+
});
|
|
13
|
+
it('Renders the subtitle for the card if one exists', () => {
|
|
14
|
+
render(
|
|
15
|
+
<Card subtitle="Subtitle" data-testid="Card">
|
|
16
|
+
Text
|
|
17
|
+
</Card>,
|
|
18
|
+
);
|
|
19
|
+
expect(screen.getByTestId('Card')).toHaveTextContent('Subtitle');
|
|
20
|
+
});
|
|
21
|
+
it('does not render a title or a subtitle if neither are provided', () => {
|
|
22
|
+
render(<Card data-testid="Card">Text</Card>);
|
|
23
|
+
expect(screen.getByTestId('Card')).not.toHaveTextContent('Title');
|
|
24
|
+
expect(screen.getByTestId('Card')).not.toHaveTextContent('Subtitle');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Card } from './Card';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Common Variables
|
|
2
|
+
:root,
|
|
3
|
+
:root [data-theme='light'],
|
|
4
|
+
:root [data-theme='dark'] {
|
|
5
|
+
--pf-card-background-color: var(--pf-white-color);
|
|
6
|
+
--pf-card-text-color: var(--pf-gray-color);
|
|
7
|
+
--pf-card-border-color: var(--pf-gray-color);
|
|
8
|
+
--pf-card-rounded: var(--pf-rounded);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Dark Theme Specific Variables
|
|
12
|
+
:root [data-theme='dark'] {
|
|
13
|
+
--pf-card-background-color: var(--pf-primary-color);
|
|
14
|
+
--pf-card-border-color: var(--pf-primary-color-200);
|
|
15
|
+
--pf-card-text-color: var(--pf-gray-color-100);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.card {
|
|
19
|
+
border-radius: var(--pf-rounded);
|
|
20
|
+
padding: var(--pf-padding-3);
|
|
21
|
+
background: var(--pf-card-background-color);
|
|
22
|
+
border: var(--pf-border-sm) solid var(--pf-card-border-color);
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.card__header {
|
|
27
|
+
margin-bottom: var(--pf-margin-2);
|
|
28
|
+
p {
|
|
29
|
+
font-size: var(--pf-font-size-subtitle2);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.card__content {
|
|
34
|
+
hr {
|
|
35
|
+
border: var(--pf-border-thin) solid var(--pf-card-border-color);
|
|
36
|
+
border-bottom: none;
|
|
37
|
+
margin-bottom: var(--pf-margin-3);
|
|
38
|
+
margin-top: var(--pf-margin-3);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.card--box-shadow {
|
|
43
|
+
box-shadow: var(--pf-dropshadow);
|
|
44
|
+
}
|
package/src/components/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -70,3 +70,4 @@ export { PasswordInput } from './components/forms/passwordInput';
|
|
|
70
70
|
export { Select as SelectInput } from './components/forms/select';
|
|
71
71
|
export { Form } from './components/forms/form';
|
|
72
72
|
export { Skeleton } from './components/skeleton';
|
|
73
|
+
export { Card } from './components/card';
|
package/src/styles/index.scss
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
@import '../components/forms/select/styles/Select.scss';
|
|
16
16
|
@import '../components/forms/toggle/styles/Toggle.scss';
|
|
17
17
|
@import '../components/skeleton/styles/Skeleton.scss';
|
|
18
|
+
@import '../components/card/styles/Card.scss';
|
|
18
19
|
|
|
19
20
|
@import 'typography';
|
|
20
21
|
@import 'colors';
|