@scality/core-ui 0.123.0 → 0.124.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.
@@ -1,14 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { IconName } from '../icon/Icon.component';
3
3
  import { CoreUITheme } from '../../style/theme';
4
- type Props = {
4
+ export type Props = {
5
5
  listedResource: {
6
6
  singular: string;
7
7
  plural: string;
8
8
  };
9
9
  icon: IconName;
10
10
  link?: string;
11
- history?: Record<string, any>;
12
11
  backgroundColor?: keyof CoreUITheme;
13
12
  /**
14
13
  * The resource to create before browsing the listed resource
@@ -1 +1 @@
1
- {"version":3,"file":"Emptystate.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/emptystate/Emptystate.component.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAQ,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,KAAK,KAAK,GAAG;IACX,cAAc,EAAE;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,WAAW,CAAC;IACpC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAgBF,eAAO,MAAM,aAAa,yGAIzB,CAAC;AACF,eAAO,MAAM,aAAa,yGAGzB,CAAC;AAEF,iBAAS,UAAU,CAAC,KAAK,EAAE,KAAK,eAwC/B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"Emptystate.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/emptystate/Emptystate.component.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAQ,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,MAAM,KAAK,GAAG;IAClB,cAAc,EAAE;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,WAAW,CAAC;IACpC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAgBF,eAAO,MAAM,aAAa,yGAIzB,CAAC;AACF,eAAO,MAAM,aAAa,yGAGzB,CAAC;AAEF,iBAAS,UAAU,CAAC,KAAK,EAAE,KAAK,eAmC/B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -4,6 +4,7 @@ import { spacing } from '../../spacing';
4
4
  import { Button } from '../buttonv2/Buttonv2.component';
5
5
  import { Icon } from '../icon/Icon.component';
6
6
  import { LargeText } from '../text/Text.component';
7
+ import { useHistory } from 'react-router';
7
8
  const EmptystateContainer = styled.div `
8
9
  ${(props) => {
9
10
  const { theme, backgroundColor } = props;
@@ -29,9 +30,10 @@ export const ActionWrapper = styled.div `
29
30
  justify-content: space-around;
30
31
  `;
31
32
  function EmptyState(props) {
32
- const { icon, listedResource, link, history, resourceToCreate, backgroundColor, } = props;
33
+ const { icon, listedResource, link, resourceToCreate, backgroundColor } = props;
34
+ const history = useHistory();
33
35
  return (_jsxs(EmptystateContainer, { className: "sc-emptystate", backgroundColor: backgroundColor, children: [_jsx(EmptyStateRow, { children: _jsx(Icon, { name: icon, color: "infoPrimary", size: "5x", withWrapper: true }) }), _jsx(EmptyStateRow, { children: _jsx(LargeText, { children: `A list of ${listedResource.plural} will appear here.` }) }), _jsx(EmptyStateRow, { children: _jsx(LargeText, { children: !resourceToCreate
34
36
  ? `There are no ${listedResource.plural} created yet, let's create your first ${listedResource.singular}.`
35
- : `Before browsing your ${listedResource.plural}, create your first ${resourceToCreate}.` }) }), history && (_jsx(ActionWrapper, { children: _jsx(Button, { label: `Create ${resourceToCreate || listedResource.singular}`, icon: _jsx(Icon, { name: "Create-add" }), type: "button", variant: "primary", onClick: () => history.push(link) }) }))] }));
37
+ : `Before browsing your ${listedResource.plural}, create your first ${resourceToCreate}.` }) }), link && (_jsx(ActionWrapper, { children: _jsx(Button, { label: `Create ${resourceToCreate || listedResource.singular}`, icon: _jsx(Icon, { name: "Create-add" }), type: "button", variant: "primary", onClick: () => history.push(link) }) }))] }));
36
38
  }
37
39
  export { EmptyState };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scality/core-ui",
3
- "version": "0.123.0",
3
+ "version": "0.124.0",
4
4
  "description": "Scality common React component library",
5
5
  "author": "Scality Engineering",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -1,18 +1,18 @@
1
1
  import styled, { css } from 'styled-components';
2
-
3
2
  import { spacing } from '../../spacing';
4
3
  import { Button } from '../buttonv2/Buttonv2.component';
5
4
  import { Icon, IconName } from '../icon/Icon.component';
6
5
  import { LargeText } from '../text/Text.component';
7
6
  import { CoreUITheme } from '../../style/theme';
8
- type Props = {
7
+ import { useHistory } from 'react-router';
8
+
9
+ export type Props = {
9
10
  listedResource: {
10
11
  singular: string;
11
12
  plural: string;
12
13
  };
13
14
  icon: IconName;
14
15
  link?: string;
15
- history?: Record<string, any>;
16
16
  backgroundColor?: keyof CoreUITheme;
17
17
  /**
18
18
  * The resource to create before browsing the listed resource
@@ -46,14 +46,9 @@ export const ActionWrapper = styled.div`
46
46
  `;
47
47
 
48
48
  function EmptyState(props: Props) {
49
- const {
50
- icon,
51
- listedResource,
52
- link,
53
- history,
54
- resourceToCreate,
55
- backgroundColor,
56
- } = props;
49
+ const { icon, listedResource, link, resourceToCreate, backgroundColor } =
50
+ props;
51
+ const history = useHistory();
57
52
  return (
58
53
  <EmptystateContainer
59
54
  className="sc-emptystate"
@@ -72,7 +67,7 @@ function EmptyState(props: Props) {
72
67
  : `Before browsing your ${listedResource.plural}, create your first ${resourceToCreate}.`}
73
68
  </LargeText>
74
69
  </EmptyStateRow>
75
- {history && (
70
+ {link && (
76
71
  <ActionWrapper>
77
72
  <Button
78
73
  label={`Create ${resourceToCreate || listedResource.singular}`}
@@ -1,21 +1,28 @@
1
- import { EmptyState } from '../src/lib/components/emptystate/Emptystate.component';
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import {
3
+ EmptyState,
4
+ Props,
5
+ } from '../src/lib/components/emptystate/Emptystate.component';
6
+ type Story = StoryObj<Props>;
2
7
 
3
- export default {
8
+ const meta: Meta<Props> = {
4
9
  title: 'Components/Data Display/EmptyState',
5
10
  component: EmptyState,
6
11
  args: {
7
12
  icon: 'Node-backend',
8
- label: 'Node',
13
+ listedResource: {
14
+ singular: 'resource',
15
+ plural: 'resources',
16
+ },
9
17
  },
10
18
  };
11
19
 
12
- export const Default = {};
20
+ export default meta;
21
+
22
+ export const Default: Story = {};
13
23
 
14
- export const WithLink = {
24
+ export const WithLink: Story = {
15
25
  args: {
16
26
  link: '',
17
- history: {
18
- push: () => {},
19
- },
20
27
  },
21
28
  };