[WIKI-602] chore: disable image alignment tooltip for touch devices (#7642)
* chore: disable image alignment tooltip for touch devices * chore: added touch-select-none style
This commit is contained in:
parent
b6cf3a5a8b
commit
eb5ac2fc2d
3 changed files with 11 additions and 3 deletions
|
|
@ -10,11 +10,12 @@ import { IMAGE_ALIGNMENT_OPTIONS } from "../../utils";
|
||||||
type Props = {
|
type Props = {
|
||||||
activeAlignment: TCustomImageAlignment;
|
activeAlignment: TCustomImageAlignment;
|
||||||
handleChange: (alignment: TCustomImageAlignment) => void;
|
handleChange: (alignment: TCustomImageAlignment) => void;
|
||||||
|
isTouchDevice: boolean;
|
||||||
toggleToolbarViewStatus: (val: boolean) => void;
|
toggleToolbarViewStatus: (val: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ImageAlignmentAction: React.FC<Props> = (props) => {
|
export const ImageAlignmentAction: React.FC<Props> = (props) => {
|
||||||
const { activeAlignment, handleChange, toggleToolbarViewStatus } = props;
|
const { activeAlignment, handleChange, isTouchDevice, toggleToolbarViewStatus } = props;
|
||||||
// states
|
// states
|
||||||
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
||||||
// refs
|
// refs
|
||||||
|
|
@ -30,7 +31,7 @@ export const ImageAlignmentAction: React.FC<Props> = (props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={dropdownRef} className="h-full relative">
|
<div ref={dropdownRef} className="h-full relative">
|
||||||
<Tooltip tooltipContent="Align">
|
<Tooltip disabled={isTouchDevice} tooltipContent="Align">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="h-full flex items-center gap-1 text-white/60 hover:text-white transition-colors"
|
className="h-full flex items-center gap-1 text-white/60 hover:text-white transition-colors"
|
||||||
|
|
@ -43,7 +44,7 @@ export const ImageAlignmentAction: React.FC<Props> = (props) => {
|
||||||
{isDropdownOpen && (
|
{isDropdownOpen && (
|
||||||
<div className="absolute top-full left-1/2 -translate-x-1/2 mt-0.5 h-7 bg-black/80 flex items-center gap-2 px-2 rounded">
|
<div className="absolute top-full left-1/2 -translate-x-1/2 mt-0.5 h-7 bg-black/80 flex items-center gap-2 px-2 rounded">
|
||||||
{IMAGE_ALIGNMENT_OPTIONS.map((option) => (
|
{IMAGE_ALIGNMENT_OPTIONS.map((option) => (
|
||||||
<Tooltip key={option.value} tooltipContent={option.label}>
|
<Tooltip disabled={isTouchDevice} key={option.value} tooltipContent={option.label}>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="flex-shrink-0 h-full grid place-items-center text-white/60 hover:text-white transition-colors"
|
className="flex-shrink-0 h-full grid place-items-center text-white/60 hover:text-white transition-colors"
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ export const ImageToolbarRoot: React.FC<Props> = (props) => {
|
||||||
<ImageAlignmentAction
|
<ImageAlignmentAction
|
||||||
activeAlignment={alignment}
|
activeAlignment={alignment}
|
||||||
handleChange={handleAlignmentChange}
|
handleChange={handleAlignmentChange}
|
||||||
|
isTouchDevice={isTouchDevice}
|
||||||
toggleToolbarViewStatus={setShouldShowToolbar}
|
toggleToolbarViewStatus={setShouldShowToolbar}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -500,3 +500,9 @@ span[data-name][data-type="emoji"] img {
|
||||||
max-width: 1.25em;
|
max-width: 1.25em;
|
||||||
max-height: 1.25em;
|
max-height: 1.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* touch device styles */
|
||||||
|
.touch-select-none {
|
||||||
|
user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue