@indico-data/design-system 2.14.0 → 2.15.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.
Files changed (31) hide show
  1. package/lib/index.css +47 -0
  2. package/lib/index.d.ts +64 -66
  3. package/lib/index.esm.css +47 -0
  4. package/lib/index.esm.js +9 -10
  5. package/lib/index.esm.js.map +1 -1
  6. package/lib/index.js +9 -9
  7. package/lib/index.js.map +1 -1
  8. package/lib/src/components/card/Card.d.ts +10 -0
  9. package/lib/src/components/card/Card.stories.d.ts +6 -0
  10. package/lib/src/components/card/__tests__/Card.test.d.ts +1 -0
  11. package/lib/src/components/card/index.d.ts +1 -0
  12. package/lib/src/components/index.d.ts +1 -0
  13. package/lib/src/index.d.ts +1 -0
  14. package/lib/src/legacy/components/basic-section/SectionHeader/SectionHeader.d.ts +1 -7
  15. package/lib/src/legacy/components/basic-section/SectionHeader/SectionHeader.stories.d.ts +4 -10
  16. package/lib/src/legacy/components/inputs/SearchInput/SearchInput.d.ts +1 -6
  17. package/lib/src/legacy/components/inputs/SearchInput/SearchInput.stories.d.ts +12 -17
  18. package/package.json +1 -1
  19. package/src/components/card/Card.mdx +14 -0
  20. package/src/components/card/Card.stories.tsx +97 -0
  21. package/src/components/card/Card.tsx +33 -0
  22. package/src/components/card/__tests__/Card.test.tsx +26 -0
  23. package/src/components/card/index.ts +1 -0
  24. package/src/components/card/styles/Card.scss +44 -0
  25. package/src/components/index.ts +1 -0
  26. package/src/index.ts +1 -0
  27. package/src/legacy/components/basic-section/SectionHeader/SectionHeader.tsx +1 -6
  28. package/src/legacy/components/inputs/SearchInput/SearchInput.tsx +1 -5
  29. package/src/styles/index.scss +1 -0
  30. package/src/styles/variables/_dropshadows.scss +5 -0
  31. package/src/styles/variables/index.scss +1 -0
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ type Props = {
3
+ className?: string;
4
+ children: React.ReactNode;
5
+ title?: string;
6
+ subtitle?: string;
7
+ hasBoxShadow?: boolean;
8
+ };
9
+ export declare const Card: React.FC<Props>;
10
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { Card } from './Card';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Card>;
6
+ export declare const Default: Story;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { Card } from './Card';
@@ -11,3 +11,4 @@ export { PasswordInput } from './forms/passwordInput';
11
11
  export { Select } from './forms/select';
12
12
  export { Form } from './forms/form';
13
13
  export { Skeleton } from './skeleton';
14
+ export { Card } from './card';
@@ -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';
@@ -4,11 +4,5 @@ type Props = PermafrostComponent & {
4
4
  style?: object;
5
5
  children?: React.ReactNode;
6
6
  };
7
- export declare const SectionHeader: {
8
- (props: Props): import("react/jsx-runtime").JSX.Element;
9
- defaultProps: {
10
- className: string;
11
- style: {};
12
- };
13
- };
7
+ export declare const SectionHeader: (props: Props) => import("react/jsx-runtime").JSX.Element;
14
8
  export {};
@@ -2,16 +2,10 @@ import React from 'react';
2
2
  import type { StoryObj } from '@storybook/react';
3
3
  import { SectionHeader } from './SectionHeader';
4
4
  declare const meta: {
5
- component: {
6
- (props: import("../../../../types").PermafrostComponent & {
7
- style?: object;
8
- children?: React.ReactNode;
9
- }): import("react/jsx-runtime").JSX.Element;
10
- defaultProps: {
11
- className: string;
12
- style: {};
13
- };
14
- };
5
+ component: (props: import("../../../../types").PermafrostComponent & {
6
+ style?: object;
7
+ children?: React.ReactNode;
8
+ }) => import("react/jsx-runtime").JSX.Element;
15
9
  title: string;
16
10
  argTypes: {};
17
11
  };
