@mirohq/design-system-badge 0.2.0 → 0.3.1-button.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/main.js +28 -13
- package/dist/main.js.map +1 -1
- package/dist/module.js +28 -13
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +13 -3
- package/package.json +5 -4
package/dist/main.js
CHANGED
|
@@ -60,6 +60,7 @@ const StyledDot = designSystemStitches.styled(designSystemPrimitive.Primitive.di
|
|
|
60
60
|
...sharedStyles
|
|
61
61
|
});
|
|
62
62
|
const StyledBadgeWrapper = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
63
|
+
userSelect: "none",
|
|
63
64
|
alignItems: "center",
|
|
64
65
|
boxSizing: "border-box",
|
|
65
66
|
display: "flex",
|
|
@@ -73,20 +74,34 @@ const StyledBadgeWrapper = designSystemStitches.styled(designSystemPrimitive.Pri
|
|
|
73
74
|
zIndex: "1"
|
|
74
75
|
});
|
|
75
76
|
|
|
76
|
-
const Badge = React__default["default"].forwardRef(
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
const Badge = React__default["default"].forwardRef(
|
|
78
|
+
({ show = true, content, children, offsetX = 0, offsetY = 0, ...restProps }, forwardRef) => {
|
|
79
|
+
if (!show) {
|
|
80
|
+
return children;
|
|
81
|
+
}
|
|
82
|
+
let offset = {};
|
|
83
|
+
if (+offsetX !== 0 || +offsetY !== 0) {
|
|
84
|
+
offset = {
|
|
85
|
+
UNSAFE_style: {
|
|
86
|
+
transform: `translate(${offsetX}px, ${offsetY}px)`
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const badgeProps = {
|
|
91
|
+
...restProps,
|
|
92
|
+
...offset
|
|
93
|
+
};
|
|
94
|
+
return /* @__PURE__ */ React__default["default"].createElement(StyledBadgeContainer, {
|
|
95
|
+
"data-testid": process.env.NODE_ENV === "test" ? "badge" : void 0
|
|
96
|
+
}, /* @__PURE__ */ React__default["default"].createElement(StyledBadgeWrapper, null, content !== void 0 ? /* @__PURE__ */ React__default["default"].createElement(StyledBadge, {
|
|
97
|
+
...badgeProps,
|
|
98
|
+
ref: forwardRef
|
|
99
|
+
}, content) : /* @__PURE__ */ React__default["default"].createElement(StyledDot, {
|
|
100
|
+
...badgeProps,
|
|
101
|
+
ref: forwardRef
|
|
102
|
+
})), children);
|
|
79
103
|
}
|
|
80
|
-
|
|
81
|
-
"data-testid": "badge"
|
|
82
|
-
}, /* @__PURE__ */ React__default["default"].createElement(StyledBadgeWrapper, null, content !== void 0 ? /* @__PURE__ */ React__default["default"].createElement(StyledBadge, {
|
|
83
|
-
...restProps,
|
|
84
|
-
ref: forwardRef
|
|
85
|
-
}, content) : /* @__PURE__ */ React__default["default"].createElement(StyledDot, {
|
|
86
|
-
...restProps,
|
|
87
|
-
ref: forwardRef
|
|
88
|
-
})), children);
|
|
89
|
-
});
|
|
104
|
+
);
|
|
90
105
|
|
|
91
106
|
exports.Badge = Badge;
|
|
92
107
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sources":["../src/badge.styled.tsx","../src/badge.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\nimport type { CSS } from '@mirohq/design-system-stitches'\n\nexport const StyledBadgeContainer = styled(Primitive.div, {\n position: 'relative',\n})\n\nconst sharedStyles: CSS = {\n alignItems: 'center',\n backgroundColor: '$background-primary-prominent',\n borderColor: '$border-primary-inverted',\n borderRadius: '$half',\n color: '$icon-primary-inverted',\n display: 'flex',\n justifyContent: 'center',\n position: 'absolute',\n pointerEvents: 'none',\n zIndex: 1,\n variants: {\n inverted: {\n true: {\n backgroundColor: '$background-neutrals',\n borderColor: '$border-primary',\n color: '$text-primary',\n },\n },\n },\n}\n\nexport const StyledBadge = styled(Primitive.div, {\n borderWidth: 2,\n borderStyle: 'solid',\n boxSizing: 'border-box',\n fontFamily: 'Formular, sans-serif',\n fontSize: '$150',\n fontWeight: 650,\n height: '20px',\n left: '50%',\n minWidth: '20px',\n padding: '2px $50',\n top: '1px',\n transform: 'translateX(-50%)',\n ...sharedStyles,\n})\n\nexport const StyledDot = styled(Primitive.div, {\n borderWidth: 1,\n bottom: '1px',\n height: '4px',\n minWidth: 0,\n padding: 0,\n right: '1px',\n width: '4px',\n ...sharedStyles,\n})\n\nexport const StyledBadgeWrapper = styled(Primitive.div, {\n alignItems: 'center',\n boxSizing: 'border-box',\n display: 'flex',\n flexFlow: 'row wrap',\n height: '10px',\n placeContent: 'center',\n position: 'absolute',\n right: '-2px',\n top: '-6px',\n width: '10px',\n zIndex: '1',\n})\n\nexport type StyledBadgeProps = ComponentPropsWithRef<typeof StyledBadge>\n","import React from 'react'\nimport type {
|
|
1
|
+
{"version":3,"file":"main.js","sources":["../src/badge.styled.tsx","../src/badge.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\nimport type { CSS } from '@mirohq/design-system-stitches'\n\nexport const StyledBadgeContainer = styled(Primitive.div, {\n position: 'relative',\n})\n\nconst sharedStyles: CSS = {\n alignItems: 'center',\n backgroundColor: '$background-primary-prominent',\n borderColor: '$border-primary-inverted',\n borderRadius: '$half',\n color: '$icon-primary-inverted',\n display: 'flex',\n justifyContent: 'center',\n position: 'absolute',\n pointerEvents: 'none',\n zIndex: 1,\n variants: {\n inverted: {\n true: {\n backgroundColor: '$background-neutrals',\n borderColor: '$border-primary',\n color: '$text-primary',\n },\n },\n },\n}\n\nexport const StyledBadge = styled(Primitive.div, {\n borderWidth: 2,\n borderStyle: 'solid',\n boxSizing: 'border-box',\n fontFamily: 'Formular, sans-serif',\n fontSize: '$150',\n fontWeight: 650,\n height: '20px',\n left: '50%',\n minWidth: '20px',\n padding: '2px $50',\n top: '1px',\n transform: 'translateX(-50%)',\n ...sharedStyles,\n})\n\nexport const StyledDot = styled(Primitive.div, {\n borderWidth: 1,\n bottom: '1px',\n height: '4px',\n minWidth: 0,\n padding: 0,\n right: '1px',\n width: '4px',\n ...sharedStyles,\n})\n\nexport const StyledBadgeWrapper = styled(Primitive.div, {\n userSelect: 'none',\n alignItems: 'center',\n boxSizing: 'border-box',\n display: 'flex',\n flexFlow: 'row wrap',\n height: '10px',\n placeContent: 'center',\n position: 'absolute',\n right: '-2px',\n top: '-6px',\n width: '10px',\n zIndex: '1',\n})\n\nexport type StyledBadgeProps = ComponentPropsWithRef<typeof StyledBadge>\n","import React from 'react'\nimport type {\n ElementRef,\n ReactNode,\n ReactElement,\n ForwardRefExoticComponent,\n HTMLAttributes,\n} from 'react'\nimport type { Numeric } from '@mirohq/design-system-types'\n\nimport {\n StyledBadgeContainer,\n StyledBadgeWrapper,\n StyledBadge,\n StyledDot,\n} from './badge.styled'\nimport type { StyledBadgeProps } from './badge.styled'\n\nexport interface BadgeProps extends StyledBadgeProps {\n /**\n * Content of the badge\n */\n content?: string\n\n /**\n * Handle whether the badge should be shown, if no content is provided a dot is displayed.\n */\n show?: boolean\n\n /**\n * Element that shows the badge\n */\n children?: ReactNode\n\n /**\n * By default the badge is filled with blue, inverted set it to white.\n */\n inverted?: boolean\n\n /**\n * Move the badge position to the left/right\n */\n offsetX?: Numeric\n\n /**\n * Move the badge position to the top/bottom\n */\n offsetY?: Numeric\n}\n\nexport const Badge: ForwardRefExoticComponent<\n BadgeProps & HTMLAttributes<ElementRef<typeof StyledBadge>>\n> = React.forwardRef(\n (\n { show = true, content, children, offsetX = 0, offsetY = 0, ...restProps },\n forwardRef\n ) => {\n if (!show) {\n return children as ReactElement\n }\n\n let offset = {}\n\n if (+offsetX !== 0 || +offsetY !== 0) {\n offset = {\n UNSAFE_style: {\n transform: `translate(${offsetX}px, ${offsetY}px)`,\n },\n }\n }\n\n const badgeProps = {\n ...restProps,\n ...offset,\n }\n\n return (\n <StyledBadgeContainer\n data-testid={process.env.NODE_ENV === 'test' ? 'badge' : undefined}\n >\n <StyledBadgeWrapper>\n {content !== undefined ? (\n <StyledBadge {...badgeProps} ref={forwardRef}>\n {content}\n </StyledBadge>\n ) : (\n <StyledDot {...badgeProps} ref={forwardRef} />\n )}\n </StyledBadgeWrapper>\n {children}\n </StyledBadgeContainer>\n )\n }\n)\n"],"names":["styled","Primitive","React"],"mappings":";;;;;;;;;;;;AAKa,MAAA,oBAAA,GAAuBA,2BAAO,CAAAC,+BAAA,CAAU,GAAK,EAAA;AAAA,EACxD,QAAU,EAAA,UAAA;AACZ,CAAC,CAAA,CAAA;AAED,MAAM,YAAoB,GAAA;AAAA,EACxB,UAAY,EAAA,QAAA;AAAA,EACZ,eAAiB,EAAA,+BAAA;AAAA,EACjB,WAAa,EAAA,0BAAA;AAAA,EACb,YAAc,EAAA,OAAA;AAAA,EACd,KAAO,EAAA,wBAAA;AAAA,EACP,OAAS,EAAA,MAAA;AAAA,EACT,cAAgB,EAAA,QAAA;AAAA,EAChB,QAAU,EAAA,UAAA;AAAA,EACV,aAAe,EAAA,MAAA;AAAA,EACf,MAAQ,EAAA,CAAA;AAAA,EACR,QAAU,EAAA;AAAA,IACR,QAAU,EAAA;AAAA,MACR,IAAM,EAAA;AAAA,QACJ,eAAiB,EAAA,sBAAA;AAAA,QACjB,WAAa,EAAA,iBAAA;AAAA,QACb,KAAO,EAAA,eAAA;AAAA,OACT;AAAA,KACF;AAAA,GACF;AACF,CAAA,CAAA;AAEa,MAAA,WAAA,GAAcD,2BAAO,CAAAC,+BAAA,CAAU,GAAK,EAAA;AAAA,EAC/C,WAAa,EAAA,CAAA;AAAA,EACb,WAAa,EAAA,OAAA;AAAA,EACb,SAAW,EAAA,YAAA;AAAA,EACX,UAAY,EAAA,sBAAA;AAAA,EACZ,QAAU,EAAA,MAAA;AAAA,EACV,UAAY,EAAA,GAAA;AAAA,EACZ,MAAQ,EAAA,MAAA;AA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S,EAAC,CAAA;AAEd,IAAA,IAAI,CAAC,OAAA,KAAY,CAAK,IAAA,CAAC,YAAY,CAAG,EAAA;AACpC,MAAS,MAAA,GAAA;AAAA,QACP,YAAc,EAAA;AAAA,UACZ,SAAA,EAAW,aAAa,OAAc,CAAA,IAAA,EAAA,OAAA,CAAA,GAAA,CAAA;AAAA,SACxC;AAAA,OACF,CAAA;AAAA,KACF;AAEA,IAAA,MAAM,UAAa,GAAA;AAAA,MACjB,GAAG,SAAA;AAAA,MACH,GAAG,MAAA;AAAA,KACL,CAAA;AAEA,IAAA,uBACGA,yBAAA,CAAA,aAAA,CAAA,oBAAA,EAAA;AAAA,MACC,aAAa,EAAA,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,SAAS,OAAU,GAAA,KAAA,CAAA;AAAA,KAAA,kBAExDA,yBAAA,CAAA,aAAA,CAAA,kBAAA,EAAA,IAAA,EACE,OAAY,KAAA,KAAA,CAAA,mBACVA,yBAAA,CAAA,aAAA,CAAA,WAAA,EAAA;AAAA,MAAa,GAAG,UAAA;AAAA,MAAY,GAAK,EAAA,UAAA;AAAA,KAC/B,EAAA,OACH,oBAECA,yBAAA,CAAA,aAAA,CAAA,SAAA,EAAA;AAAA,MAAW,GAAG,UAAA;AAAA,MAAY,GAAK,EAAA,UAAA;AAAA,KAAY,CAEhD,GACC,QACH,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
package/dist/module.js
CHANGED
|
@@ -52,6 +52,7 @@ const StyledDot = styled(Primitive.div, {
|
|
|
52
52
|
...sharedStyles
|
|
53
53
|
});
|
|
54
54
|
const StyledBadgeWrapper = styled(Primitive.div, {
|
|
55
|
+
userSelect: "none",
|
|
55
56
|
alignItems: "center",
|
|
56
57
|
boxSizing: "border-box",
|
|
57
58
|
display: "flex",
|
|
@@ -65,20 +66,34 @@ const StyledBadgeWrapper = styled(Primitive.div, {
|
|
|
65
66
|
zIndex: "1"
|
|
66
67
|
});
|
|
67
68
|
|
|
68
|
-
const Badge = React.forwardRef(
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
const Badge = React.forwardRef(
|
|
70
|
+
({ show = true, content, children, offsetX = 0, offsetY = 0, ...restProps }, forwardRef) => {
|
|
71
|
+
if (!show) {
|
|
72
|
+
return children;
|
|
73
|
+
}
|
|
74
|
+
let offset = {};
|
|
75
|
+
if (+offsetX !== 0 || +offsetY !== 0) {
|
|
76
|
+
offset = {
|
|
77
|
+
UNSAFE_style: {
|
|
78
|
+
transform: `translate(${offsetX}px, ${offsetY}px)`
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const badgeProps = {
|
|
83
|
+
...restProps,
|
|
84
|
+
...offset
|
|
85
|
+
};
|
|
86
|
+
return /* @__PURE__ */ React.createElement(StyledBadgeContainer, {
|
|
87
|
+
"data-testid": process.env.NODE_ENV === "test" ? "badge" : void 0
|
|
88
|
+
}, /* @__PURE__ */ React.createElement(StyledBadgeWrapper, null, content !== void 0 ? /* @__PURE__ */ React.createElement(StyledBadge, {
|
|
89
|
+
...badgeProps,
|
|
90
|
+
ref: forwardRef
|
|
91
|
+
}, content) : /* @__PURE__ */ React.createElement(StyledDot, {
|
|
92
|
+
...badgeProps,
|
|
93
|
+
ref: forwardRef
|
|
94
|
+
})), children);
|
|
71
95
|
}
|
|
72
|
-
|
|
73
|
-
"data-testid": "badge"
|
|
74
|
-
}, /* @__PURE__ */ React.createElement(StyledBadgeWrapper, null, content !== void 0 ? /* @__PURE__ */ React.createElement(StyledBadge, {
|
|
75
|
-
...restProps,
|
|
76
|
-
ref: forwardRef
|
|
77
|
-
}, content) : /* @__PURE__ */ React.createElement(StyledDot, {
|
|
78
|
-
...restProps,
|
|
79
|
-
ref: forwardRef
|
|
80
|
-
})), children);
|
|
81
|
-
});
|
|
96
|
+
);
|
|
82
97
|
|
|
83
98
|
export { Badge };
|
|
84
99
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sources":["../src/badge.styled.tsx","../src/badge.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\nimport type { CSS } from '@mirohq/design-system-stitches'\n\nexport const StyledBadgeContainer = styled(Primitive.div, {\n position: 'relative',\n})\n\nconst sharedStyles: CSS = {\n alignItems: 'center',\n backgroundColor: '$background-primary-prominent',\n borderColor: '$border-primary-inverted',\n borderRadius: '$half',\n color: '$icon-primary-inverted',\n display: 'flex',\n justifyContent: 'center',\n position: 'absolute',\n pointerEvents: 'none',\n zIndex: 1,\n variants: {\n inverted: {\n true: {\n backgroundColor: '$background-neutrals',\n borderColor: '$border-primary',\n color: '$text-primary',\n },\n },\n },\n}\n\nexport const StyledBadge = styled(Primitive.div, {\n borderWidth: 2,\n borderStyle: 'solid',\n boxSizing: 'border-box',\n fontFamily: 'Formular, sans-serif',\n fontSize: '$150',\n fontWeight: 650,\n height: '20px',\n left: '50%',\n minWidth: '20px',\n padding: '2px $50',\n top: '1px',\n transform: 'translateX(-50%)',\n ...sharedStyles,\n})\n\nexport const StyledDot = styled(Primitive.div, {\n borderWidth: 1,\n bottom: '1px',\n height: '4px',\n minWidth: 0,\n padding: 0,\n right: '1px',\n width: '4px',\n ...sharedStyles,\n})\n\nexport const StyledBadgeWrapper = styled(Primitive.div, {\n alignItems: 'center',\n boxSizing: 'border-box',\n display: 'flex',\n flexFlow: 'row wrap',\n height: '10px',\n placeContent: 'center',\n position: 'absolute',\n right: '-2px',\n top: '-6px',\n width: '10px',\n zIndex: '1',\n})\n\nexport type StyledBadgeProps = ComponentPropsWithRef<typeof StyledBadge>\n","import React from 'react'\nimport type {
|
|
1
|
+
{"version":3,"file":"module.js","sources":["../src/badge.styled.tsx","../src/badge.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\nimport type { CSS } from '@mirohq/design-system-stitches'\n\nexport const StyledBadgeContainer = styled(Primitive.div, {\n position: 'relative',\n})\n\nconst sharedStyles: CSS = {\n alignItems: 'center',\n backgroundColor: '$background-primary-prominent',\n borderColor: '$border-primary-inverted',\n borderRadius: '$half',\n color: '$icon-primary-inverted',\n display: 'flex',\n justifyContent: 'center',\n position: 'absolute',\n pointerEvents: 'none',\n zIndex: 1,\n variants: {\n inverted: {\n true: {\n backgroundColor: '$background-neutrals',\n borderColor: '$border-primary',\n color: '$text-primary',\n },\n },\n },\n}\n\nexport const StyledBadge = styled(Primitive.div, {\n borderWidth: 2,\n borderStyle: 'solid',\n boxSizing: 'border-box',\n fontFamily: 'Formular, sans-serif',\n fontSize: '$150',\n fontWeight: 650,\n height: '20px',\n left: '50%',\n minWidth: '20px',\n padding: '2px $50',\n top: '1px',\n transform: 'translateX(-50%)',\n ...sharedStyles,\n})\n\nexport const StyledDot = styled(Primitive.div, {\n borderWidth: 1,\n bottom: '1px',\n height: '4px',\n minWidth: 0,\n padding: 0,\n right: '1px',\n width: '4px',\n ...sharedStyles,\n})\n\nexport const StyledBadgeWrapper = styled(Primitive.div, {\n userSelect: 'none',\n alignItems: 'center',\n boxSizing: 'border-box',\n display: 'flex',\n flexFlow: 'row wrap',\n height: '10px',\n placeContent: 'center',\n position: 'absolute',\n right: '-2px',\n top: '-6px',\n width: '10px',\n zIndex: '1',\n})\n\nexport type StyledBadgeProps = ComponentPropsWithRef<typeof StyledBadge>\n","import React from 'react'\nimport type {\n ElementRef,\n ReactNode,\n ReactElement,\n ForwardRefExoticComponent,\n HTMLAttributes,\n} from 'react'\nimport type { Numeric } from '@mirohq/design-system-types'\n\nimport {\n StyledBadgeContainer,\n StyledBadgeWrapper,\n StyledBadge,\n StyledDot,\n} from './badge.styled'\nimport type { StyledBadgeProps } from './badge.styled'\n\nexport interface BadgeProps extends StyledBadgeProps {\n /**\n * Content of the badge\n */\n content?: string\n\n /**\n * Handle whether the badge should be shown, if no content is provided a dot is displayed.\n */\n show?: boolean\n\n /**\n * Element that shows the badge\n */\n children?: ReactNode\n\n /**\n * By default the badge is filled with blue, inverted set it to white.\n */\n inverted?: boolean\n\n /**\n * Move the badge position to the left/right\n */\n offsetX?: Numeric\n\n /**\n * Move the badge position to the top/bottom\n */\n offsetY?: Numeric\n}\n\nexport const Badge: ForwardRefExoticComponent<\n BadgeProps & HTMLAttributes<ElementRef<typeof StyledBadge>>\n> = React.forwardRef(\n (\n { show = true, content, children, offsetX = 0, offsetY = 0, ...restProps },\n forwardRef\n ) => {\n if (!show) {\n return children as ReactElement\n }\n\n let offset = {}\n\n if (+offsetX !== 0 || +offsetY !== 0) {\n offset = {\n UNSAFE_style: {\n transform: `translate(${offsetX}px, ${offsetY}px)`,\n },\n }\n }\n\n const badgeProps = {\n ...restProps,\n ...offset,\n }\n\n return (\n <StyledBadgeContainer\n data-testid={process.env.NODE_ENV === 'test' ? 'badge' : undefined}\n >\n <StyledBadgeWrapper>\n {content !== undefined ? (\n <StyledBadge {...badgeProps} ref={forwardRef}>\n {content}\n </StyledBadge>\n ) : (\n <StyledDot {...badgeProps} ref={forwardRef} />\n )}\n </StyledBadgeWrapper>\n {children}\n </StyledBadgeContainer>\n )\n }\n)\n"],"names":[],"mappings":";;;;AAKa,MAAA,oBAAA,GAAuB,MAAO,CAAA,SAAA,CAAU,GAAK,EAAA;AAAA,EACxD,QAAU,EAAA,UAAA;AACZ,CAAC,CAAA,CAAA;AAED,MAAM,YAAoB,GAAA;AAAA,EACxB,UAAY,EAAA,QAAA;AAAA,EACZ,eAAiB,EAAA,+BAAA;AAAA,EACjB,WAAa,EAAA,0BAAA;AAAA,EACb,YAAc,EAAA,OAAA;AAAA,EACd,KAAO,EAAA,wBAAA;AAAA,EACP,OAAS,EAAA,MAAA;AAAA,EACT,cAAgB,EAAA,QAAA;AAAA,EAChB,QAAU,EAAA,UAAA;AAAA,EACV,aAAe,EAAA,MAAA;AAAA,EACf,MAAQ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AA,MAAW,GAAG,UAAA;AAAA,MAAY,GAAK,EAAA,UAAA;AAAA,KAAY,CAEhD,GACC,QACH,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { ComponentPropsWithRef, ReactNode, ForwardRefExoticComponent, HTMLAttributes, ElementRef } from 'react';
|
|
3
|
+
import { Numeric } from '@mirohq/design-system-types';
|
|
3
4
|
import * as _mirohq_design_system_stitches from '@mirohq/design-system-stitches';
|
|
4
5
|
import * as _stitches_react_types_css_util from '@stitches/react/types/css-util';
|
|
5
6
|
import * as _mirohq_design_system_primitive from '@mirohq/design-system-primitive';
|
|
@@ -180,6 +181,7 @@ declare const StyledBadge: react.ForwardRefExoticComponent<Pick<Omit<{}, never>
|
|
|
180
181
|
readonly 50: "0 4px 16px #05003812";
|
|
181
182
|
readonly 100: "0 8px 32px #05003808";
|
|
182
183
|
readonly 'focus-small': "0 0 0 2px $colors$blue-200, inset 0 0 0 2px $colors$blue-500, inset 0 0 0 3px $colors$white";
|
|
184
|
+
readonly 'focus-small-outline': "0 0 0 2px $colors$blue-200, inset 0 0 0 1px $colors$blue-500, inset 0 0 0 2px $colors$white";
|
|
183
185
|
readonly 'focus-large': "0 0 0 4px $colors$blue-200, inset 0 0 0 2px $colors$blue-500, inset 0 0 0 3px $colors$white";
|
|
184
186
|
readonly 'focus-controls': "0 0 0 1px $colors$white, 0 0 0 3px $colors$blue-500, 0 0 0 5px $colors$blue-200";
|
|
185
187
|
};
|
|
@@ -429,7 +431,7 @@ interface BadgeProps extends StyledBadgeProps {
|
|
|
429
431
|
/**
|
|
430
432
|
* Handle whether the badge should be shown, if no content is provided a dot is displayed.
|
|
431
433
|
*/
|
|
432
|
-
show
|
|
434
|
+
show?: boolean;
|
|
433
435
|
/**
|
|
434
436
|
* Element that shows the badge
|
|
435
437
|
*/
|
|
@@ -438,7 +440,15 @@ interface BadgeProps extends StyledBadgeProps {
|
|
|
438
440
|
* By default the badge is filled with blue, inverted set it to white.
|
|
439
441
|
*/
|
|
440
442
|
inverted?: boolean;
|
|
443
|
+
/**
|
|
444
|
+
* Move the badge position to the left/right
|
|
445
|
+
*/
|
|
446
|
+
offsetX?: Numeric;
|
|
447
|
+
/**
|
|
448
|
+
* Move the badge position to the top/bottom
|
|
449
|
+
*/
|
|
450
|
+
offsetY?: Numeric;
|
|
441
451
|
}
|
|
442
|
-
declare const Badge:
|
|
452
|
+
declare const Badge: ForwardRefExoticComponent<BadgeProps & HTMLAttributes<ElementRef<typeof StyledBadge>>>;
|
|
443
453
|
|
|
444
454
|
export { Badge, BadgeProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirohq/design-system-badge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1-button.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Miro",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -27,13 +27,14 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@mirohq/design-system-primitive": "^1.1.0",
|
|
30
|
-
"@mirohq/design-system-stitches": "^2.1.0"
|
|
30
|
+
"@mirohq/design-system-stitches": "^2.1.2-button.0",
|
|
31
|
+
"@mirohq/design-system-types": "^0.3.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@mirohq/design-system-button": "^2.1.0"
|
|
34
|
+
"@mirohq/design-system-button": "^2.1.2-button.0"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
36
|
-
"build": "rollup -c
|
|
37
|
+
"build": "rollup -c ../../../rollup.config.js",
|
|
37
38
|
"clean": "rm -rf dist",
|
|
38
39
|
"prebuild": "pnpm clean"
|
|
39
40
|
}
|