Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cp/iss112 #120

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
57bb150
Adjust TenantTableCollapse
cdpadilla42 Dec 17, 2020
e6cff20
Add Tags page
cdpadilla42 Dec 17, 2020
7a41174
Write initial, ugly styling to tags display
cdpadilla42 Dec 17, 2020
23a4669
Add borders and colors to display
cdpadilla42 Dec 18, 2020
e858875
Style tags
cdpadilla42 Dec 18, 2020
f64ba18
Bring in button styling
cdpadilla42 Dec 18, 2020
aa7601a
Finishing touches to colors, accents, and spacing
cdpadilla42 Dec 18, 2020
7757247
Conditionally show editing row
cdpadilla42 Dec 18, 2020
ca0edb4
Implement dynamic text color based on label color darkness
cdpadilla42 Dec 28, 2020
63ad487
pull edit and display rows into seperate render methods
cdpadilla42 Jan 4, 2021
ea134fe
Add color picker
cdpadilla42 Jan 4, 2021
77de03e
Refactor out edit render method to component with state
cdpadilla42 Jan 5, 2021
9fceefe
Handle form logic in tag edit component
cdpadilla42 Jan 5, 2021
89e06ff
Add dummy tag deletion handler
cdpadilla42 Jan 5, 2021
409dd9d
Tie color change handler to state
cdpadilla42 Jan 6, 2021
a4c284c
Correct ts warnings
cdpadilla42 Jan 6, 2021
d011c9e
Reflect color change in editing view
cdpadilla42 Jan 7, 2021
6f9c33f
Represent tag updates in display
cdpadilla42 Jan 7, 2021
b29763c
Structure out add tag row
cdpadilla42 Jan 7, 2021
51d9e54
Hook up submit new tag function to state
cdpadilla42 Jan 8, 2021
d8f2934
Handle add tag cleanup
cdpadilla42 Jan 8, 2021
af21d65
Clean logs
cdpadilla42 Jan 8, 2021
6e51e38
Extract tag into reusable component
cdpadilla42 Jan 8, 2021
a8975ca
Style add tag button
cdpadilla42 Jan 8, 2021
e07d5f5
Clean unused function calls
cdpadilla42 Jan 8, 2021
ca94e25
Pull EditTagRow styles to shared folder
cdpadilla42 Jan 8, 2021
5dbddcb
Reorganize files - pull out styles and pages to own directories
cdpadilla42 Jan 8, 2021
c7048d1
Extract tag types to own directory
cdpadilla42 Jan 8, 2021
2d2e9ad
Merge branch 'master' into cp/iss112
cdpadilla42 Jan 10, 2021
62dbff8
Extract tag row render method toseperate component
cdpadilla42 Jan 10, 2021
5b81ace
Clear TypeScript errors
cdpadilla42 Jan 10, 2021
6696e94
Add comment
cdpadilla42 Jan 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions tenant-file/portal-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tenant-file/portal-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-color": "^3.0.4",
"@types/react-dom": "^16.9.0",
"@types/react-redux": "^7.1.8",
"@types/react-router-dom": "^5.1.5",
Expand All @@ -24,6 +25,7 @@
"graphql": "^15.3.0",
"line-awesome": "^1.3.0",
"react": "^16.13.1",
"react-color": "^2.19.3",
"react-dom": "^16.13.1",
"react-firebaseui": "^4.1.0",
"react-redux": "^7.2.0",
Expand Down
32 changes: 18 additions & 14 deletions tenant-file/portal-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import React from "react";
import React from 'react';

