Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed Dec 14, 2023
1 parent 3f474f3 commit dbfcae6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
34 changes: 13 additions & 21 deletions src/ui/deck-available-in-flag.tsx → src/ui/deck-category-logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,30 @@ const supportsEmojiFlag = WebApp.platform !== "tdesktop";

type Props = { logo: string; categoryName: string };

export const DeckAvailableInFlag = (props: Props) => {
export const DeckCategoryLogo = (props: Props) => {
const { logo, categoryName } = props;

if (supportsEmojiFlag) {
return logo;
}

const replacedFlag = replaceFlagEmojiOnWindows(logo);

return (
<span
className={css({ marginRight: 6 })}
title={`Deck category is ${categoryName}`}
>
{(() => {
if (supportsEmojiFlag) {
return logo;
}

const replacedFlag = replaceFlagEmojiOnWindows(logo);

if (!replacedFlag) {
return null;
}

return (
<img
src={`https://flagcdn.com/16x12/${replacedFlag}.png`}
width="16"
height="12"
alt={logo}
/>
);
})()}
{replacedFlag ? (
<img
src={`https://flagcdn.com/16x12/${replacedFlag}.png`}
width="16"
height="12"
alt={logo}
/>
) : (
logo
)}
</span>
);
};
4 changes: 2 additions & 2 deletions src/ui/deck-list-item-with-description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { css } from "@emotion/css";
import { theme } from "./theme.tsx";
import LinesEllipsis from "react-lines-ellipsis";
import React from "react";
import { DeckAvailableInFlag } from "./deck-available-in-flag.tsx";
import { DeckCategoryLogo } from "./deck-category-logo.tsx";

type Props = {
deck: {
Expand Down Expand Up @@ -45,7 +45,7 @@ export const DeckListItemWithDescription = observer((props: Props) => {
})}
>
{deck.deck_category?.logo ? (
<DeckAvailableInFlag
<DeckCategoryLogo
logo={deck.deck_category.logo}
categoryName={deck.deck_category.name}
/>
Expand Down

0 comments on commit dbfcae6

Please sign in to comment.