-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
186143109 drawing toolbar in new toolbar system #2309
Merged
Merged
Changes from 37 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
06aad85
set up new toolbar in drawing tile
bacalj 1c15e51
Merge branch 'master' into 186143109-drawing-toolbar-update
bacalj 0ab0130
individually implemented basic actions
bacalj 7c67be6
breaking up the button definitions for now
bacalj 4d56cda
put button definitons in folder, set up openPallette state
bacalj d3bc258
wip:getting pallettes working
bacalj 618e808
delete existing drawing-toolbar file
bacalj adff048
base implementation of all buttons
bacalj 26e927f
Merge branch 'local-try-dynamic-svg-like-vector-palette' into 1861431…
bacalj 76d3c4d
cleanup merge
bacalj e4d2159
allow for up to four rows of stamps
bacalj 3b73209
actually we can simplifty and not calculate rows at all
bacalj fb4a0b9
remove absolute positioning
bacalj 50e1a90
style simplification, triangle toggle
bacalj e44e2c3
example of removing dead button definitions (and all specified button…
bacalj bcb27fb
straggling cleanup
bacalj cb295dd
more unused buttons clean out, prepare for touchHold, making sure pal…
bacalj e9b024b
do not propagate triangle clicks, close color palettes on select stam…
bacalj 31d052c
Merge branch 'master' into 186143109-drawing-toolbar-update
bacalj 48266e0
hack jest test so we can deploy
bacalj 716a72a
less of a hack, but probably not ideal
bacalj 332c2c3
revert useTouchHold use for now
bacalj 90df55b
enabled and disabled for action buttons
bacalj a1951dd
more cleaning out of dead code
bacalj 82d5277
use-touch-hold support
bacalj 2b409a7
cleanup
bacalj be9cfd9
handle shared var buttons
bacalj 2ba7f92
remove unused stamp button, unused svg button component
bacalj 9564b8d
no need to register button components in shared var reg
bacalj fdf2e99
cleanup, file names
bacalj 4c239fa
use isLightColorRequiringContrastOffset on stroke and fill indicators
bacalj e86d37a
implement upload button
bacalj 7f6b051
settings on vector buttons
bacalj df36497
pass correct svg setting strings to avoid warnings
bacalj 8c577fb
cypress test adjustments, add class to general upload button
bacalj 55e7bfd
cy test adjustments to match new toolbar show behavior
bacalj 6fd09ca
remove accidentally committed cy download
bacalj 7e86707
review fixes
bacalj d8ca2a6
restore style import
bacalj 6ea8e41
pass handleClick to onTouchHold
bacalj 8036f70
Merge branch 'master' into 186143109-drawing-toolbar-update
bacalj ad45db2
update unit configuration documentation
bacalj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { PropsWithChildren, useRef } from "react"; | ||
import { TileToolbarButton } from "./tile-toolbar-button"; | ||
|
||
export interface IUploadButtonComponentProps { | ||
name: string; // a unique internal name used in configuration to identify the button | ||
title: string; // user-visible name, used in the tooltip | ||
keyHint?: string, // If set, displayed to the user as the hotkey equivalent | ||
accept?: string, // MIME types accepted | ||
onUpload: (file: File) => void; // Action when a file is uploaded | ||
selected?: boolean; // puts button in 'active' state if defined and true | ||
disabled?: boolean; // makes button grey and unclickable if defined and true | ||
} | ||
|
||
/** | ||
* A TileToolbarButton that is for uploading files. | ||
* It contains a hidden input element, and the toolbar button forwards a click to it. | ||
*/ | ||
export const UploadButton = | ||
function({name, title, keyHint, accept, onUpload, selected, disabled, children}: | ||
PropsWithChildren<IUploadButtonComponentProps>) { | ||
const inputRef = useRef<HTMLInputElement>(null); | ||
|
||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file | ||
// Hide the <input> element — we do this because file inputs tend to be ugly, difficult | ||
// to style, and inconsistent in their design across browsers. Opacity is used to hide the file | ||
// input instead of visibility: hidden or display: none, because assistive technology interprets | ||
// the latter two styles to mean the file input isn't interactive. | ||
const hideFileInputStyle = { opacity: 0, width: 1, height: 1, maxWidth: 1, maxHeight: 1 }; | ||
|
||
const handleFileInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const files = e.currentTarget.files; | ||
if (files?.length) { | ||
onUpload(files[0]); | ||
} | ||
}; | ||
|
||
const input = | ||
<input | ||
ref={inputRef} | ||
type="file" | ||
style={hideFileInputStyle} | ||
accept={accept || "image/png, image/jpeg"} | ||
title={title} | ||
onChange={handleFileInputChange} | ||
className="upload-button-input" | ||
/>; | ||
|
||
return ( | ||
<TileToolbarButton | ||
name={name} | ||
title={title} | ||
keyHint={keyHint} | ||
disabled={disabled} | ||
selected={selected} | ||
onClick={() => { inputRef.current?.click(); }} | ||
extraContent={input} | ||
> | ||
{children} | ||
</TileToolbarButton> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import React, { useContext } from "react"; | ||
import { observer } from "mobx-react"; | ||
import { TileToolbarButton } from "../../components/toolbar/tile-toolbar-button"; | ||
import { IToolbarButtonComponentProps } from "../../components/toolbar/toolbar-button-manager"; | ||
import { DrawingContentModelContext } from "./components/drawing-content-context"; | ||
import { OpenPaletteValues } from "./model/drawing-content"; | ||
import DeleteIcon from "../../assets/icons/delete/delete-selection-icon.svg"; | ||
import GroupObjectsIcon from "./assets/group-objects-icon.svg"; | ||
import UngroupObjectsIcon from "./assets/ungroup-objects-icon.svg"; | ||
import DuplicateIcon from "./assets/duplicate-icon.svg"; | ||
|
||
import "./drawing-toolbar.scss"; | ||
bacalj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export const GroupButton = observer(({ name }: IToolbarButtonComponentProps) => { | ||
const drawingModel = useContext(DrawingContentModelContext); | ||
const enabled = drawingModel.selection.length > 1; | ||
|
||
function groupSelection() { | ||
drawingModel.setOpenPalette(OpenPaletteValues.None); | ||
if (drawingModel.selection.length > 1) { | ||
drawingModel.createGroup(drawingModel.selection); | ||
} | ||
} | ||
return ( | ||
<TileToolbarButton | ||
name={name} title={"Group"} | ||
onClick={groupSelection} | ||
disabled={!enabled} | ||
> | ||
<GroupObjectsIcon /> | ||
</TileToolbarButton> | ||
); | ||
}); | ||
|
||
export const UngroupButton = observer(({ name }: IToolbarButtonComponentProps) => { | ||
const drawingModel = useContext(DrawingContentModelContext); | ||
const enabled = drawingModel.selection.length > 0 | ||
? drawingModel.getSelectedObjects()[0].type === "group" | ||
: false; | ||
bacalj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
function ungroupSelection() { | ||
drawingModel.setOpenPalette(OpenPaletteValues.None); | ||
if (drawingModel.selection.length > 0) { | ||
drawingModel.ungroupGroups(drawingModel.selection); | ||
} | ||
} | ||
return ( | ||
<TileToolbarButton | ||
name={name} | ||
title={"Ungroup"} | ||
onClick={ungroupSelection} | ||
disabled={!enabled} | ||
> | ||
<UngroupObjectsIcon /> | ||
</TileToolbarButton> | ||
); | ||
}); | ||
|
||
// Duplicate | ||
export const DuplicateButton = observer(({ name }: IToolbarButtonComponentProps) => { | ||
const drawingModel = useContext(DrawingContentModelContext); | ||
const enabled = drawingModel.selection.length > 0; | ||
|
||
function duplicateSelection() { | ||
drawingModel.setOpenPalette(OpenPaletteValues.None); | ||
drawingModel.duplicateObjects(drawingModel.selection); | ||
} | ||
|
||
return ( | ||
<TileToolbarButton | ||
name={name} | ||
title={"Duplicate"} | ||
onClick={duplicateSelection} | ||
disabled={!enabled} | ||
> | ||
<DuplicateIcon /> | ||
</TileToolbarButton> | ||
); | ||
}); | ||
|
||
// Delete | ||
export const DeleteButton = observer(({ name }: IToolbarButtonComponentProps) => { | ||
const drawingModel = useContext(DrawingContentModelContext); | ||
const enabled = drawingModel.selection.length > 0; | ||
|
||
const deleteSelection = () => { | ||
drawingModel.setOpenPalette(OpenPaletteValues.None); | ||
drawingModel.deleteObjects([...drawingModel.selection]); | ||
}; | ||
|
||
return ( | ||
<TileToolbarButton | ||
name={name} | ||
title={"Delete"} | ||
onClick={deleteSelection} | ||
disabled={!enabled} | ||
> | ||
<DeleteIcon /> | ||
</TileToolbarButton> | ||
); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like either
onTouchHold
should be changed to not expect an argument, or an actual event argument should be passed.