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: remove import * as React from 'react' statements #190

Merged
merged 1 commit into from
May 16, 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
2 changes: 0 additions & 2 deletions src/components/dashboard/dashboard-header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from 'react';

export function DashboardHeader() {
return (
<header className="flex items-center px-6 h-[60px] border-b border-chungking-grey-100 dark:border-chungking-grey-900">
Expand Down
4 changes: 2 additions & 2 deletions src/components/dashboard/dashboard-root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { type PropsWithChildren } from 'react';

export function DashboardRoot({ children }: React.PropsWithChildren) {
export function DashboardRoot({ children }: PropsWithChildren) {
return (
<main className="flex flex-col w-full h-full min-h-screen overflow-hidden bg-chungking-white text-chungking-black dark:bg-chungking-black dark:text-chungking-white">
{children}
Expand Down
1 change: 0 additions & 1 deletion src/components/dashboard/dashboard-sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Home } from 'react-feather';

export function DashboardSidebar() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/dashboard/page/dashboard-page-content.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { type PropsWithChildren } from 'react';

export function DashboardPageContent({ children }: React.PropsWithChildren) {
export function DashboardPageContent({ children }: PropsWithChildren) {
return (
<section className="flex-auto pt-6 px-6 pb-8">
<div className="mx-auto w-full max-w-5xl">{children}</div>
Expand Down
8 changes: 2 additions & 6 deletions src/components/dashboard/page/dashboard-page-header.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import * as React from 'react';

export interface DashboardPageHeaderProps {
title: string;
subtitle?: string;
}

export const DashboardPageHeader: React.FC<DashboardPageHeaderProps> = ({ title, subtitle }) => {
export function DashboardPageHeader({ title, subtitle }: DashboardPageHeaderProps) {
return (
<header className="pt-6 px-6 pb-4 border-b border-chungking-grey-100 dark:border-chungking-grey-900">
<div className="mx-auto w-full max-w-5xl">
Expand All @@ -14,6 +12,4 @@ export const DashboardPageHeader: React.FC<DashboardPageHeaderProps> = ({ title,
</div>
</header>
);
};

export default DashboardPageHeader;
}
4 changes: 2 additions & 2 deletions src/components/dashboard/section/dashboard-section-header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { type PropsWithChildren } from 'react';

export function DashboardSectionHeader({ children }: React.PropsWithChildren) {
export function DashboardSectionHeader({ children }: PropsWithChildren) {
return <h2 className="text-3xl font-semibold">{children}</h2>;
}
4 changes: 2 additions & 2 deletions src/components/dashboard/section/dashboard-section.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { type PropsWithChildren } from 'react';

export function DashboardSection({ children }: React.PropsWithChildren) {
export function DashboardSection({ children }: PropsWithChildren) {
return <div className="space-y-6">{children}</div>;
}
6 changes: 3 additions & 3 deletions src/components/info-item-card/info-item-card.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import clsx from 'clsx';
import * as React from 'react';
import { forwardRef, type ComponentPropsWithoutRef } from 'react';

export interface InfoItemCardProps extends React.ComponentPropsWithoutRef<'section'> {
export interface InfoItemCardProps extends ComponentPropsWithoutRef<'section'> {
title?: string;
content: string;
}

export const InfoItemCard = React.forwardRef<HTMLElement, InfoItemCardProps>(
export const InfoItemCard = forwardRef<HTMLElement, InfoItemCardProps>(
({ title, content, className, ...rest }, ref) => {
return (
<section
Expand Down
1 change: 0 additions & 1 deletion src/components/link-list/link-list-item.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Link from 'next/link';
import * as React from 'react';

export interface LinkListItemProps {
title: string;
Expand Down
6 changes: 2 additions & 4 deletions src/components/link-list/link-list.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import * as React from 'react';

import { LinkListItem, LinkListItemProps } from './link-list-item';

export interface LinkListProps {
items: LinkListItemProps[];
}

export const LinkList: React.FC<LinkListProps> = ({ items }) => {
export function LinkList({ items }: LinkListProps) {
return (
<ul className="grid gap-6 grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
{items.map(({ title, url }) => (
<LinkListItem key={url} title={title} url={url} />
))}
</ul>
);
};
}
2 changes: 0 additions & 2 deletions src/layouts/dashbard-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* eslint-disable jsx-a11y/anchor-is-valid */

import * as React from 'react';
import { DashboardHeader, DashboardRoot } from '~/components/dashboard';

export function DashboardLayout({ children }: React.PropsWithChildren) {
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/overlay-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { type PropsWithChildren } from 'react';
import { GoogleFontsPrefetch } from '~/modules/webfonts/google-fonts-prefetch';

export function OverlayLayout({ children }: React.PropsWithChildren) {
export function OverlayLayout({ children }: PropsWithChildren) {
return (
<>
<GoogleFontsPrefetch />
Expand Down
23 changes: 15 additions & 8 deletions src/modules/alert-manager/alert-toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

import { Transition } from '@headlessui/react';
import clsx from 'clsx';
import * as React from 'react';
import {
ComponentPropsWithoutRef,
createElement,
forwardRef,
useEffect,
useMemo,
useState,
} from 'react';
import {
IconBits,
IconExclamationMark,
Expand All @@ -14,7 +21,7 @@ import {
import alertsAudio from '~/lib/data/alerts-audio';
import { AlertEventTypes } from '.';

interface AlertToastProps extends React.ComponentPropsWithoutRef<'div'> {
interface AlertToastProps extends ComponentPropsWithoutRef<'div'> {
title: string;
recipient?: string;
amount?: string;
Expand Down Expand Up @@ -51,15 +58,15 @@ function alertToastVariants(variant?: AlertEventTypes) {
}
}

export const AlertToast = React.forwardRef<HTMLDivElement, AlertToastProps>(
export const AlertToast = forwardRef<HTMLDivElement, AlertToastProps>(
({ title, recipient, amount, variant = 'follow', content, ...rest }, ref) => {
const [isMounted, setIsMounted] = React.useState(false);
const audio = React.useMemo(
const [isMounted, setIsMounted] = useState(false);
const audio = useMemo(
() => (alertsAudio[variant]?.src ? new Audio(alertsAudio[variant]?.src) : undefined),
[variant],
);

React.useEffect(() => {
useEffect(() => {
void audio?.play();

const timeout = setTimeout(() => {
Expand All @@ -71,7 +78,7 @@ export const AlertToast = React.forwardRef<HTMLDivElement, AlertToastProps>(
};
}, [audio]);

const currentVariant = React.useMemo(() => alertToastVariants(variant), [variant]);
const currentVariant = useMemo(() => alertToastVariants(variant), [variant]);

return (
<div className={clsx('relative w-full h-[62px]', currentVariant.colors)} ref={ref} {...rest}>
Expand All @@ -82,7 +89,7 @@ export const AlertToast = React.forwardRef<HTMLDivElement, AlertToastProps>(
)}
>
<div className="flex items-center flex-shrink-0 h-[40px] space-x-4 pr-4">
{React.createElement(currentVariant.icon, {
{createElement(currentVariant.icon, {
className: 'inline-flex w-6 h-6 rounded-full',
'aria-hidden': true,
})}
Expand Down
8 changes: 4 additions & 4 deletions src/modules/alert-manager/alert-wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import { useEffect, useRef, useState } from 'react';
import { Transition } from '@headlessui/react';
import { AlertSettings } from './types';

Expand All @@ -15,10 +15,10 @@ export function AlertWrapper({
onRemove,
dismissAfter = 5000,
}: AlertWrapperProps) {
const [isOpen, setIsOpen] = React.useState(false);
const closeTimerRef = React.useRef<NodeJS.Timeout | undefined>(undefined);
const [isOpen, setIsOpen] = useState(false);
const closeTimerRef = useRef<NodeJS.Timeout | undefined>(undefined);

React.useEffect(() => {
useEffect(() => {
setIsOpen(true);

closeTimerRef.current = setTimeout(() => {
Expand Down
12 changes: 6 additions & 6 deletions src/modules/alerts/streamelements-alerts.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client';

/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import * as React from 'react';
import { nanoid } from 'nanoid';
import { useEffect, useState } from 'react';
import {
allowedEventListeners,
allowedTestEventListeners,
Expand All @@ -19,9 +19,9 @@ const dismissAfter = DEFAULT_DISMISS_DURATION;
type ProdOrTestEvent = StreamElementsEvent | StreamElementsTestEvent;

export function StreamElementsAlerts() {
const [events, setEvents] = React.useState<ProdOrTestEvent[]>([]);
const [stale, setStale] = React.useState(false);
const [current, setCurrent] = React.useState<ProdOrTestEvent | undefined>(undefined);
const [events, setEvents] = useState<ProdOrTestEvent[]>([]);
const [stale, setStale] = useState(false);
const [current, setCurrent] = useState<ProdOrTestEvent | undefined>(undefined);

const addEvents = (eventData: ProdOrTestEvent) => {
setEvents(prev => [eventData, ...prev]);
Expand Down Expand Up @@ -63,7 +63,7 @@ export function StreamElementsAlerts() {
},
});

React.useEffect(() => {
useEffect(() => {
console.log('[Alerts] current event:', current);
console.log('[Alerts] stale?', stale);

Expand All @@ -90,7 +90,7 @@ export function StreamElementsAlerts() {
}
}, [current, stale]);

React.useEffect(() => {
useEffect(() => {
const [recent] = events;
console.log('[Alerts] events.length', events.length);
console.log('[Alerts] events', events);
Expand Down
12 changes: 6 additions & 6 deletions src/modules/alerts/streamlabs-alerts.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'use client';

/* eslint-disable no-underscore-dangle */
import * as React from 'react';
import { useEffect, useState } from 'react';
import { useStreamlabsSocket, StreamlabsEvent } from '~/lib/streamlabs';
import { alert, AlertToast, DEFAULT_DISMISS_DURATION } from '../alert-manager';

const dismissAfter = DEFAULT_DISMISS_DURATION;

export function StreamlabsAlerts() {
const [events, setEvents] = React.useState<StreamlabsEvent[]>([]);
const [stale, setStale] = React.useState(false);
const [current, setCurrent] = React.useState<StreamlabsEvent | undefined>(undefined);
const [events, setEvents] = useState<StreamlabsEvent[]>([]);
const [stale, setStale] = useState(false);
const [current, setCurrent] = useState<StreamlabsEvent | undefined>(undefined);

const addEvents = (eventData: StreamlabsEvent) => {
setEvents(prev => [eventData, ...prev]);
Expand All @@ -30,7 +30,7 @@ export function StreamlabsAlerts() {
}
});

React.useEffect(() => {
useEffect(() => {
console.log('[Alerts] current event:', current);
console.log('[Alerts] stale?', stale);

Expand Down Expand Up @@ -170,7 +170,7 @@ export function StreamlabsAlerts() {
}
}, [current, stale, setEvents]);

React.useEffect(() => {
useEffect(() => {
const [recent] = events;
console.log('[StreamlabsAlerts] events.length', events.length);
console.log('[StreamlabsAlerts] events', events);
Expand Down
1 change: 0 additions & 1 deletion src/modules/alerts/utils/handle-test-toast.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { StreamElementsTestEvent } from '~/lib/streamelements';
import { alert, AlertToast, DEFAULT_DISMISS_DURATION } from '~/modules/alert-manager';

Expand Down
1 change: 0 additions & 1 deletion src/modules/alerts/utils/handle-toast.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { StreamElementsEvent } from '~/lib/streamelements';
import { alert, AlertToast, DEFAULT_DISMISS_DURATION } from '~/modules/alert-manager';

Expand Down
4 changes: 2 additions & 2 deletions src/modules/bottom-bar/bottom-bar-clock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { createStyleObject } from '@capsizecss/core';
import fontMetrics from '@capsizecss/metrics/inter';
import { format } from 'date-fns';
import * as React from 'react';
import { useState } from 'react';
import { useClock } from '~/lib/hooks/use-clock';
import { useOnMount } from '~/lib/hooks/use-on-mount';

Expand All @@ -15,7 +15,7 @@ const styles = createStyleObject({

export function BottomBarClock() {
const time = useClock();
const [mounted, setMounted] = React.useState<boolean>(false);
const [mounted, setMounted] = useState<boolean>(false);

useOnMount(() => {
setMounted(true);
Expand Down
6 changes: 3 additions & 3 deletions src/modules/bottom-bar/bottom-bar-event-box.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as React from 'react';
import clsx from 'clsx';
import { SVGProps, createElement } from 'react';

interface BottomBarEventBoxProps {
icon: React.ComponentType<React.SVGProps<SVGSVGElement>>;
icon: React.ComponentType<SVGProps<SVGSVGElement>>;
}

export function BottomBarEventBox({ icon }: BottomBarEventBoxProps) {
return (
<div className={clsx('flex flex-auto items-center h-6 pr-3')}>
{React.createElement(icon, { className: 'h-6 w-6' })}
{createElement(icon, { className: 'h-6 w-6' })}
<div className="flex-auto ml-2 h-6" />
</div>
);
Expand Down
1 change: 0 additions & 1 deletion src/modules/bottom-bar/bottom-bar-events.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { IconChart, IconDollarSign, IconStar } from '~/components/icons';
import { BottomBarEventBox } from './bottom-bar-event-box';

Expand Down
1 change: 0 additions & 1 deletion src/modules/bottom-bar/bottom-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { BottomBarEvents } from './bottom-bar-events';
import { BottomBarClock } from './bottom-bar-clock';

Expand Down
4 changes: 2 additions & 2 deletions src/modules/deep-dip/dd2-logo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { SVGProps } from 'react';

export function DD2Logo({ width, height, fill = '#fff', ...rest }: React.SVGProps<SVGSVGElement>) {
export function DD2Logo({ width, height, fill = '#fff', ...rest }: SVGProps<SVGSVGElement>) {
return (
<svg
width={width}
Expand Down
1 change: 0 additions & 1 deletion src/modules/deep-dip/leaderboard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client';

import * as React from 'react';
import clsx from 'clsx';
import { useCurrentProgress, useGlobalLeaderboard } from '../pre-stream/utils/deep-dip';
import { ResultBlock, ResultBlockDivider, ResultBlockFallback } from './result-block';
Expand Down
1 change: 0 additions & 1 deletion src/modules/deep-dip/result-block.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { LeaderboardResult } from '~/server/modules/deepdip/get-global-leaderboard';

export interface ResultBlockProps {
Expand Down
5 changes: 2 additions & 3 deletions src/modules/flightsim/flight-itinerary.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as React from 'react';
import { InfoItemCard } from '~/components/info-item-card';

export interface FlightItineraryProps {
origin: string;
destination: string;
}

export const FlightItinerary: React.FC<FlightItineraryProps> = ({ origin, destination }) => {
export function FlightItinerary({ origin, destination }: FlightItineraryProps) {
return <InfoItemCard content={`${origin} -> ${destination}`} />;
};
}
13 changes: 6 additions & 7 deletions src/modules/flightsim/flight-progress.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as React from 'react';
import clsx from 'clsx';
import { ComponentPropsWithoutRef, forwardRef } from 'react';

export const FlightProgress = React.forwardRef<
HTMLProgressElement,
React.ComponentPropsWithoutRef<'progress'>
>(({ className, ...rest }, ref) => {
return <progress ref={ref} className={clsx('flight-progress', className)} {...rest} />;
});
export const FlightProgress = forwardRef<HTMLProgressElement, ComponentPropsWithoutRef<'progress'>>(
({ className, ...rest }, ref) => {
return <progress ref={ref} className={clsx('flight-progress', className)} {...rest} />;
},
);

FlightProgress.displayName = 'FlightProgress';
Loading
Loading