@propellerads/badge 3.0.2 → 4.0.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.
- package/dist/index.d.ts +21 -6
- package/dist/index.js +38 -8
- package/dist/index.js.map +1 -0
- package/package.json +28 -23
- package/dist/badge.cjs.development.js +0 -65
- package/dist/badge.cjs.development.js.map +0 -1
- package/dist/badge.cjs.production.min.js +0 -2
- package/dist/badge.cjs.production.min.js.map +0 -1
- package/dist/badge.esm.js +0 -60
- package/dist/badge.esm.js.map +0 -1
- package/dist/style.d.ts +0 -8
- package/dist/types.d.ts +0 -19
- package/src/index.tsx +0 -15
- package/src/style.tsx +0 -63
- package/src/types.ts +0 -22
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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,36 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/badge",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
"version": "4.0.1",
|
|
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
|
-
"
|
|
15
|
-
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/propellerads/ui-components/issues"
|
|
16
20
|
},
|
|
17
21
|
"scripts": {
|
|
18
|
-
"
|
|
19
|
-
|
|
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"
|
|
20
28
|
},
|
|
21
29
|
"peerDependencies": {
|
|
22
|
-
"react": "
|
|
23
|
-
"styled-components": "5.1.1"
|
|
30
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
31
|
+
"styled-components": "^5.1.1 || ^6.0.0"
|
|
24
32
|
},
|
|
25
|
-
"module": "dist/badge.esm.js",
|
|
26
33
|
"devDependencies": {
|
|
27
|
-
"@types/
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@propellerads/stylevariables": "^2.0.1"
|
|
34
|
+
"@types/react": "^19.2.14",
|
|
35
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
36
|
+
"rollup": "^4.58.0",
|
|
37
|
+
"rollup-plugin-dts": "^6.3.0",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"vite": "^7.3.1"
|
|
35
40
|
}
|
|
36
41
|
}
|
|
@@ -1,65 +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
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
14
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
15
|
-
var t = arguments[e];
|
|
16
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
17
|
-
}
|
|
18
|
-
return n;
|
|
19
|
-
}, _extends.apply(null, arguments);
|
|
20
|
-
}
|
|
21
|
-
function _taggedTemplateLiteralLoose(e, t) {
|
|
22
|
-
return t || (t = e.slice(0)), e.raw = t, e;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
(function (BADGE_TYPE) {
|
|
26
|
-
BADGE_TYPE["INFO"] = "info";
|
|
27
|
-
BADGE_TYPE["WARNING"] = "warning";
|
|
28
|
-
BADGE_TYPE["DANGER"] = "danger";
|
|
29
|
-
BADGE_TYPE["SUCCESS"] = "success";
|
|
30
|
-
})(exports.BADGE_TYPE || (exports.BADGE_TYPE = {}));
|
|
31
|
-
|
|
32
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
33
|
-
var getCustomStyle = function getCustomStyle(props) {
|
|
34
|
-
return _extends({}, props);
|
|
35
|
-
};
|
|
36
|
-
var StyledBadgeContainer = /*#__PURE__*/styled__default.div(_templateObject || (_templateObject = /*#__PURE__*/_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"])), style.spacing, style.white, style.borderRadius / 2, function (props) {
|
|
37
|
-
return props.type === exports.BADGE_TYPE.INFO && styled.css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "])), style.actionColor);
|
|
38
|
-
}, function (props) {
|
|
39
|
-
return props.type === exports.BADGE_TYPE.WARNING && styled.css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "])), style.warningColor);
|
|
40
|
-
}, function (props) {
|
|
41
|
-
return props.type === exports.BADGE_TYPE.DANGER && styled.css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "])), style.errorColor);
|
|
42
|
-
}, function (props) {
|
|
43
|
-
return props.type === exports.BADGE_TYPE.SUCCESS && styled.css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "])), style.successColor);
|
|
44
|
-
}, function (props) {
|
|
45
|
-
return Boolean(Object.values(props.customStyle).length) && styled.css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n ", ",\n "])), getCustomStyle(props.customStyle));
|
|
46
|
-
});
|
|
47
|
-
var StyledBadgeIcon = /*#__PURE__*/styled__default.span(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-right: ", "px;\n display: flex;\n align-items: center;\n"])), style.spacing);
|
|
48
|
-
|
|
49
|
-
var Badge = function Badge(_ref) {
|
|
50
|
-
var _ref$label = _ref.label,
|
|
51
|
-
label = _ref$label === void 0 ? '' : _ref$label,
|
|
52
|
-
_ref$type = _ref.type,
|
|
53
|
-
type = _ref$type === void 0 ? exports.BADGE_TYPE.INFO : _ref$type,
|
|
54
|
-
_ref$customStyle = _ref.customStyle,
|
|
55
|
-
customStyle = _ref$customStyle === void 0 ? {} : _ref$customStyle,
|
|
56
|
-
_ref$icon = _ref.icon,
|
|
57
|
-
icon = _ref$icon === void 0 ? undefined : _ref$icon;
|
|
58
|
-
return React.createElement(StyledBadgeContainer, {
|
|
59
|
-
type: type,
|
|
60
|
-
customStyle: customStyle
|
|
61
|
-
}, icon && React.createElement(StyledBadgeIcon, null, icon), label);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
exports.default = Badge;
|
|
65
|
-
//# 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, {ReactNode} 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?: ReactNode;\n type?: BADGE_TYPE;\n customStyle?: CustomStyle;\n icon?: ReactNode;\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};\nexport type {CustomStyle};\n"],"names":["BADGE_TYPE","getCustomStyle","props","_extends","StyledBadgeContainer","styled","div","_templateObject","_taggedTemplateLiteralLoose","style","type","INFO","css","_templateObject2","WARNING","_templateObject3","DANGER","_templateObject4","SUCCESS","_templateObject5","Boolean","Object","values","customStyle","length","_templateObject6","StyledBadgeIcon","span","_templateObject7","Badge","_ref","_ref$label","label","_ref$type","_ref$customStyle","_ref$icon","icon","undefined","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEA,WAAYA,UAAU;EACpBA,2BAAa;EACbA,iCAAmB;EACnBA,+BAAiB;EACjBA,iCAAmB;AACrB,CAAC,EALWA,kBAAU,KAAVA,kBAAU;;;ACFtB,AAKA,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAIC,KAAkB;EAAA,OAAAC,QAAA,KAAUD,KAAK;AAAA,CAAE;AAO3D,IAAME,oBAAoB,gBAAGC,eAAM,CAACC,GAAG,CAAAC,eAAA,KAAAA,eAAA,gBAAAC,2BAAA,kTAGxBC,aAAa,EAEjBA,WAAW,EACHA,kBAAkB,GAAG,CAAC,EAMrC,UAACP,KAAgC;EAAA,OACjCA,KAAK,CAACQ,IAAI,KAAKV,kBAAU,CAACW,IAAI,IAC9BC,UAAG,CAAAC,gBAAA,KAAAA,gBAAA,GAAAL,2BAAA,8CACmBC,iBAAiB,CACtC;AAAA,GAED,UAACP,KAAgC;EAAA,OACjCA,KAAK,CAACQ,IAAI,KAAKV,kBAAU,CAACc,OAAO,IACjCF,UAAG,CAAAG,gBAAA,KAAAA,gBAAA,GAAAP,2BAAA,8CACmBC,kBAAkB,CACvC;AAAA,GAEC,UAACP,KAAgC;EAAA,OACnCA,KAAK,CAACQ,IAAI,KAAKV,kBAAU,CAACgB,MAAM,IAChCJ,UAAG,CAAAK,gBAAA,KAAAA,gBAAA,GAAAT,2BAAA,8CACmBC,gBAAgB,CACrC;AAAA,GAEC,UAACP,KAAgC;EAAA,OACnCA,KAAK,CAACQ,IAAI,KAAKV,kBAAU,CAACkB,OAAO,IACjCN,UAAG,CAAAO,gBAAA,KAAAA,gBAAA,GAAAX,2BAAA,8CACmBC,kBAAkB,CACvC;AAAA,GAGC,UAACP,KAAgC;EAAA,OACnCkB,OAAO,CAACC,MAAM,CAACC,MAAM,CAACpB,KAAK,CAACqB,WAAW,CAAC,CAACC,MAAM,CAAC,IAChDZ,UAAG,CAAAa,gBAAA,KAAAA,gBAAA,GAAAjB,2BAAA,4BACCP,cAAc,CAACC,KAAK,CAACqB,WAAW,CAAC,CACpC;AAAA,EACJ;AAED,IAAMG,eAAe,gBAAGrB,eAAM,CAACsB,IAAI,CAAAC,gBAAA,KAAAA,gBAAA,gBAAApB,2BAAA,8EACjBC,aAAa,CAG9B;;ACvDD,IAAMoB,KAAK,GAAG,SAARA,KAAKA,CAAAC,IAAA;EAAA,IAAAC,UAAA,GAAAD,IAAA,CAAKE,KAAK;IAALA,KAAK,GAAAD,UAAA,cAAG,EAAE,GAAAA,UAAA;IAAAE,SAAA,GAAAH,IAAA,CAAEpB,IAAI;IAAJA,IAAI,GAAAuB,SAAA,cAAGjC,kBAAU,CAACW,IAAI,GAAAsB,SAAA;IAAAC,gBAAA,GAAAJ,IAAA,CAAEP,WAAW;IAAXA,WAAW,GAAAW,gBAAA,cAAG,EAAE,GAAAA,gBAAA;IAAAC,SAAA,GAAAL,IAAA,CAAEM,IAAI;IAAJA,IAAI,GAAAD,SAAA,cAAGE,SAAS,GAAAF,SAAA;EAAA,OACpFG,oBAAClC,oBAAoB;IAACM,IAAI,EAAEA,IAAI;IAAEa,WAAW,EAAEA;KAC5Ca,IAAI,IAAIE,oBAACZ,eAAe,QAAEU,IAAI,CAAmB,EACjDJ,KAAK,CACe;AAAA,CACxB;;;;"}
|
|
@@ -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 e,r,t,o,i,s,c,l,a=n(require("react")),u=require("styled-components"),p=n(u),d=require("@propellerads/stylevariables");function f(){return(f=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)({}).hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n}).apply(null,arguments)}function g(n,e){return e||(e=n.slice(0)),n.raw=e,n}(e=exports.BADGE_TYPE||(exports.BADGE_TYPE={})).INFO="info",e.WARNING="warning",e.DANGER="danger",e.SUCCESS="success";var E=p.div(r||(r=g(["\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"])),d.spacing,d.white,d.borderRadius/2,(function(n){return n.type===exports.BADGE_TYPE.INFO&&u.css(t||(t=g(["\n background-color: ",";\n "])),d.actionColor)}),(function(n){return n.type===exports.BADGE_TYPE.WARNING&&u.css(o||(o=g(["\n background-color: ",";\n "])),d.warningColor)}),(function(n){return n.type===exports.BADGE_TYPE.DANGER&&u.css(i||(i=g(["\n background-color: ",";\n "])),d.errorColor)}),(function(n){return n.type===exports.BADGE_TYPE.SUCCESS&&u.css(s||(s=g(["\n background-color: ",";\n "])),d.successColor)}),(function(n){return Boolean(Object.values(n.customStyle).length)&&u.css(c||(c=g(["\n ",",\n "])),function(n){return f({},n)}(n.customStyle))})),y=p.span(l||(l=g(["\n margin-right: ","px;\n display: flex;\n align-items: center;\n"])),d.spacing);exports.default=function(n){var e=n.label,r=void 0===e?"":e,t=n.type,o=void 0===t?exports.BADGE_TYPE.INFO:t,i=n.customStyle,s=n.icon,c=void 0===s?void 0:s;return a.createElement(E,{type:o,customStyle:void 0===i?{}:i},c&&a.createElement(y,null,c),r)};
|
|
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, {ReactNode} 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?: ReactNode;\n type?: BADGE_TYPE;\n customStyle?: CustomStyle;\n icon?: ReactNode;\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};\nexport type {CustomStyle};\n"],"names":["BADGE_TYPE","StyledBadgeContainer","styled","div","_templateObject","_taggedTemplateLiteralLoose","style","props","type","INFO","css","_templateObject2","WARNING","_templateObject3","DANGER","_templateObject4","SUCCESS","_templateObject5","Boolean","Object","values","customStyle","length","_templateObject6","_extends","getCustomStyle","StyledBadgeIcon","span","_templateObject7","_ref","_ref$label","label","_ref$type","_ref$customStyle","_ref$icon","icon","undefined","React"],"mappings":"8IAEYA,iYAAAA,EAAAA,qBAAAA,oCAEVA,oBACAA,kBACAA,oBCDF,IAOMC,EAAuBC,EAAOC,IAAGC,IAAAA,EAAAC,0SAGxBC,UAEJA,QACQA,eAAqB,GAMpC,SAACC,GAAgC,OACjCA,EAAMC,OAASR,mBAAWS,MAC1BC,MAAGC,IAAAA,EAAAN,6CACmBC,kBAGtB,SAACC,GAAgC,OACjCA,EAAMC,OAASR,mBAAWY,SAC1BF,MAAGG,IAAAA,EAAAR,6CACmBC,mBAGpB,SAACC,GAAgC,OACnCA,EAAMC,OAASR,mBAAWc,QAC1BJ,MAAGK,IAAAA,EAAAV,6CACmBC,iBAGpB,SAACC,GAAgC,OACnCA,EAAMC,OAASR,mBAAWgB,SAC1BN,MAAGO,IAAAA,EAAAZ,6CACmBC,mBAIpB,SAACC,GAAgC,OACnCW,QAAQC,OAAOC,OAAOb,EAAMc,aAAaC,SACzCZ,MAAGa,IAAAA,EAAAlB,2BA9CgB,SAACE,GAAkB,OAAAiB,KAAUjB,GA+C5CkB,CAAelB,EAAMc,iBAIvBK,EAAkBxB,EAAOyB,KAAIC,IAAAA,EAAAvB,6EACjBC,2BCpDJ,SAAHuB,GAAA,IAAAC,EAAAD,EAAKE,MAAAA,WAAKD,EAAG,GAAEA,EAAAE,EAAAH,EAAErB,KAAAA,WAAIwB,EAAGhC,mBAAWS,KAAIuB,EAAAC,EAAAJ,EAAER,YAAgBa,EAAAL,EAAEM,KAAAA,WAAID,OAAGE,EAASF,EAAA,OACpFG,gBAACpC,GAAqBO,KAAMA,EAAMa,qBAD2BY,EAAG,GAAEA,GAE/DE,GAAQE,gBAACX,OAAiBS,GAC1BJ"}
|
package/dist/badge.esm.js
DELETED
|
@@ -1,60 +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
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
7
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
8
|
-
var t = arguments[e];
|
|
9
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
10
|
-
}
|
|
11
|
-
return n;
|
|
12
|
-
}, _extends.apply(null, arguments);
|
|
13
|
-
}
|
|
14
|
-
function _taggedTemplateLiteralLoose(e, t) {
|
|
15
|
-
return t || (t = e.slice(0)), e.raw = t, e;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
var BADGE_TYPE;
|
|
19
|
-
(function (BADGE_TYPE) {
|
|
20
|
-
BADGE_TYPE["INFO"] = "info";
|
|
21
|
-
BADGE_TYPE["WARNING"] = "warning";
|
|
22
|
-
BADGE_TYPE["DANGER"] = "danger";
|
|
23
|
-
BADGE_TYPE["SUCCESS"] = "success";
|
|
24
|
-
})(BADGE_TYPE || (BADGE_TYPE = {}));
|
|
25
|
-
|
|
26
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
27
|
-
var getCustomStyle = function getCustomStyle(props) {
|
|
28
|
-
return _extends({}, props);
|
|
29
|
-
};
|
|
30
|
-
var StyledBadgeContainer = /*#__PURE__*/styled.div(_templateObject || (_templateObject = /*#__PURE__*/_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"])), spacing, white, borderRadius / 2, function (props) {
|
|
31
|
-
return props.type === BADGE_TYPE.INFO && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "])), actionColor);
|
|
32
|
-
}, function (props) {
|
|
33
|
-
return props.type === BADGE_TYPE.WARNING && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "])), warningColor);
|
|
34
|
-
}, function (props) {
|
|
35
|
-
return props.type === BADGE_TYPE.DANGER && css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "])), errorColor);
|
|
36
|
-
}, function (props) {
|
|
37
|
-
return props.type === BADGE_TYPE.SUCCESS && css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "])), successColor);
|
|
38
|
-
}, function (props) {
|
|
39
|
-
return Boolean(Object.values(props.customStyle).length) && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n ", ",\n "])), getCustomStyle(props.customStyle));
|
|
40
|
-
});
|
|
41
|
-
var StyledBadgeIcon = /*#__PURE__*/styled.span(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-right: ", "px;\n display: flex;\n align-items: center;\n"])), spacing);
|
|
42
|
-
|
|
43
|
-
var Badge = function Badge(_ref) {
|
|
44
|
-
var _ref$label = _ref.label,
|
|
45
|
-
label = _ref$label === void 0 ? '' : _ref$label,
|
|
46
|
-
_ref$type = _ref.type,
|
|
47
|
-
type = _ref$type === void 0 ? BADGE_TYPE.INFO : _ref$type,
|
|
48
|
-
_ref$customStyle = _ref.customStyle,
|
|
49
|
-
customStyle = _ref$customStyle === void 0 ? {} : _ref$customStyle,
|
|
50
|
-
_ref$icon = _ref.icon,
|
|
51
|
-
icon = _ref$icon === void 0 ? undefined : _ref$icon;
|
|
52
|
-
return React.createElement(StyledBadgeContainer, {
|
|
53
|
-
type: type,
|
|
54
|
-
customStyle: customStyle
|
|
55
|
-
}, icon && React.createElement(StyledBadgeIcon, null, icon), label);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default Badge;
|
|
59
|
-
export { BADGE_TYPE };
|
|
60
|
-
//# sourceMappingURL=badge.esm.js.map
|
package/dist/badge.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"badge.esm.js","sources":["../src/types.ts","../src/style.tsx","../src/index.tsx"],"sourcesContent":["import React, {ReactNode} 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?: ReactNode;\n type?: BADGE_TYPE;\n customStyle?: CustomStyle;\n icon?: ReactNode;\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};\nexport type {CustomStyle};\n"],"names":["BADGE_TYPE","getCustomStyle","props","_extends","StyledBadgeContainer","styled","div","_templateObject","_taggedTemplateLiteralLoose","style","type","INFO","css","_templateObject2","WARNING","_templateObject3","DANGER","_templateObject4","SUCCESS","_templateObject5","Boolean","Object","values","customStyle","length","_templateObject6","StyledBadgeIcon","span","_templateObject7","Badge","_ref","_ref$label","label","_ref$type","_ref$customStyle","_ref$icon","icon","undefined","React"],"mappings":";;;;;;;;;;;;;;;;;IAEYA;AAAZ,WAAYA,UAAU;EACpBA,2BAAa;EACbA,iCAAmB;EACnBA,+BAAiB;EACjBA,iCAAmB;AACrB,CAAC,EALWA,UAAU,KAAVA,UAAU;;;ACFtB,AAKA,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAIC,KAAkB;EAAA,OAAAC,QAAA,KAAUD,KAAK;AAAA,CAAE;AAO3D,IAAME,oBAAoB,gBAAGC,MAAM,CAACC,GAAG,CAAAC,eAAA,KAAAA,eAAA,gBAAAC,2BAAA,kTAGxBC,OAAa,EAEjBA,KAAW,EACHA,YAAkB,GAAG,CAAC,EAMrC,UAACP,KAAgC;EAAA,OACjCA,KAAK,CAACQ,IAAI,KAAKV,UAAU,CAACW,IAAI,IAC9BC,GAAG,CAAAC,gBAAA,KAAAA,gBAAA,GAAAL,2BAAA,8CACmBC,WAAiB,CACtC;AAAA,GAED,UAACP,KAAgC;EAAA,OACjCA,KAAK,CAACQ,IAAI,KAAKV,UAAU,CAACc,OAAO,IACjCF,GAAG,CAAAG,gBAAA,KAAAA,gBAAA,GAAAP,2BAAA,8CACmBC,YAAkB,CACvC;AAAA,GAEC,UAACP,KAAgC;EAAA,OACnCA,KAAK,CAACQ,IAAI,KAAKV,UAAU,CAACgB,MAAM,IAChCJ,GAAG,CAAAK,gBAAA,KAAAA,gBAAA,GAAAT,2BAAA,8CACmBC,UAAgB,CACrC;AAAA,GAEC,UAACP,KAAgC;EAAA,OACnCA,KAAK,CAACQ,IAAI,KAAKV,UAAU,CAACkB,OAAO,IACjCN,GAAG,CAAAO,gBAAA,KAAAA,gBAAA,GAAAX,2BAAA,8CACmBC,YAAkB,CACvC;AAAA,GAGC,UAACP,KAAgC;EAAA,OACnCkB,OAAO,CAACC,MAAM,CAACC,MAAM,CAACpB,KAAK,CAACqB,WAAW,CAAC,CAACC,MAAM,CAAC,IAChDZ,GAAG,CAAAa,gBAAA,KAAAA,gBAAA,GAAAjB,2BAAA,4BACCP,cAAc,CAACC,KAAK,CAACqB,WAAW,CAAC,CACpC;AAAA,EACJ;AAED,IAAMG,eAAe,gBAAGrB,MAAM,CAACsB,IAAI,CAAAC,gBAAA,KAAAA,gBAAA,gBAAApB,2BAAA,8EACjBC,OAAa,CAG9B;;ACvDD,IAAMoB,KAAK,GAAG,SAARA,KAAKA,CAAAC,IAAA;EAAA,IAAAC,UAAA,GAAAD,IAAA,CAAKE,KAAK;IAALA,KAAK,GAAAD,UAAA,cAAG,EAAE,GAAAA,UAAA;IAAAE,SAAA,GAAAH,IAAA,CAAEpB,IAAI;IAAJA,IAAI,GAAAuB,SAAA,cAAGjC,UAAU,CAACW,IAAI,GAAAsB,SAAA;IAAAC,gBAAA,GAAAJ,IAAA,CAAEP,WAAW;IAAXA,WAAW,GAAAW,gBAAA,cAAG,EAAE,GAAAA,gBAAA;IAAAC,SAAA,GAAAL,IAAA,CAAEM,IAAI;IAAJA,IAAI,GAAAD,SAAA,cAAGE,SAAS,GAAAF,SAAA;EAAA,OACpFG,oBAAClC,oBAAoB;IAACM,IAAI,EAAEA,IAAI;IAAEa,WAAW,EAAEA;KAC5Ca,IAAI,IAAIE,oBAACZ,eAAe,QAAEU,IAAI,CAAmB,EACjDJ,KAAK,CACe;AAAA,CACxB;;;;;"}
|
package/dist/style.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BADGE_TYPE, CustomStyle } from './types';
|
|
2
|
-
interface StyledBadgeContainerProps {
|
|
3
|
-
type: BADGE_TYPE;
|
|
4
|
-
customStyle: CustomStyle;
|
|
5
|
-
}
|
|
6
|
-
declare const StyledBadgeContainer: import("styled-components").StyledComponent<"div", any, StyledBadgeContainerProps, never>;
|
|
7
|
-
declare const StyledBadgeIcon: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
8
|
-
export { StyledBadgeContainer, StyledBadgeIcon };
|
package/dist/types.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } 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?: ReactNode;
|
|
14
|
-
type?: BADGE_TYPE;
|
|
15
|
-
customStyle?: CustomStyle;
|
|
16
|
-
icon?: ReactNode;
|
|
17
|
-
}
|
|
18
|
-
export default class Badge extends React.Component<BadgeProps> {
|
|
19
|
-
}
|
package/src/index.tsx
DELETED
|
@@ -1,15 +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};
|
|
15
|
-
export 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, {ReactNode} 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?: ReactNode;
|
|
17
|
-
type?: BADGE_TYPE;
|
|
18
|
-
customStyle?: CustomStyle;
|
|
19
|
-
icon?: ReactNode;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default class Badge extends React.Component<BadgeProps> {}
|