Skip to content

Commit

Permalink
feat: interpolate anchor from i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
irfancoder committed Jan 16, 2023
1 parent f7f9e3d commit 3f6a96f
Show file tree
Hide file tree
Showing 78 changed files with 153 additions and 105 deletions.
2 changes: 1 addition & 1 deletion components/Chart/ChartHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CountryAndStates } from "@lib/constants";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { FunctionComponent, ReactNode } from "react";
export interface ChartHeaderProps {
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion components/Chart/Choropleth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import StateMobile from "@lib/geojson/state_mobile.json";
import { numFormat } from "@lib/helpers";
import { BREAKPOINTS } from "@lib/constants";
import { useWindowWidth } from "@hooks/useWindowWidth";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useZoom } from "@hooks/useZoom";
import { ArrowPathIcon, MinusSmallIcon, PlusSmallIcon } from "@heroicons/react/24/outline";
import type { ChoroplethColors } from "@lib/types";
Expand Down
2 changes: 1 addition & 1 deletion components/Chart/Choropleth/scale.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent } from "react";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { sequentialColorSchemes, colorSchemes } from "@nivo/colors";
import type { ChoroplethColors } from "@lib/types";
import { numFormat } from "@lib/helpers";
Expand Down
2 changes: 1 addition & 1 deletion components/Chart/Jitterplot/overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/24/outline";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { FunctionComponent } from "react";

