@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 CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ## Installation
10
10
 
11
- - `yarn add @propellerads/card` or `npm install @propellerads/card -S`
11
+ - `bun add @propellerads/card` or `npm install @propellerads/card -S`
12
12
 
13
13
  ### How to use
14
14
 
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
- type CardCustomStyles = Pick<CSSObject, 'padding' | 'borderRadius' | 'width'> & {
5
- bgColor?: CSSObject['backgroundColor'];
6
- activeBgColor?: CSSObject['backgroundColor'];
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 { jsxs as n, jsx as d } from "react/jsx-runtime";
2
- import i, { css as o } from "styled-components";
3
- import { borderRadius as m, gray95 as x, white as y, spacing as e, actionColor as f, fontBig as v, lineHeight as b, black as h } from "@propellerads/stylevariables";
4
- const S = i.div`
5
- height: 100%;
6
- border-radius: ${m}px;
7
- border: solid 2px ${x};
8
- background-color: ${y};
9
- padding: ${e * 6}px;
10
-
11
- ${(t) => t.$isActive && o`
12
- border-color: ${f};
13
- `}
14
-
15
- ${(t) => t.$customStyles.padding !== void 0 && o`
16
- padding: ${t.$customStyles.padding}px;
17
- `}
18
-
19
- ${(t) => t.$customStyles.width !== void 0 && o`
20
- width: ${t.$customStyles.width};
21
- `}
22
-
23
- ${(t) => t.$customStyles.borderRadius !== void 0 && o`
24
- border-radius: ${t.$customStyles.borderRadius}px;
25
- `}
26
-
27
- ${(t) => t.$customStyles.activeBgColor !== void 0 && t.$customStyles.bgColor !== void 0 && o`
28
- background-color: ${t.$isActive ? t.$customStyles.activeBgColor : t.$customStyles.bgColor};
29
- `}
30
- `, p = i.div`
31
- display: flex;
32
- margin-bottom: ${e * 3}px;
33
- `, C = i.div`
34
- flex: 1;
35
- font-size: ${v}px;
36
- font-weight: bold;
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
- //# sourceMappingURL=index.js.map
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","sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled, {css} from 'styled-components';\nimport {\n black,\n borderRadius,\n fontBig,\n gray95,\n actionColor,\n lineHeight,\n spacing,\n white,\n} from '@propellerads/stylevariables';\nimport type {CardCustomStyles} from './types';\n\ntype StyledCardProps = {\n $isActive: boolean;\n $customStyles: CardCustomStyles;\n};\n\nconst StyledCard = styled.div<StyledCardProps>`\n height: 100%;\n border-radius: ${borderRadius}px;\n border: solid 2px ${gray95};\n background-color: ${white};\n padding: ${spacing * 6}px;\n\n ${(props) =>\n props.$isActive &&\n css`\n border-color: ${actionColor};\n `}\n\n ${(props) =>\n props.$customStyles.padding !== undefined &&\n css`\n padding: ${props.$customStyles.padding}px;\n `}\n\n ${(props) =>\n props.$customStyles.width !== undefined &&\n css`\n width: ${props.$customStyles.width};\n `}\n\n ${(props) =>\n props.$customStyles.borderRadius !== undefined &&\n css`\n border-radius: ${props.$customStyles.borderRadius}px;\n `}\n\n ${(props) =>\n props.$customStyles.activeBgColor !== undefined &&\n props.$customStyles.bgColor !== undefined &&\n css`\n background-color: ${props.$isActive ? props.$customStyles.activeBgColor : props.$customStyles.bgColor};\n `}\n`;\n\nconst Header = styled.div`\n display: flex;\n margin-bottom: ${spacing * 3}px;\n`;\n\nconst Title = styled.div`\n flex: 1;\n font-size: ${fontBig}px;\n font-weight: bold;\n line-height: ${lineHeight}px;\n color: ${black};\n`;\n\nconst Label = styled.div`\n flex: 1;\n align-items: flex-start;\n justify-content: flex-end;\n display: flex;\n`;\n\nconst Action = styled.div`\n margin-top: ${spacing * 4}px;\n\n button + button {\n margin-left: ${spacing * 2}px;\n }\n`;\n\nexport {StyledCard, Header, Title, Label, Action};\n","import type {FC} from 'react';\nimport {Action, Header, Label, StyledCard, Title} from './style';\nimport type {CardProps} from './types';\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 return (\n <StyledCard\n className={className}\n $isActive={isActive}\n id={elementId}\n $customStyles={customStyles}\n onClick={() => onClick?.(elementId)}\n >\n {(title || label) && (\n <Header>\n {title && <Title>{title}</Title>}\n {label && <Label>{label}</Label>}\n </Header>\n )}\n\n <div>{children}</div>\n {action && <Action>{action}</Action>}\n </StyledCard>\n );\n};\n\nexport default Card;\nexport type {CardCustomStyles, CardProps} from './types';\n"],"names":["StyledCard","styled","borderRadius","gray95","white","spacing","props","css","actionColor","Header","Title","fontBig","lineHeight","black","Label","Action","Card","children","className","title","action","label","isActive","elementId","customStyles","onClick","jsxs","jsx"],"mappings":";;;AAkBA,MAAMA,IAAaC,EAAO;AAAA;AAAA,mBAEPC,CAAY;AAAA,sBACTC,CAAM;AAAA,sBACNC,CAAK;AAAA,aACdC,IAAU,CAAC;AAAA;AAAA,IAEpB,CAACC,MACDA,EAAM,aACNC;AAAA,sBACkBC,CAAW;AAAA,KAC5B;AAAA;AAAA,IAED,CAACF,MACDA,EAAM,cAAc,YAAY,UAChCC;AAAA,iBACaD,EAAM,cAAc,OAAO;AAAA,KACvC;AAAA;AAAA,IAED,CAACA,MACDA,EAAM,cAAc,UAAU,UAC9BC;AAAA,eACWD,EAAM,cAAc,KAAK;AAAA,KACnC;AAAA;AAAA,IAED,CAACA,MACDA,EAAM,cAAc,iBAAiB,UACrCC;AAAA,uBACmBD,EAAM,cAAc,YAAY;AAAA,KAClD;AAAA;AAAA,IAED,CAACA,MACDA,EAAM,cAAc,kBAAkB,UACtCA,EAAM,cAAc,YAAY,UAChCC;AAAA,0BACsBD,EAAM,YAAYA,EAAM,cAAc,gBAAgBA,EAAM,cAAc,OAAO;AAAA,KACtG;AAAA,GAGCG,IAASR,EAAO;AAAA;AAAA,mBAEHI,IAAU,CAAC;AAAA,GAGxBK,IAAQT,EAAO;AAAA;AAAA,eAENU,CAAO;AAAA;AAAA,iBAELC,CAAU;AAAA,WAChBC,CAAK;AAAA,GAGVC,IAAQb,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA,GAOfc,IAASd,EAAO;AAAA,gBACNI,IAAU,CAAC;AAAA;AAAA;AAAA,mBAGRA,IAAU,CAAC;AAAA;AAAA,GC7ExBW,IAAsB,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,WAAAC;AAAA,EACA,cAAAC,IAAe,CAAA;AAAA,EACf,SAAAC;AACF,MAEI,gBAAAC;AAAA,EAAC1B;AAAA,EAAA;AAAA,IACC,WAAAkB;AAAA,IACA,WAAWI;AAAA,IACX,IAAIC;AAAA,IACJ,eAAeC;AAAA,IACf,SAAS,MAAMC,IAAUF,CAAS;AAAA,IAEhC,UAAA;AAAA,OAAAJ,KAASE,wBACRZ,GAAA,EACE,UAAA;AAAA,QAAAU,KAAS,gBAAAQ,EAACjB,KAAO,UAAAS,EAAA,CAAM;AAAA,QACvBE,KAAS,gBAAAM,EAACb,GAAA,EAAO,UAAAO,EAAA,CAAM;AAAA,MAAA,GAC1B;AAAA,MAGF,gBAAAM,EAAC,SAAK,UAAAV,GAAS;AAAA,MACdG,KAAU,gBAAAO,EAACZ,GAAA,EAAQ,UAAAK,EAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAAA;"}
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.0.0",
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
- "react": "^18.0.0 || ^19.0.0",
31
- "styled-components": "^5.1.1 || ^6.0.0"
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": "^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"
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
  }