diff --git a/package.json b/package.json index 05da6d14a5..92853dcbd0 100644 --- a/package.json +++ b/package.json @@ -239,7 +239,6 @@ "ws": "^7.3.0" }, "devDependencies": { - "@emeraldpay/hashicon-react": "^0.4.0", "@material-ui/core": "^4.10.1", "@pmmmwh/react-refresh-webpack-plugin": "^0.4.3", "@testing-library/jest-dom": "^5.11.5", diff --git a/src/renderer/components/cluster-icon/cluster-icon.scss b/src/renderer/components/cluster-icon/cluster-icon.scss index 540cecf9eb..f246a8d9ee 100644 --- a/src/renderer/components/cluster-icon/cluster-icon.scss +++ b/src/renderer/components/cluster-icon/cluster-icon.scss @@ -7,25 +7,27 @@ user-select: none; cursor: pointer; - &.interactive { - img { - opacity: .55; - } + + div.MuiAvatar-colorDefault { + font-weight:500; + text-transform: uppercase; + } + + div.active { + background-color: var(--primary); + } + + div.default { + background-color: var(--halfGray); } &.active, &.interactive:hover { background-color: #fff; - - img { - opacity: 1; + div { + background-color: var(--primary); } } - img { - width: var(--size); - height: var(--size); - } - .Badge { position: absolute; right: 0; @@ -35,4 +37,4 @@ background: $colorError; color: white; } -} \ No newline at end of file +} diff --git a/src/renderer/components/cluster-icon/cluster-icon.tsx b/src/renderer/components/cluster-icon/cluster-icon.tsx index 48d23eb91f..c7806e3ce3 100644 --- a/src/renderer/components/cluster-icon/cluster-icon.tsx +++ b/src/renderer/components/cluster-icon/cluster-icon.tsx @@ -2,14 +2,13 @@ import "./cluster-icon.scss"; import React, { DOMAttributes } from "react"; import { disposeOnUnmount, observer } from "mobx-react"; -import { Params as HashiconParams } from "@emeraldpay/hashicon"; -import { Hashicon } from "@emeraldpay/hashicon-react"; import { Cluster } from "../../../main/cluster"; import { cssNames, IClassName } from "../../utils"; import { Badge } from "../badge"; import { Tooltip } from "../tooltip"; import { subscribeToBroadcast } from "../../../common/ipc"; import { observable } from "mobx"; +import { Avatar } from "@material-ui/core"; interface Props extends DOMAttributes { cluster: Cluster; @@ -19,7 +18,6 @@ interface Props extends DOMAttributes { showTooltip?: boolean; interactive?: boolean; isActive?: boolean; - options?: HashiconParams; } const defaultProps: Partial = { @@ -47,9 +45,29 @@ export class ClusterIcon extends React.Component { ]); } + get iconString() { + let splittedName = this.props.cluster.name.split(" "); + + if (splittedName.length === 1) { + splittedName = splittedName[0].split("-"); + } + + if (splittedName.length === 1) { + splittedName = splittedName[0].split("@"); + } + + splittedName = splittedName.map((part) => part.replace(/\W/g, "")); + + if (splittedName.length === 1) { + return splittedName[0].substring(0, 2); + } else { + return splittedName[0].substring(0, 1) + splittedName[1].substring(0, 1); + } + } + render() { const { - cluster, showErrors, showTooltip, errorClass, options, interactive, isActive, + cluster, showErrors, showTooltip, errorClass, interactive, isActive, children, ...elemProps } = this.props; const { name, preferences, id: clusterId, online } = cluster; @@ -67,7 +85,7 @@ export class ClusterIcon extends React.Component { {name} )} {icon && {name}/} - {!icon && } + {!icon && {this.iconString}} {showErrors && eventCount > 0 && !isActive && online && (