@mobilestockweb/badge 0.0.5 → 0.1.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.
Files changed (3) hide show
  1. package/index.d.ts +118 -1
  2. package/index.js +8 -5
  3. package/package.json +3 -3
package/index.d.ts CHANGED
@@ -5,17 +5,134 @@ import { TypographyProps } from '@mobilestockweb/typography';
5
5
 
6
6
  type BadgeType = Uppercase<keyof DefaultTheme['colors']['badge'] & string> | null;
7
7
  interface BadgeProps extends Omit<ViewBaseProps, 'children'> {
8
+ /**
9
+ * @description Main text displayed in the badge.
10
+ * Default: required
11
+ * @example text="New" | text="3"
12
+ */
8
13
  text: string;
14
+ /**
15
+ * @description Additional label displayed above or inside the badge.
16
+ * Default: undefined (no label)
17
+ * @example label="DISCOUNT"
18
+ */
9
19
  label?: string;
20
+ /**
21
+ * @description If true, the label appears above the badge instead of inside.
22
+ * Default: false
23
+ * @example isLabelOnTop={true}
24
+ */
10
25
  isLabelOnTop?: boolean;
26
+ /**
27
+ * @description If true, the label stays inside the badge along with the main text.
28
+ * Default: false
29
+ * @example isLabelInside={true}
30
+ */
11
31
  isLabelInside?: boolean;
32
+ /**
33
+ * @description If true, the badge has completely rounded corners (pill shape).
34
+ * Default: false
35
+ * @example isRounded={true}
36
+ */
12
37
  isRounded?: boolean;
38
+ /**
39
+ * @description Type/variant of the badge that defines its background color.
40
+ * Default: undefined (uses theme default color)
41
+ * @example type="SUCCESS" // green badge for success
42
+ */
13
43
  type?: BadgeType;
44
+ /**
45
+ * @description Font size of the main text.
46
+ * Default: 'LG'
47
+ * @example size="SM"
48
+ */
14
49
  size?: Uppercase<keyof DefaultTheme['font']['size'] & string>;
50
+ /**
51
+ * @description Internal padding of the badge (spacing between text and edges).
52
+ * Supports single or compound values (see Container.padding).
53
+ * Default: '2XS_XS' (compressed spacing)
54
+ * @example padding="MD"
55
+ */
15
56
  padding?: ViewBaseProps['padding'];
57
+ /**
58
+ * @description Color of the main text.
59
+ * Default: undefined (uses type default color)
60
+ * @example textColor="CONTRAST" // white text
61
+ */
16
62
  textColor?: TypographyProps['color'];
63
+ /**
64
+ * @description Weight/thickness of the main text font.
65
+ * Default: 'BOLD'
66
+ * @example textWeight="BOLD"
67
+ */
68
+ textWeight?: TypographyProps['weight'];
69
+ /**
70
+ * @description Horizontal alignment of the main text.
71
+ * Default: 'CENTER'
72
+ * @example textAlign="CENTER"
73
+ */
74
+ textAlign?: TypographyProps['align'];
75
+ /**
76
+ * @description Font family of the main text.
77
+ * Default: undefined (uses default font)
78
+ * @example textFamily="ARIAL"
79
+ */
80
+ textFamily?: TypographyProps['family'];
81
+ /**
82
+ * @description Text case transformation of the main text.
83
+ * Default: undefined (no transformation)
84
+ * @example textTransform="UPPERCASE"
85
+ */
86
+ textTransform?: TypographyProps['transform'];
87
+ /**
88
+ * @description Font size of the label (if present).
89
+ * Default: 'SM'
90
+ * @example labelSize="XS"
91
+ */
92
+ labelSize?: Uppercase<keyof DefaultTheme['font']['size'] & string>;
93
+ /**
94
+ * @description Color of the label.
95
+ * Default: undefined (uses type default color)
96
+ * @example labelColor="SUCCESS"
97
+ */
17
98
  labelColor?: TypographyProps['color'];
99
+ /**
100
+ * @description Font weight of the label.
101
+ * Default: undefined
102
+ * @example labelWeight="BOLD"
103
+ */
104
+ labelWeight?: TypographyProps['weight'];
105
+ /**
106
+ * @description Alignment of the label.
107
+ * Default: undefined
108
+ * @example labelAlign="CENTER"
109
+ */
110
+ labelAlign?: TypographyProps['align'];
111
+ /**
112
+ * @description Font family of the label.
113
+ * Default: undefined
114
+ * @example labelFamily="ARIAL"
115
+ */
116
+ labelFamily?: TypographyProps['family'];
117
+ /**
118
+ * @description Text case transformation of the label.
119
+ * Default: undefined
120
+ * @example labelTransform="UPPERCASE"
121
+ */
122
+ labelTransform?: TypographyProps['transform'];
123
+ /**
124
+ * @description Border thickness of the badge.
125
+ * Default: undefined (no border)
126
+ * @example borderWidth="LIGHT"
127
+ */
128
+ borderWidth?: Uppercase<keyof DefaultTheme['borderWidth'] & string>;
129
+ /**
130
+ * @description Border color of the badge.
131
+ * Default: undefined (no border)
132
+ * @example borderColor="VISIBLEAREA"
133
+ */
134
+ borderColor?: Uppercase<keyof DefaultTheme['colors']['border'] & string>;
18
135
  }
