Skip to content

Commit

Permalink
Merge pull request #1 from Sokilskill/add-i18
Browse files Browse the repository at this point in the history
Add i18
  • Loading branch information
Sokilskill authored Oct 22, 2024
2 parents 14f2f82 + 5a97bbf commit 0e13d69
Show file tree
Hide file tree
Showing 52 changed files with 763 additions and 301 deletions.
76 changes: 73 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"framer-motion": "^11.0.20",
"i18next": "^23.15.1",
"i18next-browser-languagedetector": "^8.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^15.0.2",
"react-router-dom": "^6.22.3",
"swiper": "^11.1.0"
},
Expand All @@ -28,10 +31,10 @@
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"husky": "^7.0.4",
"lint-staged": "^12.1.3",
"prettier": "^2.4.1"
"prettier": "^2.4.1",
"typescript": "^5.2.2",
"vite": "^5.2.0"
}
}
19 changes: 10 additions & 9 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ const App: React.FC = () => {
path="/"
element={
<Suspense fallback={<SuspenseLoader />}>
<Box
w={{ base: "375px", md: "1024px", lg: "1440px" }}
position="relative"
minHeight="100vh"
mx="auto"
overflow={"hidden"}
>
<Background />
<Box overflow-x={"hidden"}>
<Box
w={{ base: "375px", md: "1024px", lg: "1440px" }}
position="relative"
minHeight="100vh"
mx="auto"
>
<Background />

<LandingPage />
<LandingPage />
</Box>
</Box>
</Suspense>
}
Expand Down
10 changes: 5 additions & 5 deletions src/assets/logo/logo-mobile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 12 additions & 5 deletions src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@ import { Flex, Image, useBreakpointValue } from "@chakra-ui/react";
import { Animal } from "../../types";
import { CardInfo } from "./CardInfo";
import { CardButton } from "./CardButton";
import { useTranslation } from "react-i18next";

interface CardProps {
item: Animal;
}

export const Card: React.FC<CardProps> = ({ item }) => {
const { imgLg, imgMob, name, age, description } = item;
const { t } = useTranslation();

const { imgLg, imgMob, translationKey, age, description } = item;
const getImageSrc = useBreakpointValue({
base: imgMob,
md: imgLg,
lg: imgLg,
});

// форматування відображення віку
const formatAge = () => {
let ageText = "";

if (age.year) {
ageText = `${age.year} ${Number(age.year) > 1 ? "роки" : "рік"} `;
ageText = `${age.year} ${
Number(age.year) > 1 ? t("card.years") : t("card.year")
} `;
}
if (age.month) {
ageText += `${age.month} місяців`;
ageText += `${age.month} ${t("card.months")}`;
}
return ageText;
};
Expand All @@ -38,7 +42,10 @@ export const Card: React.FC<CardProps> = ({ item }) => {
borderTopRightRadius={"80px"}
/>
<Flex py="14px" justifyContent="space-between" alignItems="center">
<CardInfo name={name} ageText={formatAge()} />
<CardInfo
name={t(`animals.${translationKey}.name`)}
ageText={formatAge()}
/>

<CardButton />
</Flex>
Expand Down
5 changes: 4 additions & 1 deletion src/components/Card/CardInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Box, Heading, Text } from "@chakra-ui/react";
import { useTranslation } from "react-i18next";

interface CardInfo {
name: string;
ageText: string;
}
export const CardInfo: React.FC<CardInfo> = ({ name, ageText }) => {
const { t } = useTranslation();

return (
<Box>
<Heading
Expand All @@ -18,7 +21,7 @@ export const CardInfo: React.FC<CardInfo> = ({ name, ageText }) => {
</Heading>

<Text fontSize={{ lg: "24px" }} fontWeight={{ lg: 700 }}>
Вік {ageText}
{t("card.age")} {ageText}
</Text>
</Box>
);
Expand Down
13 changes: 8 additions & 5 deletions src/components/Footer/DonationInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { Box, Flex, Text } from "@chakra-ui/react";
import { useTranslation } from "react-i18next";

const DonationInfo: React.FC = () => {
const { t } = useTranslation();

return (
<>
<Text>Допомогти матеріально:</Text>
<Text>ГО “ХАТИНА”</Text>
<Text>{t("donation.donate_financially")}:</Text>
<Text>{t("donation.ngo_name")}</Text>
<Text text-wrap="nowrap">
ЄДРПОУ:
{t("donation.edrpou")}:
<Box as="strong" fontWeight={{ sm: 500, md: 600 }}>
123456789
</Box>
</Text>
<Text text-wrap="nowrap">Карта Приватбанку</Text>
<Text text-wrap="nowrap">{t("donation.privatbank_card")}</Text>
<Text fontWeight={{ sm: 600 }}>4141 2929 4646 1111</Text>
<Text>Прокопів Петро Павлович</Text>
<Text>{t("donation.account_holder_name")}</Text>
</>
);
};
Expand Down
86 changes: 40 additions & 46 deletions src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, Flex, Text } from "@chakra-ui/react";

import { LogoTabletDesk } from "../Logo";
import { Logo } from "../Logo";
import { NavList } from "../NavList/NavList";
import {
listGoodness,
Expand All @@ -11,54 +11,52 @@ import { useBreakpoint } from "../../hooks/useBreakpoint";
import { SocialSection } from "./SocialSection";
import { NavigationListsContainer } from "./NavigationListContainer";
import { HelpSection } from "./DonationInfo";
import { useTranslation } from "react-i18next";

const Footer: React.FC = () => {
const breakpoint = useBreakpoint();
const { t } = useTranslation();

const MobileDesktopFooter = () => {
return (
const MobileDesktopFooter = () => (
<Flex
direction={{ base: "column", lg: "row" }}
alignItems={{ base: "center", lg: "flex-start" }}
justify={{ md: "space-between", lg: "center" }}
gap={{ base: "36px", md: "unset" }}
mb="44px"
>
<SocialSection>
<Logo />
</SocialSection>

<NavigationListsContainer>
<NavList listItem={listGoodness} aria-label="Goodness" />
<NavList listItem={listAbout} aria-label="About us" />
<NavList listItem={listContactDetails} aria-label="Contact details" />
<HelpSection />
</NavigationListsContainer>
</Flex>
);

const TabletFooter = () => (
<>
<Flex
direction={{ base: "column", lg: "row" }}
alignItems={{ base: "center" }}
justify={{ md: "space-between", lg: "center" }}
gap={{ base: "36px", md: "unset" }}
flexDirection={{ md: "row" }}
justifyContent="space-between"
mb="44px"
>
<SocialSection>
<LogoTabletDesk />
</SocialSection>

<NavigationListsContainer>
<NavList listItem={listGoodness} aria-label="Goodness" />
<NavList listItem={listAbout} aria-label="About us" />
<NavList listItem={listContactDetails} aria-label="Contact details" />
<HelpSection />
</NavigationListsContainer>
<Logo style={{ mr: "0" }} />
<SocialSection />
<HelpSection />
</Flex>
);
};

const TabletFooter = () => {
return (
<>
<Flex
flexDirection={{ md: "row" }}
justifyContent="space-between"
mb="44px"
>
<LogoTabletDesk style={{ mr: "unset" }} />
<SocialSection />
<HelpSection />
</Flex>

<NavigationListsContainer>
<NavList listItem={listAbout} aria-label="About us" />
<NavList listItem={listGoodness} aria-label="Goodness" />
<NavList listItem={listContactDetails} aria-label="Contact details" />
</NavigationListsContainer>
</>
);
};
<NavigationListsContainer>
<NavList listItem={listAbout} aria-label="About us" />
<NavList listItem={listGoodness} aria-label="Goodness" />
<NavList listItem={listContactDetails} aria-label="Contact details" />
</NavigationListsContainer>
</>
);

return (
<Box
Expand All @@ -69,14 +67,10 @@ const Footer: React.FC = () => {
pb={{ base: "25px", md: "50px" }}
px={{ base: "16px", md: "32px", lg: "40px" }}
>
{breakpoint === "mobile" || breakpoint === "desktop" ? (
<MobileDesktopFooter />
) : (
<TabletFooter />
)}
{breakpoint !== "laptop" ? <MobileDesktopFooter /> : <TabletFooter />}

<Text textAlign="center" mt={20}>
© 2024. Всі права захищено <b>[email protected]</b>
© 2024. {t("policy")} <b>[email protected]</b>
</Text>
</Box>
);
Expand Down
Loading

0 comments on commit 0e13d69

Please sign in to comment.