@propellerads/card 5.0.0 → 5.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.
- package/README.md +1 -1
- package/dist/index.css +1 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +39 -80
- package/dist/index.js.map +1 -1
- package/package.json +21 -12
package/README.md
CHANGED
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.card{height:100%;padding:var(--card-padding,var(--space-24,24px));border:solid 2px var(--color-formal,#f2f2f2);border-radius:var(--card-radius,var(--radius-8,8px));background-color:var(--color-light-inversion,#fff)}.card--active{border-color:var(--color-action,#0080ff)}.card--custom-width{width:var(--card-width)}.card--custom-bg{background-color:var(--card-bg)}.card__header{margin-bottom:var(--space-12,12px);display:flex}.card__title{color:var(--color-dark-inversion,#000);flex:1;font-size:18px;font-weight:700;line-height:36px}.card__label{flex:1;justify-content:flex-end;align-items:flex-start;display:flex}.card__action{margin-top:var(--space-16,16px)}.card__action button+button{margin-left:var(--space-8,8px)}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { ReactNode, FC } from 'react';
|
|
2
|
-
import { CSSObject } from 'styled-components';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/** A length: a number is pixels, a string is used as is (`'50%'`, `'1rem'`). */
|
|
4
|
+
type CardLength = number | string;
|
|
5
|
+
type CardCustomStyles = {
|
|
6
|
+
padding?: CardLength;
|
|
7
|
+
borderRadius?: CardLength;
|
|
8
|
+
width?: CardLength;
|
|
9
|
+
/** The background; applied when `activeBgColor` is given too. */
|
|
10
|
+
bgColor?: string;
|
|
11
|
+
/** The background of an active card; applied when `bgColor` is given too. */
|
|
12
|
+
activeBgColor?: string;
|
|
7
13
|
};
|
|
8
14
|
type CardProps = {
|
|
9
15
|
title?: ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -1,81 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
line-height: ${b}px;
|
|
38
|
-
color: ${h};
|
|
39
|
-
`, w = i.div`
|
|
40
|
-
flex: 1;
|
|
41
|
-
align-items: flex-start;
|
|
42
|
-
justify-content: flex-end;
|
|
43
|
-
display: flex;
|
|
44
|
-
`, k = i.div`
|
|
45
|
-
margin-top: ${e * 4}px;
|
|
46
|
-
|
|
47
|
-
button + button {
|
|
48
|
-
margin-left: ${e * 2}px;
|
|
49
|
-
}
|
|
50
|
-
`, R = ({
|
|
51
|
-
children: t,
|
|
52
|
-
className: $,
|
|
53
|
-
title: s,
|
|
54
|
-
action: l,
|
|
55
|
-
label: r,
|
|
56
|
-
isActive: a = !1,
|
|
57
|
-
elementId: c,
|
|
58
|
-
customStyles: u = {},
|
|
59
|
-
onClick: g
|
|
60
|
-
}) => /* @__PURE__ */ n(
|
|
61
|
-
S,
|
|
62
|
-
{
|
|
63
|
-
className: $,
|
|
64
|
-
$isActive: a,
|
|
65
|
-
id: c,
|
|
66
|
-
$customStyles: u,
|
|
67
|
-
onClick: () => g?.(c),
|
|
68
|
-
children: [
|
|
69
|
-
(s || r) && /* @__PURE__ */ n(p, { children: [
|
|
70
|
-
s && /* @__PURE__ */ d(C, { children: s }),
|
|
71
|
-
r && /* @__PURE__ */ d(w, { children: r })
|
|
72
|
-
] }),
|
|
73
|
-
/* @__PURE__ */ d("div", { children: t }),
|
|
74
|
-
l && /* @__PURE__ */ d(k, { children: l })
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
export {
|
|
79
|
-
R as default
|
|
1
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
import './index.css';// src/index.tsx
|
|
3
|
+
var n = (e) => typeof e == "number" ? `${e}px` : e, r = ({ padding: e, borderRadius: t, width: r, bgColor: i, activeBgColor: a }, o) => {
|
|
4
|
+
let s = {};
|
|
5
|
+
return e !== void 0 && (s["--card-padding"] = n(e)), t !== void 0 && (s["--card-radius"] = n(t)), r !== void 0 && (s["--card-width"] = n(r)), i !== void 0 && a !== void 0 && (s["--card-bg"] = o ? a : i), s;
|
|
6
|
+
}, i = ({ children: n, className: i, title: a, action: o, label: s, isActive: c = !1, elementId: l, customStyles: u = {}, onClick: d }) => {
|
|
7
|
+
let f = r(u, c), p = [
|
|
8
|
+
"card",
|
|
9
|
+
c && "card--active",
|
|
10
|
+
f["--card-width"] !== void 0 && "card--custom-width",
|
|
11
|
+
f["--card-bg"] !== void 0 && "card--custom-bg",
|
|
12
|
+
i
|
|
13
|
+
].filter(Boolean).join(" ");
|
|
14
|
+
return /* @__PURE__ */ t("div", {
|
|
15
|
+
className: p,
|
|
16
|
+
id: l,
|
|
17
|
+
style: f,
|
|
18
|
+
onClick: () => d?.(l),
|
|
19
|
+
children: [
|
|
20
|
+
(a || s) && /* @__PURE__ */ t("div", {
|
|
21
|
+
className: "card__header",
|
|
22
|
+
children: [a && /* @__PURE__ */ e("div", {
|
|
23
|
+
className: "card__title",
|
|
24
|
+
children: a
|
|
25
|
+
}), s && /* @__PURE__ */ e("div", {
|
|
26
|
+
className: "card__label",
|
|
27
|
+
children: s
|
|
28
|
+
})]
|
|
29
|
+
}),
|
|
30
|
+
/* @__PURE__ */ e("div", { children: n }),
|
|
31
|
+
o && /* @__PURE__ */ e("div", {
|
|
32
|
+
className: "card__action",
|
|
33
|
+
children: o
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
});
|
|
80
37
|
};
|
|
81
|
-
|
|
38
|
+
export { i as default };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","names":["toLength","value","getCardStyle","style","padding","borderRadius","width","bgColor","activeBgColor","isActive","Card","customStyles","classes","className","elementId","onClick","title","label","action"],"sources":["../src/index.tsx"],"sourcesContent":["import type {CSSProperties, FC} from 'react';\nimport './card.css';\nimport type {CardCustomStyles, CardProps} from './types';\n\nconst toLength = (value: number | string) => (typeof value === 'number' ? `${value}px` : value);\n\ntype CardStyle = CSSProperties & Record<`--card-${string}`, string>;\n\n/** `customStyles` as the custom properties card.css reads. */\nconst getCardStyle = ({padding, borderRadius, width, bgColor, activeBgColor}: CardCustomStyles, isActive: boolean) => {\n const style: CardStyle = {};\n\n if (padding !== undefined) {\n style['--card-padding'] = toLength(padding);\n }\n\n if (borderRadius !== undefined) {\n style['--card-radius'] = toLength(borderRadius);\n }\n\n if (width !== undefined) {\n style['--card-width'] = toLength(width);\n }\n\n // Both or neither, as before: a single colour leaves the card white\n if (bgColor !== undefined && activeBgColor !== undefined) {\n style['--card-bg'] = isActive ? activeBgColor : bgColor;\n }\n\n return style;\n};\n\nconst Card: FC<CardProps> = ({\n children,\n className,\n title,\n action,\n label,\n isActive = false,\n elementId,\n customStyles = {},\n onClick,\n}) => {\n const style = getCardStyle(customStyles, isActive);\n const classes = [\n 'card',\n isActive && 'card--active',\n style['--card-width'] !== undefined && 'card--custom-width',\n style['--card-bg'] !== undefined && 'card--custom-bg',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n // biome-ignore lint/a11y/useKeyWithClickEvents: a clickable card without a keyboard path is the behaviour of 5.x, out of scope of moving off styled-components\n <div className={classes} id={elementId} style={style} onClick={() => onClick?.(elementId)}>\n {(title || label) && (\n <div className=\"card__header\">\n {title && <div className=\"card__title\">{title}</div>}\n {label && <div className=\"card__label\">{label}</div>}\n </div>\n )}\n\n <div>{children}</div>\n {action && <div className=\"card__action\">{action}</div>}\n </div>\n );\n};\n\nexport default Card;\nexport type {CardCustomStyles, CardProps} from './types';\n"],"mappings":";;AAIA,IAAMA,KAAY,MAA4B,OAAOC,KAAU,WAAW,GAAGA,EAAM,MAAMA,GAKnFC,KAAgB,EAAC,YAAS,iBAAc,UAAO,YAAS,oBAAkC,MAAsB;CACpH,IAAMC,IAAmB,CAAC;CAmB1B,OAjBIC,MAAY,KAAA,MACd,EAAM,oBAAoBJ,EAASI,CAAO,IAGxCC,MAAiB,KAAA,MACnB,EAAM,mBAAmBL,EAASK,CAAY,IAG5CC,MAAU,KAAA,MACZ,EAAM,kBAAkBN,EAASM,CAAK,IAIpCC,MAAY,KAAA,KAAaC,MAAkB,KAAA,MAC7C,EAAM,eAAeC,IAAWD,IAAgBD,IAG3CJ;AACT,GAEMO,KAAuB,EAC3B,aACA,cACA,UACA,WACA,UACA,cAAW,IACX,cACA,kBAAe,CAAC,GAChB,iBACI;CACJ,IAAMP,IAAQD,EAAaS,GAAcF,CAAQ,GAC3CG,IAAU;EACd;EACAH,KAAY;EACZN,EAAM,oBAAoB,KAAA,KAAa;EACvCA,EAAM,iBAAiB,KAAA,KAAa;EACpCU;CACF,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;CAEX,OAEE,kBAAC,OAAD;EAAK,WAAWD;EAAS,IAAIE;EAAkB;EAAO,eAAeC,IAAUD,CAAS;EAAxF,UAAA;IACIE,KAASC,MACT,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACGD,KAAS,kBAAC,OAAD;KAAK,WAAU;KAAe,UAAAA;IAAW,CAAA,GAClDC,KAAS,kBAAC,OAAD;KAAK,WAAU;KAAe,UAAAA;IAAW,CAAA,CAChD;;GAGP,kBAAC,OAAD,EAAM,YAAc,CAAA;GACnBC,KAAU,kBAAC,OAAD;IAAK,WAAU;IAAgB,UAAAA;GAAY,CAAA;EACnD;;AAET"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/card",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
+
"style": "dist/index.css",
|
|
6
7
|
"exports": {
|
|
7
8
|
".": {
|
|
8
9
|
"types": "./dist/index.d.ts",
|
|
9
10
|
"import": "./dist/index.js"
|
|
10
|
-
}
|
|
11
|
+
},
|
|
12
|
+
"./index.css": "./dist/index.css"
|
|
11
13
|
},
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"**/*.css"
|
|
16
|
+
],
|
|
12
17
|
"files": [
|
|
13
18
|
"dist"
|
|
14
19
|
],
|
|
@@ -23,19 +28,23 @@
|
|
|
23
28
|
},
|
|
24
29
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
25
30
|
"private": false,
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"@propellerads/stylevariables": "^2.0.2"
|
|
28
|
-
},
|
|
29
31
|
"peerDependencies": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
+
"@propellerads/tokens": ">=0.4.0",
|
|
33
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"@propellerads/tokens": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
32
39
|
},
|
|
33
40
|
"devDependencies": {
|
|
41
|
+
"@propellerads/tokens": "workspace:^",
|
|
34
42
|
"@types/react": "^19.2.14",
|
|
35
|
-
"@vitejs/plugin-react": "^
|
|
36
|
-
"rollup": "^4.
|
|
37
|
-
"rollup-plugin-dts": "^6.
|
|
38
|
-
"typescript": "^
|
|
39
|
-
"vite": "^
|
|
43
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
44
|
+
"rollup": "^4.60.3",
|
|
45
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
46
|
+
"typescript": "^6.0.3",
|
|
47
|
+
"vite": "^8.0.11",
|
|
48
|
+
"vite-plugin-lib-inject-css": "^2.2.2"
|
|
40
49
|
}
|
|
41
50
|
}
|