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

style: add hover effect on elements #98

Merged
merged 2 commits into from
Nov 13, 2023
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
4 changes: 4 additions & 0 deletions .env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ NEXT_PUBLIC_MATOMO_URL=https://analytics.forbole.com
NEXT_PUBLIC_MATOMO_SITE_ID=1
NEXT_PUBLIC_GRAPHQL_API=https://api.forbole.com/graphql
NEXT_PUBLIC_COINGECKO_API=https://api.coingecko.com/api/v3

# Optional, to send the email to different account locally (not added into
# docker)
SEND_EMAIL_TO=
12 changes: 2 additions & 10 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module.exports = {
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/control-has-associated-label": "off",
"jsx-a11y/interactive-supports-focus": "off",
"jsx-a11y/no-static-element-interactions": "off",

"import/extensions": [
"error",
Expand Down Expand Up @@ -73,16 +72,9 @@ module.exports = {
},
overrides: [
{
files: ["tests/**/*"],
files: ["server/**/*"],
rules: {
"no-undef": "off",
},
},
{
files: ["src/**/*.test.tsx", "src/**/*.test.ts", "**/*.spec.ts"],
rules: {
"no-undef": "off",
"import/no-extraneous-dependencies": "off",
"no-console": "off",
},
},
],
Expand Down
16 changes: 16 additions & 0 deletions e2e/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ test.describe.parallel("Main Pages", () => {
await expect(page.locator('[data-test="nav"]')).toBeVisible();
});
});

test.describe.parallel("Contact Page", () => {
test("Main components", async ({ page }) => {
await page.goto("/contact");

await expect(page.locator('[data-test="contact-submit"]')).toBeVisible();
});
});

test.describe.parallel("DevTools Page", () => {
test("Main components", async ({ page }) => {
await page.goto("/developer-tools");

await expect(page.locator('[data-test="devtools-cta"]')).toBeVisible();
});
});
});

