Skip to content

Commit

Permalink
simulated data
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocjohn committed Jun 11, 2024
1 parent 17fec13 commit 3c1d1d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ header h1 {
margin-bottom: 3px;
}
}

.item.charge {
cursor: pointer;
}
Expand All @@ -111,7 +112,7 @@ header h1 {
.info-box.charge.active {
max-height: 100px; /* Adjust this to be more than the expected height of the content */
opacity: 1;
padding-top: 0.5rem;
padding-block: 0.5rem;
}

.info-box.charge .item {
Expand Down
17 changes: 15 additions & 2 deletions src/vehicle-info-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,28 @@ export class VehicleCard extends LitElement {
const generateChargingDataSimulated = () => {
const data = [
{ name: 'Power', state: 3.7, unit: 'kW', icon: 'mdi:flash' },
{ name: 'Current state', state: 50, unit: '%', icon: 'mdi:battery-charging-medium' },
{ name: 'Maximum', state: 60, unit: '%' },
{ name: 'Current state', state: 25, unit: '%' },
{ name: 'Maximum', state: 80, unit: '%' },
{ name: 'Program', state: selectedProgramMapping[3], icon: 'mdi:ev-station' },
];

return data.map((item) => {
if (item.name === 'Maximum') {
return { ...item, icon: `mdi:battery-charging-${item.state}` };
}
if (item.name === 'Current state') {
const itemState = typeof item.state === 'string' ? parseFloat(item.state) : item.state;
let icon;
if (itemState < 35) {
icon = 'mdi:battery-charging-low';
} else if (itemState < 70) {
icon = 'mdi:battery-charging-medium';
} else {
icon = 'mdi:battery-charging-high';
}
return { ...item, icon };
}

return item;
});
};
Expand Down

0 comments on commit 3c1d1d9

Please sign in to comment.