mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-27 16:10:30 +08:00
Deleting a small set of components that aren't used within the project anymore
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
import clsx from "clsx";
|
||||
|
||||
const formClasses =
|
||||
"block w-full appearance-none rounded-lg border border-gray-200 bg-white py-[calc(theme(spacing.2)-1px)] px-[calc(theme(spacing.3)-1px)] text-gray-900 placeholder:text-gray-400 focus:border-cyan-500 focus:outline-none focus:ring-cyan-500 sm:text-sm";
|
||||
|
||||
function Label({ id, children }) {
|
||||
return (
|
||||
<label htmlFor={id} className="mb-2 block text-sm font-semibold text-gray-900">
|
||||
{children}
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
export function TextField({ id, label, type = "text", className, ...props }) {
|
||||
return (
|
||||
<div className={className}>
|
||||
{label && <Label id={id}>{label}</Label>}
|
||||
<input id={id} type={type} {...props} className={formClasses} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function SelectField({ id, label, className, ...props }) {
|
||||
return (
|
||||
<div className={className}>
|
||||
{label && <Label id={id}>{label}</Label>}
|
||||
<select id={id} {...props} className={clsx(formClasses, "pr-8")} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { NavLinks } from "./NavLinks";
|
||||
|
||||
// eslint-disable-next-line import/no-anonymous-default-export
|
||||
export default {
|
||||
title: "Header/NavLinks",
|
||||
component: NavLinks,
|
||||
};
|
||||
|
||||
const Template = (args) => (
|
||||
<div className="hidden lg:flex lg:gap-10">
|
||||
<NavLinks {...args} />
|
||||
</div>
|
||||
);
|
||||
|
||||
export const Default = Template.bind({});
|
||||
@@ -1,49 +0,0 @@
|
||||
import { Text, useColorMode } from "@chakra-ui/react";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { colors } from "styles/Theme/colors";
|
||||
|
||||
export function NavLinks(): JSX.Element {
|
||||
const [hoveredIndex, setHoveredIndex] = useState(null);
|
||||
const { colorMode } = useColorMode();
|
||||
|
||||
const linkColor = colorMode === "light" ? "text-gray-700 hover:text-gray-900" : "text-gray-50 hover:text-white";
|
||||
|
||||
const hoverBgColor = colorMode === "light" ? "bg-gray-100" : "bg-gray-800";
|
||||
|
||||
return (
|
||||
<>
|
||||
{[
|
||||
["FAQ", "/#faq"],
|
||||
["Join Us", "/#join-us"],
|
||||
].map(([label, href], index) => (
|
||||
<Link
|
||||
key={label}
|
||||
href={href}
|
||||
className={`${linkColor} relative -my-2 -mx-3 rounded-lg px-3 py-2 text-sm transition-colors delay-150 hover:delay-[0ms]`}
|
||||
onMouseEnter={() => setHoveredIndex(index)}
|
||||
onMouseLeave={() => setHoveredIndex(null)}
|
||||
>
|
||||
<AnimatePresence>
|
||||
{hoveredIndex === index && (
|
||||
<motion.span
|
||||
className={`${hoverBgColor} absolute inset-0 rounded-lg`}
|
||||
layoutId="hoverBackground"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1, transition: { duration: 0.15 } }}
|
||||
exit={{
|
||||
opacity: 0,
|
||||
transition: { duration: 0.15, delay: 0.2 },
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
<Text color={colorMode === "light" ? colors.light.text : colors.dark.text} className="relative z-10">
|
||||
{label}
|
||||
</Text>
|
||||
</Link>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,2 @@
|
||||
export { Header } from "./Header";
|
||||
export { NavLinks } from "./NavLinks";
|
||||
export { UserMenu } from "./UserMenu";
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { RouterContext } from "next/dist/shared/lib/router-context";
|
||||
import React from "react";
|
||||
import { createMockRouter } from "src/test-utils/createMockRouter";
|
||||
|
||||
import { OptionProps, TaskOption } from "./TaskOption";
|
||||
|
||||
describe("TaskOption component", () => {
|
||||
const testProps: OptionProps = {
|
||||
title: "Task Title",
|
||||
alt: "Task Title",
|
||||
img: "/imgPath",
|
||||
link: "/fake/path",
|
||||
};
|
||||
|
||||
it("should render", () => {
|
||||
render(<TaskOption {...testProps} />);
|
||||
expect(screen.getByRole("heading")).toHaveTextContent("Task Title");
|
||||
expect(screen.getByRole("img")).toHaveAttribute("alt", "Task Title");
|
||||
expect(screen.getByRole("link")).toHaveAttribute("href", "/fake/path");
|
||||
});
|
||||
|
||||
it("should navigate properly on click", () => {
|
||||
const router = createMockRouter({ pathname: "/fake/path" });
|
||||
render(
|
||||
<RouterContext.Provider value={router}>
|
||||
<TaskOption {...testProps} />
|
||||
</RouterContext.Provider>
|
||||
);
|
||||
expect(screen.getByRole("link")).toHaveAttribute("href", "/fake/path");
|
||||
fireEvent.click(screen.getByRole("link"));
|
||||
expect(router.push).toHaveBeenCalledWith("/fake/path", expect.anything(), expect.anything());
|
||||
});
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
import { useColorMode } from "@chakra-ui/react";
|
||||
import { CiDark } from "react-icons/ci";
|
||||
import { CiLight } from "react-icons/ci";
|
||||
|
||||
export function ColorModeIconToggle(props) {
|
||||
const { colorMode, toggleColorMode } = useColorMode();
|
||||
const propsClassName = props.className ?? "";
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`flex h-6 w-6 items-center justify-center rounded-md transition hover:bg-zinc-900/5 dark:hover:bg-white/5 ${propsClassName}`}
|
||||
aria-label="Toggle dark mode"
|
||||
onClick={toggleColorMode}
|
||||
>
|
||||
{colorMode === "light" ? (
|
||||
<CiDark className="h-5 w-5 stroke-zinc-900" />
|
||||
) : (
|
||||
<CiLight className="h-5 w-5 stroke-white" />
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import { Switch, useColorMode } from "@chakra-ui/react";
|
||||
import React from "react";
|
||||
|
||||
const ColorModeSwitch = () => {
|
||||
const { colorMode, toggleColorMode } = useColorMode();
|
||||
return (
|
||||
<Switch
|
||||
onChange={toggleColorMode}
|
||||
defaultChecked={colorMode === "light"}
|
||||
checked={colorMode === "light"}
|
||||
size="lg"
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default ColorModeSwitch;
|
||||
Reference in New Issue
Block a user