Skip to content

Commit

Permalink
Use ts(x) instead of js
Browse files Browse the repository at this point in the history
  • Loading branch information
kilemensi committed Sep 2, 2024
1 parent cc3bd6a commit 78fe1bb
Show file tree
Hide file tree
Showing 17 changed files with 238 additions and 174 deletions.
17 changes: 0 additions & 17 deletions apps/engineeringblog/app/StyledRoot.tsx

This file was deleted.

24 changes: 18 additions & 6 deletions apps/engineeringblog/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import type { Metadata } from "next";
import Navbar from "@/engineeringblog/components/Navbar";
import { CssBaseline, ThemeProvider } from "@mui/material";
import { AppRouterCacheProvider } from "@mui/material-nextjs/v13-appRouter";
import StyledRoot from "./StyledRoot";
import type { Metadata } from "next";

import NavBar from "@/engineeringblog/components/NavBar";
import theme from "@/engineeringblog/theme";

// TODO: blurWidth/blueHeight https://github.com/vercel/next.js/issues/56511
import logoLight from "@/engineeringblog/assets/images/logo-light.png";

export const metadata: Metadata = {
title: "Technology | Code for Africa",
Expand All @@ -14,14 +19,21 @@ export default function RootLayout({
}: Readonly<{
children: React.ReactNode;
}>) {
const logo = {
...logoLight,
alt: "Technology | Code for Africa",
title: "Technology",
};

return (
<html lang="en">
<body>
<AppRouterCacheProvider>
<StyledRoot>
<Navbar />
<ThemeProvider theme={theme}>
<CssBaseline enableColorScheme />
<NavBar logo={logo} />
{children}
</StyledRoot>
</ThemeProvider>
</AppRouterCacheProvider>
</body>
</html>
Expand Down
40 changes: 0 additions & 40 deletions apps/engineeringblog/components/Logo/Logo.js

This file was deleted.

105 changes: 105 additions & 0 deletions apps/engineeringblog/components/Logo/Logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { Link, Stack, SvgIcon } from "@mui/material";
import { SxProps, Theme } from "@mui/material/styles";
import Image, { ImageProps } from "next/image";
import React from "react";

import PreviousIcon from "@/engineeringblog/assets/icons/Type=chevron-left, Size=24, Color=CurrentColor.svg";

export interface LogoProps extends ImageProps {
href?: string;
sx?: SxProps<Theme>;
title?: string;
}

const Logo = React.forwardRef(function Logo(
props: LogoProps,
ref: React.ForwardedRef<HTMLDivElement>,
) {
const {
alt,
href: hrefProp,
src,
sx,
title,
...other // All next/image supported props
} = props;
const logoHref = title?.length ? "https://codeforafrica.org" : "/";

return (
<Stack
direction="row"
spacing={1}
sx={{
color: "inherit",
alignItems: "center",
position: "relative",
...sx,
}}
ref={ref}
>
<Link
color="inherit"
href={logoHref}
sx={(theme) => ({
"&>svg,&>img": {
transition: theme.transitions.create(["opacity", "transform"]),
},
"&:hover": {
"&>svg,&>img": {
opacity: 0.65,
},
"&>svg": {
transform: "translateX(-5px)",
},
},
})}
>
{title?.length ? (
<SvgIcon
sx={(theme) => ({
fill: { xs: "none" },
fontSize: 32,
left: -24,
opacity: 0,
position: "absolute",
right: 0,
})}
>
<PreviousIcon />
</SvgIcon>
) : null}
<Image
{...other}
alt={alt}
priority
src={src}
style={{
height: 32,
width: "auto",
}}
/>
</Link>
{title?.length ? (
<Link
color="text.primary"
href="/"
textTransform="uppercase"
typography="h4"
underline="none"
sx={({ transitions, typography }) => ({
display: "flex",
fontFamily: typography.fontFamilyMono,
transition: transitions.create(["opacity", "transform"]),
"&:hover": {
opacity: 0.65,
},
})}
>
Technology
</Link>
) : null}
</Stack>
);
});

export default Logo;
3 changes: 0 additions & 3 deletions apps/engineeringblog/components/Logo/index.js

This file was deleted.

5 changes: 5 additions & 0 deletions apps/engineeringblog/components/Logo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { LogoProps } from "./Logo";
import Logo from "./Logo";

export type { LogoProps };
export default Logo;
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Grid } from "@mui/material";
import PropTypes from "prop-types";
import React from "react";

import Logo from "@/engineeringblog/components/Logo";
import type NavBarProps from "@/engineeringblog/components/NavBar/NavBarProps";

const DesktopNavBar = React.forwardRef(function DesktopNavBar(props, ref) {
const DesktopNavBar = React.forwardRef(function DesktopNavBar(
props: NavBarProps,
ref: React.ForwardedRef<HTMLDivElement>,
) {
const { logo, sx } = props;

return (
Expand All @@ -22,14 +25,4 @@ const DesktopNavBar = React.forwardRef(function DesktopNavBar(props, ref) {
);
});

DesktopNavBar.propTypes = {
direction: PropTypes.string,
menu: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string,
href: PropTypes.string,
}),
),
};

export default DesktopNavBar;
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import {
Grid,
IconButton,
Slide,
SlideProps,
SvgIcon,
} from "@mui/material";
import { styled } from "@mui/material/styles";
import PropTypes from "prop-types";
import React from "react";

import type NavBarProps from "@/engineeringblog/components/NavBar/NavBarProps";
import Logo from "@/engineeringblog/components/Logo";
import CloseIcon from "@/engineeringblog/assets/icons/Type=x, Size=24, Color=CurrentColor.svg";
import MenuIcon from "@/engineeringblog/assets/icons/Type=menu, Size=24, Color=CurrentColor.svg";
Expand All @@ -29,11 +30,19 @@ const DialogContainer = styled(Dialog)(({ theme: { palette, spacing } }) => ({
},
}));

const Transition = React.forwardRef(function Transition(props, ref) {
interface TransitionProps extends SlideProps {}

const Transition = React.forwardRef(function Transition(
props: TransitionProps,
ref,
) {
return <Slide direction="up" ref={ref} {...props} />;
});

const MobileNavBar = React.forwardRef(function MobileNavBar(props, ref) {
const MobileNavBar = React.forwardRef(function MobileNavBar(
props: NavBarProps,
ref: React.ForwardedRef<HTMLDivElement>,
) {
const { logo, sx } = props;
const [open, setOpen] = React.useState(false);

Expand Down Expand Up @@ -88,23 +97,11 @@ const MobileNavBar = React.forwardRef(function MobileNavBar(props, ref) {
justifyContent: "space-between",
alignItems: "flex-start",
}}
onClose={handleClose}
></DialogContent>
</DialogContainer>
</Grid>
</Grid>
);
});

MobileNavBar.propTypes = {
direction: PropTypes.string,
logo: PropTypes.shape({}),
menus: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string,
href: PropTypes.string,
}),
),
};

export default MobileNavBar;
78 changes: 0 additions & 78 deletions apps/engineeringblog/components/NavBar/NavBar.js

This file was deleted.

Loading

0 comments on commit 78fe1bb

Please sign in to comment.