react-battery-level 1.0.0 → 1.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 CHANGED
@@ -6,9 +6,9 @@ type Props = {
6
6
  isCharging: boolean;
7
7
  isShowGaugePercentage: boolean;
8
8
  lightningBoltStyles?: {
9
- fill?: string;
10
- stroke?: string;
11
- strokeWidth?: string | number;
9
+ fill: string;
10
+ stroke: string;
11
+ strokeWidth: string | number;
12
12
  };
13
13
  gaugePercentageStyles?: {
14
14
  fontSize: string | number;
package/dist/index.js CHANGED
@@ -1,27 +1,112 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ var __assign =
3
+ (this && this.__assign) ||
4
+ function () {
5
+ __assign =
6
+ Object.assign ||
7
+ function (t) {
3
8
  for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
9
+ s = arguments[i];
10
+ for (var p in s)
11
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
7
12
  }
8
13
  return t;
9
- };
14
+ };
10
15
  return __assign.apply(this, arguments);
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
+ };
17
+
13
18
  var BatteryLevel = function (_a) {
14
- var gauge = _a.gauge, _b = _a.width, width = _b === void 0 ? "100%" : _b, _c = _a.height, height = _c === void 0 ? "100%" : _c, _d = _a.isCharging, isCharging = _d === void 0 ? false : _d, _e = _a.isShowGaugePercentage, isShowGaugePercentage = _e === void 0 ? true : _e, _f = _a.gaugeColor, gaugeColor = _f === void 0 ? "#6EF47A" : _f, _g = _a.lightningBoltStyles, lightningBoltStyles = _g === void 0 ? {
15
- fill: "white",
16
- stroke: "black",
17
- strokeWidth: 0.5,
18
- } : _g, _h = _a.gaugePercentageStyles, gaugePercentageStyles = _h === void 0 ? {
19
- fontSize: 7,
20
- color: "black",
21
- } : _h;
22
- var maxGaugeWidth = 73;
23
- var batteryHeight = 73;
24
- var gaugeWidth = gauge * (maxGaugeWidth / 100);
25
- return (_jsxs("svg", __assign({ width: width, height: height, viewBox: "0 0 45 23", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { d: "M44.2102 11.4C44.2102 9.96999 43.2702 8.76999 41.9702 8.35999V14.43C43.2702 14.02 44.2102 12.82 44.2102 11.39V11.4Z", fill: "black" }), _jsx("path", { d: "M41.9702 14.93C41.8702 14.93 41.7602 14.9 41.6702 14.83C41.5402 14.74 41.4702 14.59 41.4702 14.43V8.35999C41.4702 8.19999 41.5502 8.04999 41.6702 7.95999C41.8002 7.86999 41.9702 7.83999 42.1202 7.88999C43.6702 8.37999 44.7102 9.78999 44.7102 11.4C44.7102 13.01 43.6702 14.42 42.1202 14.91C42.0702 14.93 42.0202 14.93 41.9702 14.93ZM42.4702 9.13999V13.65C43.2302 13.16 43.7102 12.32 43.7102 11.39C43.7102 10.46 43.2302 9.61999 42.4702 9.12999V9.13999Z", fill: "black" }), _jsx("path", { d: "M33.5 22.74H7.60995C3.94995 22.74 0.959961 19.76 0.959961 16.09V6.7C0.959961 3.04 3.93995 0.0500031 7.60995 0.0500031H33.5C37.16 0.0500031 40.1499 3.03 40.1499 6.7V16.09C40.1499 19.75 37.17 22.74 33.5 22.74ZM7.60995 2.56C5.31995 2.56 3.45996 4.42 3.45996 6.71V16.1C3.45996 18.39 5.31995 20.25 7.60995 20.25H33.5C35.79 20.25 37.6499 18.39 37.6499 16.1V6.71C37.6499 4.42 35.79 2.56 33.5 2.56H7.60995Z", fill: "black" }), _jsx("rect", { id: "4", x: "4.1", y: "3", width: gaugeWidth + "%", height: batteryHeight + "%", rx: "3", ry: "3", fill: gaugeColor }), isShowGaugePercentage && (_jsxs("text", __assign({ x: "20", y: "11", fontSize: gaugePercentageStyles.fontSize, color: gaugePercentageStyles.color, textAnchor: "middle", alignmentBaseline: "central", fill: "black" }, { children: [gauge, "%"] }))), isCharging && (_jsx("path", { d: "M27.6495 12.15L18.7595 7.23C18.7595 7.23 18.6696 7.21 18.6396 7.23C18.5996 7.25 18.5796 7.29 18.5796 7.34V10.3H11.5996C11.5396 10.3 11.4896 10.34 11.4796 10.39C11.4696 10.44 11.4895 10.5 11.5395 10.53L20.4295 15.45C20.4295 15.45 20.4696 15.47 20.4896 15.47C20.5096 15.47 20.5296 15.47 20.5496 15.45C20.5896 15.43 20.6096 15.39 20.6096 15.34V12.38H27.5896C27.6496 12.38 27.6995 12.34 27.7095 12.29C27.7195 12.24 27.6995 12.18 27.6495 12.15Z", fill: lightningBoltStyles.fill, stroke: lightningBoltStyles.stroke, strokeWidth: lightningBoltStyles.strokeWidth }))] })));
19
+ var gauge = _a.gauge,
20
+ _b = _a.width,
21
+ width = _b === void 0 ? "100%" : _b,
22
+ _c = _a.height,
23
+ height = _c === void 0 ? "100%" : _c,
24
+ _d = _a.isCharging,
25
+ isCharging = _d === void 0 ? false : _d,
26
+ _e = _a.isShowGaugePercentage,
27
+ isShowGaugePercentage = _e === void 0 ? true : _e,
28
+ _f = _a.gaugeColor,
29
+ gaugeColor = _f === void 0 ? "#6EF47A" : _f,
30
+ _g = _a.lightningBoltStyles,
31
+ lightningBoltStyles =
32
+ _g === void 0
33
+ ? {
34
+ fill: "white",
35
+ stroke: "black",
36
+ strokeWidth: 0.5,
37
+ }
38
+ : _g,
39
+ _h = _a.gaugePercentageStyles,
40
+ gaugePercentageStyles =
41
+ _h === void 0
42
+ ? {
43
+ fontSize: 7,
44
+ color: "black",
45
+ }
46
+ : _h;
47
+ var maxGaugeWidth = 73;
48
+ var batteryHeight = 73;
49
+ var gaugeWidth = gauge * (maxGaugeWidth / 100);
50
+ return _jsxs(
51
+ "svg",
52
+ __assign(
53
+ {
54
+ width: width,
55
+ height: height,
56
+ viewBox: "0 0 45 23",
57
+ fill: "none",
58
+ xmlns: "http://www.w3.org/2000/svg",
59
+ },
60
+ {
61
+ children: [
62
+ _jsx("path", {
63
+ d: "M44.2102 11.4C44.2102 9.96999 43.2702 8.76999 41.9702 8.35999V14.43C43.2702 14.02 44.2102 12.82 44.2102 11.39V11.4Z",
64
+ fill: "black",
65
+ }),
66
+ _jsx("path", {
67
+ d: "M41.9702 14.93C41.8702 14.93 41.7602 14.9 41.6702 14.83C41.5402 14.74 41.4702 14.59 41.4702 14.43V8.35999C41.4702 8.19999 41.5502 8.04999 41.6702 7.95999C41.8002 7.86999 41.9702 7.83999 42.1202 7.88999C43.6702 8.37999 44.7102 9.78999 44.7102 11.4C44.7102 13.01 43.6702 14.42 42.1202 14.91C42.0702 14.93 42.0202 14.93 41.9702 14.93ZM42.4702 9.13999V13.65C43.2302 13.16 43.7102 12.32 43.7102 11.39C43.7102 10.46 43.2302 9.61999 42.4702 9.12999V9.13999Z",
68
+ fill: "black",
69
+ }),
70
+ _jsx("path", {
71
+ d: "M33.5 22.74H7.60995C3.94995 22.74 0.959961 19.76 0.959961 16.09V6.7C0.959961 3.04 3.93995 0.0500031 7.60995 0.0500031H33.5C37.16 0.0500031 40.1499 3.03 40.1499 6.7V16.09C40.1499 19.75 37.17 22.74 33.5 22.74ZM7.60995 2.56C5.31995 2.56 3.45996 4.42 3.45996 6.71V16.1C3.45996 18.39 5.31995 20.25 7.60995 20.25H33.5C35.79 20.25 37.6499 18.39 37.6499 16.1V6.71C37.6499 4.42 35.79 2.56 33.5 2.56H7.60995Z",
72
+ fill: "black",
73
+ }),
74
+ _jsx("rect", {
75
+ id: "4",
76
+ x: "4.1",
77
+ y: "3",
78
+ width: gaugeWidth + "%",
79
+ height: batteryHeight + "%",
80
+ rx: "3",
81
+ ry: "3",
82
+ fill: gaugeColor,
83
+ }),
84
+ isShowGaugePercentage &&
85
+ _jsxs(
86
+ "text",
87
+ __assign(
88
+ {
89
+ x: "20",
90
+ y: "11",
91
+ fontSize: gaugePercentageStyles.fontSize,
92
+ color: gaugePercentageStyles.color,
93
+ textAnchor: "middle",
94
+ alignmentBaseline: "central",
95
+ fill: "black",
96
+ },
97
+ { children: [gauge, "%"] }
98
+ )
99
+ ),
100
+ isCharging &&
101
+ _jsx("path", {
102
+ d: "M27.6495 12.15L18.7595 7.23C18.7595 7.23 18.6696 7.21 18.6396 7.23C18.5996 7.25 18.5796 7.29 18.5796 7.34V10.3H11.5996C11.5396 10.3 11.4896 10.34 11.4796 10.39C11.4696 10.44 11.4895 10.5 11.5395 10.53L20.4295 15.45C20.4295 15.45 20.4696 15.47 20.4896 15.47C20.5096 15.47 20.5296 15.47 20.5496 15.45C20.5896 15.43 20.6096 15.39 20.6096 15.34V12.38H27.5896C27.6496 12.38 27.6995 12.34 27.7095 12.29C27.7195 12.24 27.6995 12.18 27.6495 12.15Z",
103
+ fill: lightningBoltStyles.fill,
104
+ stroke: lightningBoltStyles.stroke,
105
+ strokeWidth: lightningBoltStyles.strokeWidth,
106
+ }),
107
+ ],
108
+ }
109
+ )
110
+ );
26
111
  };
27
112
  export default BatteryLevel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-battery-level",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": false,
5
5
  "description": "Simple customizable react battery component",
6
6
  "main": "dist/index.js",
@@ -25,8 +25,8 @@
25
25
  },
26
26
  "license": "MIT",
27
27
  "keywords": [
28
- "react",
29
28
  "battery",
29
+ "gauge",
30
30
  "battery svg",
31
31
  "battery indicator",
32
32
  "battery level"