mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-21 18:58:03 +00:00
* Bump lint-staged * Check * Check * Added husky * Check * Check * Check * Check * Check * Check * Check * Check * Fix husky * Used * instead **/* in lint-staged * Bump tailwindcss and related * Added @tailwindcss/vite and removed postcss * Added lint into staged * Bump @babel/core and updated .prettierignore * Removed tailwind.config.cjs * Added ThemeInit * Added cursor-pointer to Help dropdown * Bump react-router * Removed @types/uuid and react-router-dom * Bump diff2html, prettier, @typescript-eslint/eslint-plugin, @typescript-eslint/parser * removed vite-plugin-html-config and @babel/core * removed "@eslint/eslintrc" and "@eslint/js" * Removed redundant link * Returned plugins and source to index.css * Set dark to false in tailwindcss * Fixed storybook * Fixed useGetLatestVersion with correct gcTime: 0 option * Added eslint-plugin-prettier * Removed spaces * ClustersList.tsx improved and type fixes for another files * Repository.tsx improved * Huge fix of types * Huge fix of types missed * Fixed type of SingleValue * Added cursor pointer
84 lines
2.4 KiB
TypeScript
84 lines
2.4 KiB
TypeScript
/**
|
|
*
|
|
* @file SelectMenu.tsx
|
|
* @description SelectMenu component
|
|
* This component is used to render a select menu. This is a component
|
|
* with two parts: The menu header and the menu items. The menu header
|
|
* is just text, and the menu items are radio toggles.
|
|
* The menu items are passed as children of type SelectMenuItem,
|
|
* which is an object with a label and id.
|
|
* SelectMenuItem is defined in this file.
|
|
* The menu header is a string.
|
|
*
|
|
* We use an interface to define the props that are passed to the component.
|
|
* The interface name is SelectMenuProps. The interface is defined in the
|
|
* same file as the component.
|
|
*
|
|
* @interface SelectMenuProps:
|
|
* @property {string} header - The menu header
|
|
* @property {SelectMenuItem[]} children - The menu items
|
|
* @property {number} selected - The id of the selected menu item
|
|
* @property {Function} onSelect - The function to call when a menu item is selected
|
|
*
|
|
* @return {JSX.Element} - The component
|
|
*
|
|
*
|
|
*/
|
|
import { JSX } from "react";
|
|
|
|
// define the SelectMenuItem type:
|
|
// This is an object with a label and id.
|
|
// The label is a string, and the id is a number.
|
|
// The id is used to identify the selected menu item.
|
|
export interface SelectMenuItemProps {
|
|
label: string;
|
|
id: number;
|
|
}
|
|
|
|
// define the SelectMenuProps interface:
|
|
|
|
export interface SelectMenuProps {
|
|
header: string;
|
|
children: React.ReactNode;
|
|
selected: number;
|
|
onSelect: (id: number) => void;
|
|
}
|
|
|
|
// define the SelectMenu component:
|
|
// remember to use tailwind classes for styling
|
|
// recall that the menu items are radio buttons
|
|
// the selected menu item is the one that is checked
|
|
// the onSelect function is called when a menu item is selected
|
|
// the onSelect function is passed the id of the selected menu item
|
|
|
|
export function SelectMenuItem({
|
|
label,
|
|
id,
|
|
}: SelectMenuItemProps): JSX.Element {
|
|
return (
|
|
<div className="flex flex-row">
|
|
<input
|
|
type="radio"
|
|
name="menu"
|
|
id={id.toString()} // id must be a string
|
|
value={id}
|
|
checked={false}
|
|
onChange={() => {
|
|
return;
|
|
}}
|
|
/>
|
|
<label htmlFor={id.toString()}>{label}</label>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default function SelectMenu(props: SelectMenuProps): JSX.Element {
|
|
const { header, children } = props;
|
|
return (
|
|
<div className="card flex flex-col">
|
|
<h2 className="text-xl font-bold">{header}</h2>
|
|
<div className="flex flex-col">{children}</div>
|
|
</div>
|
|
);
|
|
}
|