@@ -13,10 +13,5 @@ type Props = PermafrostComponent & {
13
13
  placeholder?: string;
14
14
  value?: string;
15
15
  };
16
- export declare const SearchInput: {
17
- (props: Props): import("react/jsx-runtime").JSX.Element;
18
- defaultProps: {
19
- className: string;
20
- };
21
- };
16
+ export declare const SearchInput: (props: Props) => import("react/jsx-runtime").JSX.Element;
22
17
  export default SearchInput;
@@ -1,24 +1,19 @@
1
1
  import { StoryObj } from '@storybook/react';
2
2
  import { SearchInput } from './SearchInput';
3
3
  declare const meta: {
4
- component: {
5
- (props: import("../../../../types").PermafrostComponent & {
6
- inputBorder?: boolean;
7
- showClearInputIcon?: boolean;
8
- showSearchIcon?: boolean;
9
- inputProps?: {
10
- [key: string]: string;
11
- };
12
- onChange?: (e: import("react").ChangeEvent<HTMLInputElement>) => void;
13
- onClear?(): void;
14
- onKeyUp?: (e: import("react").KeyboardEvent<HTMLInputElement>) => void;
15
- placeholder?: string;
16
- value?: string;
17
- }): import("react/jsx-runtime").JSX.Element;
18
- defaultProps: {
19
- className: string;
4
+ component: (props: import("../../../../types").PermafrostComponent & {
5
+ inputBorder?: boolean;
6
+ showClearInputIcon?: boolean;
7
+ showSearchIcon?: boolean;
8
+ inputProps?: {
9
+ [key: string]: string;
20
10
  };
21
- };
11
+ onChange?: (e: import("react").ChangeEvent<HTMLInputElement>) => void;
12
+ onClear?(): void;
13
+ onKeyUp?: (e: import("react").KeyboardEvent<HTMLInputElement>) => void;
14
+ placeholder?: string;
15
+ value?: string;
16
+ }) => import("react/jsx-runtime").JSX.Element;
22
17
  title: string;
23
18
  argTypes: {};
24
19
  args: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indico-data/design-system",
3
- "version": "2.14.0",
3
+ "version": "2.15.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "lib/index.js",
@@ -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
+ }
@@ -11,3 +11,4 @@ export { PasswordInput } from './forms/passwordInput';
11
11
  export { Select } from './forms/select';
12
12
  export { Form } from './forms/form';
13
13
  export { Skeleton } from './skeleton';
14
+ export { Card } from './card';
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';
@@ -14,7 +14,7 @@ type Props = PermafrostComponent & {
14
14
  };
15
15
 
16
16
  export const SectionHeader = (props: Props) => {
17
- const { className, style, children, id, ...restOfProps } = props;
17
+ const { className = '', style = {}, children, id, ...restOfProps } = props;
18
18
 
19
19
  return (
20
20
  <StyledSectionHeader
@@ -28,8 +28,3 @@ export const SectionHeader = (props: Props) => {
28
28
  </StyledSectionHeader>
29
29
  );
30
30
  };
31
-
32
- SectionHeader.defaultProps = {
33
- className: '',
34
- style: {},
35
- };
@@ -27,7 +27,7 @@ export const SearchInput = (props: Props) => {
27
27
  inputBorder,
28
28
  showSearchIcon,
29
29
  showClearInputIcon,
30
- className,
30
+ className = '',
31
31
  inputProps,
32
32
  onChange,
33
33
  onClear,
@@ -70,8 +70,4 @@ export const SearchInput = (props: Props) => {
70
70
  );
71
71
  };
72
72
 
73
- SearchInput.defaultProps = {
74
- className: '',
75
- };
76
-
77
73
  export default SearchInput;
@@ -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';
@@ -0,0 +1,5 @@
1
+ :root,
2
+ :root [data-theme='light'],
3
+ :root [data-theme='dark'] {
4
+ --pf-dropshadow: 5px 0 10px rgba(0, 0, 0, 0.3);
5
+ }
@@ -4,3 +4,4 @@
4
4
  @import 'borders';
5
5
  @import 'padding';
6
6
  @import 'margin';
7
+ @import 'dropshadows';