Skip to content

Commit

Permalink
Better styles
Browse files Browse the repository at this point in the history
  • Loading branch information
hasnainroopawalla authored Sep 1, 2023
1 parent 6483862 commit a26c8ce
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/aco/ant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class Ant {
config.antAntennaRadius,
pheromoneType
);
// console.log(leftAntenna, frontAntenna, rightAntenna);

if (frontAntenna > leftAntenna && frontAntenna > rightAntenna) {
// do nothing
} else if (leftAntenna > rightAntenna) {
Expand Down
27 changes: 26 additions & 1 deletion src/components/control-panel/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,40 @@ type IControlPanelContentProps = {
updateAcoConfig: IUpdateAcoConfig;
};

const styles = {
controlPanelContent: {
width: "350px",
maxHeight: "60%",
position: "absolute",
margin: "20px 0 0 20px",
borderRadius: "0.6rem",
backgroundColor: "rgba(0, 0, 0, 0.7)",
overflow: "auto",
paddingTop: "60px",
},
closeButton: {
padding: "8px",
textDecoration: "none",
display: "block",
color: "#fff",
position: "absolute",
top: "0",
right: "10px",
fontSize: "30px",
cursor: "pointer",
},
} as const;

export const ControlPanelContent = (props: IControlPanelContentProps) => {
const { hideControlPanel, updateAcoConfig } = props;

return (
<div className="control-panel-content">
<div className="control-panel-content" style={styles.controlPanelContent}>
<a
className="close-button"
data-testid="control-panel-close-button"
onClick={hideControlPanel}
style={styles.closeButton}
>
&times;
</a>
Expand Down
25 changes: 22 additions & 3 deletions src/components/control-panel/setting-item.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import React, { ReactNode } from "react";

const styles = {
settingItem: {
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
padding: "8px",
},
settingTitle: {
color: "#fff",
},
settingComponent: {
display: "flex",
flexDirection: "row",
gap: "10px",
},
} as const;

type ISettingItemProps = {
title: string;
slider?: ReactNode;
Expand All @@ -10,9 +27,11 @@ export const SettingItem = (props: ISettingItemProps) => {
const { title, slider, checkbox } = props;

return (
<div className="slider-container">
<span className="slider-title">{title}</span>
<div className="slider-component">
<div className="setting-item" style={styles.settingItem}>
<span className="setting-title" style={styles.settingTitle}>
{title}
</span>
<div className="setting-component" style={styles.settingComponent}>
{checkbox}
{slider}
</div>
Expand Down
16 changes: 15 additions & 1 deletion src/components/control-panel/slider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import React from "react";
import { IConfig, IUpdateAcoConfig } from "../../aco";

const styles = {
sliderOutput: {
color: "#fff",
backgroundColor: "#3691ec",
borderRadius: "7px",
alignItems: "center",
padding: "4px 6px 4px 6px",
},
} as const;

type ISliderProps = {
configParam: keyof IConfig;
min: number;
Expand Down Expand Up @@ -39,7 +49,11 @@ export const Slider = (props: ISliderProps) => {
step={step}
onInput={(event) => updateValue(event)}
/>
<span id={`${configParam}Value`} className="slider-output">
<span
id={`${configParam}Value`}
className="slider-output"
style={styles.sliderOutput}
>
{formatValue()}
</span>
</>
Expand Down
20 changes: 19 additions & 1 deletion src/components/control-panel/toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import React from "react";

const styles = {
toggleButtonContainer: {
display: "flex",
justifyContent: "left",
},
toggleButton: {
color: "#fff",
position: "absolute",
margin: "20px 0 0 20px",
/* TODO: transitions */
cursor: "pointer",
},
} as const;

type IControlPanelToggleProps = {
showControlPanel: () => void;
};
Expand All @@ -8,11 +22,15 @@ export const ControlPanelToggle = (props: IControlPanelToggleProps) => {
const { showControlPanel } = props;

return (
<div className="control-panel-toggle-button-container">
<div
className="control-panel-toggle-button-container"
style={styles.toggleButtonContainer}
>
<a
className="control-panel-toggle-button icon"
data-testid="control-panel-toggle-button"
onClick={showControlPanel}
style={styles.toggleButton}
>
<i className="fa fa-cog fa-lg" />
</a>
Expand Down
8 changes: 8 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
margin: 0px;
font-family: Tahoma;
font-size: 13px;
letter-spacing: 0.5px;
}
</style>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
Expand Down
1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import { createRoot } from "react-dom/client";
import { App } from "./components/app";
import "./styles/style.css";

createRoot(document.getElementById("root")).render(<App />);

0 comments on commit a26c8ce

Please sign in to comment.