test.describe.parallel("Blog", () => {
Expand Down
18 changes: 15 additions & 3 deletions server/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* eslint-disable @typescript-eslint/no-shadow */

/* eslint-disable no-console */
import axios from "axios";
import cors from "cors";
import "dotenv-defaults/config";
Expand Down Expand Up @@ -76,7 +74,21 @@ const ghostAdminApi = new GhostAdminAPI({
async (req: Request, res: Response, next: any) => {
try {
if (process.env.NODE_ENV === "production") {
await transporter.sendMail(req.body);
const { source, ...restBody } = req.body;
const subject =
{
devtools:
"A new customer just wanted to get in touch with us via Developer Tools form",
staking: "Inquiry From Forbole Validator Website",
enterprise:
"A new customer just wanted to get in touch with us via Contact form",
}[source as string] || "A new enquiry from Forbole's website";

await transporter.sendMail({
...restBody,
subject,
to: process.env.SEND_EMAIL_TO || "[email protected]",
});
}
res.status(200).json({
success: true,
Expand Down
7 changes: 2 additions & 5 deletions src/api/authors/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
/* eslint-disable no-console */
import { ghostApi as api } from "../index";

// import { IPost } from "./interface";

/** Get blog posts by tag */
export const getAuthorBySlug = async (query: { author: string }) => {
try {
const authorInfo = await api.authors.read({
slug: `${query.author}`,
});
return authorInfo ?? null;
} catch (err) {
// eslint-disable-next-line no-console
console.error(`tag: ${err}`);
return [];
}
};

/** Get blog posts by author */
export const getPostsByAuthor = async (query: {
author: string;
page?: number;
Expand All @@ -31,6 +27,7 @@ export const getPostsByAuthor = async (query: {
});
return posts ?? null;
} catch (err) {
// eslint-disable-next-line no-console
console.error(`tag: ${err}`);
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/networks/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { ghostApi as api } from "../index";
import { IPost } from "./interface";

Expand All @@ -18,6 +17,7 @@ export const getNetworkPosts = async ({
formats: "html",
});
} catch (err) {
// eslint-disable-next-line no-console
console.error(err);
return [];
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/cta-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const ColorButton = styled(LoadingButton)<LoadingButtonProps>(() => ({
"height": "45px",
"fontSize": "16px",
"padding": " 0px 16px",
"transition": "transform 0.2s ease-in-out",
"&:hover": {
transform: "scale(1.02)",
background:
"linear-gradient(175.41deg, #623DF5 11.57%, #362187 173.5%),linear-gradient(0deg, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0.32))",
boxShadow:
Expand Down
36 changes: 17 additions & 19 deletions src/components/footer/components/footer_items/useStyles.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { css, useTheme } from "@mui/material";
import { css } from "@mui/material";

const useStyles = () => {
const theme = useTheme();
return {
word: css({
"fontSize": "14px",
"fontStyle": "normal",
"fontWeight": "590",
"lineHeight": "20px",
"letterSpacing": "0.336px",
"textDecoration": "none",
"color": "inherit",
"&:hover": {
cursor: "pointer",
color: theme.palette.custom.forbole.purple,
},
}),
};
};
const useStyles = () => ({
word: css({
"fontSize": "14px",
"fontStyle": "normal",
"fontWeight": "590",
"lineHeight": "20px",
"letterSpacing": "0.336px",
"textDecoration": "none",
"color": "inherit",
"padding": "4px 8px",
"&:hover": {
background: "rgba(0,0,0,0.2)",
borderRadius: "24px",
},
}),
});

export default useStyles;
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@
outline: none;
vertical-align: middle;
}
.icon {
transition: all 0.2s ease-in-out;
}
.icon:hover {
transform: scale(1.5);
}
1 change: 1 addition & 0 deletions src/components/footer/components/social_media/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const SocialMedia = () => {
{socialMediaInfo.map((x) => (
<a
key={x.key}
className={classes.icon}
href={x.url}
rel="noreferrer"
style={{ color: "currentcolor" }}
Expand Down
1 change: 0 additions & 1 deletion src/components/footer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/require-default-props */
import { Box, Container, Stack, Typography, useTheme } from "@mui/material";
import { useWindowDimensions } from "@src/hooks";
import useTranslation from "next-translate/useTranslation";
Expand Down
3 changes: 0 additions & 3 deletions src/components/guide_nav/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable react/require-default-props */

/* eslint-disable jsx-a11y/anchor-is-valid */
import { Forbole as ForboleLogo, ForboleShadowIcon } from "@icons";
import { Box, Button, useTheme } from "@mui/material";
import Link from "next/link";
Expand Down
12 changes: 4 additions & 8 deletions src/components/nav/components/desktop_nav_menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import { Box, useTheme } from "@mui/material";
import CtaButton from "@src/components/cta-button";
import useTranslation from "next-translate/useTranslation";
import Link from "next/link";
import * as React from "react";

import CompanyMenuButton from "../company_menu_button";
import { navItems } from "../config";
import LangMenuButton from "../lang_menu_button";
import ProductsMenuButton from "../products_menu_button";
import classes from "./index.module.css";

interface NavMenuProps {
itemColor: string | undefined;
}

const DesktopNavMenu = ({ itemColor }: NavMenuProps) => {
const DesktopNavMenu = () => {
const { t } = useTranslation("common");
const theme = useTheme();

Expand All @@ -37,7 +31,9 @@ const DesktopNavMenu = ({ itemColor }: NavMenuProps) => {
"fontWeight": 600,
"fontSize": theme.spacing(2),
"&:hover": {
color: itemColor || theme.palette.custom.forbole.indigo,
background: "rgba(0,0,0,0.2)",
borderRadius: "24px",
color: theme.palette.common.white,
},
"userSelect": "none",
}}
Expand Down
16 changes: 9 additions & 7 deletions src/components/nav/components/mobile_nav_menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useWindowDimensions } from "@src/hooks";
import { anchorElState } from "@src/recoil/settings/anchorEl";
import useTranslation from "next-translate/useTranslation";
import { useRouter } from "next/router";
import * as React from "react";
import { MouseEvent, useEffect, useState } from "react";
import { useRecoilState } from "recoil";

import CompanyMenuButton from "../company_menu_button";
Expand All @@ -24,15 +24,15 @@ const MobileNavMenu = () => {
const { width } = windowDimensions;
const [anchorEl, setAnchorEl] = useRecoilState(anchorElState);
const open = Boolean(anchorEl);
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
const handleClick = (event: MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const [openDrawer, setOpenDrawer] = React.useState(false);
const [openShowCompany, setOpenShowCompany] = React.useState(false);
const [openShowProducts, setOpenShowProducts] = React.useState(false);
const [openDrawer, setOpenDrawer] = useState(false);
const [openShowCompany, setOpenShowCompany] = useState(false);
const [openShowProducts, setOpenShowProducts] = useState(false);
const handleDropdownClick = () => {
setOpenDrawer((prevState) => !prevState);
setOpenShowCompany(() => false);
Expand All @@ -49,8 +49,8 @@ const MobileNavMenu = () => {
setOpenShowCompany(() => false);
setOpenShowProducts((prevState) => !prevState);
};
// close other drawer
React.useEffect(() => {

useEffect(() => {
setOpenDrawer(() => false);
setOpenShowCompany(() => false);
setOpenShowProducts(() => false);
Expand Down Expand Up @@ -147,13 +147,15 @@ const MobileNavMenu = () => {
onClick={() => {
router.push("/products").finally(handleClose);
}}
role="button"
>
{t("Products")}
</div>
<div
onClick={() => {
handlerCLickShowProducts();
}}
role="button"
>
{openShowProducts ? (
<KeyboardArrowUpIcon />
Expand Down
1 change: 0 additions & 1 deletion src/components/nav/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-unused-vars */
import { useScrollPosition } from "@n8tb1t/use-scroll-position";
import { useEffect, useState } from "react";

Expand Down
2 changes: 1 addition & 1 deletion src/components/nav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const Nav = ({ staking, stakeNowRef, itemColor }: NavProps) => {
},
}}
>
<DesktopNavMenu itemColor={itemColor} />
<DesktopNavMenu />
</Box>
</>
)}
Expand Down
8 changes: 4 additions & 4 deletions src/components/selection-tab/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Tab from "@mui/material/Tab";
import Tabs from "@mui/material/Tabs";
import { styled } from "@mui/material/styles";
import * as React from "react";
import { ReactElement, ReactNode, SyntheticEvent } from "react";

interface StyledTabsProps {
children?: React.ReactNode;
children?: ReactNode;
value: number;
onChange: (event: React.SyntheticEvent, newValue: number) => void;
onChange: (event: SyntheticEvent, newValue: number) => void;
}

export const StyledTabs = styled((props: StyledTabsProps) => (
Expand All @@ -31,7 +31,7 @@ export const StyledTabs = styled((props: StyledTabsProps) => (

interface StyledTabProps {
label: string;
icon?: string | React.ReactElement;
icon?: string | ReactElement;
disabled?: boolean;
value?: string;
onClick?: (e: any) => void;
Expand Down
14 changes: 7 additions & 7 deletions src/hooks/get_screen_size.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTheme } from "@mui/material";
import * as React from "react";
import { useEffect, useState } from "react";

const getWindowDimensions = () => {
const { innerWidth: width, innerHeight: height } = window;
Expand All @@ -10,17 +10,17 @@ const getWindowDimensions = () => {
};

export const useWindowDimensions = () => {
const [windowDimensions, setWindowDimensions] = React.useState({
const [windowDimensions, setWindowDimensions] = useState({
width: 0,
height: 0,
}); // <-- don't invoke the function here

const theme = useTheme();
const [isDesktop, setIsDesktop] = React.useState<boolean>(false);
const [isTablet, setIsTablet] = React.useState<boolean>(false);
const [isMobile, setIsMobile] = React.useState<boolean>(true);
const [isDesktop, setIsDesktop] = useState<boolean>(false);
const [isTablet, setIsTablet] = useState<boolean>(false);
const [isMobile, setIsMobile] = useState<boolean>(true);

React.useEffect(() => {
useEffect(() => {
function handleResize() {
setWindowDimensions(getWindowDimensions());
}
Expand All @@ -33,7 +33,7 @@ export const useWindowDimensions = () => {
};
}, []);

React.useEffect(() => {
useEffect(() => {
const width = windowDimensions?.width ?? 0;
// is mobile
if (width < theme?.breakpoints?.values?.tablet) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/author/[author]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { getAuthorBySlug, getPostsByAuthor } from "@api/authors";
import { getPosts, getTags } from "@api/posts";
import { Post, Tag } from "@models";
Expand Down Expand Up @@ -41,6 +40,7 @@ export async function getServerSideProps(context: { query: any }) {
);
} catch (err) {
error = true;
// eslint-disable-next-line no-console
console.log(error, "error");
}
return {
Expand Down
Loading