@propellerads/badge 3.0.1 → 4.0.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/dist/index.d.ts CHANGED
@@ -1,5 +1,21 @@
1
- import React from 'react';
2
- import { BADGE_TYPE, BadgeProps, CustomStyle } from './types';
3
- declare const Badge: ({ label, type, customStyle, icon }: BadgeProps) => React.JSX.Element;
4
- export default Badge;
5
- export { BADGE_TYPE, CustomStyle };
1
+ import { ReactNode, FC } from 'react';
2
+ import { CSSObject } from 'styled-components';
3
+
4
+ declare const BadgeType: {
5
+ readonly Info: "info";
6
+ readonly Warning: "warning";
7
+ readonly Danger: "danger";
8
+ readonly Success: "success";
9
+ };
10
+ type BadgeType = (typeof BadgeType)[keyof typeof BadgeType];
11
+ type BadgeProps = {
12
+ label?: ReactNode;
13
+ type?: BadgeType;
14
+ customStyle?: CSSObject;
15
+ icon?: ReactNode;
16
+ };
17
+
18
+ declare const Badge: FC<BadgeProps>;
19
+
20
+ export { BadgeType, Badge as default };
21
+ export type { BadgeProps };
package/dist/index.js CHANGED
@@ -1,8 +1,38 @@
1
-
2
- 'use strict'
3
-
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./badge.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./badge.cjs.development.js')
8
- }
1
+ import { jsxs as a, jsx as c } from "react/jsx-runtime";
2
+ import o from "styled-components";
3
+ import { spacing as s, white as l, successColor as d, errorColor as g, warningColor as p, actionColor as m, borderRadius as f } from "@propellerads/stylevariables";
4
+ const n = {
5
+ Info: "info",
6
+ Warning: "warning",
7
+ Danger: "danger",
8
+ Success: "success"
9
+ }, u = {
10
+ [n.Info]: m,
11
+ [n.Warning]: p,
12
+ [n.Danger]: g,
13
+ [n.Success]: d
14
+ }, x = o.div`
15
+ display: inline-flex;
16
+ align-items: center;
17
+ padding: 0 ${s}px;
18
+ text-transform: uppercase;
19
+ color: ${l};
20
+ border-radius: ${f / 2}px;
21
+ font-size: 10px;
22
+ line-height: 1.5;
23
+ min-height: 16px;
24
+ background-color: ${(e) => u[e.$type]};
25
+ ${(e) => e.$customStyle}
26
+ `, y = o.span`
27
+ margin-right: ${s}px;
28
+ display: flex;
29
+ align-items: center;
30
+ `, C = ({ label: e = "", type: t = n.Info, customStyle: i = {}, icon: r }) => /* @__PURE__ */ a(x, { $type: t, $customStyle: i, children: [
31
+ r && /* @__PURE__ */ c(y, { children: r }),
32
+ e
33
+ ] });
34
+ export {
35
+ n as BadgeType,
36
+ C as default
37
+ };
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/types.ts","../src/style.tsx","../src/index.tsx"],"sourcesContent":["import type {ReactNode} from 'react';\nimport type {CSSObject} from 'styled-components';\n\nexport const BadgeType = {\n Info: 'info',\n Warning: 'warning',\n Danger: 'danger',\n Success: 'success',\n} as const;\nexport type BadgeType = (typeof BadgeType)[keyof typeof BadgeType];\n\nexport type BadgeProps = {\n label?: ReactNode;\n type?: BadgeType;\n customStyle?: CSSObject;\n icon?: ReactNode;\n};\n","import styled from 'styled-components';\nimport {\n white,\n borderRadius,\n actionColor,\n warningColor,\n errorColor,\n successColor,\n spacing,\n} from '@propellerads/stylevariables';\nimport {BadgeType, type BadgeProps} from './types';\n\ntype StyledBadgeContainerProps = {\n $type: BadgeType;\n $customStyle: NonNullable<BadgeProps['customStyle']>;\n};\n\nconst BADGE_COLORS = {\n [BadgeType.Info]: actionColor,\n [BadgeType.Warning]: warningColor,\n [BadgeType.Danger]: errorColor,\n [BadgeType.Success]: successColor,\n} as const satisfies Record<BadgeType, string>;\n\nconst StyledBadgeContainer = styled.div<StyledBadgeContainerProps>`\n display: inline-flex;\n align-items: center;\n padding: 0 ${spacing}px;\n text-transform: uppercase;\n color: ${white};\n border-radius: ${borderRadius / 2}px;\n font-size: 10px;\n line-height: 1.5;\n min-height: 16px;\n background-color: ${(props) => BADGE_COLORS[props.$type]};\n ${(props) => props.$customStyle}\n`;\n\nconst StyledBadgeIcon = styled.span`\n margin-right: ${spacing}px;\n display: flex;\n align-items: center;\n`;\n\nexport {StyledBadgeContainer, StyledBadgeIcon};\n","import {FC} from 'react';\nimport {StyledBadgeContainer, StyledBadgeIcon} from './style';\nimport {BadgeType, BadgeProps} from './types';\n\nconst Badge: FC<BadgeProps> = ({label = '', type = BadgeType.Info, customStyle = {}, icon}) => (\n <StyledBadgeContainer $type={type} $customStyle={customStyle}>\n {icon && <StyledBadgeIcon>{icon}</StyledBadgeIcon>}\n {label}\n </StyledBadgeContainer>\n);\n\nexport default Badge;\n\nexport {BadgeType, type BadgeProps};\n"],"names":["BadgeType","BADGE_COLORS","actionColor","warningColor","errorColor","successColor","StyledBadgeContainer","styled","spacing","white","borderRadius","props","StyledBadgeIcon","Badge","label","type","customStyle","icon","jsxs","jsx"],"mappings":";;;AAGO,MAAMA,IAAY;AAAA,EACvB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AACX,GCSMC,IAAe;AAAA,EACnB,CAACD,EAAU,IAAI,GAAGE;AAAA,EAClB,CAACF,EAAU,OAAO,GAAGG;AAAA,EACrB,CAACH,EAAU,MAAM,GAAGI;AAAA,EACpB,CAACJ,EAAU,OAAO,GAAGK;AACvB,GAEMC,IAAuBC,EAAO;AAAA;AAAA;AAAA,eAGrBC,CAAO;AAAA;AAAA,WAEXC,CAAK;AAAA,mBACGC,IAAe,CAAC;AAAA;AAAA;AAAA;AAAA,sBAIb,CAACC,MAAUV,EAAaU,EAAM,KAAK,CAAC;AAAA,IACtD,CAACA,MAAUA,EAAM,YAAY;AAAA,GAG3BC,IAAkBL,EAAO;AAAA,kBACbC,CAAO;AAAA;AAAA;AAAA,GCnCnBK,IAAwB,CAAC,EAAC,OAAAC,IAAQ,IAAI,MAAAC,IAAOf,EAAU,MAAM,aAAAgB,IAAc,CAAA,GAAI,MAAAC,QACnF,gBAAAC,EAACZ,KAAqB,OAAOS,GAAM,cAAcC,GAC9C,UAAA;AAAA,EAAAC,KAAQ,gBAAAE,EAACP,KAAiB,UAAAK,EAAA,CAAK;AAAA,EAC/BH;AAAA,EAAA,CACH;"}
package/package.json CHANGED
@@ -1,38 +1,42 @@
1
1
  {
2
2
  "name": "@propellerads/badge",
3
- "version": "3.0.1",
4
- "repository": "https://github.com/propellerads/ui-components",
5
- "private": false,
6
- "license": "MIT",
7
- "main": "dist/index.js",
8
- "typings": "dist/index.d.ts",
3
+ "version": "4.0.0",
4
+ "type": "module",
5
+ "types": "dist/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ }
11
+ },
9
12
  "files": [
10
- "dist",
11
- "src"
13
+ "dist"
12
14
  ],
