Skip to content

Commit

Permalink
fix: remaining time & logo
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonSalvatoreDeveloper committed Mar 19, 2024
1 parent 586c43d commit 97a4452
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 41 deletions.
Binary file added src/assets/images/hiddify-logo-noroz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/pages/home/components/BrandAndLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Text } from "@designSystem/Text"
import { CardMedia } from "@mui/material";
import HLogo from '@assets/images/hiddify-logo.png'
import HLogo from '@assets/images/hiddify-logo-noroz.png'
import { getWindowData } from "../../../utils/getWindowData";
import { useState } from "react";

Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ShareIcon from '@mui/icons-material/Share';
import MenuDropdown from "./MenuDropdown";
import { Dispatch, FC, SetStateAction, useState } from "react";
import { Button, CardMedia, Tooltip } from "@mui/material";
import HLogo from '@assets/images/hiddify-logo.png'
import HLogo from '@assets/images/hiddify-logo-noroz.png'
import { Modal } from "../../../designSystem/Modal";
import ShareLinks from "./ShareLinks";
import DohContent from "./DohContent";
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/components/PreLoading.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Text } from '../../../designSystem/Text'
import HLogoSvg from '@assets/svg/hiddify-logo.svg?react';
import HLogoSvg from '@assets/images/hiddify-logo-noroz.png';



Expand All @@ -9,7 +9,7 @@ const PreLoading = () => {
<div className='bg-[#F4F4F9] w-screen h-screen overflow-hidden md:flex md:justify-center md:items-center'>
<div className='w-full h-full bg-transparent flex flex-col gap-5 items-center justify-center'>
<div className='w-[250px] h-[250px] md:w-[350px] md:h-[350px] bg-gray-300 bg-opacity-50 rounded-full flex items-center justify-center p-20'>
<HLogoSvg />
<img src={HLogoSvg} />
</div>
<Text fontSize='lg' fontWeight='semibold' className='text-[#455FE9]'>Hiddify</Text>
<Text fontSize='lg' fontWeight='semibold' className='text-[#455FE9]'>Powered By Hiddify.com</Text>
Expand Down
41 changes: 5 additions & 36 deletions src/pages/home/components/RemainingTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,19 @@ import AccessAlarmIcon from '@mui/icons-material/AccessAlarm';
import AllInclusiveIcon from '@mui/icons-material/AllInclusive';
import { ClickAwayListener, Tooltip } from '@mui/material';
import { useEffect, useState } from 'react';
import moment from 'moment';

Check failure on line 7 in src/pages/home/components/RemainingTime.tsx

View workflow job for this annotation

GitHub Actions / build-and-deploy

Cannot find module 'moment' or its corresponding type declarations.


const RemainingTime = ({ remainingDays, resetIn }) => {
const [showFullTime, setShowFullTime] = useState(false)
const [dateRepresentation, setDateRepresentation] = useState('-')
const { t } = useTranslation();

const calculateRemainingTime = (days) => {
const years = Math.floor(days / 365);
const months = Math.floor((days % 365) / 30);
const daysLeft = days % 365 === 0 || days % 30 === 0 ? 0 : days % 30;

return { years, months, days: daysLeft };
};

const [timeRemaining, setTimeRemaining] = useState(calculateRemainingTime(remainingDays));

useEffect(() => {
const remaining = calculateRemainingTime(remainingDays)

setTimeRemaining(remaining)

if (remaining.years > 0) {
setDateRepresentation(remaining.years + (remaining.years === 1 ? " " + t('Year') : " " + t('Years')))
} else if (remaining.months > 0) {
setDateRepresentation(remaining.months + (remaining.months === 1 ? " " + t('Month') : " " + t('Months')))
} else if (remaining.days > 0) {
setDateRepresentation(remaining.days + (remaining.days === 1 ? " " + t('Day') : " " + t('Days')))
}
}, [remainingDays]);

const tooltipContent = (
<div>
<span>
{t('Remaining time') + ': '}
{timeRemaining.years > 0 && (
<span>{timeRemaining.years} {timeRemaining.years === 1 ? t('Year') + ' ' : t('Years') + ' '}</span>
)}
{timeRemaining.months > 0 && (
<span>{timeRemaining.months} {timeRemaining.months === 1 ? t('Month') + ' ' : t('Months') + ' '}</span>
)}
{timeRemaining.days > 0 && (
<span>{timeRemaining.days} {timeRemaining.days === 1 ? t('Day') + ' ' : t('Days') + ' '}</span>
)}
</div>
{remainingDays ? remainingDays + ' ' + t('Days') : '-'}
</span>
);

return (
Expand All @@ -62,7 +31,7 @@ const RemainingTime = ({ remainingDays, resetIn }) => {
{t('Remaining time')}
</Text>
<Text className="text-[#212529] whitespace-nowrap" fontSize="sm" fontWeight="regular">
{remainingDays > 1000 ? <AllInclusiveIcon className='text-[#212529]' fontSize='small' /> : dateRepresentation ? dateRepresentation : '-'}
{remainingDays > 1000 ? <AllInclusiveIcon className='text-[#212529]' fontSize='small' /> : remainingDays ? remainingDays + ' ' + t('Days') : '-'}
</Text>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/components/UsedTraffic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const UsedTraffic = ({ current, total }) => {

return (
<ClickAwayListener onClickAway={() => setShowFullTraffic(false)}>
<Tooltip open={showFullTraffic} title={roundedCurrent || roundedCurrent === 0 ? t('Used Traffic') + ': ' + roundedCurrent + ' GB' : t('Used Traffic') + ': '} placement="top">
<Tooltip open={showFullTraffic} title={roundedCurrent ? t('Used Traffic') + ': ' + roundedCurrent + ' GB' : t('Used Traffic') + ': -'} placement="top">
<div onClick={() => setShowFullTraffic(!showFullTraffic)} className="flex flex-col lg:flex-row items-center justify-center gap-2">
<div className="w-8 h-8 bg-[#D6DEF7] rounded-[8px] flex items-center justify-center">
<InsertChartOutlinedIcon sx={{ color: '#495057'}} />
Expand Down

0 comments on commit 97a4452

Please sign in to comment.