Skip to content

Commit

Permalink
[app] code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Jirous committed Feb 25, 2023
1 parent 8bc2941 commit 5a41518
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 31 deletions.
10 changes: 4 additions & 6 deletions src/app/(advice)/advice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import { Heading, IconButton, Text } from "@chakra-ui/react";
import { useQuery } from "@tanstack/react-query";
import React, { useCallback } from "react";

export default function Advice({
initialAdvice,
}: {
initialAdvice: AdviceType;
}) {
const Advice = ({ initialAdvice }: { initialAdvice: AdviceType }) => {
const {
data: advice,
isFetching,
Expand Down Expand Up @@ -72,4 +68,6 @@ export default function Advice({
/>
</Section>
);
}
};

export default Advice;
10 changes: 4 additions & 6 deletions src/app/(advice)/adviceBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import React from "react";
import { ErrorBoundary } from "react-error-boundary";
import { Suspense } from "react";

export default function AdviceBoundary({
initialAdvice,
}: {
initialAdvice: AdviceType;
}) {
const AdviceBoundary = ({ initialAdvice }: { initialAdvice: AdviceType }) => {
const { reset } = useQueryErrorResetBoundary();

return (
Expand All @@ -28,4 +24,6 @@ export default function AdviceBoundary({
</Suspense>
</ErrorBoundary>
);
}
};

export default AdviceBoundary;
6 changes: 4 additions & 2 deletions src/app/(advice)/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import MobileDividerIcon from "@/theme/icons/MobileDividerIcon";
import { Heading, IconButton, Text } from "@chakra-ui/react";
import React from "react";

export default function Error({ onClick }: { onClick: () => void }) {
const Error = ({ onClick }: { onClick: () => void }) => {
return (
<Section
size={["sm", "sm", "md"]}
Expand Down Expand Up @@ -48,4 +48,6 @@ export default function Error({ onClick }: { onClick: () => void }) {
/>
</Section>
);
}
};

export default Error;
6 changes: 4 additions & 2 deletions src/app/(advice)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import { Grid } from "@chakra-ui/react";
import React, { ReactNode } from "react";

export default function AdviceLayout({ children }: { children: ReactNode }) {
const AdviceLayout = ({ children }: { children: ReactNode }) => {
return (
<Grid h="100vh" placeItems="center">
{children}
</Grid>
);
}
};

export default AdviceLayout;
6 changes: 4 additions & 2 deletions src/app/(advice)/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Box } from "@chakra-ui/react";
const rollAnimation = `${roll} 400ms linear infinite`;
const pulseAnimation = `${pulse} 2s linear infinite`;

export default function Loading() {
const Loading = () => {
return (
<Box
display="flex"
Expand All @@ -24,4 +24,6 @@ export default function Loading() {
<DiceIcon animation={rollAnimation} />
</Box>
);
}
};

export default Loading;
6 changes: 4 additions & 2 deletions src/app/(advice)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import AdviceBoundary from "@/app/(advice)/adviceBoundary";
import { fetchAdvice } from "@/app/(fetch)/fetchAdvice";
import React from "react";

export default async function Page() {
const Page = async () => {
const initialAdvice = await fetchAdvice();

return <AdviceBoundary initialAdvice={initialAdvice} />;
}
};

export default Page;
6 changes: 4 additions & 2 deletions src/app/head.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function Head() {
const Head = () => {
return (
<>
<title>Frontend Mentor | Advice Generator App</title>
Expand All @@ -10,4 +10,6 @@ export default function Head() {
<link rel="icon" href="/assets/favicon.ico" />
</>
);
}
};

export default Head;
10 changes: 4 additions & 6 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { manrope } from "@/app/fonts";
import Providers from "@/app/providers";
import React from "react";

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const RootLayout = ({ children }: { children: React.ReactNode }) => {
return (
<html lang="en" className={manrope.variable}>
<head />
Expand All @@ -17,4 +13,6 @@ export default function RootLayout({
</body>
</html>
);
}
};

export default RootLayout;
6 changes: 4 additions & 2 deletions src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ChakraProvider, ColorModeScript } from "@chakra-ui/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import React, { ReactNode, useState } from "react";

export default function Providers({ children }: { children: ReactNode }) {
const Providers = ({ children }: { children: ReactNode }) => {
const [queryClient] = useState(
() =>
new QueryClient({
Expand All @@ -28,4 +28,6 @@ export default function Providers({ children }: { children: ReactNode }) {
</CacheProvider>
</QueryClientProvider>
);
}
};

export default Providers;
3 changes: 2 additions & 1 deletion src/theme/components/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const Button = defineStyleConfig({
variants: {
fixed: {
position: "absolute",
bottom: "-8",
bottom: 0,
transform: "translateY(var(--chakra-space-8))",
},
},
});
Expand Down

0 comments on commit 5a41518

Please sign in to comment.