-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into TASK-94-Management-page-sketch
- Loading branch information
Showing
22 changed files
with
349 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/components/common-components/autocomplete/autocomplete.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 0 additions & 77 deletions
77
src/components/schedule-page/table/schedule/schedule-parts/base-cell.component.tsx
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...nents/schedule-page/table/schedule/schedule-parts/base-cell/base-cell-input.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} />; | ||
} |
85 changes: 85 additions & 0 deletions
85
src/components/schedule-page/table/schedule/schedule-parts/base-cell/base-cell.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.