Skip to content
Open
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: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"plugin:react-hooks/recommended",
// "plugin:react-hooks/recommended",
"next/core-web-vitals"
],
"overrides": [],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lint": "eslint --ignore-path .gitignore .",
"lint:fix": "eslint --ignore-path .gitignore --fix .",
"pret": "prettier -c .",
"pret:fix": "prettier --ignore-path .gitignore --config ./.prettierrc --write './**/*.{js,jsx,ts,tsx,css,md,json}'",
"pret:fix": "prettier --ignore-path .gitignore --config ./.prettierrc --write \"./**/*.{js,jsx,ts,tsx,css,md,json}\"",
"code-style": "npm run pret && npm run lint",
"code-style:fix": "npm run pret:fix && npm run pret:fix",
"build": "npm run code-style && npm run clean && rollup -c",
Expand Down
12 changes: 9 additions & 3 deletions src/components/Shortcuts.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dayjs from "dayjs";
import React, { useCallback, useContext, useMemo } from "react";

import { DATE_FORMAT, TEXT_COLOR } from "../constants";
import { DATE_FORMAT, TEXT_COLOR, BG_COLOR } from "../constants";
import DEFAULT_SHORTCUTS from "../constants/shortcuts";
import DatepickerContext from "../contexts/DatepickerContext";
import { Period, ShortcutsItem } from "../types";
Expand Down Expand Up @@ -29,8 +29,14 @@ const ItemTemplate = React.memo((props: ItemTemplateProps) => {
const getClassName: () => string = useCallback(() => {
const textColor = TEXT_COLOR["600"][primaryColor as keyof (typeof TEXT_COLOR)["600"]];
const textColorHover = TEXT_COLOR.hover[primaryColor as keyof typeof TEXT_COLOR.hover];
return `whitespace-nowrap w-1/2 md:w-1/3 lg:w-auto transition-all duration-300 hover:bg-gray-100 dark:hover:bg-white/10 p-2 rounded cursor-pointer ${textColor} ${textColorHover}`;
}, [primaryColor]);
const bgColor = BG_COLOR["500"][primaryColor as keyof (typeof BG_COLOR)["500"]];
const bgColorHover = BG_COLOR.hover[primaryColor as keyof typeof BG_COLOR.hover];
const isSelected =
period.start === props?.item.period.start && period.end === props?.item.period.end;
return `whitespace-nowrap w-1/2 md:w-1/3 lg:w-auto transition-all duration-300 hover:bg-gray-100 dark:hover:bg-white/10 p-2 rounded cursor-pointer ${textColor} ${textColorHover} ${
isSelected ? bgColor + " text-white " + bgColorHover : ""
}`;
}, [primaryColor, period, props?.item.period]);

const chosePeriod = useCallback(
(item: Period) => {
Expand Down