Skip to content

Commit

Permalink
Merge branch 'develop' into TASK-94-Management-page-sketch
Browse files Browse the repository at this point in the history
  • Loading branch information
pectom authored Nov 27, 2020
2 parents 566dc27 + 11f7284 commit 1174736
Show file tree
Hide file tree
Showing 22 changed files with 349 additions and 309 deletions.
1 change: 1 addition & 0 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const env = dotenv.config().parsed;
function createWindow() {
mainWindow = new BrowserWindow({show: false});
mainWindow.maximize();
mainWindow.removeMenu();
mainWindow.show();
mainWindow.loadURL(isDev ? `http://localhost:${env.PORT}` : `file://${path.join(__dirname, "../build/index.html")}`);
mainWindow.on("closed", () => (mainWindow = null));
Expand Down
2 changes: 2 additions & 0 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import React from "react";
import SchedulePage from "./components/schedule-page/schedule-page.component";
import ManagementPage from "./components/workers-page/management-page.component";
import { CustomGlobalHotKeys } from "./components/common-components/tools/globalhotkeys.component";
import Header from "./components/common-components/header/header";

function App(): JSX.Element {
return (
<React.Fragment>
<CustomGlobalHotKeys />
<Header />
<Switch>
<Route path="/" component={SchedulePage} exact />
<Route path="/management" component={ManagementPage} />
Expand Down
2 changes: 2 additions & 0 deletions src/assets/styles/styles-all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
@import "styles/custom/tables";
@import "styles/custom/toolbar";
@import "styles/custom/add-worker-modal";
@import "styles/custom/header";
@import "styles/custom/month-switch";
@import "styles/custom/management_page";
@import "styles/custom/autocomplete";
21 changes: 21 additions & 0 deletions src/assets/styles/styles/custom/_autocomplete.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.listbox {
position: absolute;
margin: 0;
padding: 0;
z-index: 1;
background-color: $white;
list-style: none;
overflow: auto;
max-height: 200;
& li {
&:active {
background-color: "#2977f5";
color: "white";
}
&[data-focus="true"] {
background-color: "#4a8df6";
color: "white";
cursor: "pointer";
}
}
}
18 changes: 18 additions & 0 deletions src/assets/styles/styles/custom/_header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#header {
display: flex;
flex-direction: row;
width: 100%;
height: 52px;
background-color: $primary-header-color;
padding: 0 20px 0 20px;
align-items: center;
justify-content: left;

#AssignmentIndIcon {
color: $header-text-color;
}

.filler {
flex-grow: 1;
}
}
2 changes: 1 addition & 1 deletion src/assets/styles/styles/custom/_month-switch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
font-size: 16px;
letter-spacing: 1px;
* {
color: $primary-text-color;
color: $header-text-color;
}
span {
margin: 5px;
Expand Down
4 changes: 4 additions & 0 deletions src/assets/styles/styles/custom/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ $enable-transitions: true !default;
$enable-grid-classes: true !default;
$enable-print-styles: true !default;

// Header
$primary-header-color: #1d3557 !default;
$header-text-color: #ffffff !default;

// Color system

$primary: #1d3557 !default;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { useAutocomplete } from "@material-ui/lab";
import React, { useEffect, useState } from "react";

interface AutocompleteOptions<T> {
options: T[];
getOptionLabel: (option: T) => string;
onValueChange: (newValue: T) => void;
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
className?: string;
}
export function AutocompleteComponent<T>({
className = "",
options,
getOptionLabel,
onValueChange,
onKeyDown,
}: AutocompleteOptions<T>): JSX.Element {
const [value, setValue] = useState<T>();
useEffect(() => {
if (value) {
onValueChange(value);
}
}, [value, onValueChange]);

const {
getRootProps,
getInputProps,
getListboxProps,
getOptionProps,
groupedOptions,
} = useAutocomplete({
options,
getOptionLabel,
});

return (
<div>
<div {...getRootProps()}>
<input
className={className}
autoFocus={true}
value={value && getOptionLabel(value)}
{...getInputProps()}
onKeyDown={onKeyDown}
/>
</div>
{groupedOptions.length > 0 ? (
<ul {...getListboxProps()} className="listbox">
{groupedOptions.map((option, index) => (
<li
{...getOptionProps({ option, index })}
onClick={(): void => {
setValue(option);
}}
>
{getOptionLabel(option)}
</li>
))}
</ul>
) : null}
</div>
);
}
15 changes: 15 additions & 0 deletions src/components/common-components/header/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import { MonthSwitchComponent } from "../month-switch/month-switch.component";
import AssignmentIndIcon from "@material-ui/icons/AssignmentInd";

export default function Header(): JSX.Element {
return (
<>
<div id={"header"}>
<AssignmentIndIcon id={"AssignmentIndIcon"} />
<MonthSwitchComponent />
<div className={"filler"} />
</div>
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { StringHelper } from "../../../helpers/string.helper";
interface MonthSwitchOpions {
key?: string;
}
export function MonthSwitchComponent(options: MonthSwitchOpions) {
export function MonthSwitchComponent(options: MonthSwitchOpions): JSX.Element {
const arrowSize = "small";
/* eslint-disable @typescript-eslint/camelcase */
const { month_number, year } = useSelector(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from "react";
import { CellManagementKeys } from "./base-cell.component";

export interface BaseCellInputOptions {
className: string;
onValueChange: (value: string) => void;
onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
}

export function BaseCellInputComponent({
className,
onValueChange,
onKeyDown,
}: BaseCellInputOptions): JSX.Element {
function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>): void {
if (e.key === CellManagementKeys.Enter) {
onValueChange(e.currentTarget.value);
return;
}
onKeyDown(e);
}

return <input autoFocus={true} className={className} onKeyDown={handleKeyDown} />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import React from "react";
import { ColorHelper } from "../../../../../../helpers/colors/color.helper";
import { CellColorSet } from "../../../../../../helpers/colors/cell-color-set.model";
import { BaseCellInputComponent, BaseCellInputOptions } from "./base-cell-input.component";

export enum CellManagementKeys {
Enter = "Enter",
Escape = "Escape",
}

export interface BaseCellOptions {
index: number;
value: string;
style?: CellColorSet;
isBlocked: boolean;
isPointerOn: boolean;
isSelected: boolean;
onClick?: () => void;
onContextMenu?: () => void;
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
onValueChange?: (value: string) => void;
onBlur?: () => void;
input?: React.FC<BaseCellInputOptions>;
}

export function BaseCellComponent({
index,
value,
style = ColorHelper.DEFAULT_COLOR_SET,
isBlocked,
isSelected,
isPointerOn,
onKeyDown,
onValueChange,
onContextMenu,
onClick,
onBlur,
input: InputComponent = BaseCellInputComponent,
}: BaseCellOptions): JSX.Element {
function handleContextMenu(e: React.MouseEvent): void {
e.preventDefault();
onContextMenu && onContextMenu();
}
function _onKeyDown(e: React.KeyboardEvent<HTMLInputElement>): void {
if (e.key === CellManagementKeys.Enter) {
onValueChange && onValueChange(e.currentTarget.value);
return;
}
onKeyDown && onKeyDown(e);
}
function _onValueChange(newValue: string): void {
onValueChange && onValueChange(newValue);
}

// #region view
return (
<td
className="cell"
onClick={(): void => {
!isBlocked && onClick && onClick();
}}
onContextMenu={handleContextMenu}
style={{
color: style.textColor.toString(),
backgroundColor:
isSelected || isPointerOn
? ColorHelper.getHighlightColor().toString()
: style.backgroundColor.toString(),
}}
onBlur={(e): void => {
onBlur && onBlur();
}}
>
{isPointerOn && !isBlocked && (
<InputComponent
className="cell-input"
onValueChange={(value): void => _onValueChange(value)}
onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>): void => _onKeyDown(e)}
/>
)}
{(!isPointerOn || (isPointerOn && isBlocked)) && <span>{value}</span>}
</td>
);
//#endregion
}
Loading

0 comments on commit 1174736

Please sign in to comment.