Skip to content

Commit

Permalink
Improving accent color
Browse files Browse the repository at this point in the history
  • Loading branch information
javizqh committed Jan 10, 2025
1 parent 446d610 commit 6d97b12
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 48 deletions.
7 changes: 0 additions & 7 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@ const App = ({ isUnibotics }: { isUnibotics: boolean }) => {
const [forceSaveCurrent, setForcedSaveCurrent] = useState<boolean>(false);
const [currentProjectname, setCurrentProjectname] = useState<string>("");
const [currentUniverseName, setCurrentUniverseName] = useState<string>("");
const [actionNodesData, setActionNodesData] = useState<Record<string, any>>(
{},
);
const [saveCurrentDiagram, setSaveCurrentDiagram] = useState<boolean>(false);
const [updateFileExplorer, setUpdateFileExplorer] = useState<boolean>(false);
const [isErrorModalOpen, setErrorModalOpen] = useState<boolean>(false);
const [projectChanges, setProjectChanges] = useState<boolean>(false);
const [gazeboEnabled, setGazeboEnabled] = useState<boolean>(false);
const [manager, setManager] = useState<CommsManager | null>(null);
const [diagramEditorReady, setDiagramEditorReady] = useState<boolean>(false);
const [showSim, setSimVisible] = useState<boolean>(false);
const [showTerminal, setTerminalVisible] = useState<boolean>(false);

Expand Down Expand Up @@ -190,9 +186,6 @@ const App = ({ isUnibotics }: { isUnibotics: boolean }) => {
currentFilename={currentFilename}
currentProjectname={currentProjectname}
setProjectChanges={setProjectChanges}
actionNodesData={actionNodesData}
showAccentColor={"editorShowAccentColors"}
diagramEditorReady={diagramEditorReady}
setAutosave={setAutosave}
forceSaveCurrent={forceSaveCurrent}
setForcedSaveCurrent={setForcedSaveCurrent}
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/components/file_browser/FileBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ const FileBrowser = ({
currentFilename,
currentProjectname,
setProjectChanges,
actionNodesData,
showAccentColor,
diagramEditorReady,
setAutosave,
forceSaveCurrent,
setForcedSaveCurrent,
Expand Down Expand Up @@ -395,9 +392,6 @@ const FileBrowser = ({
currentFilename={currentFilename}
currentProjectname={currentProjectname}
setSelectedEntry={setSelectedEntry}
actionNodesData={actionNodesData}
showAccentColor={showAccentColor}
diagramEditorReady={diagramEditorReady}
fileList={fileList}
fetchFileList={fetchFileList}
onDelete={handleDeleteModal}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import React, { useEffect, useState } from "react";

import "./FileExplorer.css";
import TreeNode from "./TreeNode.jsx";
import TreeNode from "./TreeNode";
import MoreActionsMenu, { ContextMenuProps } from "./MoreActionsMenu.jsx";

const FileExplorer = ({
setCurrentFilename,
currentFilename,
currentProjectname,
setSelectedEntry,
actionNodesData,
showAccentColor,
diagramEditorReady,
fileList,
fetchFileList,
onDelete,
Expand Down Expand Up @@ -65,9 +62,6 @@ const FileExplorer = ({
depth={0}
parentGroup=""
currentFilename={currentFilename}
showAccentColor={showAccentColor}
diagramEditorReady={diagramEditorReady}
actionNodesData={actionNodesData}
handleFileClick={handleFileClick}
handleFolderClick={handleFolderClick}
menuProps={MenuProps}
Expand All @@ -76,7 +70,6 @@ const FileExplorer = ({
{showMenu && (
<MoreActionsMenu
menuProps={MenuProps}
actionNodesData={actionNodesData}
onDelete={onDelete}
onCreateFile={onCreateFile}
onCreateFolder={onCreateFolder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import "./MoreActionsMenu.css";

function MoreActionsMenu({
menuProps,
actionNodesData,
onDelete,
onCreateFile,
onCreateFolder,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
import React, { useEffect, useState } from "react";
import React, { useEffect, useState, useContext } from "react";

import { ReactComponent as ActionIcon } from "./img/action.svg";
import FileIcon from "./FileIcon.jsx";
import { OptionsContext } from "../../options/Options";
import { ContextMenuProps } from "./MoreActionsMenu";
import {
getActionFrame,
} from "../../helper/TreeEditorHelper";

interface Entry {
name: string;
is_dir: boolean;
path: string;
files: Entry[];
}

function TreeNode({
node,
depth,
parentGroup,
currentFilename,
showAccentColor,
diagramEditorReady,
actionNodesData,
handleFileClick,
handleFolderClick,
menuProps,
}: {
node: Entry;
depth: number;
parentGroup: string;
currentFilename: string;
handleFileClick: Function;
handleFolderClick: Function;
menuProps: ContextMenuProps;
}) {
const [isCollapsed, setCollapsed] = useState(false);
const [group, setGroup] = useState(parentGroup);
const [isCollapsed, setCollapsed] = useState<boolean>(false);
const [group, setGroup] = useState<string>(parentGroup);
const settings = React.useContext(OptionsContext);

useEffect(() => {
if (node.is_dir) {
Expand All @@ -25,7 +43,7 @@ function TreeNode({
}
}
}, []);

const handleClick = () => {
if (node.is_dir) {
setCollapsed(!isCollapsed);
Expand Down Expand Up @@ -61,17 +79,15 @@ function TreeNode({
menuProps.showMoreActionsMenu(
e,
node,
parentGroup === "" ? group : parentGroup,
parentGroup === "" ? group : parentGroup
);
}}
/>
{showAccentColor && diagramEditorReady && (
{settings.editorShowAccentColors.value && (
<div
className="bt-accent-color"
style={{
backgroundColor: actionNodesData[node.name.replace(".py", "")]
? actionNodesData[node.name.replace(".py", "")]["color"]
: "none",
backgroundColor: getActionFrame(node.name.replace(".py", "")) ? getActionFrame(node.name.replace(".py", ""))?.getColor() : "none",
}}
/>
)}
Expand All @@ -84,9 +100,6 @@ function TreeNode({
depth={depth + 1}
parentGroup={group}
currentFilename={currentFilename}
showAccentColor={showAccentColor}
diagramEditorReady={diagramEditorReady}
actionNodesData={actionNodesData}
handleFileClick={handleFileClick}
handleFolderClick={handleFolderClick}
menuProps={menuProps}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/options/Options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { createContext, useState } from "react";
const OptionsContext = createContext<SettingsData>({
editorShowAccentColors: {
setter: () => {},
value: true,
default_value: true,
value: false,
default_value: false,
},
theme: { setter: () => {}, value: "dark", default_value: "dark" },
btOrder: {
Expand All @@ -30,7 +30,7 @@ export interface SettingsData {

const OptionsProvider = ({ children }: { children: any }) => {
// TODO: try to not repeat the default values
const [editorShowAccentColors, setEditorShowAccentColors] = useState(true);
const [editorShowAccentColors, setEditorShowAccentColors] = useState(false);
const [theme, setTheme] = useState("dark");
const [btOrder, setBtOrder] = useState("bottom-to-top");

Expand All @@ -39,7 +39,7 @@ const OptionsProvider = ({ children }: { children: any }) => {
editorShowAccentColors: {
setter: setEditorShowAccentColors,
value: editorShowAccentColors,
default_value: true,
default_value: false,
},
theme: { setter: setTheme, value: theme, default_value: "dark" },
btOrder: {
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/components/settings_popup/SettingsModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@ import { OptionsContext } from "../options/Options";
import { saveProjectConfig } from "./../../api_helper/TreeWrapper";

const SettingsModal = ({ onSubmit, isOpen, onClose, currentProjectname }) => {
const [color, setColor] = useColor("rgb(128 0 128)");
const [open, setOpen] = useState(false);

// const [color, setColor] = useColor("rgb(128 0 128)");
const settings = React.useContext(OptionsContext);

useEffect(() => {
// Load settings
}, [isOpen]);

// useEffect(() => {
// console.log("rgb("+Math.round(color.rgb.r)+","+Math.round(color.rgb.g)+","+Math.round(color.rgb.b)+")")
// document.documentElement.style.setProperty("--header", "rgb("+Math.round(color.rgb.r)+","+Math.round(color.rgb.g)+","+Math.round(color.rgb.b)+")");
Expand Down

0 comments on commit 6d97b12

Please sign in to comment.