@synerise/ds-badge 0.7.1 → 0.8.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.8.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-badge@0.7.1...@synerise/ds-badge@0.8.0) (2024-07-05)
7
+
8
+
9
+ ### Features
10
+
11
+ * **badge:** added IconBadge ([4f44b60](https://github.com/Synerise/synerise-design/commit/4f44b60b3eff77eb6c21b9ba0ec0cdf745100eff))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.7.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-badge@0.7.0...@synerise/ds-badge@0.7.1) (2024-05-29)
7
18
 
8
19
  **Note:** Version bump only for package @synerise/ds-badge
package/README.md CHANGED
@@ -93,3 +93,17 @@ import Badge from '@synerise/ds-badge'
93
93
  | Values |
94
94
  | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
95
95
  | `green` / `grey` / `yellow` / `blue` / `pink`/ `mars`/ `orange`/ `fern`/ `cyan`/ `purple` / `violet` / `blue-600` / `green-600` / `mars-600` / `purple-600` / `cyan-600` / `yellow-600` / `violet-600` / `blue-700` / `green-700` / `mars-700` / `purple-700` / `cyan-700` / `yellow-700` / `violet-700` / `blue-500` / `green-500` / `mars-500` / `purple-500` / `cyan-500` / `yellow-500` / `violet-500` |
96
+
97
+
98
+ ### IconBadge
99
+
100
+ Displays a predefined (depending on status) or custom icon as badge
101
+
102
+
103
+ | Property | Description | Type | Default |
104
+ |----------|---------------------------|--------------------------------------------------------------|---------|
105
+ | status | Set badge as a status dot | `active` / `inactive` / `blocked` / `processing` / `warning` | - |
106
+ | icon | Custom icon to display | `ReactNode` | - |
107
+
108
+
109
+ Either icon or status is mandatory.
@@ -0,0 +1,3 @@
1
+ import { IconProps } from '@synerise/ds-icon';
2
+ import { Status } from '../Badge.types';
3
+ export declare const STATUS_ICONS: Record<Exclude<Status, undefined | 'inactive'>, Partial<IconProps>>;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { Check3S, ErrorFillS, SpinnerS, WarningFillS } from '@synerise/ds-icon';
3
+ import { theme } from '@synerise/ds-core';
4
+ export var STATUS_ICONS = {
5
+ active: {
6
+ component: /*#__PURE__*/React.createElement(Check3S, null),
7
+ color: theme.palette['fern-600']
8
+ },
9
+ blocked: {
10
+ component: /*#__PURE__*/React.createElement(ErrorFillS, null),
11
+ color: theme.palette['red-600']
12
+ },
13
+ processing: {
14
+ component: /*#__PURE__*/React.createElement(SpinnerS, null),
15
+ color: theme.palette['blue-600']
16
+ },
17
+ warning: {
18
+ component: /*#__PURE__*/React.createElement(WarningFillS, null),
19
+ color: theme.palette['yellow-600']
20
+ }
21
+ };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { IconBadgeProps } from './IconBadge.types';
3
+ export declare const IconBadge: ({ children, ...props }: IconBadgeProps) => React.JSX.Element;
@@ -0,0 +1,23 @@
1
+ var _excluded = ["children"];
2
+
3
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+
5
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
+
7
+ import React from 'react';
8
+ import { omitKeys } from '@synerise/ds-utils';
9
+ import * as S from './IconBadge.styles';
10
+ import { hasCustomIcon, renderStatusIcon } from './IconBadge.utils';
11
+ export var IconBadge = function IconBadge(_ref) {
12
+ var children = _ref.children,
13
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
14
+
15
+ // eslint-disable-next-line react/destructuring-assignment
16
+ var iconComponent = hasCustomIcon(props) ? props.icon : renderStatusIcon(props.status);
17
+ var rest = omitKeys(['icon', 'status'], props);
18
+ return /*#__PURE__*/React.createElement(S.IconBadgeWrapper, _extends({
19
+ "data-testid": "ds-badge-icon-badge"
20
+ }, rest), children, /*#__PURE__*/React.createElement(S.IconBadgeIcon, {
21
+ className: "ds-icon-badge"
22
+ }, iconComponent));
23
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const IconBadgeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const IconBadgeIcon: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ export declare const Icon: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-icon").IconProps>, any, {
5
+ status?: string | undefined;
6
+ }, never>;
@@ -0,0 +1,17 @@
1
+ import styled, { css, keyframes } from 'styled-components';
2
+ import DSIcon from '@synerise/ds-icon';
3
+ var spinnerAnimation = keyframes(["0%{transform:rotate(0deg);}100%{transform:rotate(720deg);}"]);
4
+ export var IconBadgeWrapper = styled.div.withConfig({
5
+ displayName: "IconBadgestyles__IconBadgeWrapper",
6
+ componentId: "dio7h6-0"
7
+ })(["position:relative;display:inline-block;"]);
8
+ export var IconBadgeIcon = styled.div.withConfig({
9
+ displayName: "IconBadgestyles__IconBadgeIcon",
10
+ componentId: "dio7h6-1"
11
+ })(["position:absolute;top:0;right:0;z-index:10;"]);
12
+ export var Icon = styled(DSIcon).withConfig({
13
+ displayName: "IconBadgestyles__Icon",
14
+ componentId: "dio7h6-2"
15
+ })(["", ""], function (props) {
16
+ return props.status === 'processing' && css(["animation:", " 2s linear infinite;"], spinnerAnimation);
17
+ });
@@ -0,0 +1,11 @@
1
+ import { ReactElement, ReactNode, HTMLAttributes } from 'react';
2
+ import { Status } from '../Badge.types';
3
+ export type CustomIconBadgeProps = {
4
+ icon: ReactElement;
5
+ };
6
+ export type StatusIconBadgeProps = {
7
+ status: Exclude<Status, undefined>;
8
+ };
9
+ export type IconBadgeProps = (CustomIconBadgeProps | StatusIconBadgeProps) & {
10
+ children?: ReactNode;
11
+ } & HTMLAttributes<HTMLDivElement>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { CustomIconBadgeProps, StatusIconBadgeProps } from './IconBadge.types';
3
+ export declare const hasCustomIcon: (props: CustomIconBadgeProps | StatusIconBadgeProps) => props is CustomIconBadgeProps;
4
+ export declare const renderStatusIcon: (status: StatusIconBadgeProps['status']) => React.JSX.Element | null;
@@ -0,0 +1,13 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React from 'react';
4
+ import { STATUS_ICONS } from './IconBadge.constants';
5
+ import * as S from './IconBadge.styles';
6
+ export var hasCustomIcon = function hasCustomIcon(props) {
7
+ return 'icon' in props;
8
+ };
9
+ export var renderStatusIcon = function renderStatusIcon(status) {
10
+ return STATUS_ICONS[status] ? /*#__PURE__*/React.createElement(S.Icon, _extends({
11
+ status: status
12
+ }, STATUS_ICONS[status])) : null;
13
+ };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { default } from './Badge';
2
2
  export type { Status as BadgeStatus, BadgeProps, Color as BadgeColor, ColorHue as BadgeColorHue } from './Badge.types';
3
+ export * from './IconBadge/IconBadge';
4
+ export type { IconBadgeProps, StatusIconBadgeProps, CustomIconBadgeProps } from './IconBadge/IconBadge.types';
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
- export { default } from './Badge';
1
+ export { default } from './Badge';
2
+ export * from './IconBadge/IconBadge';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-badge",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Badge UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -33,17 +33,15 @@
33
33
  ],
34
34
  "types": "dist/index.d.ts",
35
35
  "dependencies": {
36
- "@synerise/ds-typography": "^0.15.0"
36
+ "@synerise/ds-icon": "^0.64.0",
37
+ "@synerise/ds-typography": "^0.15.1",
38
+ "@synerise/ds-utils": "^0.28.0"
37
39
  },
38
40
  "peerDependencies": {
39
41
  "@synerise/ds-core": "*",
40
42
  "antd": "4.7.0",
41
- "react": ">=16.9.0 < 17.0.0",
43
+ "react": ">=16.9.0 <= 17.0.2",
42
44
  "styled-components": "5.0.1"
43
45
  },
44
- "devDependencies": {
45
- "@synerise/ds-utils": "^0.27.0",
46
- "@testing-library/jest-dom": "5.1.1"
47
- },
48
- "gitHead": "6bd94c78745df68ee3b853120a863ab24fc233ef"
46
+ "gitHead": "6e5e5202d6c6f1c2caf6bfef799009813b437b3d"
49
47
  }