Skip to content

Commit

Permalink
feat: use generic types
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-hosseini-deriv committed May 17, 2024
1 parent 6613791 commit 766e4e3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import React, { ReactElement } from "react";
import React, { ComponentProps, ReactElement } from "react";
import { Modal, Text } from "../../../main";
import "./LanguagesModal.scss";
import { IconTypes } from "@deriv/quill-icons";
import { LanguageItem } from "./LanguageItem";

type TLanguagesModalProps = {
isModalOpen: boolean;
languages: {
code: string;
displayName: string | ReactElement;
icon: IconTypes;
}[];
languages: ComponentProps<typeof LanguageItem>['language'][]
onClose: () => void;
onLanguageSwitch: (code: string) => void;
currentLang: string;
Expand Down
4 changes: 2 additions & 2 deletions src/components/AppLayout/LanguagesSwitcher/LanguageItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { ReactElement } from "react";
import { Button } from "../../Button";
import { Text } from "../../Text";
import { IconTypes } from "@deriv/quill-icons";
export type TLanguageItem = {
type TLanguageItem = {
code: string;
displayName: string | ReactElement;
icon: IconTypes;
};
export type TLangComponent = {
type TLangComponent = {
language: TLanguageItem;
onButtonClick: () => void;
currentLang: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "./LanguagesDrawer.scss";
import clsx from "clsx";
import { LanguageItem, TLanguageItem } from "./LanguageItem";
import { LanguageItem } from "./LanguageItem";
import { ComponentProps } from "react";

type TLanguageDrawer = {
onClose: () => void;
Expand All @@ -12,7 +13,7 @@ type TLanguageDrawer = {

// Define the props for the component using intersection type
type TLanguagesItemsDrawerProps = {
languages: TLanguageItem[];
languages: ComponentProps<typeof LanguageItem>['language'][];
} & TLanguageDrawer;

export const MobileLanguagesDrawer = ({
Expand Down

0 comments on commit 766e4e3

Please sign in to comment.