From 2242494e2da182ed4424192a69a4148233369210 Mon Sep 17 00:00:00 2001 From: Bhushan Pardeshi Date: Fri, 8 Nov 2024 17:38:54 +0530 Subject: [PATCH 1/3] migrated --- src/components/TutorialMetadata.tsx | 163 +++++++++++----------------- 1 file changed, 62 insertions(+), 101 deletions(-) diff --git a/src/components/TutorialMetadata.tsx b/src/components/TutorialMetadata.tsx index bc081d90304..ae7dab2abca 100644 --- a/src/components/TutorialMetadata.tsx +++ b/src/components/TutorialMetadata.tsx @@ -1,22 +1,23 @@ -import { useRouter } from "next/router" -import { useTranslation } from "next-i18next" -import { Badge, Box, Flex, HStack, Text } from "@chakra-ui/react" +import { useRouter } from "next/router"; +import { useTranslation } from "next-i18next"; +import { Badge } from "@chakra-ui/react"; -import type { Lang, TranslationKey } from "@/lib/types" -import { TutorialFrontmatter } from "@/lib/interfaces" +import type { Lang, TranslationKey } from "@/lib/types"; +import { TutorialFrontmatter } from "@/lib/interfaces"; -import CopyToClipboard from "@/components/CopyToClipboard" -import Emoji from "@/components/Emoji" -import InlineLink from "@/components/Link" -import Translation from "@/components/Translation" -import TutorialTags from "@/components/TutorialTags" +import CopyToClipboard from "@/components/CopyToClipboard"; +import Emoji from "@/components/Emoji"; +import InlineLink from "@/components/Link"; +import Translation from "@/components/Translation"; +import TutorialTags from "@/components/TutorialTags"; -import { getLocaleTimestamp } from "@/lib/utils/time" +import { getLocaleTimestamp } from "@/lib/utils/time"; +import { Flex } from "./ui/flex"; export type TutorialMetadataProps = { - frontmatter: TutorialFrontmatter - timeToRead: number -} + frontmatter: TutorialFrontmatter; + timeToRead: number; +}; export enum Skill { BEGINNER = "beginner", @@ -25,120 +26,80 @@ export enum Skill { } export const getSkillTranslationId = (skill: Skill): TranslationKey => - `page-developers-tutorials:page-tutorial-${ - Skill[skill.toUpperCase() as keyof typeof Skill] - }` + `page-developers-tutorials:page-tutorial-${Skill[skill.toUpperCase() as keyof typeof Skill] + }`; const TutorialMetadata = ({ frontmatter, timeToRead, }: TutorialMetadataProps) => { - const { locale } = useRouter() - const { t } = useTranslation("page-developers-tutorials") + const { locale } = useRouter(); + const { t } = useTranslation("page-developers-tutorials"); - const hasSource = frontmatter.source && frontmatter.sourceUrl - const published = frontmatter.published - const author = frontmatter.author - const address = frontmatter.address + const hasSource = frontmatter.source && frontmatter.sourceUrl; + const published = frontmatter.published; + const author = frontmatter.author; + const address = frontmatter.address; return ( - - - + + +
- - +
+ {t(getSkillTranslationId(frontmatter.skill as Skill))} -
+
- +
{author && ( - +
{author} - +
)} {hasSource && ( - +
{frontmatter.source} - +
)} {published && ( - +
{" "} {getLocaleTimestamp(locale! as Lang, published)} - +
)} - - +
+ {timeToRead} {t("comp-tutorial-metadata-minute-read")} minute read - - - - {address && ( - - - {(isCopied) => ( - - +
+ {address && ( +
+ + {(isCopied) => ( +
+
+ {" "} - {address} {isCopied && } - {isCopied && ( - - )} - - )} - - - )} - +
+ {address} {isCopied && } + {isCopied && ( + + )} +
+ )} +
+
+ )} - ) -} + ); +}; -export default TutorialMetadata +export default TutorialMetadata; From 88b49aa976a16de161e67bebc2e912d2321b0e0c Mon Sep 17 00:00:00 2001 From: Bhushan Pardeshi Date: Sat, 9 Nov 2024 17:59:03 +0530 Subject: [PATCH 2/3] used flex --- src/components/TutorialMetadata.tsx | 88 ++++++++++++++--------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/components/TutorialMetadata.tsx b/src/components/TutorialMetadata.tsx index ae7dab2abca..78a486e11a8 100644 --- a/src/components/TutorialMetadata.tsx +++ b/src/components/TutorialMetadata.tsx @@ -1,23 +1,24 @@ -import { useRouter } from "next/router"; -import { useTranslation } from "next-i18next"; -import { Badge } from "@chakra-ui/react"; +import { useRouter } from "next/router" +import { useTranslation } from "next-i18next" +import { Badge } from "@chakra-ui/react" -import type { Lang, TranslationKey } from "@/lib/types"; -import { TutorialFrontmatter } from "@/lib/interfaces"; +import type { Lang, TranslationKey } from "@/lib/types" +import { TutorialFrontmatter } from "@/lib/interfaces" -import CopyToClipboard from "@/components/CopyToClipboard"; -import Emoji from "@/components/Emoji"; -import InlineLink from "@/components/Link"; -import Translation from "@/components/Translation"; -import TutorialTags from "@/components/TutorialTags"; +import CopyToClipboard from "@/components/CopyToClipboard" +import Emoji from "@/components/Emoji" +import InlineLink from "@/components/Link" +import Translation from "@/components/Translation" +import TutorialTags from "@/components/TutorialTags" -import { getLocaleTimestamp } from "@/lib/utils/time"; -import { Flex } from "./ui/flex"; +import { getLocaleTimestamp } from "@/lib/utils/time" + +import { Flex } from "./ui/flex" export type TutorialMetadataProps = { - frontmatter: TutorialFrontmatter; - timeToRead: number; -}; + frontmatter: TutorialFrontmatter + timeToRead: number +} export enum Skill { BEGINNER = "beginner", @@ -27,31 +28,34 @@ export enum Skill { export const getSkillTranslationId = (skill: Skill): TranslationKey => `page-developers-tutorials:page-tutorial-${Skill[skill.toUpperCase() as keyof typeof Skill] - }`; + }` const TutorialMetadata = ({ frontmatter, timeToRead, }: TutorialMetadataProps) => { - const { locale } = useRouter(); - const { t } = useTranslation("page-developers-tutorials"); + const { locale } = useRouter() + const { t } = useTranslation("page-developers-tutorials") - const hasSource = frontmatter.source && frontmatter.sourceUrl; - const published = frontmatter.published; - const author = frontmatter.author; - const address = frontmatter.address; + const hasSource = frontmatter.source && frontmatter.sourceUrl + const published = frontmatter.published + const author = frontmatter.author + const address = frontmatter.address return ( - - -
+ + + -
- +
+ {t(getSkillTranslationId(frontmatter.skill as Skill))}
-
+ {author && (
@@ -59,7 +63,7 @@ const TutorialMetadata = ({
)} {hasSource && ( -
+
{frontmatter.source} @@ -67,27 +71,23 @@ const TutorialMetadata = ({
)} {published && ( -
+
{" "} {getLocaleTimestamp(locale! as Lang, published)}
)} -
- +
+ {timeToRead} {t("comp-tutorial-metadata-minute-read")} minute read
-
+ {address && ( -
+ {(isCopied) => ( -
+
- {" "} + {" "}
{address} {isCopied && } {isCopied && ( @@ -96,10 +96,10 @@ const TutorialMetadata = ({
)} -
+
)} - ); -}; + ) +} -export default TutorialMetadata; +export default TutorialMetadata \ No newline at end of file From 0e138a20fdeaf4dd97f9cad36956f1e061640583 Mon Sep 17 00:00:00 2001 From: Pablo Date: Tue, 24 Dec 2024 12:21:42 +0100 Subject: [PATCH 3/3] fix translation and placement of address text --- src/components/TutorialMetadata.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/TutorialMetadata.tsx b/src/components/TutorialMetadata.tsx index 78a486e11a8..d2565a5cb0d 100644 --- a/src/components/TutorialMetadata.tsx +++ b/src/components/TutorialMetadata.tsx @@ -27,7 +27,8 @@ export enum Skill { } export const getSkillTranslationId = (skill: Skill): TranslationKey => - `page-developers-tutorials:page-tutorial-${Skill[skill.toUpperCase() as keyof typeof Skill] + `page-developers-tutorials:page-tutorial-${ + Skill[skill.toUpperCase() as keyof typeof Skill] }` const TutorialMetadata = ({ @@ -82,16 +83,16 @@ const TutorialMetadata = ({
{address && ( - + {(isCopied) => ( -
-
- {" "} -
- {address} {isCopied && } +
+ + + {" "} + {address} {isCopied && }{" "} {isCopied && ( - + )}
)} @@ -102,4 +103,4 @@ const TutorialMetadata = ({ ) } -export default TutorialMetadata \ No newline at end of file +export default TutorialMetadata