Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ui avatar for validator not shown when encounter special chars #305

Merged
merged 3 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,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, "");
Loading