15
+ "repository": "https://github.com/propellerads/ui-components.git",
13
16
  "author": "i.pasyuk@propellerads.net",
14
- "engines": {
15
- "node": ">=10"
17
+ "license": "MIT",
18
+ "bugs": {
19
+ "url": "https://github.com/propellerads/ui-components/issues"
16
20
  },
17
21
  "scripts": {
18
- "prepublishOnly": "tsdx build",
19
- "start": "tsdx watch",
20
- "build": "tsdx build"
22
+ "build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
23
+ },
24
+ "homepage": "https://github.com/propellerads/ui-components#readme",
25
+ "private": false,
26
+ "dependencies": {
27
+ "@propellerads/stylevariables": "^2.0.2"
21
28
  },
22
29
  "peerDependencies": {
23
- "react": ">=18 <19",
24
- "styled-components": "5.1.1"
30
+ "react": "^18.0.0 || ^19.0.0",
31
+ "styled-components": "^5.1.1 || ^6.0.0"
25
32
  },
26
- "module": "dist/badge.esm.js",
27
33
  "devDependencies": {
28
- "@types/react": ">=18 <19",
29
- "@types/styled-components": "5.1.34",
30
- "tsdx": "^0.13.3",
31
- "tslib": "^2.0.1",
32
- "typescript": "^4.9.5"
33
- },
34
- "dependencies": {
35
- "@propellerads/stylevariables": "^1.3.0"
36
- },
37
- "gitHead": "e4a84ba8a4df9120d4940351f91ceaa947919574"
34
+ "@types/react": "^19.2.14",
35
+ "@types/styled-components": "^5.1.36",
36
+ "@vitejs/plugin-react": "^5.1.4",
37
+ "rollup": "^4.58.0",
38
+ "rollup-plugin-dts": "^6.3.0",
39
+ "typescript": "^5.9.3",
40
+ "vite": "^7.3.1"
41
+ }
38
42
  }
