Skip to content

Commit

Permalink
Merge pull request #305 from alleslabs/fix/validator-picture
Browse files Browse the repository at this point in the history
fix: ui avatar for validator not shown when encounter special chars
  • Loading branch information
evilpeach committed Apr 28, 2023
2 parents 8454469 + f8d98a7 commit e4521aa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#305](https://github.com/alleslabs/celatone-frontend/pull/305) Fix UI avatar for validator not shown when encounter special chars
- [#302](https://github.com/alleslabs/celatone-frontend/pull/302) Fix token card width, text size for unsupported token button in account details page and tx count color when equal to zero
- [#300](https://github.com/alleslabs/celatone-frontend/pull/300) Fix search bar's placeholder text and remove separator in latest block height
- [#290](https://github.com/alleslabs/celatone-frontend/pull/290) Fix spacing and styling in account detail
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/ValidatorBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useWallet } from "@cosmos-kit/react";
import { getChainApiPath } from "env";
import { ExplorerLink } from "lib/components/ExplorerLink";
import type { ValidatorInfo } from "lib/types";
import { removeSpecialChars } from "lib/utils";

interface ValidatorBadgeProps {
validator: ValidatorInfo | null;
Expand Down Expand Up @@ -44,9 +45,9 @@ export const ValidatorBadge = ({
currentChainName
)}/moniker/${validator.validatorAddress}.png`}
alt={validator.moniker}
fallbackSrc={`https://ui-avatars.com/api/?name=${
fallbackSrc={`https://ui-avatars.com/api/?name=${removeSpecialChars(
validator.moniker ?? ""
}&background=9793F3&color=fff`}
)}&background=9793F3&color=fff`}
borderRadius="50%"
/>
<ExplorerLink
Expand Down
1 change: 1 addition & 0 deletions src/lib/utils/formatter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from "./snakeToCamel";
export * from "./formatBalanceWithDenom";
export * from "./tokenType";
export * from "./token";
export * from "./text";
2 changes: 2 additions & 0 deletions src/lib/utils/formatter/text.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const removeSpecialChars = (text: string) =>
text.replace(/[^a-zA-Z0-9]/g, "");

2 comments on commit e4521aa

@vercel
Copy link

@vercel vercel bot commented on e4521aa Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on e4521aa Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.