19
- declare function Badge({ text, label, isLabelOnTop, isLabelInside, isRounded, type, size, padding, textColor, labelColor }: BadgeProps): react_jsx_runtime.JSX.Element;
136
+ declare function Badge({ text, label, isLabelOnTop, isLabelInside, isRounded, type, size, padding, textColor, textWeight, textAlign, textFamily, textTransform, labelColor, labelSize, labelWeight, labelAlign, labelFamily, labelTransform, borderWidth, borderColor }: BadgeProps): react_jsx_runtime.JSX.Element;
20
137
 
21
138
  export { Badge, type BadgeType };
package/index.js CHANGED
@@ -1,8 +1,11 @@
1
- "use strict";var E=Object.create;var p=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var z=(o,e)=>{for(var r in e)p(o,r,{get:e[r],enumerable:!0})},f=(o,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of R(e))!x.call(o,t)&&t!==r&&p(o,t,{get:()=>e[t],enumerable:!(n=P(e,t))||n.enumerable});return o};var u=(o,e,r)=>(r=o!=null?E(w(o)):{},f(e||!o||!o.__esModule?p(r,"default",{value:o,enumerable:!0}):r,o)),N=o=>f(p({},"__esModule",{value:!0}),o);var D={};z(D,{Badge:()=>V});module.exports=N(D);var d=u(require("styled-components")),s=require("@mobilestockweb/container"),h=u(require("@mobilestockweb/tools")),c=require("@mobilestockweb/typography"),a=require("react/jsx-runtime");function V({text:o,label:e,isLabelOnTop:r=!1,isLabelInside:n=!1,isRounded:t=!1,type:g,size:m="LG",padding:B="2XS_XS",textColor:i,labelColor:l}){let y=e&&!n?(0,a.jsx)(c.Typography,{size:"SM",color:l,children:e}):null,T=e&&n?(0,a.jsx)(C,{size:"SM",color:l,$type:l?null:g,children:e}):null;return(0,a.jsxs)(b,{align:"CENTER_CENTER",children:[r&&!n&&y,(0,a.jsxs)(k,{"data-testid":"badge-colored-content",padding:B,$type:g,align:"CENTER_CENTER",$isRounded:t,children:[r&&n&&T,(0,a.jsx)(C,{size:m,weight:"BOLD",align:"CENTER",color:i,$type:i?null:g,children:o}),!r&&n&&T]}),!r&&!n&&y]})}var b=(0,d.default)(s.Container.Vertical)`
1
+ "use strict";var $=Object.create;var p=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var L=(o,r)=>{for(var e in r)p(o,e,{get:r[e],enumerable:!0})},b=(o,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of N(r))!_.call(o,a)&&a!==e&&p(o,a,{get:()=>r[a],enumerable:!(t=z(r,a))||t.enumerable});return o};var P=(o,r,e)=>(e=o!=null?$(S(o)):{},b(r||!o||!o.__esModule?p(e,"default",{value:o,enumerable:!0}):e,o)),X=o=>b(p({},"__esModule",{value:!0}),o);var M={};L(M,{Badge:()=>A});module.exports=X(M);var s=P(require("styled-components")),d=require("@mobilestockweb/container"),w=P(require("@mobilestockweb/tools")),i=require("@mobilestockweb/typography"),n=require("react/jsx-runtime");function A({text:o,label:r,isLabelOnTop:e=!1,isLabelInside:t=!1,isRounded:a=!1,type:l,size:E="LG",padding:k="2XS_XS",textColor:y,textWeight:x="BOLD",textAlign:D="CENTER",textFamily:R,textTransform:U,labelColor:g,labelSize:f="SM",labelWeight:c,labelAlign:h,labelFamily:T,labelTransform:m,borderWidth:V,borderColor:W}){let u=r&&!t?(0,n.jsx)(i.Typography,{size:f,weight:c,align:h,color:g,family:T,transform:m,children:r}):null,C=r&&t?(0,n.jsx)(B,{size:f,weight:c,align:h,color:g,family:T,transform:m,$type:g?null:l,children:r}):null;return(0,n.jsxs)(F,{align:"CENTER_CENTER",children:[e&&!t&&u,(0,n.jsxs)(G,{"data-testid":"badge-colored-content",padding:k,$type:l,align:"CENTER_CENTER",$isRounded:a,$borderWidth:V,$borderColor:W,children:[e&&t&&C,(0,n.jsx)(B,{size:E,weight:x,align:D,color:y,family:R,transform:U,$type:y?null:l,children:o}),!e&&t&&C]}),!e&&!t&&u]})}var F=(0,s.default)(d.Container.Vertical)`
2
2
  background-color: transparent;
