-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] adding a yLabel to the charts [add] adding units to the charts …
…tooltip [update] using granularity for tooltip timestamp
- Loading branch information
1 parent
1653f8a
commit 50b6cb9
Showing
5 changed files
with
70 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { createContext, useContext, useState } from "react"; | ||
|
||
import { Granularity } from "types/granularity"; | ||
|
||
export const ChartDataContext = createContext<{ | ||
granularity: Granularity | ||
setGranularity: (granularity: Granularity) => any | ||
unit: string | ||
yLabel: string | ||
}>(undefined); | ||
|
||
export const useChartData = () => useContext(ChartDataContext); | ||
|
||
export const ChartDataContextConsumer = ChartDataContext.Consumer; | ||
|
||
export interface ChartDataContextProps { | ||
unit: string | ||
yLabel: string | ||
children | ||
} | ||
|
||
export const ChartDataContextProvider = ({ children, unit, yLabel }: ChartDataContextProps) => { | ||
const [granularity, setGranularity] = useState<Granularity>("hour"); | ||
const [chartUnit, setUnit] = useState<string>(unit); | ||
const [chartYLabel, setYLabel] = useState<string>(yLabel); | ||
|
||
|
||
// SETTING THE VALUES | ||
return <ChartDataContext.Provider value={{ | ||
granularity, | ||
setGranularity, | ||
unit: chartUnit, | ||
yLabel: chartYLabel | ||
}}> | ||
{children} | ||
</ChartDataContext.Provider> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
import { Chart } from 'components/ui/charts/chart' | ||
import { ChartDataContextProvider } from 'contexts/chartData' | ||
import type { NextPage } from 'next' | ||
import { SEO } from 'components/common/seo' | ||
import { ServicesColorContextProvider } from 'contexts/servicesColor' | ||
import { useLanguage } from 'contexts/language' | ||
|
||
const Home: NextPage = () => { | ||
const { strings } = useLanguage(); | ||
|
||
return <div> | ||
<SEO description='Use multiple services to translate your texts!' /> | ||
return <ServicesColorContextProvider> | ||
<div> | ||
<SEO description='Use multiple services to translate your texts!' /> | ||
|
||
<div className="flex items-center flex-col p-3 gap-5 w-screen"> | ||
<div className='p-5 w-full'> | ||
<h2 className='text-xl font-bold'>{strings.heading.timeTakenForTranslation}</h2> | ||
<Chart endpoint='/stats/timings' /> | ||
</div> | ||
<div className='p-5 w-full'> | ||
<h2 className='text-xl font-bold'>{strings.heading.errorsCount}</h2> | ||
<Chart endpoint='/stats/errors' /> | ||
<div className="flex items-center flex-col p-3 gap-5 w-screen"> | ||
<div className='p-5 w-full'> | ||
<h2 className='text-xl font-bold'>{strings.heading.timeTakenForTranslation}</h2> | ||
<ChartDataContextProvider unit="ms" yLabel="Time (ms)"> | ||
<Chart endpoint='/stats/timings' /> | ||
</ChartDataContextProvider> | ||
</div> | ||
<div className='p-5 w-full'> | ||
<h2 className='text-xl font-bold'>{strings.heading.errorsCount}</h2> | ||
<ChartDataContextProvider unit="" yLabel="Count"> | ||
<Chart endpoint='/stats/errors' /> | ||
</ChartDataContextProvider> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</ServicesColorContextProvider> | ||
} | ||
|
||
export default Home |
50b6cb9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
translate – ./
translate-ruby.vercel.app
translatep.vercel.app
translatepy.vercel.app
translate-git-website-animenosekai.vercel.app
translate-animenosekai.vercel.app