package/CHANGELOG.md DELETED
@@ -1,35 +0,0 @@
1
- ## `3.0.1`
2
-
3
- - Fixed dependencies
4
-
5
- ## `3.0.0`
6
-
7
- - upgrade to React 18
8
-
9
- ## `2.4.0`
10
-
11
- - updated peerDependencies
12
-
13
- ## `2.3.0`
14
-
15
- - update style-variables
16
- - apply new border-radius 8px
17
-
18
- ## `2.2.0`
19
-
20
- - exported interface `CustomStyle`
21
- - Badge component exported as default module
22
-
23
- ## `2.1.0`
24
-
25
- - exported enum `BADGE_TYPE`
26
-
27
- ## `2.0.0`
28
-
29
- - TS
30
- - Production build
31
- - Breaking changes - an icon component became external
32
-
33
- ## `1.1.0`
34
-
35
- - Badge styles now fully customizable
@@ -1,149 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var React = _interopDefault(require('react'));
8
- var styled = require('styled-components');
9
- var styled__default = _interopDefault(styled);
10
- var style = require('@propellerads/stylevariables');
11
-
12
- function _extends() {
13
- _extends = Object.assign || function (target) {
14
- for (var i = 1; i < arguments.length; i++) {
15
- var source = arguments[i];
16
-
17
- for (var key in source) {
18
- if (Object.prototype.hasOwnProperty.call(source, key)) {
19
- target[key] = source[key];
20
- }
21
- }
22
- }
23
-
24
- return target;
25
- };
26
-
27
- return _extends.apply(this, arguments);
28
- }
29
-
30
- function _taggedTemplateLiteralLoose(strings, raw) {
31
- if (!raw) {
32
- raw = strings.slice(0);
33
- }
34
-
35
- strings.raw = raw;
36
- return strings;
37
- }
38
-
39
- (function (BADGE_TYPE) {
40
- BADGE_TYPE["INFO"] = "info";
41
- BADGE_TYPE["WARNING"] = "warning";
42
- BADGE_TYPE["DANGER"] = "danger";
43
- BADGE_TYPE["SUCCESS"] = "success";
44
- })(exports.BADGE_TYPE || (exports.BADGE_TYPE = {}));
45
-
46
- function _templateObject7() {
47
- var data = _taggedTemplateLiteralLoose(["\n margin-right: ", "px;\n display: flex;\n align-items: center;\n"]);
48
-
49
- _templateObject7 = function _templateObject7() {
50
- return data;
51
- };
52
-
53
- return data;
54
- }
55
-
56
- function _templateObject6() {
57
- var data = _taggedTemplateLiteralLoose(["\n ", ",\n "]);
58
-
59
- _templateObject6 = function _templateObject6() {
60
- return data;
61
- };
62
-
63
- return data;
64
- }
65
-
66
- function _templateObject5() {
67
- var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
68
-
69
- _templateObject5 = function _templateObject5() {
70
- return data;
71
- };
72
-
73
- return data;
74
- }
75
-
76
- function _templateObject4() {
77
- var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
78
-
79
- _templateObject4 = function _templateObject4() {
80
- return data;
81
- };
82
-
83
- return data;
84
- }
85
-
86
- function _templateObject3() {
87
- var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
88
-
89
- _templateObject3 = function _templateObject3() {
90
- return data;
91
- };
92
-
93
- return data;
94
- }
95
-
96
- function _templateObject2() {
97
- var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
98
-
99
- _templateObject2 = function _templateObject2() {
100
- return data;
101
- };
102
-
103
- return data;
104
- }
105
-
106
- function _templateObject() {
107
- var data = _taggedTemplateLiteralLoose(["\n display: inline-flex;\n align-items: center;\n padding: 0 ", "px;\n text-transform: uppercase;\n color: ", ";\n border-radius: ", "px;\n font-size: 10px;\n line-height: 1.5;\n min-height: 16px;\n\n // Color\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n // Have priority\n ", "\n"]);
108
-
109
- _templateObject = function _templateObject() {
110
- return data;
111
- };
112
-
113
- return data;
114
- }
115
-
116
- var getCustomStyle = function getCustomStyle(props) {
117
- return _extends({}, props);
118
- };
119
-
120
- var StyledBadgeContainer = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject(), style.spacing, style.white, style.borderRadius / 2, function (props) {
121
- return props.type === exports.BADGE_TYPE.INFO && styled.css(_templateObject2(), style.actionColor);
122
- }, function (props) {
123
- return props.type === exports.BADGE_TYPE.WARNING && styled.css(_templateObject3(), style.warningColor);
124
- }, function (props) {
125
- return props.type === exports.BADGE_TYPE.DANGER && styled.css(_templateObject4(), style.errorColor);
126
- }, function (props) {
127
- return props.type === exports.BADGE_TYPE.SUCCESS && styled.css(_templateObject5(), style.successColor);
128
- }, function (props) {
129
- return Boolean(Object.values(props.customStyle).length) && styled.css(_templateObject6(), getCustomStyle(props.customStyle));
130
- });
131
- var StyledBadgeIcon = /*#__PURE__*/styled__default.span( /*#__PURE__*/_templateObject7(), style.spacing);
132
-
133
- var Badge = function Badge(_ref) {
134
- var _ref$label = _ref.label,
135
- label = _ref$label === void 0 ? '' : _ref$label,
136
- _ref$type = _ref.type,
137
- type = _ref$type === void 0 ? exports.BADGE_TYPE.INFO : _ref$type,
138
- _ref$customStyle = _ref.customStyle,
139
- customStyle = _ref$customStyle === void 0 ? {} : _ref$customStyle,
140
- _ref$icon = _ref.icon,
141
- icon = _ref$icon === void 0 ? undefined : _ref$icon;
142
- return React.createElement(StyledBadgeContainer, {
143
- type: type,
144
- customStyle: customStyle
145
- }, icon && React.createElement(StyledBadgeIcon, null, icon), label);
146
- };
147
-
148
- exports.default = Badge;
149
- //# sourceMappingURL=badge.cjs.development.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"badge.cjs.development.js","sources":["../src/types.ts","../src/style.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\n\nexport enum BADGE_TYPE {\n INFO = 'info',\n WARNING = 'warning',\n DANGER = 'danger',\n SUCCESS = 'success',\n}\n\nexport interface CustomStyle {\n color?: string;\n background?: string;\n}\n\nexport interface BadgeProps {\n label?: React.ReactChildren | string | React.ComponentElement<any, any>;\n type?: BADGE_TYPE;\n customStyle?: CustomStyle;\n icon?: React.ComponentElement<any, any>;\n}\n\nexport default class Badge extends React.Component<BadgeProps> {}\n","import styled, {css} from 'styled-components';\nimport * as style from '@propellerads/stylevariables';\n\nimport {BADGE_TYPE, CustomStyle} from './types';\n\nconst getCustomStyle = (props: CustomStyle) => ({...props});\n\ninterface StyledBadgeContainerProps {\n type: BADGE_TYPE;\n customStyle: CustomStyle;\n}\n\nconst StyledBadgeContainer = styled.div`\n display: inline-flex;\n align-items: center;\n padding: 0 ${style.spacing}px;\n text-transform: uppercase;\n color: ${style.white};\n border-radius: ${style.borderRadius / 2}px;\n font-size: 10px;\n line-height: 1.5;\n min-height: 16px;\n\n // Color\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.INFO &&\n css`\n background-color: ${style.actionColor};\n `}\n\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.WARNING &&\n css`\n background-color: ${style.warningColor};\n `}\n\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.DANGER &&\n css`\n background-color: ${style.errorColor};\n `}\n\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.SUCCESS &&\n css`\n background-color: ${style.successColor};\n `}\n\n // Have priority\n ${(props: StyledBadgeContainerProps) =>\n Boolean(Object.values(props.customStyle).length) &&\n css`\n ${getCustomStyle(props.customStyle)},\n `}\n`;\n\nconst StyledBadgeIcon = styled.span`\n margin-right: ${style.spacing}px;\n display: flex;\n align-items: center;\n`;\n\nexport {StyledBadgeContainer, StyledBadgeIcon};\n","import React from 'react';\n\nimport {StyledBadgeContainer, StyledBadgeIcon} from './style';\nimport {BADGE_TYPE, BadgeProps, CustomStyle} from './types';\n\nconst Badge = ({label = '', type = BADGE_TYPE.INFO, customStyle = {}, icon = undefined}: BadgeProps) => (\n <StyledBadgeContainer type={type} customStyle={customStyle}>\n {icon && <StyledBadgeIcon>{icon}</StyledBadgeIcon>}\n {label}\n </StyledBadgeContainer>\n);\n\nexport default Badge;\nexport {BADGE_TYPE, CustomStyle};\n"],"names":["BADGE_TYPE","getCustomStyle","props","StyledBadgeContainer","styled","div","style","type","INFO","css","WARNING","DANGER","SUCCESS","Boolean","Object","values","customStyle","length","StyledBadgeIcon","span","Badge","label","icon","undefined","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,WAAYA;AACVA,EAAAA,kBAAA,SAAA;AACAA,EAAAA,qBAAA,YAAA;AACAA,EAAAA,oBAAA,WAAA;AACAA,EAAAA,qBAAA,YAAA;AACD,CALD,EAAYA,kBAAU,KAAVA,kBAAU,KAAA,CAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACGA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,KAAD;AAAA,sBAA6BA,KAA7B;AAAA,CAAvB;;AAOA,IAAMC,oBAAoB,gBAAGC,eAAM,CAACC,GAAV,kCAGXC,aAHW,EAKfA,WALe,EAMPA,kBAAA,GAAqB,CANd,EAYtB,UAACJ,KAAD;AAAA,SACAA,KAAK,CAACK,IAAN,KAAeP,kBAAU,CAACQ,IAA1B,IACAC,UADA,qBAEsBH,iBAFtB,CADA;AAAA,CAZsB,EAkBtB,UAACJ,KAAD;AAAA,SACAA,KAAK,CAACK,IAAN,KAAeP,kBAAU,CAACU,OAA1B,IACAD,UADA,qBAEsBH,kBAFtB,CADA;AAAA,CAlBsB,EAwBpB,UAACJ,KAAD;AAAA,SACFA,KAAK,CAACK,IAAN,KAAeP,kBAAU,CAACW,MAA1B,IACAF,UADA,qBAEsBH,gBAFtB,CADE;AAAA,CAxBoB,EA8BpB,UAACJ,KAAD;AAAA,SACFA,KAAK,CAACK,IAAN,KAAeP,kBAAU,CAACY,OAA1B,IACAH,UADA,qBAEsBH,kBAFtB,CADE;AAAA,CA9BoB,EAqCpB,UAACJ,KAAD;AAAA,SACFW,OAAO,CAACC,MAAM,CAACC,MAAP,CAAcb,KAAK,CAACc,WAApB,EAAiCC,MAAlC,CAAP,IACAR,UADA,qBAEIR,cAAc,CAACC,KAAK,CAACc,WAAP,CAFlB,CADE;AAAA,CArCoB,CAA1B;AA4CA,IAAME,eAAe,gBAAGd,eAAM,CAACe,IAAV,mCACHb,aADG,CAArB;;ACnDA,IAAMc,KAAK,GAAG,SAARA,KAAQ;AAAA,wBAAEC,KAAF;AAAA,MAAEA,KAAF,2BAAU,EAAV;AAAA,uBAAcd,IAAd;AAAA,MAAcA,IAAd,0BAAqBP,kBAAU,CAACQ,IAAhC;AAAA,8BAAsCQ,WAAtC;AAAA,MAAsCA,WAAtC,iCAAoD,EAApD;AAAA,uBAAwDM,IAAxD;AAAA,MAAwDA,IAAxD,0BAA+DC,SAA/D;AAAA,SACZC,mBAAA,CAACrB,oBAAD;AAAsBI,IAAAA,IAAI,EAAEA;AAAMS,IAAAA,WAAW,EAAEA;GAA/C,EACGM,IAAI,IAAIE,mBAAA,CAACN,eAAD,MAAA,EAAkBI,IAAlB,CADX,EAEGD,KAFH,CADY;AAAA,CAAd;;;;"}
@@ -1,2 +0,0 @@
1
- "use strict";function n(n){return n&&"object"==typeof n&&"default"in n?n.default:n}Object.defineProperty(exports,"__esModule",{value:!0});var r,e=n(require("react")),t=require("styled-components"),o=n(t),u=require("@propellerads/stylevariables");function i(){return(i=Object.assign||function(n){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t])}return n}).apply(this,arguments)}function c(n,r){return r||(r=n.slice(0)),n.raw=r,n}function s(){var n=c(["\n margin-right: ","px;\n display: flex;\n align-items: center;\n"]);return s=function(){return n},n}function a(){var n=c(["\n ",",\n "]);return a=function(){return n},n}function l(){var n=c(["\n background-color: ",";\n "]);return l=function(){return n},n}function p(){var n=c(["\n background-color: ",";\n "]);return p=function(){return n},n}function f(){var n=c(["\n background-color: ",";\n "]);return f=function(){return n},n}function d(){var n=c(["\n background-color: ",";\n "]);return d=function(){return n},n}function v(){var n=c(["\n display: inline-flex;\n align-items: center;\n padding: 0 ","px;\n text-transform: uppercase;\n color: ",";\n border-radius: ","px;\n font-size: 10px;\n line-height: 1.5;\n min-height: 16px;\n\n // Color\n ","\n\n ","\n\n ","\n\n ","\n\n // Have priority\n ","\n"]);return v=function(){return n},n}(r=exports.BADGE_TYPE||(exports.BADGE_TYPE={})).INFO="info",r.WARNING="warning",r.DANGER="danger",r.SUCCESS="success";var y=o.div(v(),u.spacing,u.white,u.borderRadius/2,(function(n){return n.type===exports.BADGE_TYPE.INFO&&t.css(d(),u.actionColor)}),(function(n){return n.type===exports.BADGE_TYPE.WARNING&&t.css(f(),u.warningColor)}),(function(n){return n.type===exports.BADGE_TYPE.DANGER&&t.css(p(),u.errorColor)}),(function(n){return n.type===exports.BADGE_TYPE.SUCCESS&&t.css(l(),u.successColor)}),(function(n){return Boolean(Object.values(n.customStyle).length)&&t.css(a(),function(n){return i({},n)}(n.customStyle))})),E=o.span(s(),u.spacing);exports.default=function(n){var r=n.label,t=void 0===r?"":r,o=n.type,u=void 0===o?exports.BADGE_TYPE.INFO:o,i=n.customStyle,c=n.icon,s=void 0===c?void 0:c;return e.createElement(y,{type:u,customStyle:void 0===i?{}:i},s&&e.createElement(E,null,s),t)};
2
- //# sourceMappingURL=badge.cjs.production.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"badge.cjs.production.min.js","sources":["../src/types.ts","../src/style.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\n\nexport enum BADGE_TYPE {\n INFO = 'info',\n WARNING = 'warning',\n DANGER = 'danger',\n SUCCESS = 'success',\n}\n\nexport interface CustomStyle {\n color?: string;\n background?: string;\n}\n\nexport interface BadgeProps {\n label?: React.ReactChildren | string | React.ComponentElement<any, any>;\n type?: BADGE_TYPE;\n customStyle?: CustomStyle;\n icon?: React.ComponentElement<any, any>;\n}\n\nexport default class Badge extends React.Component<BadgeProps> {}\n","import styled, {css} from 'styled-components';\nimport * as style from '@propellerads/stylevariables';\n\nimport {BADGE_TYPE, CustomStyle} from './types';\n\nconst getCustomStyle = (props: CustomStyle) => ({...props});\n\ninterface StyledBadgeContainerProps {\n type: BADGE_TYPE;\n customStyle: CustomStyle;\n}\n\nconst StyledBadgeContainer = styled.div`\n display: inline-flex;\n align-items: center;\n padding: 0 ${style.spacing}px;\n text-transform: uppercase;\n color: ${style.white};\n border-radius: ${style.borderRadius / 2}px;\n font-size: 10px;\n line-height: 1.5;\n min-height: 16px;\n\n // Color\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.INFO &&\n css`\n background-color: ${style.actionColor};\n `}\n\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.WARNING &&\n css`\n background-color: ${style.warningColor};\n `}\n\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.DANGER &&\n css`\n background-color: ${style.errorColor};\n `}\n\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.SUCCESS &&\n css`\n background-color: ${style.successColor};\n `}\n\n // Have priority\n ${(props: StyledBadgeContainerProps) =>\n Boolean(Object.values(props.customStyle).length) &&\n css`\n ${getCustomStyle(props.customStyle)},\n `}\n`;\n\nconst StyledBadgeIcon = styled.span`\n margin-right: ${style.spacing}px;\n display: flex;\n align-items: center;\n`;\n\nexport {StyledBadgeContainer, StyledBadgeIcon};\n","import React from 'react';\n\nimport {StyledBadgeContainer, StyledBadgeIcon} from './style';\nimport {BADGE_TYPE, BadgeProps, CustomStyle} from './types';\n\nconst Badge = ({label = '', type = BADGE_TYPE.INFO, customStyle = {}, icon = undefined}: BadgeProps) => (\n <StyledBadgeContainer type={type} customStyle={customStyle}>\n {icon && <StyledBadgeIcon>{icon}</StyledBadgeIcon>}\n {label}\n </StyledBadgeContainer>\n);\n\nexport default Badge;\nexport {BADGE_TYPE, CustomStyle};\n"],"names":["BADGE_TYPE","StyledBadgeContainer","styled","div","style","props","type","INFO","css","WARNING","DANGER","SUCCESS","Boolean","Object","values","customStyle","length","getCustomStyle","StyledBadgeIcon","span","label","icon","undefined","React"],"mappings":"8IAEYA,+wCAAAA,EAAAA,qBAAAA,oCAEVA,oBACAA,kBACAA,oBCDF,IAOMC,EAAuBC,EAAOC,QAGrBC,UAEJA,QACQA,eAAqB,GAMpC,SAACC,UACDA,EAAMC,OAASN,mBAAWO,MAC1BC,UACsBJ,kBAGtB,SAACC,UACDA,EAAMC,OAASN,mBAAWS,SAC1BD,UACsBJ,mBAGpB,SAACC,UACHA,EAAMC,OAASN,mBAAWU,QAC1BF,UACsBJ,iBAGpB,SAACC,UACHA,EAAMC,OAASN,mBAAWW,SAC1BH,UACsBJ,mBAIpB,SAACC,UACHO,QAAQC,OAAOC,OAAOT,EAAMU,aAAaC,SACzCR,UA9CmB,SAACH,eAA4BA,GA+C5CY,CAAeZ,EAAMU,iBAIvBG,EAAkBhB,EAAOiB,SACbf,2BCpDJ,oBAAEgB,MAAAA,aAAQ,SAAId,KAAAA,aAAON,mBAAWO,WAAMQ,gBAAkBM,KAAAA,kBAAOC,WAC3EC,gBAACtB,GAAqBK,KAAMA,EAAMS,uBAD8B,MAE7DM,GAAQE,gBAACL,OAAiBG,GAC1BD"}
package/dist/badge.esm.js DELETED
@@ -1,145 +0,0 @@
1
- import React from 'react';
2
- import styled, { css } from 'styled-components';
3
- import { spacing, white, borderRadius, actionColor, warningColor, errorColor, successColor } from '@propellerads/stylevariables';
4
-
5
- function _extends() {
6
- _extends = Object.assign || function (target) {
7
- for (var i = 1; i < arguments.length; i++) {
8
- var source = arguments[i];
9
-
10
- for (var key in source) {
11
- if (Object.prototype.hasOwnProperty.call(source, key)) {
12
- target[key] = source[key];
13
- }
14
- }
15
- }
16
-
17
- return target;
18
- };
19
-
20
- return _extends.apply(this, arguments);
21
- }
22
-
23
- function _taggedTemplateLiteralLoose(strings, raw) {
24
- if (!raw) {
25
- raw = strings.slice(0);
26
- }
27
-
28
- strings.raw = raw;
29
- return strings;
30
- }
31
-
32
- var BADGE_TYPE;
33
-
34
- (function (BADGE_TYPE) {
35
- BADGE_TYPE["INFO"] = "info";
36
- BADGE_TYPE["WARNING"] = "warning";
37
- BADGE_TYPE["DANGER"] = "danger";
38
- BADGE_TYPE["SUCCESS"] = "success";
39
- })(BADGE_TYPE || (BADGE_TYPE = {}));
40
-
41
- function _templateObject7() {
42
- var data = _taggedTemplateLiteralLoose(["\n margin-right: ", "px;\n display: flex;\n align-items: center;\n"]);
43
-
44
- _templateObject7 = function _templateObject7() {
45
- return data;
46
- };
47
-
48
- return data;
49
- }
50
-
51
- function _templateObject6() {
52
- var data = _taggedTemplateLiteralLoose(["\n ", ",\n "]);
53
-
54
- _templateObject6 = function _templateObject6() {
55
- return data;
56
- };
57
-
58
- return data;
59
- }
60
-
61
- function _templateObject5() {
62
- var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
63
-
64
- _templateObject5 = function _templateObject5() {
65
- return data;
66
- };
67
-
68
- return data;
69
- }
70
-
71
- function _templateObject4() {
72
- var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
73
-
74
- _templateObject4 = function _templateObject4() {
75
- return data;
76
- };
77
-
78
- return data;
79
- }
80
-
81
- function _templateObject3() {
82
- var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
83
-
84
- _templateObject3 = function _templateObject3() {
85
- return data;
86
- };
87
-
88
- return data;
89
- }
90
-
91
- function _templateObject2() {
92
- var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
93
-
94
- _templateObject2 = function _templateObject2() {
95
- return data;
96
- };
97
-
98
- return data;
99
- }
100
-
101
- function _templateObject() {
102
- var data = _taggedTemplateLiteralLoose(["\n display: inline-flex;\n align-items: center;\n padding: 0 ", "px;\n text-transform: uppercase;\n color: ", ";\n border-radius: ", "px;\n font-size: 10px;\n line-height: 1.5;\n min-height: 16px;\n\n // Color\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n // Have priority\n ", "\n"]);
103
-
104
- _templateObject = function _templateObject() {
105
- return data;
106
- };
107
-
108
- return data;
109
- }
110
-
111
- var getCustomStyle = function getCustomStyle(props) {
112
- return _extends({}, props);
113
- };
114
-
115
- var StyledBadgeContainer = /*#__PURE__*/styled.div( /*#__PURE__*/_templateObject(), spacing, white, borderRadius / 2, function (props) {
116
- return props.type === BADGE_TYPE.INFO && css(_templateObject2(), actionColor);
117
- }, function (props) {
118
- return props.type === BADGE_TYPE.WARNING && css(_templateObject3(), warningColor);
119
- }, function (props) {
120
- return props.type === BADGE_TYPE.DANGER && css(_templateObject4(), errorColor);
121
- }, function (props) {
122
- return props.type === BADGE_TYPE.SUCCESS && css(_templateObject5(), successColor);
123
- }, function (props) {
124
- return Boolean(Object.values(props.customStyle).length) && css(_templateObject6(), getCustomStyle(props.customStyle));
125
- });
126
- var StyledBadgeIcon = /*#__PURE__*/styled.span( /*#__PURE__*/_templateObject7(), spacing);
127
-
128
- var Badge = function Badge(_ref) {
129
- var _ref$label = _ref.label,
130
- label = _ref$label === void 0 ? '' : _ref$label,
131
- _ref$type = _ref.type,
132
- type = _ref$type === void 0 ? BADGE_TYPE.INFO : _ref$type,
133
- _ref$customStyle = _ref.customStyle,
134
- customStyle = _ref$customStyle === void 0 ? {} : _ref$customStyle,
135
- _ref$icon = _ref.icon,
136
- icon = _ref$icon === void 0 ? undefined : _ref$icon;
137
- return React.createElement(StyledBadgeContainer, {
138
- type: type,
139
- customStyle: customStyle
140
- }, icon && React.createElement(StyledBadgeIcon, null, icon), label);
141
- };
142
-
143
- export default Badge;
144
- export { BADGE_TYPE };
145
- //# sourceMappingURL=badge.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"badge.esm.js","sources":["../src/types.ts","../src/style.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\n\nexport enum BADGE_TYPE {\n INFO = 'info',\n WARNING = 'warning',\n DANGER = 'danger',\n SUCCESS = 'success',\n}\n\nexport interface CustomStyle {\n color?: string;\n background?: string;\n}\n\nexport interface BadgeProps {\n label?: React.ReactChildren | string | React.ComponentElement<any, any>;\n type?: BADGE_TYPE;\n customStyle?: CustomStyle;\n icon?: React.ComponentElement<any, any>;\n}\n\nexport default class Badge extends React.Component<BadgeProps> {}\n","import styled, {css} from 'styled-components';\nimport * as style from '@propellerads/stylevariables';\n\nimport {BADGE_TYPE, CustomStyle} from './types';\n\nconst getCustomStyle = (props: CustomStyle) => ({...props});\n\ninterface StyledBadgeContainerProps {\n type: BADGE_TYPE;\n customStyle: CustomStyle;\n}\n\nconst StyledBadgeContainer = styled.div`\n display: inline-flex;\n align-items: center;\n padding: 0 ${style.spacing}px;\n text-transform: uppercase;\n color: ${style.white};\n border-radius: ${style.borderRadius / 2}px;\n font-size: 10px;\n line-height: 1.5;\n min-height: 16px;\n\n // Color\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.INFO &&\n css`\n background-color: ${style.actionColor};\n `}\n\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.WARNING &&\n css`\n background-color: ${style.warningColor};\n `}\n\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.DANGER &&\n css`\n background-color: ${style.errorColor};\n `}\n\n ${(props: StyledBadgeContainerProps) =>\n props.type === BADGE_TYPE.SUCCESS &&\n css`\n background-color: ${style.successColor};\n `}\n\n // Have priority\n ${(props: StyledBadgeContainerProps) =>\n Boolean(Object.values(props.customStyle).length) &&\n css`\n ${getCustomStyle(props.customStyle)},\n `}\n`;\n\nconst StyledBadgeIcon = styled.span`\n margin-right: ${style.spacing}px;\n display: flex;\n align-items: center;\n`;\n\nexport {StyledBadgeContainer, StyledBadgeIcon};\n","import React from 'react';\n\nimport {StyledBadgeContainer, StyledBadgeIcon} from './style';\nimport {BADGE_TYPE, BadgeProps, CustomStyle} from './types';\n\nconst Badge = ({label = '', type = BADGE_TYPE.INFO, customStyle = {}, icon = undefined}: BadgeProps) => (\n <StyledBadgeContainer type={type} customStyle={customStyle}>\n {icon && <StyledBadgeIcon>{icon}</StyledBadgeIcon>}\n {label}\n </StyledBadgeContainer>\n);\n\nexport default Badge;\nexport {BADGE_TYPE, CustomStyle};\n"],"names":["BADGE_TYPE","getCustomStyle","props","StyledBadgeContainer","styled","div","style","type","INFO","css","WARNING","DANGER","SUCCESS","Boolean","Object","values","customStyle","length","StyledBadgeIcon","span","Badge","label","icon","undefined","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEYA;;AAAZ,WAAYA;AACVA,EAAAA,kBAAA,SAAA;AACAA,EAAAA,qBAAA,YAAA;AACAA,EAAAA,oBAAA,WAAA;AACAA,EAAAA,qBAAA,YAAA;AACD,CALD,EAAYA,UAAU,KAAVA,UAAU,KAAA,CAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACGA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,KAAD;AAAA,sBAA6BA,KAA7B;AAAA,CAAvB;;AAOA,IAAMC,oBAAoB,gBAAGC,MAAM,CAACC,GAAV,kCAGXC,OAHW,EAKfA,KALe,EAMPA,YAAA,GAAqB,CANd,EAYtB,UAACJ,KAAD;AAAA,SACAA,KAAK,CAACK,IAAN,KAAeP,UAAU,CAACQ,IAA1B,IACAC,GADA,qBAEsBH,WAFtB,CADA;AAAA,CAZsB,EAkBtB,UAACJ,KAAD;AAAA,SACAA,KAAK,CAACK,IAAN,KAAeP,UAAU,CAACU,OAA1B,IACAD,GADA,qBAEsBH,YAFtB,CADA;AAAA,CAlBsB,EAwBpB,UAACJ,KAAD;AAAA,SACFA,KAAK,CAACK,IAAN,KAAeP,UAAU,CAACW,MAA1B,IACAF,GADA,qBAEsBH,UAFtB,CADE;AAAA,CAxBoB,EA8BpB,UAACJ,KAAD;AAAA,SACFA,KAAK,CAACK,IAAN,KAAeP,UAAU,CAACY,OAA1B,IACAH,GADA,qBAEsBH,YAFtB,CADE;AAAA,CA9BoB,EAqCpB,UAACJ,KAAD;AAAA,SACFW,OAAO,CAACC,MAAM,CAACC,MAAP,CAAcb,KAAK,CAACc,WAApB,EAAiCC,MAAlC,CAAP,IACAR,GADA,qBAEIR,cAAc,CAACC,KAAK,CAACc,WAAP,CAFlB,CADE;AAAA,CArCoB,CAA1B;AA4CA,IAAME,eAAe,gBAAGd,MAAM,CAACe,IAAV,mCACHb,OADG,CAArB;;ACnDA,IAAMc,KAAK,GAAG,SAARA,KAAQ;AAAA,wBAAEC,KAAF;AAAA,MAAEA,KAAF,2BAAU,EAAV;AAAA,uBAAcd,IAAd;AAAA,MAAcA,IAAd,0BAAqBP,UAAU,CAACQ,IAAhC;AAAA,8BAAsCQ,WAAtC;AAAA,MAAsCA,WAAtC,iCAAoD,EAApD;AAAA,uBAAwDM,IAAxD;AAAA,MAAwDA,IAAxD,0BAA+DC,SAA/D;AAAA,SACZC,mBAAA,CAACrB,oBAAD;AAAsBI,IAAAA,IAAI,EAAEA;AAAMS,IAAAA,WAAW,EAAEA;GAA/C,EACGM,IAAI,IAAIE,mBAAA,CAACN,eAAD,MAAA,EAAkBI,IAAlB,CADX,EAEGD,KAFH,CADY;AAAA,CAAd;;;;;"}
package/dist/style.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare const StyledBadgeContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- declare const StyledBadgeIcon: import("styled-components").StyledComponent<"span", any, {}, never>;
3
- export { StyledBadgeContainer, StyledBadgeIcon };
package/dist/types.d.ts DELETED
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- export declare enum BADGE_TYPE {
3
- INFO = "info",
4
- WARNING = "warning",
5
- DANGER = "danger",
6
- SUCCESS = "success"
7
- }
8
- export interface CustomStyle {
9
- color?: string;
10
- background?: string;
11
- }
12
- export interface BadgeProps {
13
- label?: React.ReactChildren | string | React.ComponentElement<any, any>;
14
- type?: BADGE_TYPE;
15
- customStyle?: CustomStyle;
16
- icon?: React.ComponentElement<any, any>;
17
- }
18
- export default class Badge extends React.Component<BadgeProps> {
19
- }
package/src/index.tsx DELETED
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
-
3
- import {StyledBadgeContainer, StyledBadgeIcon} from './style';
4
- import {BADGE_TYPE, BadgeProps, CustomStyle} from './types';
5
-
6
- const Badge = ({label = '', type = BADGE_TYPE.INFO, customStyle = {}, icon = undefined}: BadgeProps) => (
7
- <StyledBadgeContainer type={type} customStyle={customStyle}>
8
- {icon && <StyledBadgeIcon>{icon}</StyledBadgeIcon>}
9
- {label}
10
- </StyledBadgeContainer>
11
- );
12
-
13
- export default Badge;
14
- export {BADGE_TYPE, CustomStyle};
package/src/style.tsx DELETED
@@ -1,63 +0,0 @@
1
- import styled, {css} from 'styled-components';
2
- import * as style from '@propellerads/stylevariables';
3
-
4
- import {BADGE_TYPE, CustomStyle} from './types';
5
-
6
- const getCustomStyle = (props: CustomStyle) => ({...props});
7
-
8
- interface StyledBadgeContainerProps {
9
- type: BADGE_TYPE;
10
- customStyle: CustomStyle;
11
- }
12
-
13
- const StyledBadgeContainer = styled.div`
14
- display: inline-flex;
15
- align-items: center;
16
- padding: 0 ${style.spacing}px;
17
- text-transform: uppercase;
18
- color: ${style.white};
19
- border-radius: ${style.borderRadius / 2}px;
20
- font-size: 10px;
21
- line-height: 1.5;
22
- min-height: 16px;
23
-
24
- // Color
25
- ${(props: StyledBadgeContainerProps) =>
26
- props.type === BADGE_TYPE.INFO &&
27
- css`
28
- background-color: ${style.actionColor};
29
- `}
30
-
31
- ${(props: StyledBadgeContainerProps) =>
32
- props.type === BADGE_TYPE.WARNING &&
33
- css`
34
- background-color: ${style.warningColor};
35
- `}
36
-
37
- ${(props: StyledBadgeContainerProps) =>
38
- props.type === BADGE_TYPE.DANGER &&
39
- css`
40
- background-color: ${style.errorColor};
41
- `}
42
-
43
- ${(props: StyledBadgeContainerProps) =>
44
- props.type === BADGE_TYPE.SUCCESS &&
45
- css`
46
- background-color: ${style.successColor};
47
- `}
48
-
49
- // Have priority
50
- ${(props: StyledBadgeContainerProps) =>
51
- Boolean(Object.values(props.customStyle).length) &&
52
- css`
53
- ${getCustomStyle(props.customStyle)},
54
- `}
55
- `;
56
-
57
- const StyledBadgeIcon = styled.span`
58
- margin-right: ${style.spacing}px;
59
- display: flex;
60
- align-items: center;
61
- `;
62
-
63
- export {StyledBadgeContainer, StyledBadgeIcon};
package/src/types.ts DELETED
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
-
3
- export enum BADGE_TYPE {
4
- INFO = 'info',
5
- WARNING = 'warning',
6
- DANGER = 'danger',
7
- SUCCESS = 'success',
8
- }
9
-
10
- export interface CustomStyle {
11
- color?: string;
12
- background?: string;
13
- }
14
-
15
- export interface BadgeProps {
16
- label?: React.ReactChildren | string | React.ComponentElement<any, any>;
17
- type?: BADGE_TYPE;
18
- customStyle?: CustomStyle;
19
- icon?: React.ComponentElement<any, any>;
20
- }
21
-
22
- export default class Badge extends React.Component<BadgeProps> {}