button tooltip from b90e32886a

This commit is contained in:
Sanster 2022-05-21 13:04:09 +08:00 committed by Qing
parent 92900933e5
commit 22834a8243
9 changed files with 56 additions and 1 deletions

View File

@ -731,11 +731,15 @@ export default function Editor(props: EditorProps) {
/> />
<div className="editor-toolkit-btns"> <div className="editor-toolkit-btns">
<Button <Button
toolTip="Show Full"
tooltipPosition="top"
icon={<ArrowsExpandIcon />} icon={<ArrowsExpandIcon />}
disabled={scale === minScale && panned === false} disabled={scale === minScale && panned === false}
onClick={resetZoom} onClick={resetZoom}
/> />
<Button <Button
toolTip="Undo"
tooltipPosition="top"
icon={ icon={
<svg <svg
width="19" width="19"
@ -754,6 +758,8 @@ export default function Editor(props: EditorProps) {
disabled={disableUndo()} disabled={disableUndo()}
/> />
<Button <Button
toolTip="Show Original"
tooltipPosition="top"
icon={<EyeIcon />} icon={<EyeIcon />}
className={showOriginal ? 'eyeicon-active' : ''} className={showOriginal ? 'eyeicon-active' : ''}
onDown={ev => { onDown={ev => {
@ -774,6 +780,8 @@ export default function Editor(props: EditorProps) {
disabled={renders.length === 0} disabled={renders.length === 0}
/> />
<Button <Button
toolTip="Save Image"
tooltipPosition="top"
icon={<DownloadIcon />} icon={<DownloadIcon />}
disabled={!renders.length} disabled={!renders.length}
onClick={download} onClick={download}
@ -781,6 +789,8 @@ export default function Editor(props: EditorProps) {
{settings.runInpaintingManually && ( {settings.runInpaintingManually && (
<Button <Button
toolTip="Run Inpainting"
tooltipPosition="top"
icon={ icon={
<svg <svg
width="24" width="24"

View File

@ -14,6 +14,8 @@ const SettingIcon = () => {
<div> <div>
<Button <Button
onClick={onClick} onClick={onClick}
toolTip="Settings"
tooltipPosition="bottom"
style={{ border: 0 }} style={{ border: 0 }}
icon={ icon={
<svg <svg

View File

@ -22,6 +22,8 @@ const Shortcuts = () => {
<div className="shortcuts"> <div className="shortcuts">
<Button <Button
onClick={shortcutStateHandler} onClick={shortcutStateHandler}
toolTip="Hotkeys"
tooltipPosition="bottom"
disabled={shortcutVisibility} disabled={shortcutVisibility}
style={{ border: 0 }} style={{ border: 0 }}
icon={ icon={

View File

@ -1,8 +1,9 @@
@use '../../styles/Mixins/' as *;
.btn-primary { .btn-primary {
display: grid; display: grid;
grid-auto-flow: column; grid-auto-flow: column;
column-gap: 1rem; column-gap: 1rem;
// border: 1px solid var(--btn-border-color);
color: var(--btn-text-color); color: var(--btn-text-color);
font-family: 'WorkSans', sans-serif; font-family: 'WorkSans', sans-serif;
width: max-content; width: max-content;

View File

@ -5,6 +5,8 @@ interface ButtonProps {
children?: ReactNode children?: ReactNode
className?: string className?: string
icon?: ReactNode icon?: ReactNode
toolTip?: string
tooltipPosition?: string
onKeyDown?: () => void onKeyDown?: () => void
onClick?: () => void onClick?: () => void
onDown?: (ev: PointerEvent) => void onDown?: (ev: PointerEvent) => void
@ -18,6 +20,8 @@ const Button: React.FC<ButtonProps> = props => {
className, className,
disabled, disabled,
icon, icon,
toolTip,
tooltipPosition,
onKeyDown, onKeyDown,
onClick, onClick,
onDown, onDown,
@ -33,6 +37,7 @@ const Button: React.FC<ButtonProps> = props => {
return ( return (
<div <div
role="button" role="button"
data-tooltip={toolTip}
style={style} style={style}
onKeyDown={onKeyDown} onKeyDown={onKeyDown}
onClick={blurOnClick} onClick={blurOnClick}
@ -47,6 +52,8 @@ const Button: React.FC<ButtonProps> = props => {
'btn-primary', 'btn-primary',
children ? 'btn-primary-content' : '', children ? 'btn-primary-content' : '',
disabled === true ? 'btn-primary-disabled' : '', disabled === true ? 'btn-primary-disabled' : '',
toolTip ? 'info-tooltip' : '',
tooltipPosition ? `info-tooltip-${tooltipPosition}` : '',
className, className,
].join(' ')} ].join(' ')}
> >

View File

@ -0,0 +1,28 @@
$tooltip-translate: 100%;
$tooltip-margin: 1.5rem;
.info-tooltip {
&:hover:before {
content: attr(data-tooltip);
position: absolute;
background-color: var(--tooltip-bg);
color: var(--tooltip-text-color);
padding: 0.5rem;
border-radius: 0.3rem;
z-index: 2;
}
}
.info-tooltip-top {
&:hover:before {
transform: translateY(calc($tooltip-translate * -1));
margin-bottom: $tooltip-margin;
}
}
.info-tooltip-bottom {
&:hover:before {
transform: translateY($tooltip-translate);
margin-top: $tooltip-margin;
}
}

View File

@ -9,6 +9,8 @@
--link-color: rgb(0, 0, 0); --link-color: rgb(0, 0, 0);
--border-color: rgb(100, 100, 120); --border-color: rgb(100, 100, 120);
--border-color-light: rgba(100, 100, 120, 0.5); --border-color-light: rgba(100, 100, 120, 0.5);
--tooltip-bg: rgb(230, 230, 234);
--tooltip-text-color: rgb(0, 0,0);
--error-color: rgb(239, 68, 68); --error-color: rgb(239, 68, 68);
--success-color: rgb(16, 185, 129); --success-color: rgb(16, 185, 129);

View File

@ -9,6 +9,8 @@
--link-color: var(--yellow-accent); --link-color: var(--yellow-accent);
--border-color: rgb(100, 100, 120); --border-color: rgb(100, 100, 120);
--border-color-light: rgba(102, 102, 102); --border-color-light: rgba(102, 102, 102);
--tooltip-bg: rgb(33, 33, 33);
--tooltip-text-color: rgb(210, 210, 210);
// Editor // Editor
--editor-toolkit-bg: rgba(0, 0, 0, 0.5); --editor-toolkit-bg: rgba(0, 0, 0, 0.5);

View File

@ -21,6 +21,7 @@
@use '../components/shared/Switch'; @use '../components/shared/Switch';
@use '../components/shared/NumberInput'; @use '../components/shared/NumberInput';
@use '../components/shared/Toast'; @use '../components/shared/Toast';
@use '../components/shared/Tooltip';
// Main CSS // Main CSS
*, *,