1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

cluster-menu tooltip fixes

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-07-15 15:38:23 +03:00
parent 717dfff851
commit 47f6a2b7e1
8 changed files with 43 additions and 40 deletions

View File

@ -5,8 +5,6 @@ import type { ClusterId } from "../common/cluster-store";
import { clusterStore } from "../common/cluster-store"; import { clusterStore } from "../common/cluster-store";
import logger from "./logger"; import logger from "./logger";
// fixme: activate landing-page when no-clusters exists
export class WindowManager { export class WindowManager {
protected activeView: BrowserWindow; protected activeView: BrowserWindow;
protected views = new Map<ClusterId, BrowserWindow>(); protected views = new Map<ClusterId, BrowserWindow>();

View File

@ -14,6 +14,7 @@ interface Props extends DOMAttributes<HTMLElement> {
className?: IClassName; className?: IClassName;
errorClass?: IClassName; errorClass?: IClassName;
showErrors?: boolean; showErrors?: boolean;
showTooltip?: boolean;
interactive?: boolean; interactive?: boolean;
isActive?: boolean; isActive?: boolean;
options?: HashiconParams; options?: HashiconParams;
@ -21,6 +22,7 @@ interface Props extends DOMAttributes<HTMLElement> {
const defaultProps: Partial<Props> = { const defaultProps: Partial<Props> = {
showErrors: true, showErrors: true,
showTooltip: true,
}; };
@observer @observer
@ -28,19 +30,24 @@ export class ClusterIcon extends React.Component<Props> {
static defaultProps = defaultProps as object; static defaultProps = defaultProps as object;
render() { render() {
const { className: cName, cluster, showErrors, errorClass, options, interactive, isActive, children, ...elemProps } = this.props; const {
cluster, showErrors, showTooltip, errorClass, options, interactive, isActive,
children, ...elemProps
} = this.props;
const { isAdmin, eventCount, preferences, id: clusterId } = cluster; const { isAdmin, eventCount, preferences, id: clusterId } = cluster;
const { clusterName, icon } = preferences; const { clusterName, icon } = preferences;
const clusterIconId = `cluster-icon-${clusterId}`; const clusterIconId = `cluster-icon-${clusterId}`;
const className = cssNames("ClusterIcon flex inline", cName, { const className = cssNames("ClusterIcon flex inline", this.props.className, {
interactive: interactive || !!this.props.onClick, interactive: interactive || !!this.props.onClick,
active: isActive, active: isActive,
}); });
return ( return (
<div {...elemProps} className={className} id={clusterIconId}> <div {...elemProps} className={className} id={clusterIconId}>
<Tooltip htmlFor={clusterIconId} following> {showTooltip && (
<TooltipContent nowrap>{clusterName}</TooltipContent> <Tooltip htmlFor={clusterIconId} position={{ right: true }}>
</Tooltip> <TooltipContent nowrap>{clusterName}</TooltipContent>
</Tooltip>
)}
{icon && <img src={icon} alt={clusterName}/>} {icon && <img src={icon} alt={clusterName}/>}
{!icon && <Hashicon value={clusterName} options={options}/>} {!icon && <Hashicon value={clusterName} options={options}/>}
{showErrors && isAdmin && eventCount > 0 && ( {showErrors && isAdmin && eventCount > 0 && (

View File

@ -8,7 +8,7 @@ export class ClusterManager extends React.Component {
const { children: lensView } = this.props; const { children: lensView } = this.props;
return ( return (
<div className="ClusterManager"> <div className="ClusterManager">
<div id="draggable-top"></div> <div id="draggable-top"/>
<div id="lens-view">{lensView}</div> <div id="lens-view">{lensView}</div>
<ClustersMenu/> <ClustersMenu/>
<BottomBar/> <BottomBar/>

View File

@ -1,5 +1,6 @@
.ClustersMenu { .ClustersMenu {
@include hidden-scrollbar; // fixme: uncomment when tooltips handled correctly (rendered outside of parent)
//@include hidden-scrollbar;
--flex-gap: #{$padding * 2}; --flex-gap: #{$padding * 2};
--menu-bgc: #252729; --menu-bgc: #252729;
@ -7,10 +8,15 @@
padding: $padding * 2; padding: $padding * 2;
background: var(--menu-bgc); background: var(--menu-bgc);
.add-cluster { #add-cluster {
position: relative; position: relative;
.Icon.add { .TooltipContent {
min-width: 300px;
text-align: left;
}
.Icon {
border-radius: $radius; border-radius: $radius;
padding: $padding / 3; padding: $padding / 3;
color: var(--menu-bgc) !important; color: var(--menu-bgc) !important;
@ -29,7 +35,7 @@
} }
} }
.Badge.counter { .Badge {
$boxSize: 17px; $boxSize: 17px;
$offset: -7px; $offset: -7px;

View File

@ -16,6 +16,7 @@ import { navigate } from "../../navigation";
import { addClusterURL } from "../+add-cluster"; import { addClusterURL } from "../+add-cluster";
import { clusterSettingsURL } from "../+cluster-settings"; import { clusterSettingsURL } from "../+cluster-settings";
import { landingURL } from "../+landing-page"; import { landingURL } from "../+landing-page";
import { Tooltip, TooltipContent } from "../tooltip";
// fixme: allow to rearrange clusters with drag&drop // fixme: allow to rearrange clusters with drag&drop
// fixme: make add-icon's tooltip visible on init // fixme: make add-icon's tooltip visible on init
@ -80,20 +81,17 @@ export class ClustersMenu extends React.Component<Props> {
/> />
) )
})} })}
<div className="add-cluster" onClick={this.addCluster}> <div id="add-cluster" onClick={this.addCluster}>
<Icon <Tooltip htmlFor="add-cluster" position={{ right: true }}>
big material="add" className="add" <TooltipContent>
tooltip={( <Trans>This is the quick launch menu.</Trans>
<div className="flex column gaps"> <br/><br/>
<p><Trans>This is the quick launch menu.</Trans></p> <Trans>
<p> Associate clusters and choose the ones you want to access via quick launch menu by clicking the + button.
<Trans> </Trans>
Associate clusters and choose the ones you want to access via quick launch menu by clicking the + button. </TooltipContent>
</Trans> </Tooltip>
</p> <Icon big material="add"/>
</div>
)}
/>
{newContexts.length > 0 && ( {newContexts.length > 0 && (
<Badge className="counter" label={newContexts.length}/> <Badge className="counter" label={newContexts.length}/>
)} )}

View File

@ -46,7 +46,6 @@
background: $sidebarBackground; background: $sidebarBackground;
white-space: nowrap; white-space: nowrap;
transition: width 150ms cubic-bezier(0.4, 0, 0.2, 1); transition: width 150ms cubic-bezier(0.4, 0, 0.2, 1);
z-index: 100;
&.pinned { &.pinned {
width: var(--sidebar-max-size); width: var(--sidebar-max-size);

View File

@ -32,12 +32,14 @@
} }
&:not(.following) { &:not(.following) {
margin: #{$margin};
&.left { &.left {
left: 0; right: 100%;
} }
&.right { &.right {
right: 0; left: 100%;
} }
&.top { &.top {
@ -47,24 +49,19 @@
&.bottom { &.bottom {
top: 100%; top: 100%;
} }
&.center {
left: 50%;
transform: translateX(-50%);
}
} }
} }
.TooltipContent { .TooltipContent {
&.nowrap { &.nowrap {
white-space: nowrap; &, * {
white-space: nowrap;
}
} }
&.narrow { &.narrow {
max-width: 300px; max-width: 300px;
overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: normal;
word-wrap: break-word; word-wrap: break-word;
text-align: left; text-align: left;
} }

View File

@ -7,7 +7,7 @@ import { createPortal } from "react-dom"
import { autobind, cssNames } from "../../utils"; import { autobind, cssNames } from "../../utils";
import { Animate } from "../animate"; import { Animate } from "../animate";
// todo: refactoring // todo: refactor
// todo: add flag to show visible tooltip by default (until mouse-over the target) // todo: add flag to show visible tooltip by default (until mouse-over the target)
// fixme: better positioning + remove "flying effect" // fixme: better positioning + remove "flying effect"
@ -26,13 +26,11 @@ interface Position {
right?: boolean; right?: boolean;
top?: boolean; top?: boolean;
bottom?: boolean; bottom?: boolean;
center?: boolean;
} }
const defaultProps: Partial<TooltipProps> = { const defaultProps: Partial<TooltipProps> = {
useAnimation: true, useAnimation: true,
position: { position: {
center: true,
bottom: true, bottom: true,
} }
}; };