Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor insterface props #381

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import React, { ComponentPropsWithoutRef, ReactNode, useState } from 'react';
import { FiChevronDown, FiChevronUp, FiMinus, FiPlus } from 'react-icons/fi';

interface AccordionProps extends ComponentPropsWithoutRef<'div'> {
children?: ReactNode;
title: string;
customClass?: string;
state?: boolean;
}

interface AccordionCategoryProps extends ComponentPropsWithoutRef<'div'> {
categoryTitle: string | React.ReactNode;
categoryTitle: string | ReactNode;
state?: boolean;
isChild?: boolean;
iconOpen?: ReactNode;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Balance/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { ComponentPropsWithoutRef } from 'react';
import { MassaLogo } from '../Icons/Svg/Massa/MassaLogo';

export interface BalanceProps extends ComponentPropsWithoutRef<'div'> {
size: 'xs' | 'md' | 'lg';
size?: 'xs' | 'md' | 'lg' | undefined;
amount: string;
equal?: string;
customClass?: string;
}

export function Balance({ ...props }) {
export function Balance(props: BalanceProps) {
const { size = 'lg', amount, equal, customClass } = props;

const isLg = size === 'lg';
Expand Down
5 changes: 0 additions & 5 deletions src/components/Colors/Color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
// @ts-ignore
import React from 'react';

import { ComponentPropsWithoutRef } from 'react';

export interface ColorRectangleProps extends ComponentPropsWithoutRef<'div'> {
theme: string;
}
const baseClass = 'w-40 h-10 mb-2';
function Color({ color }: { color: string }) {
return <div id={color} className={`${baseClass} ${color}`} />;
Expand Down
3 changes: 2 additions & 1 deletion src/components/DashboardStation/DashboardStation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import React from 'react';

import { ReactNode, useEffect, useState } from 'react';
import { Theme } from '../../util/types';

export interface IDashboardStationProps {
imagesDark: ReactNode[];
imagesLight: ReactNode[];
components: ReactNode[];
theme?: string;
theme?: Theme | undefined;
}

export function DashboardStation(props: IDashboardStationProps) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/Icons/Svg/Massa/StationLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import React from 'react';

import { ComponentPropsWithoutRef } from 'react';
import { Theme } from '../../../../util/types';

interface SVGProps extends ComponentPropsWithoutRef<'div'> {
theme?: 'theme-light' | 'theme-dark' | undefined;
theme?: Theme | undefined;
}

/* eslint-disable max-len */
Expand Down
2 changes: 1 addition & 1 deletion src/components/Selector/Selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export function Selector(props: SelectorProps) {
content,
posIcon,
amount,
customClass,
variant = 'primary',
children,
customClass,
...rest
} = props;

Expand Down
10 changes: 5 additions & 5 deletions src/components/SidePanel/SidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ export interface SidePanelProps extends ComponentPropsWithoutRef<'div'> {
side?: 'left' | 'right';
customClass?: string;
children?: ReactNode;
onOpen?: () => void;
onClose?: () => void;
onOpen?: (e: ChangeEvent<unknown>) => void;
onClose?: (e: ChangeEvent<unknown>) => void;
}

export function SidePanel({ ...props }) {
export function SidePanel(props: SidePanelProps) {
const {
side = 'right',
customClass,
children,
onClose,
onOpen,
customClass,
onClose,
...rest
} = props;
const [toggle, setToggle] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tabs/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const tabsConfig = [
{
label: 'Tab 1',
content: <Button> Tab 1 component </Button>,
onClickTab: () => console.log('Hello'),
onClickTab: () => console.log('tab clicked'),
},
{
label: 'Tab 2',
Expand Down
6 changes: 4 additions & 2 deletions src/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import { ComponentPropsWithoutRef, useState } from 'react';

export interface TabConfig {
label: string;
content: string;
content: React.ReactNode | string;
onClickTab?: () => void;
}

export interface TabsProps extends ComponentPropsWithoutRef<'div'> {
tabsConfig: TabConfig[];
defaultIndex?: number | undefined;
}

export function Tabs({ ...props }) {
export function Tabs(props: TabsProps) {
const { tabsConfig, defaultIndex, ...rest } = props;
const [selectedIndex, setSelectedIndex] = useState(defaultIndex ?? 0);

Expand Down
3 changes: 2 additions & 1 deletion src/components/ThemeMode/ThemeMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import React from 'react';
import { useState } from 'react';
import { FiMoon, FiSun } from 'react-icons/fi';
import { useLocalStorage } from '../../util/useLocalStorage';
import { Theme } from '../../util/types';

interface ThemeProps {
onSetTheme?: (theme: string) => void;
onSetTheme?: (theme: Theme) => void;
}

export function ThemeMode(props: ThemeProps) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/Toggle/Toggle.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export default { title: 'Components/Toggle', component: Toggle };
export const _Toggle = {
render: () => (
<>
<Toggle size="sm" value="1" onClick={() => console.log('clicked')} />
<Toggle tShirtSize="sm" onClick={() => console.log('clicked')} />
<br />
<Toggle value="1" />
<Toggle />
<br />
<Toggle size="lg" value="1" />
<Toggle tShirtSize="lg" />
<br />
<Toggle value="1" disabled />
<Toggle disabled />
</>
),
};
8 changes: 4 additions & 4 deletions src/components/Toggle/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import React from 'react';

import { ComponentPropsWithoutRef } from 'react';

export interface ToggleProps extends ComponentPropsWithoutRef<'div'> {
size?: 'sm' | 'md' | 'lg';
export interface ToggleProps extends ComponentPropsWithoutRef<'input'> {
tShirtSize?: 'sm' | 'md' | 'lg' | undefined;
Thykof marked this conversation as resolved.
Show resolved Hide resolved
}

export function Toggle({ ...props }) {
const { size = 'md', ...rest } = props;
export function Toggle(props: ToggleProps) {
const { tShirtSize: size = 'md', ...rest } = props;

const isSm = size === 'sm';
const isMd = size === 'md';
Expand Down
6 changes: 3 additions & 3 deletions src/components/Token/Token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ export interface TokenProps extends ComponentPropsWithoutRef<'div'> {
onDelete?: () => void;
}

export function Token({ ...props }) {
export function Token(props: TokenProps) {
const {
logo,
name,
symbol,
decimals,
balance,
onDelete,
disable,
customClass,
disable,
onDelete,
...rest
} = props;

Expand Down
3 changes: 2 additions & 1 deletion src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { FiHelpCircle } from 'react-icons/fi';

export interface TooltipProps extends ComponentPropsWithoutRef<'div'> {
icon?: ReactNode;
customClass?: string;
}

export function Tooltip({ ...props }) {
export function Tooltip(props: TooltipProps) {
const { content, icon, customClass, ...rest } = props;

const [showTooltip, setShowTooltip] = useState(false);
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './components';
import './global.css';
export * from './util/types';
1 change: 1 addition & 0 deletions src/util/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Theme = 'theme-light' | 'theme-dark';
Loading