From 10ed9b42d8fd56364ca8dcfd5b9005fae28b305f Mon Sep 17 00:00:00 2001 From: Geireann Lindfield Roberts <60007097+geireann@users.noreply.github.com> Date: Sun, 9 Jul 2023 20:08:14 -0400 Subject: fixing dropdown components --- src/client/views/nodes/button/FontIconBox.tsx | 92 ++++++++------------------- src/client/views/topbar/TopBar.tsx | 13 ++-- 2 files changed, 31 insertions(+), 74 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/nodes/button/FontIconBox.tsx b/src/client/views/nodes/button/FontIconBox.tsx index b9f75444f..7d5c38140 100644 --- a/src/client/views/nodes/button/FontIconBox.tsx +++ b/src/client/views/nodes/button/FontIconBox.tsx @@ -1,11 +1,12 @@ 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 { 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'; import { ColorState, SketchPicker } from 'react-color'; +import * as fa from 'react-icons/fa'; import { Doc, StrListCast } from '../../../../fields/Doc'; import { Height, Width } from '../../../../fields/DocSymbols'; import { InkTool } from '../../../../fields/InkField'; @@ -33,8 +34,6 @@ import { CollectionFreeFormDocumentView } from '../CollectionFreeFormDocumentVie 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 { @@ -316,8 +315,8 @@ export class FontIconBox extends DocComponent() { .map(value => ( { text: value, - shortcut: '#', - icon: + style: { fontFamily: value } + // shortcut: '#', } //
() { ); return ( - + ) return ( @@ -405,6 +404,7 @@ export class FontIconBox extends DocComponent() { const color = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.Color); const backgroundColor = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor); const curColor = this.colorScript?.script.run({ self: this.rootDoc, value: undefined, _readOnly_: true }).result ?? 'transparent'; + const tooltip: string = StrCast(this.rootDoc.toolTip); const label = !this.label || !FontIconBox.GetShowLabels() ? null : ( @@ -414,12 +414,15 @@ export class FontIconBox extends DocComponent() { ); return ( - { - this.colorPickerClosed = !this.colorPickerClosed; - this.noTooltip = !this.colorPickerClosed; - setTimeout(() => Doc.UnBrushAllDocs()); - e.stopPropagation(); - }}/> + { + this.colorPickerClosed = !this.colorPickerClosed; + setTimeout(() => Doc.UnBrushAllDocs()); + e.stopPropagation(); + }} + icon={this.Icon(color)!} + tooltip={tooltip} + /> ) return ( @@ -462,40 +465,15 @@ export class FontIconBox extends DocComponent() { // Determine the type of toggle button const switchToggle: boolean = BoolCast(this.rootDoc.switchToggle); const buttonText: string = StrCast(this.rootDoc.buttonText); + const tooltip: string = StrCast(this.rootDoc.toolTip); // Colors const color = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.Color); const backgroundColor = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor); - // Button label - const label = - !this.label || !FontIconBox.GetShowLabels() ? null : ( -
- {this.label} -
- ); - console.log("switchToggle", switchToggle, this.rootDoc.title) + console.log(buttonText, tooltip); return ( - + ) - - if (switchToggle) { - return ( -
- {buttonText ? buttonText : null} - -
- ); - } else { - return ( -
- {this.Icon(color)} - {label} -
- ); - } } /** @@ -504,24 +482,11 @@ export class FontIconBox extends DocComponent() { @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); + const tooltip: string = StrCast(this.rootDoc.toolTip); return ( - + ) - - return ( -
-
- {this.Icon(color)} - {!this.label || !FontIconBox.GetShowLabels() ? null : ( -
- {' '} - {this.label}{' '} -
- )} -
-
- ); } @computed get editableText() { @@ -544,6 +509,8 @@ export class FontIconBox extends DocComponent() { render() { const color = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.Color); const backgroundColor = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor); + const tooltip: string = StrCast(this.rootDoc.toolTip); + const label = (noBackground: boolean = false) => !this.label || !FontIconBox.GetShowLabels() ? null : (
@@ -577,25 +544,16 @@ export class FontIconBox extends DocComponent() { break; case ButtonType.ClickButton: case ButtonType.ToolButton: button = ( - - //
- // {this.Icon(color)} - // {label()} - //
+ ); break; case ButtonType.MenuButton: button = ( - - //
- // {this.Icon(color)} - // {label(true)} - // - //
+ ); break; } - return !this.layoutDoc.toolTip || this.noTooltip ? button : {StrCast(this.layoutDoc.toolTip)}
}>{button}; + return button; } } diff --git a/src/client/views/topbar/TopBar.tsx b/src/client/views/topbar/TopBar.tsx index a73d5cce0..80294917f 100644 --- a/src/client/views/topbar/TopBar.tsx +++ b/src/client/views/topbar/TopBar.tsx @@ -166,13 +166,12 @@ export class TopBar extends React.Component { render() { return ( //TODO:glr Add support for light / dark mode -
-
+
+
{this.topbarLeft} {this.topbarCenter} {this.topbarRight} -- cgit v1.2.3-70-g09d2