Skip to content

Commit

Permalink
Improves frontend propTypes, Changes colorPalette types
Browse files Browse the repository at this point in the history
Resolves: #59
  • Loading branch information
stephanzwicknagl committed Jan 30, 2024
1 parent 3f3d944 commit a183d3d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 24 deletions.
22 changes: 11 additions & 11 deletions backend/src/viasp/server/static/colorPalette.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"light": "#F4F5FA",
"dark": "#444",
"infoBackground": "#B3BAC5",
"rowShading": {
"0": "#a9a9a92f",
"1": "#ffffff"
},
"rowShading": [
"#a9a9a92f",
"#ffffff"
],
"explanationSuccess": "#e2b38a",
"explanationHighlights": {
"0": "#98f4e2",
"1": "#9a8298",
"2": "#bbf9a9",
"3": "#14ceaf",
"4": "#e1ed5c"
}
"explanationHighlights": [
"#98f4e2",
"#9a8298",
"#bbf9a9",
"#14ceaf",
"#e1ed5c"
]
}
11 changes: 2 additions & 9 deletions frontend/src/lib/contexts/ColorPalette.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import { COLORPALETTE } from "../types/propTypes";

const ColorPaletteContext = React.createContext([]);

Expand All @@ -20,13 +21,5 @@ ColorPaletteProvider.propTypes = {
/**
* The color palette to update the color palette with
*/
colorPalette: PropTypes.exact({
primary: PropTypes.string,
light: PropTypes.string,
dark: PropTypes.string,
infoBackground: PropTypes.string,
rowShading: PropTypes.objectOf(PropTypes.string),
explanationSuccess: PropTypes.string,
explanationHighlights: PropTypes.objectOf(PropTypes.string),
}),
colorPalette: COLORPALETTE
};
2 changes: 1 addition & 1 deletion frontend/src/lib/contexts/HighlightedSymbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const useHighlightedSymbol = () => React.useContext(HighlightedSymbolCont
export const HighlightedSymbolProvider = ({ children }) => {
const [highlightedSymbol, setHighlightedSymbol] = React.useState(defaultHighlightedSymbol);
const colorPalette = useColorPalette();
const colorArray = Object.values(colorPalette.explanationHighlights);
const colorArray = colorPalette.explanationHighlights;

function getNextColor(l, arrowsColors){
var c = JSON.stringify(colorArray[l % colorArray.length])
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/main/ViaspDash.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function GraphContainer(props) {
const {state: {transformations}} = useTransformations()
const lastNodeInGraph = transformations.length - 1;
const colorPalette = useColorPalette();
const background = Object.values(colorPalette.rowShading);
const background = colorPalette.rowShading;


return <div className="graph_container" >
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/lib/types/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ export const BOX = PropTypes.exact({
_type: PropTypes.oneOf(['Box']),
uuid: PropTypes.string
})
export const COLORPALETTE = PropTypes.exact({
primary: PropTypes.string,
light: PropTypes.string,
dark: PropTypes.string,
infoBackground: PropTypes.string,
rowShading: PropTypes.arrayOf(PropTypes.string),
explanationSuccess: PropTypes.string,
explanationHighlights: PropTypes.arrayOf(PropTypes.string),
})
2 changes: 1 addition & 1 deletion frontend/viasp_dash/viasp_dash.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/viasp_dash/viasp_dash.min.js.map

Large diffs are not rendered by default.

0 comments on commit a183d3d

Please sign in to comment.