3
- `,k=(0,d.default)(s.Container.Vertical)`
3
+ `,G=(0,s.default)(d.Container.Vertical)`
4
4
  border-radius: ${({$isRounded:o})=>o?50:8}px;
5
- background-color: ${({$type:o,theme:e})=>e.colors.badge[(o==null?void 0:o.toLowerCase())||"default"]};
6
- `,C=(0,d.default)(c.Typography)`
7
- color: ${({$type:o,theme:e})=>h.default.defineTextColor(e.colors.badge[(o==null?void 0:o.toLowerCase())||"default"])};
5
+ background-color: ${({$type:o,theme:r})=>r.colors.badge[(o==null?void 0:o.toLowerCase())||"default"]};
6
+ ${({$borderWidth:o,$borderColor:r,theme:e})=>{if(!o||!r)return"";let t=e.borderWidth[o.toLowerCase()],a=e.colors.border[r.toLowerCase()];return`
7
+ border: ${t} solid ${a};
8
+ `}}
9
+ `,B=(0,s.default)(i.Typography)`
10
+ color: ${({$type:o,theme:r})=>w.default.defineTextColor(r.colors.badge[(o==null?void 0:o.toLowerCase())||"default"])};
8
11
  `;0&&(module.exports={Badge});
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@mobilestockweb/badge",
3
- "version": "0.0.5",
3
+ "version": "0.1.0",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
- "@mobilestockweb/container": "^0.1.0",
6
+ "@mobilestockweb/container": "^1.1.0",
7
7
  "@mobilestockweb/tools": "^0.0.16",
8
- "@mobilestockweb/typography": "^0.0.6"
8
+ "@mobilestockweb/typography": "^0.1.0"
9
9
  },
10
10
  "peerDependencies": {
11
11
  "react": "18.2.0",