Add keybindings for shapes (#648)

* Add keybindings for shapes

I'm not 100% sure about this one. I feel like it's going to help people be a lot more productive to display the key bindings at all time. But it also clutters the UI...

* increase font-size

* fix shape keybindings for non-qwerty keyboards

* tweak position and color

Co-authored-by: David Luzar <luzar.david@gmail.com>
This commit is contained in:
Christopher Chedeau 2020-02-01 17:31:28 +00:00 committed by GitHub
parent be97bd980e
commit f8a41cee16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -13,6 +13,7 @@ type ToolButtonBaseProps = {
name?: string;
id?: string;
size?: ToolIconSize;
keyBindingLabel?: string;
};
type ToolButtonProps =
@ -63,7 +64,12 @@ export const ToolButton = React.forwardRef(function(
checked={props.checked}
ref={innerRef}
/>
<div className="ToolIcon__icon">{props.icon}</div>
<div className="ToolIcon__icon">
{props.icon}
{props.keyBindingLabel && (
<span className="ToolIcon__keybinding">{props.keyBindingLabel}</span>
)}
</div>
</label>
);
});

View File

@ -83,3 +83,12 @@
box-shadow: none;
}
}
.ToolIcon__keybinding {
position: absolute;
bottom: 2px;
right: 3px;
font-size: 0.5em;
color: #adb5bd; // OC GRAY 5
font-family: Arial, Helvetica, sans-serif;
}

View File

@ -374,7 +374,6 @@ export class App extends React.Component<any, AppState> {
} else if (
shapesShortcutKeys.includes(event.key.toLowerCase()) &&
!event.ctrlKey &&
!event.shiftKey &&
!event.altKey &&
!event.metaKey &&
this.state.draggingElement === null
@ -564,6 +563,7 @@ export class App extends React.Component<any, AppState> {
title={`${capitalizeString(label)}${
capitalizeString(value)[0]
}, ${index + 1}`}
keyBindingLabel={`${index + 1}`}
aria-label={capitalizeString(label)}
aria-keyshortcuts={`${label[0]} ${index + 1}`}
onChange={() => {