import "bootstrap/dist/css/bootstrap.min.css";
import "@fortawesome/fontawesome-free/css/all.min.css";
import "line-awesome/dist/line-awesome/css/line-awesome.min.css";
import { Switch, Route, Redirect } from "react-router-dom";
import Login from "./component/login";
import Layout from "./component/layout";
import PrivateRoute from "./component/private-route";
import DisplayImages from "./component/display-images";
import Admin from "./component/admin";
import Dashboard from "./component/dashboard";
import Properties from "./component/properties";
import Home from "./component/home";
import TenantDetails from "./component/tenant-details";
import 'bootstrap/dist/css/bootstrap.min.css';
import '@fortawesome/fontawesome-free/css/all.min.css';
import 'line-awesome/dist/line-awesome/css/line-awesome.min.css';
import { Switch, Route, Redirect } from 'react-router-dom';
import Login from './component/login';
import Layout from './component/layout';
import PrivateRoute from './component/private-route';
import DisplayImages from './component/display-images';
import Admin from './component/admin';
import Dashboard from './component/dashboard';
import Properties from './component/properties';
import Home from './component/home';
import TenantDetails from './component/tenant-details';
import Tags from './pages/Tags-Page';

function App() {
return (
Expand All @@ -28,6 +29,9 @@ function App() {
<PrivateRoute exact path="/dashboard">
<Dashboard />
</PrivateRoute>
<PrivateRoute exact path="/tags">
<Tags />
</PrivateRoute>
<PrivateRoute
path="/dashboard/tenant/:id"
component={TenantDetails}
Expand Down
116 changes: 116 additions & 0 deletions tenant-file/portal-app/src/component/add-tag-row.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import React, { useState } from 'react';
import { TwitterPicker, ColorResult } from 'react-color';
import Tag from './tag';
import StyledEditTagRow from './styles/TagEditRow';
import { Tags } from '../types/tag';

type Props = {
setData: React.Dispatch<React.SetStateAction<Tags>>;
toggleAddTag: () => void;
};

const AddTagRow = ({ setData, toggleAddTag }: Props) => {
const initialState = {
name: 'New Tag',
description: '',
photoCount: 0,
id: Math.floor(Math.random() * 10000),
color: '#F78DA7',
};
const [editTagFields, setEditTagFields] = useState(initialState);
const [showColorPicker, setShowColorPicker] = useState(false);

function handleChange(e: React.ChangeEvent) {
const target = e.currentTarget as HTMLInputElement;
setEditTagFields((prevState) => {
return {
...prevState,
[target.id]: target.value,
};
});
}

function handleSubmit(e: React.MouseEvent<HTMLButtonElement, MouseEvent>) {
// Perform tag updating magic here
e.preventDefault();
setData((prevState) => {
return [editTagFields, ...prevState];
});
toggleAddTag();
}

function toggleColorPicker() {
setShowColorPicker(!showColorPicker);
}

function hadleColorChangeComplete(color: ColorResult) {
setEditTagFields((prevState) => {
return { ...prevState, color: color.hex };
});
}

function cancelAddTag() {
setEditTagFields(initialState);
toggleAddTag();
}

return (
<>
<div className="flex-row" key="add">
<div className="label">
<Tag tag={editTagFields} />
</div>

<div className="description"></div>
<div className="photoCount"></div>

<div className="buttons"></div>
</div>

<StyledEditTagRow
color={editTagFields.color}
className="flex-row"
onSubmit={() => console.log('ok!')}
>
<div>
<input
type="text"
name="name"
id="name"
value={editTagFields.name}
onChange={handleChange}
placeholder="Name"
></input>
</div>

<div>
<input
type="text"
name="description"
id="description"
value={editTagFields.description}
onChange={handleChange}
placeholder="Description"
/>
</div>
<div onClick={toggleColorPicker} className="color_section">
<div className="color"></div>
{showColorPicker && (
<div className="color-picker">
<TwitterPicker
onChangeComplete={hadleColorChangeComplete}
color={editTagFields.color}
/>
</div>
)}
</div>
<div className="buttons">
<button onClick={handleSubmit}>Save</button>
<button onClick={cancelAddTag}>Cancel</button>
</div>
</StyledEditTagRow>
</>
);
};

export default AddTagRow;
Loading