Skip to content

Commit

Permalink
add stable classname to flair badge img
Browse files Browse the repository at this point in the history
  • Loading branch information
kabeaty committed Aug 10, 2023
1 parent 55ba208 commit 56e9485
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ const FlairBadgeConfigContainer: FunctionComponent<Props> = ({
[deleteFlairBadge]
);
const validFlairURL = useCallback(
(values: any) => {
(values: string) => {
const isValid = validateImageURL(flairBadgeURLInput, values);
return !(isValid === undefined);
},
[flairBadgeURLInput]
[flairBadgeURLInput, validateImageURL]
);
return (
<ConfigBox
Expand Down
5 changes: 5 additions & 0 deletions src/core/client/stream/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ const CLASSES = {
*/
userBadge: "coral coral-userBadge coral-comment-userBadge",

/**
* flairBadge can be used to target a flair badge image associated with a User.
*/
flairBadge: "coral coral-flairBadge coral-comment-flairBadge",

/**
* commentTag can be used to target a tag associated with a Comment.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import cn from "classnames";
import React, { FunctionComponent } from "react";
import { graphql } from "react-relay";

import { withFragmentContainer } from "coral-framework/lib/relay";
import CLASSES from "coral-stream/classes";
import { Tag } from "coral-ui/components/v2";

import { AuthorBadgesContainer_settings } from "coral-stream/__generated__/AuthorBadgesContainer_settings.graphql";
Expand All @@ -27,8 +29,17 @@ const AuthorBadgesContainer: FunctionComponent<Props> = ({
{badges.map((badge) => {
if (/\.(jpe?g|png|gif)$/i.test(badge)) {
if (settings.flairBadges?.flairBadgeURLs?.includes(badge)) {
// todo: add stable classname specific to flair badge
return <img src={badge} alt="" className={styles.flairBadge} />;
return (
<img
key={badge}
src={badge}
alt=""
className={cn(
styles.flairBadge,
CLASSES.comment.topBar.flairBadge
)}
/>
);
} else {
return null;
}
Expand Down

0 comments on commit 56e9485

Please sign in to comment.