interface JitterplotOverlayProps {
Expand Down
23 changes: 11 additions & 12 deletions components/Chart/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Dispatch,
SetStateAction,
useCallback,
ReactNode,
} from "react";
import {
ColumnDef,
Expand All @@ -26,7 +27,7 @@ import { ArrowUpIcon, ArrowDownIcon } from "@heroicons/react/20/solid";
import { rankItem } from "@tanstack/match-sorter-utils";
import { CountryAndStates } from "@lib/constants";
import Image from "next/image";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { default as debounce } from "lodash/debounce";
import type { DebouncedFunc } from "lodash";

Expand All @@ -38,7 +39,7 @@ export interface TableConfigColumn {

export interface TableConfig {
id: string | undefined;
header?: string;
header?: ReactNode;
accessorKey?: string;
className?: string;
/**
Expand Down Expand Up @@ -254,21 +255,19 @@ const Table: FunctionComponent<TableProps> = ({
const scale = cell.column.columnDef.scale ?? undefined;

const classNames = [
...(cell.row.original.state === "mys" ? ["bg-outline"] : []),
...(lastCellInGroup.id === cell.column.id
? ["text-sm border-r-black"]
: []),
...(relative
? [relativeColor(value as number, inverse), "bg-opacity-20"]
: []),
...(scale ? [scaleColor(value as number)] : []),
...(value === null ? ["bg-outlineHover"] : []),
cell.row.original.state === "mys" && "bg-outline",
lastCellInGroup.id === cell.column.id && "text-sm border-r-black",
relative ? relativeColor(value as number, inverse) : "bg-opacity-20",
scale && scaleColor(value as number),
value === null && "bg-outlineHover",
index !== 0
? cell.column.columnDef.className
? cell.column.columnDef.className
: cellClass
: "",
].join(" ");
]
.filter(Boolean)
.join(" ");

return (
<td key={cell.id} className={classNames}>
Expand Down
14 changes: 11 additions & 3 deletions components/Chart/Timeseries/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { FunctionComponent, ReactElement, useMemo, useCallback, ForwardedRef } from "react";
import {
FunctionComponent,
ReactElement,
ReactNode,
useMemo,
useCallback,
ForwardedRef,
} from "react";
import Tooltip from "@components/Tooltip";
import { default as ChartHeader, ChartHeaderProps } from "@components/Chart/ChartHeader";
import {
Expand All @@ -17,6 +24,7 @@ import {
ChartTypeRegistry,
Filler,
BarController,
ChartDataset,
} from "chart.js";
import { CrosshairPlugin } from "chartjs-plugin-crosshair";
import AnnotationPlugin from "chartjs-plugin-annotation";
Expand Down Expand Up @@ -149,7 +157,7 @@ const Timeseries: FunctionComponent<TimeseriesProps> = ({
intersect: false,
callbacks: {
label: function (item) {
return `${item.dataset.label}: ${
return `${item.dataset.label as string}: ${
item.parsed.y !== undefined || item.parsed.y !== null
? display(item.parsed.y, "standard", 1)
: "-"
Expand Down Expand Up @@ -391,7 +399,7 @@ interface StatsProps {
}

type StatProps = {
title: string;
title: ReactNode;
value: string;
tooltip?: string;
};
Expand Down
2 changes: 1 addition & 1 deletion components/Chips/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Button from "@components/Button";
import { OptionType } from "@components/types";
import { XMarkIcon } from "@heroicons/react/24/outline";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { FunctionComponent } from "react";

interface ChipsProps {
Expand Down
2 changes: 1 addition & 1 deletion components/CodeBlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import python from "highlight.js/lib/languages/python";
import "highlight.js/styles/shades-of-purple.css";
import { OptionType } from "@components/types";
import { copyClipboard } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { track } from "@lib/mixpanel";

interface CodeBlockProps {
Expand Down
2 changes: 1 addition & 1 deletion components/Combobox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Fragment, useState } from "react";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { Combobox, Transition } from "@headlessui/react";

import { OptionType } from "@components/types";
Expand Down
2 changes: 1 addition & 1 deletion components/Dropdown/StateDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { OptionType } from "@components/types";
import { useWindowScroll } from "@hooks/useWindowWidth";
import { statesOptions } from "@lib/options";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useRouter } from "next/router";
import { FunctionComponent, useMemo } from "react";
import { default as Dropdown } from ".";
Expand Down
4 changes: 2 additions & 2 deletions components/Dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ type ConditionalProps<L, V> =
multiple?: false;
selected?: any;
title?: never;
placeholder?: string;
placeholder?: ReactNode;
onChange: (selected: any) => void;
};

type DropdownProps<L, V> = CommonProps<L, V> & ConditionalProps<L, V> & LabelProps;

const Dropdown = <L extends string | number | ReactElement = string, V = string>({
const Dropdown = <L extends string | number | ReactElement | ReactElement[] = string, V = string>({
className = "flex-col lg:flex-row ",
disabled = false,
multiple = false,
Expand Down
2 changes: 1 addition & 1 deletion components/Error/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Dropdown from "@components/Dropdown";
import { GlobeAltIcon } from "@heroicons/react/24/outline";
import "highlight.js/styles/shades-of-purple.css";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { FunctionComponent } from "react";

interface ErrorProps {
Expand Down
2 changes: 1 addition & 1 deletion components/Layout/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from "next/link";
import Image from "next/image";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";

import Container from "@components/Container";
import At from "@components/At";
Expand Down
2 changes: 1 addition & 1 deletion components/Layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Link from "next/link";
import Image from "next/image";
import { FunctionComponent, ReactElement, useState } from "react";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import {
HomeIcon,
Bars3BottomRightIcon,
Expand Down
2 changes: 1 addition & 1 deletion components/Modal/StateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FunctionComponent, useEffect, useState } from "react";
import Modal from ".";
import { useRouter } from "next/router";
import { useWindowScroll } from "@hooks/useWindowWidth";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";

interface StateModalProps {
exclude?: string[];
Expand Down
2 changes: 1 addition & 1 deletion components/Search/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MagnifyingGlassIcon as SearchIcon } from "@heroicons/react/24/solid";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { FunctionComponent, useEffect, useRef } from "react";

type SearchProps = {
Expand Down
4 changes: 2 additions & 2 deletions components/Section/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useRouter } from "next/router";
import { FunctionComponent, ReactNode, forwardRef, LegacyRef, ForwardedRef, useMemo } from "react";
import { DateTime } from "luxon";
Expand Down Expand Up @@ -35,7 +35,7 @@ const Section: FunctionComponent<SectionProps> = forwardRef(
<section className={className} ref={ref}>
<div className="pb-2 lg:pb-4">
<div className="flex flex-col items-start gap-2 pb-4 lg:flex-row lg:items-center lg:justify-between">
{title && typeof title === "string" ? <h4>{title}</h4> : title}
<h4>{title}</h4>
{date && date !== null && (
<span className="text-right text-sm text-dim">
{t("common.data_of", { date: displayDate })}
Expand Down
2 changes: 1 addition & 1 deletion components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FunctionComponent, ReactNode, useState } from "react";
import { Transition } from "@headlessui/react";
import Button from "@components/Button";
import { Bars3BottomLeftIcon, XMarkIcon } from "@heroicons/react/24/outline";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";

interface SidebarProps {
children: ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion components/Tabs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FunctionComponent, ReactElement, ReactNode, useMemo, useState } from "react";
import { Tab } from "@headlessui/react";
import { CountryAndStates } from "@lib/constants";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";

interface TabsProps {
children: ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion components/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactElement } from "react";

export type OptionType<L = ReactElement | string, V = string> = {
export type OptionType<L = ReactElement | ReactElement[] | string, V = string> = {
label: L;
value: V;
};
2 changes: 1 addition & 1 deletion dashboards/composite-indices/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Container, Dropdown, Hero, Section } from "@components/index";
import { FunctionComponent, useCallback, useEffect, useMemo } from "react";
import dynamic from "next/dynamic";
import { numFormat, toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useSlice } from "@hooks/useSlice";
import { useData } from "@hooks/useData";
import type { OptionType } from "@components/types";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/consumer-prices/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Container, Dropdown, Hero, Section } from "@components/index";
import { FunctionComponent, useCallback, useEffect } from "react";
import dynamic from "next/dynamic";
import { numFormat, toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useSlice } from "@hooks/useSlice";
import { useData } from "@hooks/useData";
import type { OptionType } from "@components/types";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/consumer-prices/inflation-snapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useWatch } from "@hooks/useWatch";
import { get } from "@lib/api";
import { SHORT_LANG } from "@lib/constants";
import type { ChartDataset } from "chart.js";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import dynamic from "next/dynamic";
import { FunctionComponent, useCallback } from "react";

Expand Down
2 changes: 1 addition & 1 deletion dashboards/consumer-prices/inflation-trends.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SHORT_LANG } from "@lib/constants";
import { numFormat } from "@lib/helpers";
import type { ChartDataset, ChartTypeRegistry } from "chart.js";
import groupBy from "lodash/groupBy";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import dynamic from "next/dynamic";
import { FunctionComponent, useCallback } from "react";

Expand Down
2 changes: 1 addition & 1 deletion dashboards/crime/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Image from "next/image";
import { FunctionComponent, useEffect } from "react";
import dynamic from "next/dynamic";
import { flip, numFormat, toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useData } from "@hooks/useData";
import { AKSARA_COLOR, CountryAndStates } from "@lib/constants";
import { useRouter } from "next/router";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/currency-in-circulation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Container, Dropdown, Hero, Section } from "@components/index";
import { FunctionComponent, useCallback, useEffect } from "react";
import dynamic from "next/dynamic";
import { numFormat, smartNumFormat, toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useSlice } from "@hooks/useSlice";
import { useData } from "@hooks/useData";
import type { OptionType } from "@components/types";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/daily-prices/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Container, Hero, Section, StateDropdown } from "@components/index";
import { FunctionComponent, useEffect } from "react";
import dynamic from "next/dynamic";
import { toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useRouter } from "next/router";
import { routes } from "@lib/routes";
import { AKSARA_COLOR, CountryAndStates } from "@lib/constants";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/drug-addiction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Container, Hero, Section, StateDropdown } from "@components/index";
import { FunctionComponent, useEffect } from "react";
import dynamic from "next/dynamic";
import { toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useRouter } from "next/router";
import { routes } from "@lib/routes";
import { AKSARA_COLOR, CountryAndStates } from "@lib/constants";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/exchange-rates/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FunctionComponent, useCallback, useEffect } from "react";
import dynamic from "next/dynamic";
import { sortMulti, toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useData } from "@hooks/useData";
import { AKSARA_COLOR, SHORT_LANG } from "@lib/constants";
import { default as Tabs, Panel } from "@components/Tabs";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/gdp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Container, Dropdown, Hero, Section } from "@components/index";
import { FunctionComponent, useCallback, useEffect } from "react";
import dynamic from "next/dynamic";
import { numFormat, smartNumFormat, toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useSlice } from "@hooks/useSlice";
import { useData } from "@hooks/useData";
import type { OptionType } from "@components/types";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/industrial-production/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Slider from "@components/Chart/Slider";
import { FunctionComponent, useCallback, useEffect, useMemo } from "react";
import dynamic from "next/dynamic";
import { numFormat, toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useSlice } from "@hooks/useSlice";
import { useData } from "@hooks/useData";
import type { OptionType } from "@components/types";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/interest-rates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Container, Dropdown, Hero, Section } from "@components/index";
import { FunctionComponent, useCallback, useEffect } from "react";
import dynamic from "next/dynamic";
import { numFormat, toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useSlice } from "@hooks/useSlice";
import { useData } from "@hooks/useData";
import type { OptionType } from "@components/types";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/international-reserves/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Container, Dropdown, Hero, Section } from "@components/index";
import { FunctionComponent, useCallback, useEffect } from "react";
import dynamic from "next/dynamic";
import { numFormat, toDate } from "@lib/helpers";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useSlice } from "@hooks/useSlice";
import { useData } from "@hooks/useData";
import type { OptionType } from "@components/types";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/kawasanku/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { JitterData } from "@components/Chart/Jitterplot";
import Container from "@components/Container";
import Hero from "@components/Hero";
import Section from "@components/Section";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { FunctionComponent, useEffect, useMemo } from "react";
import JitterplotOverlay from "@components/Chart/Jitterplot/overlay";
import Dropdown from "@components/Dropdown";
Expand Down
2 changes: 1 addition & 1 deletion dashboards/labour-market/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Slider from "@components/Chart/Slider";
import { FunctionComponent, useEffect } from "react";
import dynamic from "next/dynamic";
import { default as Image } from "next/image";
import { useTranslation } from "next-i18next";
import { useTranslation } from "@hooks/useTranslation";
import { useData } from "@hooks/useData";
import { useSlice } from "@hooks/useSlice";
import { AKSARA_COLOR, CountryAndStates } from "@lib/constants";
Expand Down
Loading

0 comments on commit 3f6a96f

Please sign in to comment.