aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/DashboardView.tsx
diff options
context:
space:
mode:
authorsrichman333 <sarah_n_richman@brown.edu>2023-07-19 13:39:22 -0400
committersrichman333 <sarah_n_richman@brown.edu>2023-07-19 13:39:22 -0400
commit984db272dc37fc827291010796f300e8745eddf2 (patch)
tree8ec56aa04f32a3edd0a2a8413a3d4b09dac7769b /src/client/views/DashboardView.tsx
parentb24babcd89d51e7f6461c57ac16701630c86cf87 (diff)
parentd7a3e39e901054d0308df158cfa578a94f80c467 (diff)
Merge branch 'master' into collaboration-again
Diffstat (limited to 'src/client/views/DashboardView.tsx')
-rw-r--r--src/client/views/DashboardView.tsx115
1 files changed, 70 insertions, 45 deletions
diff --git a/src/client/views/DashboardView.tsx b/src/client/views/DashboardView.tsx
index b8c89d2ff..1a5781df0 100644
--- a/src/client/views/DashboardView.tsx
+++ b/src/client/views/DashboardView.tsx
@@ -1,5 +1,5 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { Button, ColorPicker, Size } from 'browndash-components';
+import { Button, ColorPicker, EditableText, FontSize, IconButton, Size, Type } from 'browndash-components';
import { action, computed, observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
@@ -25,7 +25,7 @@ import { ContextMenu } from './ContextMenu';
import './DashboardView.scss';
import { Colors } from './global/globalEnums';
import { MainViewModal } from './MainViewModal';
-import { ButtonType } from './nodes/button/FontIconBox';
+import { ButtonType } from './nodes/FontIconBox/FontIconBox';
enum DashboardGroup {
MyDashboards,
@@ -43,13 +43,16 @@ export class DashboardView extends React.Component {
@observable private selectedDashboardGroup = DashboardGroup.MyDashboards;
@observable private newDashboardName: string | undefined = undefined;
- @observable private newDashboardColor: string | undefined = undefined;
+ @observable private newDashboardColor: string | undefined = "#AFAFAF";
@action abortCreateNewDashboard = () => {
this.newDashboardName = undefined;
};
@action setNewDashboardName(name: string) {
this.newDashboardName = name;
}
+ @action setNewDashboardColor(color: string) {
+ this.newDashboardColor = color;
+ }
@action
selectDashboardGroup = (group: DashboardGroup) => {
@@ -97,23 +100,33 @@ export class DashboardView extends React.Component {
const dashboardCount = DocListCast(Doc.MyDashboards.data).length + 1;
const placeholder = `Dashboard ${dashboardCount}`;
return (
- <div className="new-dashboard">
+ <div className="new-dashboard"
+ style={{
+ background: StrCast(Doc.UserDoc().userBackgroundColor),
+ color: StrCast(Doc.UserDoc().userColor)
+ }}
+ >
<div className="header">Create New Dashboard</div>
- <div className="title-input">
- Title
- <input className="input" placeholder={placeholder} onChange={e => this.setNewDashboardName((e.target as any).value)} />
- </div>
- <div className="color-picker">
- Background
- <ColorPicker
- onChange={color => {
- this.newDashboardColor = color;
- }}
- />
- </div>
+ <EditableText
+ formLabel='Title'
+ placeholder={placeholder}
+ type={Type.SEC}
+ color={StrCast(Doc.UserDoc().userColor)}
+ setVal={val => this.setNewDashboardName(val as string)}
+ fillWidth
+ />
+ <ColorPicker
+ formLabel='Background'
+ colorPickerType='github'
+ type={Type.TERT}
+ selectedColor={this.newDashboardColor}
+ setSelectedColor={color => {
+ this.setNewDashboardColor(color);
+ }}
+ />
<div className="button-bar">
- <Button text="Cancel" onClick={this.abortCreateNewDashboard} />
- <Button text="Create" onClick={() => this.createNewDashboard(this.newDashboardName!, this.newDashboardColor)} />
+ <Button text="Cancel" color={StrCast(Doc.UserDoc().userColor)} onClick={this.abortCreateNewDashboard} />
+ <Button type={Type.TERT} text="Create" color={StrCast(Doc.UserDoc().userVariantColor)} onClick={() => this.createNewDashboard(this.newDashboardName!, this.newDashboardColor)} />
</div>
</div>
);
@@ -152,25 +165,29 @@ export class DashboardView extends React.Component {
};
render() {
+ const color = StrCast(Doc.UserDoc().userColor)
+ const variant = StrCast(Doc.UserDoc().userVariantColor)
return (
<>
<div className="dashboard-view">
<div className="left-menu">
- <div className="new-dashboard-button">
- <Button icon={<FaPlus />} size={Size.MEDIUM} text="New" onClick={() => this.setNewDashboardName('')} />
- </div>
- <div className={`text-button ${this.selectedDashboardGroup === DashboardGroup.MyDashboards && 'selected'}`} onClick={() => this.selectDashboardGroup(DashboardGroup.MyDashboards)}>
- {'My Dashboards (' + this.getDashboards(DashboardGroup.MyDashboards).length + ')'}
- </div>
- <div className={`text-button ${this.selectedDashboardGroup === DashboardGroup.SharedDashboards && 'selected'}`} onClick={() => this.selectDashboardGroup(DashboardGroup.SharedDashboards)}>
- Shared Dashboards{' '}
- <span
- style={{
- background: this.getDashboards(DashboardGroup.SharedDashboards).some(dash => !DocListCast(Doc.MySharedDocs.viewed).includes(dash)) ? 'lightgreen' : 'undefined',
- }}>
- {'(' + this.getDashboards(DashboardGroup.SharedDashboards).length + ')'}
- </span>
- </div>
+ <Button
+ text={'My Dashboards'}
+ active={this.selectedDashboardGroup === DashboardGroup.MyDashboards}
+ color={color}
+ align={'flex-start'}
+ onClick={() => this.selectDashboardGroup(DashboardGroup.MyDashboards)}
+ fillWidth
+ />
+ <Button
+ text={'Shared Dashboards' + ' (' + this.getDashboards(DashboardGroup.SharedDashboards).length + ')'}
+ active={this.selectedDashboardGroup === DashboardGroup.SharedDashboards}
+ color={this.getDashboards(DashboardGroup.SharedDashboards).some(dash => !DocListCast(Doc.MySharedDocs.viewed).includes(dash)) ? 'green' : color}
+ align={'flex-start'}
+ onClick={() => this.selectDashboardGroup(DashboardGroup.SharedDashboards)}
+ fillWidth
+ />
+ <Button icon={<FaPlus />} color={variant} iconPlacement="left" text="New Dashboard" type={Type.TERT} onClick={() => this.setNewDashboardName('')} />
</div>
<div className="all-dashboards">
{this.getDashboards(this.selectedDashboardGroup).map(dashboard => {
@@ -179,11 +196,11 @@ export class DashboardView extends React.Component {
.filter(key => key !== `acl-${Doc.CurrentUserEmailNormalized}` && !['acl-Me', 'acl-Guest'].includes(key))
.some(key => dashboard[DocAcl][key] !== AclPrivate);
return (
- <div
- className="dashboard-container"
- key={dashboard[Id]} //
- style={{ background: this.isUnviewedSharedDashboard(dashboard) && this.selectedDashboardGroup === DashboardGroup.SharedDashboards ? 'lightgreen' : shared ? 'lightblue' : '' }}
- onContextMenu={e => this.onContextMenu(dashboard, e)}
+ <div
+ className="dashboard-container"
+ key={dashboard[Id]}
+ style={{ background: this.isUnviewedSharedDashboard(dashboard) && this.selectedDashboardGroup === DashboardGroup.SharedDashboards ? 'green' : shared ? 'blue' : '' }}
+ onContextMenu={e => this.onContextMenu(dashboard, e)}
onClick={e => this.clickDashboard(e, dashboard)}>
<img
src={
@@ -191,12 +208,11 @@ export class DashboardView extends React.Component {
}
/>
<div className="info">
- <input
- style={{ border: 'unset', borderRadius: '5px' }}
- className="input"
- onClick={e => e.stopPropagation()}
- defaultValue={StrCast(dashboard.title)}
- onChange={e => (Doc.GetProto(dashboard).title = (e.target as any).value)}
+ <EditableText
+ type={Type.PRIM}
+ color={color}
+ val={StrCast(dashboard.title)}
+ setVal={val => (Doc.GetProto(dashboard).title = val)}
/>
{this.selectedDashboardGroup === DashboardGroup.SharedDashboards && this.isUnviewedSharedDashboard(dashboard) ? <div>unviewed</div> : <div></div>}
<div
@@ -210,9 +226,13 @@ export class DashboardView extends React.Component {
e.stopPropagation();
this.onContextMenu(dashboard, e);
}}>
- <Button size={Size.SMALL} icon={<FontAwesomeIcon color="black" size="lg" icon="bars" />} />
+ <Button size={Size.SMALL} color={color} icon={<FontAwesomeIcon color={color} icon="bars" />} />
</div>
</div>
+ <div className={`background`} style={{
+ background: StrCast(Doc.UserDoc().userColor),
+ filter: 'opacity(0.2)'
+ }}/>
<div className={'dashboard-status' + (shared ? '-shared' : '')}>{shared ? 'shared' : ''}</div>
</div>
);
@@ -223,6 +243,10 @@ export class DashboardView extends React.Component {
this.setNewDashboardName('');
}}>
+
+ <div className={`background`} style={{
+ background: StrCast(Doc.UserDoc().userColor),
+ filter: 'opacity(0.2)'
+ }}/>
</div>
</div>
</div>
@@ -418,6 +442,7 @@ export class DashboardView extends React.Component {
_layout_hideContextMenu: true,
title: 'New trail',
toolTip: 'Create new trail',
+ color: Colors.BLACK,
btnType: ButtonType.ClickButton,
buttonText: 'New trail',
icon: 'plus',