@propellerads/badge 2.4.0 → 3.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/badge.cjs.development.js +7 -7
- package/dist/badge.cjs.development.js.map +1 -1
- package/dist/badge.cjs.production.min.js +1 -1
- package/dist/badge.cjs.production.min.js.map +1 -1
- package/dist/badge.esm.js +7 -7
- package/dist/badge.esm.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/style.d.ts +1 -6
- package/package.json +7 -10
- package/src/index.tsx +2 -11
- package/src/style.tsx +37 -27
- package/src/types.ts +10 -10
- package/CHANGELOG.md +0 -25
|
@@ -44,7 +44,7 @@ function _taggedTemplateLiteralLoose(strings, raw) {
|
|
|
44
44
|
})(exports.BADGE_TYPE || (exports.BADGE_TYPE = {}));
|
|
45
45
|
|
|
46
46
|
function _templateObject7() {
|
|
47
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
47
|
+
var data = _taggedTemplateLiteralLoose(["\n margin-right: ", "px;\n display: flex;\n align-items: center;\n"]);
|
|
48
48
|
|
|
49
49
|
_templateObject7 = function _templateObject7() {
|
|
50
50
|
return data;
|
|
@@ -54,7 +54,7 @@ function _templateObject7() {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
function _templateObject6() {
|
|
57
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
57
|
+
var data = _taggedTemplateLiteralLoose(["\n ", ",\n "]);
|
|
58
58
|
|
|
59
59
|
_templateObject6 = function _templateObject6() {
|
|
60
60
|
return data;
|
|
@@ -64,7 +64,7 @@ function _templateObject6() {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
function _templateObject5() {
|
|
67
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
67
|
+
var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
|
|
68
68
|
|
|
69
69
|
_templateObject5 = function _templateObject5() {
|
|
70
70
|
return data;
|
|
@@ -74,7 +74,7 @@ function _templateObject5() {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
function _templateObject4() {
|
|
77
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
77
|
+
var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
|
|
78
78
|
|
|
79
79
|
_templateObject4 = function _templateObject4() {
|
|
80
80
|
return data;
|
|
@@ -84,7 +84,7 @@ function _templateObject4() {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
function _templateObject3() {
|
|
87
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
87
|
+
var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
|
|
88
88
|
|
|
89
89
|
_templateObject3 = function _templateObject3() {
|
|
90
90
|
return data;
|
|
@@ -94,7 +94,7 @@ function _templateObject3() {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
function _templateObject2() {
|
|
97
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
97
|
+
var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
|
|
98
98
|
|
|
99
99
|
_templateObject2 = function _templateObject2() {
|
|
100
100
|
return data;
|
|
@@ -104,7 +104,7 @@ function _templateObject2() {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
function _templateObject() {
|
|
107
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
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
108
|
|
|
109
109
|
_templateObject = function _templateObject() {
|
|
110
110
|
return data;
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 +1,2 @@
|
|
|
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
|
|
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
2
|
//# sourceMappingURL=badge.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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,uyCAAAA,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
CHANGED
|
@@ -39,7 +39,7 @@ var BADGE_TYPE;
|
|
|
39
39
|
})(BADGE_TYPE || (BADGE_TYPE = {}));
|
|
40
40
|
|
|
41
41
|
function _templateObject7() {
|
|
42
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
42
|
+
var data = _taggedTemplateLiteralLoose(["\n margin-right: ", "px;\n display: flex;\n align-items: center;\n"]);
|
|
43
43
|
|
|
44
44
|
_templateObject7 = function _templateObject7() {
|
|
45
45
|
return data;
|
|
@@ -49,7 +49,7 @@ function _templateObject7() {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function _templateObject6() {
|
|
52
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
52
|
+
var data = _taggedTemplateLiteralLoose(["\n ", ",\n "]);
|
|
53
53
|
|
|
54
54
|
_templateObject6 = function _templateObject6() {
|
|
55
55
|
return data;
|
|
@@ -59,7 +59,7 @@ function _templateObject6() {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function _templateObject5() {
|
|
62
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
62
|
+
var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
|
|
63
63
|
|
|
64
64
|
_templateObject5 = function _templateObject5() {
|
|
65
65
|
return data;
|
|
@@ -69,7 +69,7 @@ function _templateObject5() {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function _templateObject4() {
|
|
72
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
72
|
+
var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
|
|
73
73
|
|
|
74
74
|
_templateObject4 = function _templateObject4() {
|
|
75
75
|
return data;
|
|
@@ -79,7 +79,7 @@ function _templateObject4() {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
function _templateObject3() {
|
|
82
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
82
|
+
var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
|
|
83
83
|
|
|
84
84
|
_templateObject3 = function _templateObject3() {
|
|
85
85
|
return data;
|
|
@@ -89,7 +89,7 @@ function _templateObject3() {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function _templateObject2() {
|
|
92
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
92
|
+
var data = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "]);
|
|
93
93
|
|
|
94
94
|
_templateObject2 = function _templateObject2() {
|
|
95
95
|
return data;
|
|
@@ -99,7 +99,7 @@ function _templateObject2() {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
function _templateObject() {
|
|
102
|
-
var data = _taggedTemplateLiteralLoose(["\n
|
|
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
103
|
|
|
104
104
|
_templateObject = function _templateObject() {
|
|
105
105
|
return data;
|
package/dist/badge.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { BADGE_TYPE, BadgeProps, CustomStyle } from './types';
|
|
2
|
-
declare const Badge: ({ label, type, customStyle, icon
|
|
3
|
+
declare const Badge: ({ label, type, customStyle, icon }: BadgeProps) => React.JSX.Element;
|
|
3
4
|
export default Badge;
|
|
4
5
|
export { BADGE_TYPE, CustomStyle };
|
package/dist/style.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
interface StyledBadgeContainerProps {
|
|
3
|
-
type: BADGE_TYPE;
|
|
4
|
-
customStyle: CustomStyle;
|
|
5
|
-
}
|
|
6
|
-
declare const StyledBadgeContainer: import("styled-components").StyledComponent<"div", any, StyledBadgeContainerProps, never>;
|
|
1
|
+
declare const StyledBadgeContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
2
|
declare const StyledBadgeIcon: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
8
3
|
export { StyledBadgeContainer, StyledBadgeIcon };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/badge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"repository": "https://github.com/propellerads/ui-components",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,21 +20,18 @@
|
|
|
20
20
|
"build": "tsdx build"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"@types/styled-components": "5.1.
|
|
26
|
-
"react": "^17.0.2",
|
|
27
|
-
"react-dom": "^17.0.2",
|
|
28
|
-
"styled-components": "5.1.1"
|
|
23
|
+
"react": ">=18 <19",
|
|
24
|
+
"styled-components": "5.1.1",
|
|
25
|
+
"@types/styled-components": "5.1.34"
|
|
29
26
|
},
|
|
30
27
|
"module": "dist/badge.esm.js",
|
|
31
28
|
"devDependencies": {
|
|
32
29
|
"tsdx": "^0.13.3",
|
|
33
30
|
"tslib": "^2.0.1",
|
|
34
|
-
"typescript": "^4.
|
|
31
|
+
"typescript": "^4.9.5",
|
|
32
|
+
"@types/react": ">=18 <19"
|
|
35
33
|
},
|
|
36
34
|
"dependencies": {
|
|
37
35
|
"@propellerads/stylevariables": "^1.3.0"
|
|
38
|
-
}
|
|
39
|
-
"gitHead": "82824622b4ac991d78567c473a46b5044cd72035"
|
|
36
|
+
}
|
|
40
37
|
}
|
package/src/index.tsx
CHANGED
|
@@ -3,18 +3,9 @@ import React from 'react';
|
|
|
3
3
|
import {StyledBadgeContainer, StyledBadgeIcon} from './style';
|
|
4
4
|
import {BADGE_TYPE, BadgeProps, CustomStyle} from './types';
|
|
5
5
|
|
|
6
|
-
const Badge = ({
|
|
7
|
-
label = '',
|
|
8
|
-
type = BADGE_TYPE.INFO,
|
|
9
|
-
customStyle = {},
|
|
10
|
-
icon = undefined,
|
|
11
|
-
}: BadgeProps) => (
|
|
6
|
+
const Badge = ({label = '', type = BADGE_TYPE.INFO, customStyle = {}, icon = undefined}: BadgeProps) => (
|
|
12
7
|
<StyledBadgeContainer type={type} customStyle={customStyle}>
|
|
13
|
-
{icon &&
|
|
14
|
-
<StyledBadgeIcon>
|
|
15
|
-
{icon}
|
|
16
|
-
</StyledBadgeIcon>
|
|
17
|
-
)}
|
|
8
|
+
{icon && <StyledBadgeIcon>{icon}</StyledBadgeIcon>}
|
|
18
9
|
{label}
|
|
19
10
|
</StyledBadgeContainer>
|
|
20
11
|
);
|
package/src/style.tsx
CHANGED
|
@@ -6,48 +6,58 @@ import {BADGE_TYPE, CustomStyle} from './types';
|
|
|
6
6
|
const getCustomStyle = (props: CustomStyle) => ({...props});
|
|
7
7
|
|
|
8
8
|
interface StyledBadgeContainerProps {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
type: BADGE_TYPE;
|
|
10
|
+
customStyle: CustomStyle;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const StyledBadgeContainer = styled.div`
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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};
|
|
27
29
|
`}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
${(props: StyledBadgeContainerProps) =>
|
|
32
|
+
props.type === BADGE_TYPE.WARNING &&
|
|
33
|
+
css`
|
|
34
|
+
background-color: ${style.warningColor};
|
|
31
35
|
`}
|
|
32
36
|
|
|
33
|
-
${(props: StyledBadgeContainerProps) =>
|
|
34
|
-
|
|
37
|
+
${(props: StyledBadgeContainerProps) =>
|
|
38
|
+
props.type === BADGE_TYPE.DANGER &&
|
|
39
|
+
css`
|
|
40
|
+
background-color: ${style.errorColor};
|
|
35
41
|
`}
|
|
36
42
|
|
|
37
|
-
${(props: StyledBadgeContainerProps) =>
|
|
38
|
-
|
|
43
|
+
${(props: StyledBadgeContainerProps) =>
|
|
44
|
+
props.type === BADGE_TYPE.SUCCESS &&
|
|
45
|
+
css`
|
|
46
|
+
background-color: ${style.successColor};
|
|
39
47
|
`}
|
|
40
48
|
|
|
41
49
|
// Have priority
|
|
42
|
-
${(props: StyledBadgeContainerProps) =>
|
|
43
|
-
|
|
50
|
+
${(props: StyledBadgeContainerProps) =>
|
|
51
|
+
Boolean(Object.values(props.customStyle).length) &&
|
|
52
|
+
css`
|
|
53
|
+
${getCustomStyle(props.customStyle)},
|
|
44
54
|
`}
|
|
45
55
|
`;
|
|
46
56
|
|
|
47
57
|
const StyledBadgeIcon = styled.span`
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
margin-right: ${style.spacing}px;
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
51
61
|
`;
|
|
52
62
|
|
|
53
63
|
export {StyledBadgeContainer, StyledBadgeIcon};
|
package/src/types.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
export enum BADGE_TYPE {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
INFO = 'info',
|
|
5
|
+
WARNING = 'warning',
|
|
6
|
+
DANGER = 'danger',
|
|
7
|
+
SUCCESS = 'success',
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface CustomStyle {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
color?: string;
|
|
12
|
+
background?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface BadgeProps {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
label?: React.ReactChildren | string | React.ComponentElement<any, any>;
|
|
17
|
+
type?: BADGE_TYPE;
|
|
18
|
+
customStyle?: CustomStyle;
|
|
19
|
+
icon?: React.ComponentElement<any, any>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export default class Badge extends React.Component<BadgeProps> {}
|
package/CHANGELOG.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
### `2.4.0`
|
|
2
|
-
* updated peerDependencies
|
|
3
|
-
|
|
4
|
-
#### `2.3.0`
|
|
5
|
-
* update style-variables
|
|
6
|
-
* apply new border-radius 8px
|
|
7
|
-
|
|
8
|
-
#### `2.2.0`
|
|
9
|
-
|
|
10
|
-
* exported interface `CustomStyle`
|
|
11
|
-
* Badge component exported as default module
|
|
12
|
-
|
|
13
|
-
#### `2.1.0`
|
|
14
|
-
|
|
15
|
-
* exported enum `BADGE_TYPE`
|
|
16
|
-
|
|
17
|
-
#### `2.0.0`
|
|
18
|
-
|
|
19
|
-
* TS
|
|
20
|
-
* Production build
|
|
21
|
-
* Breaking changes - an icon component became external
|
|
22
|
-
|
|
23
|
-
#### `1.1.0`
|
|
24
|
-
|
|
25
|
-
* Badge styles now fully customizable
|