aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes')
-rw-r--r--src/client/views/nodes/DocumentView.scss5
-rw-r--r--src/client/views/nodes/DocumentView.tsx2
-rw-r--r--src/client/views/nodes/button/FontIconBox.tsx71
-rw-r--r--src/client/views/nodes/button/colorDropdown/ColorDropdown.tsx77
-rw-r--r--src/client/views/nodes/button/colorDropdown/index.ts1
5 files changed, 56 insertions, 100 deletions
diff --git a/src/client/views/nodes/DocumentView.scss b/src/client/views/nodes/DocumentView.scss
index f1627e1e1..b25540dd3 100644
--- a/src/client/views/nodes/DocumentView.scss
+++ b/src/client/views/nodes/DocumentView.scss
@@ -115,7 +115,10 @@
width: 100%;
height: 100%;
transition: inherit;
-
+ display: flex;
+ justify-content: center;
+ align-items: center;
+
.sharingIndicator {
height: 30px;
width: 30px;
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index b6f1626f8..6b37dc419 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -1232,7 +1232,7 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
const renderDoc = this.renderDoc({
borderRadius: this.borderRounding,
outline: highlighting && !this.borderRounding && !highlighting.highlightStroke ? `${highlighting.highlightColor} ${highlighting.highlightStyle} ${highlighting.highlightIndex}px` : 'solid 0px',
- border: highlighting && this.borderRounding && highlighting.highlightStyle === 'dashed' ? `${highlighting.highlightStyle} ${highlighting.highlightColor} ${highlighting.highlightIndex}px` : undefined,
+ border: highlighting && this.borderRounding && highlighting.highlightStyle === 'dashed' ? `${highlighting.highlightStyle} ${highlighting.highlightColor} ${highlighting.highlightIndex}px` : undefined,
boxShadow,
clipPath: borderPath?.clipPath,
});
diff --git a/src/client/views/nodes/button/FontIconBox.tsx b/src/client/views/nodes/button/FontIconBox.tsx
index 5bba51ec8..e2fe0bcf1 100644
--- a/src/client/views/nodes/button/FontIconBox.tsx
+++ b/src/client/views/nodes/button/FontIconBox.tsx
@@ -1,6 +1,7 @@
import { IconProp } from '@fortawesome/fontawesome-svg-core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Tooltip } from '@material-ui/core';
+import { Button, ColorPicker, Dropdown, DropdownType, IconButton, IListItemProps, OrientationType, Size, Toggle, ToggleType, Type } from 'browndash-components';
import { action, computed, observable, runInAction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
@@ -33,6 +34,7 @@ import { OpenWhere } from '../DocumentView';
import { RichTextMenu } from '../formattedText/RichTextMenu';
import { WebBox } from '../WebBox';
import { FontIconBadge } from './FontIconBadge';
+import * as fa from 'react-icons/fa'
import './FontIconBox.scss';
export enum ButtonType {
@@ -309,19 +311,24 @@ export class FontIconBox extends DocComponent<ButtonProps>() {
}
// Get items to place into the list
- const list = this.buttonList
+ const list: IListItemProps[] = this.buttonList
.filter(value => !Doc.noviceMode || !noviceList.length || noviceList.includes(value))
.map(value => (
- <div
- className="list-item"
- key={value}
- style={{
- fontFamily: script.script.originalScript.startsWith('{ return setFont') ? value : undefined,
- backgroundColor: value === text ? Colors.LIGHT_BLUE : undefined,
- }}
- onClick={undoable(() => script.script.run({ self: this.rootDoc, value }), value)}>
- {value[0].toUpperCase() + value.slice(1)}
- </div>
+ {
+ text: value,
+ shortcut: '#',
+ icon: <fa.FaCaretUp/>
+ }
+ // <div
+ // className="list-item"
+ // key={value}
+ // style={{
+ // fontFamily: script.script.originalScript.startsWith('{ return setFont') ? value : undefined,
+ // backgroundColor: value === text ? Colors.LIGHT_BLUE : undefined,
+ // }}
+ // onClick={undoable(() => script.script.run({ self: this.rootDoc, value }), value)}>
+ // {value[0].toUpperCase() + value.slice(1)}
+ // </div>
));
const label =
@@ -332,6 +339,10 @@ export class FontIconBox extends DocComponent<ButtonProps>() {
);
return (
+ <Dropdown type={Type.PRIM} dropdownType={DropdownType.CLICK} items={list} location={OrientationType.LEFT}/>
+ )
+
+ return (
<div
className={`menuButton ${this.type} ${active}`}
style={{ backgroundColor: this.rootDoc.dropDownOpen ? Colors.MEDIUM_BLUE : backgroundColor, color: color, display: dropdown ? undefined : 'flex' }}
@@ -401,6 +412,15 @@ export class FontIconBox extends DocComponent<ButtonProps>() {
{this.label}
</div>
);
+
+ return (
+ <ColorPicker onChange={(e) => {
+ this.colorPickerClosed = !this.colorPickerClosed;
+ this.noTooltip = !this.colorPickerClosed;
+ setTimeout(() => Doc.UnBrushAllDocs());
+ e.stopPropagation();
+ }}/>
+ )
return (
<div
@@ -453,6 +473,10 @@ export class FontIconBox extends DocComponent<ButtonProps>() {
{this.label}
</div>
);
+ console.log("switchToggle", switchToggle, this.rootDoc.title)
+ return (
+ <Toggle toggleType={ToggleType.BUTTON} type={Type.PRIM} toggleStatus={switchToggle} text={buttonText} color={color} icon={this.Icon(color)!} label={this.label}/>
+ )
if (switchToggle) {
return (
@@ -480,6 +504,11 @@ export class FontIconBox extends DocComponent<ButtonProps>() {
@computed get defaultButton() {
const color = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.Color);
const backgroundColor = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor);
+
+ return (
+ <IconButton icon={this.Icon(color)!} label={this.label}/>
+ )
+
return (
<div className={`menuButton ${this.type}`} onContextMenu={this.specificContextMenu} style={{ backgroundColor: 'transparent', borderBottomLeftRadius: this.dropdown ? 0 : undefined }}>
<div className="menuButton-wrap">
@@ -548,18 +577,20 @@ export class FontIconBox extends DocComponent<ButtonProps>() {
break;
case ButtonType.ClickButton:
case ButtonType.ToolButton: button = (
- <div className={`menuButton ${this.type + (FontIconBox.GetShowLabels() ? 'Label' : '')}`} style={{ backgroundColor, color, opacity: 1 }}>
- {this.Icon(color)}
- {label()}
- </div>
+ <IconButton color={color} icon={this.Icon(color)!} label={this.label}/>
+ // <div className={`menuButton ${this.type + (FontIconBox.GetShowLabels() ? 'Label' : '')}`} style={{ backgroundColor, color, opacity: 1 }}>
+ // {this.Icon(color)}
+ // {label()}
+ // </div>
);
break;
case ButtonType.MenuButton: button = (
- <div className={`menuButton ${this.type}`} style={{ color, backgroundColor }}>
- {this.Icon(color)}
- {label(true)}
- <FontIconBadge value={Cast(this.Document.badgeValue, 'string', null)} />
- </div>
+ <IconButton size={Size.LARGE} color={color} icon={this.Icon(color)!} label={this.label}/>
+ // <div className={`menuButton ${this.type}`} style={{ color, backgroundColor }}>
+ // {this.Icon(color)}
+ // {label(true)}
+ // <FontIconBadge value={Cast(this.Document.badgeValue, 'string', null)} />
+ // </div>
);
break;
}
diff --git a/src/client/views/nodes/button/colorDropdown/ColorDropdown.tsx b/src/client/views/nodes/button/colorDropdown/ColorDropdown.tsx
deleted file mode 100644
index 74c3c563c..000000000
--- a/src/client/views/nodes/button/colorDropdown/ColorDropdown.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import React, { Component } from 'react';
-import { BoolCast, StrCast } from '../../../../../fields/Types';
-import { IButtonProps } from '../ButtonInterface';
-import { ColorState, SketchPicker } from 'react-color';
-import { ScriptField } from '../../../../../fields/ScriptField';
-import { Doc } from '../../../../../fields/Doc';
-import { FontIconBox } from '../FontIconBox';
-
-export class ColorDropdown extends Component<IButtonProps> {
- render() {
- const active: string = StrCast(this.props.rootDoc.dropDownOpen);
-
- const script: string = StrCast(this.props.rootDoc.script);
- const scriptCheck: string = script + '(undefined, true)';
- const boolResult = ScriptField.MakeScript(scriptCheck)?.script.run().result;
-
- const stroke: boolean = false;
- // if (script === "setStrokeColor") {
- // stroke = true;
- // const checkWidth = ScriptField.MakeScript("setStrokeWidth(0, true)")?.script.run().result;
- // const width = 20 + (checkWidth / 100) * 70;
- // const height = 20 + (checkWidth / 100) * 70;
- // strokeIcon = (<div style={{ borderRadius: "100%", width: width + '%', height: height + '%', backgroundColor: boolResult ? boolResult : "#FFFFFF" }} />);
- // }
-
- const colorOptions: string[] = ['#D0021B', '#F5A623', '#F8E71C', '#8B572A', '#7ED321', '#417505', '#9013FE', '#4A90E2', '#50E3C2', '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF', '#f1efeb'];
-
- const colorBox = (func: (color: ColorState) => void) => <SketchPicker disableAlpha={!stroke} onChange={func} color={boolResult ? boolResult : '#FFFFFF'} presetColors={colorOptions} />;
- const label =
- !this.props.label || !FontIconBox.GetShowLabels() ? null : (
- <div className="fontIconBox-label" style={{ color: this.props.color, backgroundColor: this.props.backgroundColor, position: 'absolute' }}>
- {this.props.label}
- </div>
- );
-
- const dropdownCaret = (
- <div className="menuButton-dropDown" style={{ borderBottomRightRadius: active ? 0 : undefined }}>
- <FontAwesomeIcon icon={'caret-down'} color={this.props.color} size="sm" />
- </div>
- );
-
- const click = (value: ColorState) => {
- const hex: string = value.hex;
- const s = ScriptField.MakeScript(script + '("' + hex + '", false)');
- if (s) {
- s.script.run().result;
- }
- };
- return (
- <div
- className={`menuButton ${this.props.type} ${active}`}
- style={{ color: this.props.color, borderBottomLeftRadius: active ? 0 : undefined }}
- onClick={() => (this.props.rootDoc.dropDownOpen = !this.props.rootDoc.dropDownOpen)}
- onPointerDown={e => e.stopPropagation()}>
- <FontAwesomeIcon className={`fontIconBox-icon-${this.props.type}`} icon={this.props.icon} color={this.props.color} />
- <div className="colorButton-color" style={{ backgroundColor: boolResult ? boolResult : '#FFFFFF' }} />
- {label}
- {/* {dropdownCaret} */}
- {this.props.rootDoc.dropDownOpen ? (
- <div>
- <div className="menuButton-dropdownBox" onPointerDown={e => e.stopPropagation()} onClick={e => e.stopPropagation()}>
- {colorBox(click)}
- </div>
- <div
- className="dropbox-background"
- onClick={e => {
- e.stopPropagation();
- this.props.rootDoc.dropDownOpen = false;
- }}
- />
- </div>
- ) : null}
- </div>
- );
- }
-}
diff --git a/src/client/views/nodes/button/colorDropdown/index.ts b/src/client/views/nodes/button/colorDropdown/index.ts
deleted file mode 100644
index 1147d6457..000000000
--- a/src/client/views/nodes/button/colorDropdown/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './ColorDropdown'; \ No newline at end of file