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

Dark Theme Integration #122

Merged
merged 27 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b07619a
Add dark theme to ./theme
durulkoca Dec 12, 2023
cf27184
Add theme options setting
durulkoca Dec 12, 2023
8dff209
Update editor to change based on theme
durulkoca Dec 12, 2023
2664224
use useTheme to manage styles inside components
durulkoca Dec 12, 2023
f52dd3a
Add custom dark theme to monaco editor
durulkoca Dec 12, 2023
4348898
Create temporary palette
durulkoca Dec 12, 2023
7d3b393
Change from hardcoded colors to colors from platform
durulkoca Dec 12, 2023
b116dc1
Change naming space in local storage
durulkoca Dec 12, 2023
e5b8a45
Remove import theme instances for useTheme instead
durulkoca Dec 12, 2023
fd262b8
fix linting problems
durulkoca Dec 12, 2023
75a9a75
Add theme selection option to LandingDialog
durulkoca Dec 15, 2023
8a93ec3
Move Monaco Editor theme to separate lib file
durulkoca Dec 15, 2023
e0b9218
Update Palette to dark dim colors
durulkoca Dec 15, 2023
cdcafcf
Fix shadow error on dialog on dark theme
durulkoca Dec 15, 2023
28066ff
Change Nucleoid Gray color to a darker gray
durulkoca Dec 15, 2023
0c1c9f5
Update LandingDialog styling
durulkoca Dec 15, 2023
fefb8c6
Fix small icon not showing pointer
durulkoca Dec 20, 2023
fb5a811
Remove .addeventlisteners for subscribe
durulkoca Dec 20, 2023
9165975
Remove subscribe and publish events for theme selection
durulkoca Dec 21, 2023
40df176
Remove now unused imports
durulkoca Dec 21, 2023
114d53b
Merge branch 'main' into dark-theme
durulkoca Dec 21, 2023
626b82e
Change usestorage usage
durulkoca Dec 22, 2023
4bde71f
Change import orders
durulkoca Dec 22, 2023
1465213
update webstorage
durulkoca Dec 25, 2023
0f0cd31
Update webstorage usage
durulkoca Dec 25, 2023
2756c30
Change import order
durulkoca Dec 25, 2023
0b6b509
Change light dark if statements for consistency
durulkoca Dec 26, 2023
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
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@mui/x-data-grid": "^5.5.0",
"@nucleoidjs/components": "^1.2.0",
"@nucleoidjs/synapses": "^1.0.8",
"@nucleoidjs/webstorage": "^1.0.2",
"@nucleoidjs/webstorage": "^1.0.3",
"@types/react": "^17.0.2",
"axios": "^0.27.2",
"axios-auth-refresh": "^3.3.1",
Expand Down
2 changes: 1 addition & 1 deletion public/loading.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ body {
font-family: Roboto, sans-serif;
font-size: 2rem;
height: 100%;
background-color: #323a40;
background-color: #343a43;
align-items: center;
display: flex;
display: -webkit-flex;
Expand Down
15 changes: 13 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { contextReducer } from "./context/reducer";
import { contextToMap } from "./utils/Parser";
import routes from "./routes";
import { subscribe } from "@nucleoidjs/synapses";
import theme from "./theme";
import { useStorage } from "@nucleoidjs/webstorage";
import vfs from "./vfs";

import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom";
Expand All @@ -18,8 +18,19 @@ import {
StyledEngineProvider,
ThemeProvider,
} from "@mui/material";
import { darkTheme, lightTheme } from "./theme";

function App() {
const prefersLightMode = window.matchMedia(
"(prefers-color-scheme: light)"
).matches;

const [theme] = useStorage(
"platform",
"theme",
prefersLightMode ? "light" : "dark"
);

const progressElement = document.getElementById("nuc-progress-indicator");

function checkMobileSize() {
Expand Down Expand Up @@ -145,7 +156,7 @@ function App() {

return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<ThemeProvider theme={theme === "light" ? lightTheme : darkTheme}>
<CssBaseline />
<BrowserRouter basename="ide">
<ContextProvider state={context} reducer={contextReducer}>
Expand Down
4 changes: 3 additions & 1 deletion src/components/ClosableDialogTitle/ClosableDialogTitle.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import CloseIcon from "@mui/icons-material/Close";
import styles from "./styles";
import theme from "../../theme";
import { useTheme } from "@mui/material/styles";

import { DialogTitle, Grid, IconButton, Typography } from "@mui/material";

function ClosableDialogTitle({ handleClose, label, content, grey }) {
const theme = useTheme();
return (
<DialogTitle sx={styles.dialogTitle}>
<Grid container sx={styles.content}>
Expand Down
42 changes: 40 additions & 2 deletions src/components/LandingDialog/LandingDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import ClosableDialogTitle from "../ClosableDialogTitle";
import { Divider } from "@mui/material";
import NumberOne from "../../images/number-one.png";
import NumberThree from "../../images/number-three.png";
import NumberTwo from "../../images/number-two.png";
import React from "react";
import { Switch } from "@mui/material";
import codeImage from "../../images/code.png";
import onboardDispatcher from "../Onboard/onboardDispatcher";

import styles from "./styles";
import theme from "../../theme";
import { useTheme } from "@mui/material/styles";

import {
Avatar,
Box,
Expand All @@ -18,12 +22,23 @@ import {
ListItem,
ListItemAvatar,
ListItemText,
Typography,
} from "@mui/material";
import { storage, useStorage } from "@nucleoidjs/webstorage";

const LandingDialog = () => {
const [themeStorage] = useStorage("platform", "theme", "light");

const handleThemeChange = (event) => {
const newTheme = event.target.checked ? "dark" : "light";

storage.set("platform", "theme", newTheme);
};

const handleClose = () => {
onboardDispatcher({ level: 1 });
};
const theme = useTheme();
return (
<Dialog
open={true}
Expand All @@ -43,6 +58,7 @@ const LandingDialog = () => {
<Box sx={styles.welcome}>
<h2> Welcome to Nucleoid Project </h2>
</Box>

<Box>
Nucleoid low-code framework lets you build your APIs with the help of
AI and built-in datastore.
Expand All @@ -57,7 +73,7 @@ const LandingDialog = () => {
<ListItemAvatar>
<Avatar src={NumberOne}></Avatar>
</ListItemAvatar>
<ListItemText primary="Write your business logic in JavaScript" />
<ListItemText primary="Write your business logic in TypeScript" />
</ListItem>
<ListItem>
<ListItemAvatar>
Expand All @@ -81,6 +97,28 @@ const LandingDialog = () => {
</Box>
</Box>
</DialogContent>
<Divider sx={{ marginY: 2 }} />
<Box
sx={{
flexGrow: 1,
display: "flex",
alignItems: "center",
justifyContent: "center",
marginTop: 2,
marginBottom: 1,
}}
>
<Typography variant="body2" sx={{ marginRight: 1 }}>
Light
</Typography>
<Switch
checked={themeStorage !== "light"}
onChange={handleThemeChange}
/>
<Typography variant="body2" sx={{ marginLeft: 1 }}>
Dark
</Typography>
</Box>
<DialogActions>
<Button sx={{ color: theme.palette.custom.grey }} onClick={handleClose}>
CLOSE
Expand Down
5 changes: 3 additions & 2 deletions src/components/NonExpandableAPITreeItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from "react";
import ResourceMenu from "../widgets/ResourceMenu";
import Typography from "@mui/material/Typography";
import clsx from "clsx";
import theme from "../theme";
import { useTheme } from "@mui/material/styles";

import { TreeItem, useTreeItem } from "@mui/lab";

const NonExpandableTreeContent = React.forwardRef(function CustomContent(
Expand Down Expand Up @@ -51,7 +52,7 @@ const NonExpandableTreeContent = React.forwardRef(function CustomContent(
const handleCloseResourceMenu = () => {
setOpen(false);
};

const theme = useTheme();
return (
<div
className={clsx(className, classes.root, {
Expand Down
4 changes: 3 additions & 1 deletion src/components/OpenSandboxButton.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from "react";
import Swagger from "../icons/Swagger";
import theme from "../theme";
import { useTheme } from "@mui/material/styles";

import { Box, Button, Typography } from "@mui/material";

const OpenSandboxButton = ({ clickEvent, small, disabled }) => {
const theme = useTheme();
return (
<Button
disabled={disabled}
Expand Down
4 changes: 3 additions & 1 deletion src/components/OpenSwaggerButton.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from "react";
import Swagger from "../icons/Swagger";
import theme from "../theme";
import { useTheme } from "@mui/material/styles";

import { Box, Button, Typography } from "@mui/material";

const OpenSwaggerButton = ({ clickEvent, small, disabled }) => {
const theme = useTheme();
return (
<Button
disabled={disabled}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectSelect/ProjectSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function ProjectSelect({ title }) {
variant="contained"
color={"inherit"}
onClick={() => setOpen(true)}
endIcon={<ArrowDropDown />}
endIcon={<ArrowDropDown sx={{ color: "#121212" }} />}
>
{title}
</Button>
Expand Down
3 changes: 1 addition & 2 deletions src/components/ProjectSelectSmall/ProjectSelectSmall.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { FileOpen } from "@mui/icons-material/";
import ProjectDialog from "../../widgets/ProjectDialog";
import React from "react";

import { useContext } from "../../context/context";

import { Box, Button, Tooltip } from "@mui/material/";
Expand Down Expand Up @@ -29,7 +28,7 @@ export default function ProjectSelectSmall() {
color={"inherit"}
onClick={() => setOpen(true)}
>
<FileOpen sx={{ color: "#323a40" }} />
<FileOpen sx={{ color: "#343a43" }} />
</Button>
{open && <ProjectDialog handleClose={handleClose} />}
</Box>
Expand Down
18 changes: 18 additions & 0 deletions src/components/SettingsDialogRuntime/SettingsDialogRuntime.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import React from "react";

import styles from "./styles";

import { Box, Switch, TextField, Typography } from "@mui/material";
import { storage, useStorage } from "@nucleoidjs/webstorage";

const SettingsDialogRuntime = React.forwardRef((props, urlRef) => {
const [themeStorage] = useStorage("platform", "theme", "light");

const handleThemeChange = (event) => {
const newTheme = event.target.checked ? "dark" : "light";
storage.set("platform.theme", newTheme);
};

const [url, setUrl] = React.useState(urlRef.current.url);
const [custom, setCustom] = React.useState(
urlRef.current.runtime === "custom" ? true : false
Expand Down Expand Up @@ -129,6 +139,14 @@ const SettingsDialogRuntime = React.forwardRef((props, urlRef) => {
/>
</BetweenComponents>
</Section>
<Section title={"Theme"}>
<BetweenComponents title={"Dark Mode"}>
<Switch
checked={themeStorage !== "light"}
onChange={handleThemeChange}
/>
</BetweenComponents>
</Section>
</Box>
);
});
Expand Down
7 changes: 6 additions & 1 deletion src/components/SmallLogo/SmallLogo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { Typography } from "@mui/material";

const SmallLogo = () => {
return (
<Typography display={"inline"} fontSize={"26px"} color={"#209958"}>
<Typography
display={"inline"}
fontSize={"26px"}
color={"#209958"}
style={{ cursor: "pointer" }}
>
nuc
</Typography>
);
Expand Down
7 changes: 5 additions & 2 deletions src/components/SwaggerDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import Settings from "../settings";
import StarUsOnGithub from "./StarUsOnGithub";
import Swagger from "../icons/Swagger";
import onboardDispatcher from "./Onboard/onboardDispatcher";
import theme from "../theme";
import { useTheme } from "@mui/material/styles";

import {
AppBar,
Box,
Expand All @@ -22,6 +23,7 @@ const Transition = React.forwardRef(function Transition(props, ref) {
});

export default function SwaggerDialog() {
const theme = useTheme();
const [swagger] = useEvent("SWAGGER_DIALOG", { open: false });

function handleClose() {
Expand All @@ -46,7 +48,7 @@ export default function SwaggerDialog() {
<AppBar
sx={{
position: "relative",
backgroundColor: "#323a40",
backgroundColor: "#343a43",
color: theme.palette.custom.grey,
}}
>
Expand Down Expand Up @@ -119,6 +121,7 @@ export default function SwaggerDialog() {
}

function OpenSwaggerNewTabButton(props) {
const theme = useTheme();
const { url } = props;

function handleClick() {
Expand Down
Loading
Loading