App.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import ListGroupBS from "./components/ListGroupBS";
  2. import MyAlert from "./components/Alert";
  3. import { useState } from "react";
  4. import MyButt from "./components/MyButt";
  5. import Button from "@mui/material/Button";
  6. import Alert from "@mui/material/Alert";
  7. import ListGroupMUI from "./components/ListGroupMUI";
  8. import { createTheme } from "@mui/material/styles";
  9. import { ThemeProvider } from "@emotion/react";
  10. import { dark } from "@mui/material/styles/createPalette";
  11. import { Box, CssBaseline } from "@mui/material";
  12. import { blue, pink } from "@mui/material/colors";
  13. import {
  14. createBrowserRouter,
  15. createRoutesFromElements,
  16. Route,
  17. RouterProvider,
  18. } from "react-router-dom";
  19. // Following tutorial https://www.youtube.com/watch?v=SqcY0GlETPk
  20. function App() {
  21. const items = ["Dude", "Man", "Shit", "Is it working?"];
  22. const [alertVisible, setAlertVisible] = useState(false);
  23. const handleSelectItem = (item: string) => {
  24. console.debug(item);
  25. };
  26. const dismissError = () => {
  27. setAlertVisible(false);
  28. };
  29. const darkTheme = createTheme({
  30. palette: {
  31. mode: "dark",
  32. },
  33. });
  34. const customTheme = createTheme({
  35. palette: {
  36. mode: "light",
  37. primary: blue,
  38. secondary: pink,
  39. },
  40. components: {
  41. MuiListItemButton: {
  42. styleOverrides: {
  43. root: {
  44. backgroundColor: "#00ff00",
  45. accentColor: "#00ff00",
  46. caretColor: "#00ff00",
  47. },
  48. },
  49. },
  50. MuiListItemText: {
  51. styleOverrides: {
  52. primary: {
  53. color: "red",
  54. background: "black",
  55. },
  56. secondary: {
  57. color: "yellow",
  58. background: "grey",
  59. },
  60. },
  61. },
  62. },
  63. });
  64. return (
  65. <ThemeProvider theme={customTheme}>
  66. <BrowserRouter></BrowserRouter>
  67. <CssBaseline />
  68. <div>
  69. {alertVisible && (
  70. <Alert onClose={() => setAlertVisible(false)} severity="error">
  71. This is bad
  72. </Alert>
  73. )}
  74. <MyButt name="LöBöttån!" onClick={() => setAlertVisible(true)}>
  75. Maan
  76. </MyButt>
  77. <Button
  78. disabled={alertVisible}
  79. variant="contained"
  80. onMouseEnter={() => setAlertVisible(true)}
  81. >
  82. Hello World
  83. </Button>
  84. <ListGroupBS
  85. items={items}
  86. heading="Man shit list"
  87. onSelectItem={handleSelectItem}
  88. />
  89. <ListGroupBS
  90. items={["Hoho", "Hihi", "Thhihih"]}
  91. heading="Skrat prat datt"
  92. onSelectItem={handleSelectItem}
  93. />
  94. <Box width={360}>
  95. <ListGroupMUI
  96. items={["This", "is", "MUI"]}
  97. heading="MAGGA BAGGA HAGGA"
  98. onSelectItem={handleSelectItem}
  99. />
  100. </Box>
  101. </div>
  102. </ThemeProvider>
  103. );
  104. }
  105. export default App;