Skip to content
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

Drag-n-drop layout #37

Merged
merged 149 commits into from
Jan 3, 2021
Merged

Drag-n-drop layout #37

merged 149 commits into from
Jan 3, 2021

Conversation

NoahBres
Copy link
Contributor

@NoahBres NoahBres commented Dec 20, 2020

Drag-n-drop layout feature

  • Added tailwind
  • Added styled-components
    • Small styling tweaks
  • Implemented ConfigurableLayout
    • Added RadialFab button and RadialFabChild
    • Added ViewPicker
  • Added more Roboto font weights
    • 300/500 weights added. Previously only 400. Caused blurry rendering on bold texts (at least on my device, rendering probably differs from device to device as I'm betting the browsers try to fake bold text when font weights aren't available)
    • Change AutoFitCanvas resizing behavior to use ResizeObserver
      • Improves responsiveness
  • Added new icons
    • create.svg, delete_x.svg, delete.svg, lock_open.svg, lock.svg, (and more now)
  • Add unique ID's toMultipleCheckbox inputs so you can also click on the label
  • Add clarification labels to GraphView
    • It seemed quite common that users not know the top right button in the variable selection view switched to the graphing view. Added text letting the users know
    • Added label alerting user that no variables were selected in graph view
  • Undo/redo functionality for the grid
  • Pause indicator for graph
    • Also added 'k' keypress to pause the graph. A lot of the times the graph can't steal focus and space bar scrolls down the page. YouTube uses both 'space' and 'k' for pausing/unpausing videos for this same reason.
  • Red outline on invalid inputs

(I still don't know why git pulls commits from Sep. 15 on every PR, this branch's commits should start on Dec. 13 3db3cad)

…rrupt

Moving to a typescript enum for LayoutPreset changed how it was encoded (went from object mapping to typescript encoding the enum using integer keys). This threw an error when loading the saved layout.
Just set a default one in case the getter returns null and it should handle any future layout changes.
Not required in React 17

See:
https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

Supposed to be in an upstream version of CRA but not merged yet it seems
@NoahBres
Copy link
Contributor Author

Turns out half of the original undo history reducer was simply due to faulty logic and patching over it with poor fixes (although it did work). Refactoring the logic obviated the need for most of them. The end result is so much cleaner and very simple (for the entire PR). Thank you so much for your patience despite the fatuity. I really really appreciate it.

@rbrott
Copy link
Member

rbrott commented Dec 24, 2020

Alright! This is really close. I noticed two things:

  • On reload, I think the grid should start out locked.
  • Some of the graph text (and maybe canvas) positioning is off for regular layouts. The "Graph" preset is a good example.

This should probably go in a separate PR, but I was thinking about changing some copy to make it more direct and actionable. Here are some possible substitutions:

  • "No variables selected to graph" -> "No telemetry selected to graph"
  • "Click the button in the upper right to switch to the graphing view" -> "Press the upper-right button to graph selected keys over time"
  • "Graph related telemetry packets have not yet been received \ They will appear here once sent" -> "Send number-valued telemetry data to graph them over time"
  • "Event loop detached" -> "Op mode controls have not initialized"

@rbrott
Copy link
Member

rbrott commented Dec 25, 2020

Ok I took out the hardware for a final spin.

  • I missed some text: replace "Variables to graph:" with "Telemetry to graph:" (I'm trying to distinguish telemetry from config variables).
  • I like the scroll behavior of config, and I was wondering if you could port it to the other scrollable views without too much difficulty.
  • This is a super nit but the little arrow in the op mode select dropdown interferes with the names of the longest op modes.
  • The "Press the upper-right button to graph selected keys over time" text should probably move to the top of the graphing view and be a bit bigger (maybe text-lg). I guess this applies to the op mode view no initialization text.
  • Also it would be great if that op mode text were centered in the container as well.
  • Pause indicator is a great feature, but I think it would be better as a button that users can press as well as use the shortcut (click the double bars to pause, click triangle to resume).

I think this is the last batch of requests.

@rbrott
Copy link
Member

rbrott commented Dec 25, 2020

Sigh. I forgot to mention that the node version in FtcDashboard/build.gradle needs to be bumped from 12.9.0 to 12.13.0 for the new dependencies.

@NoahBres
Copy link
Contributor Author

Sigh. I forgot to mention that the node version in FtcDashboard/build.gradle needs to be bumped from 12.9.0 to 12.13.0 for the new dependencies.

I didn't even notice that gradle managed the compilation. That's really neat.

I like the scroll behavior of config, and I was wondering if you could port it to the other scrollable views without too much difficulty.

Do you mean how the main content scrolls on overflow separately from the heading?

Pause indicator is a great feature, but I think it would be better as a button that users can press as well as use the shortcut (click the double bars to pause, click triangle to resume).

What are your thoughts on putting the play/pause button there? (Ignore the offset. That's because I used unicode characters instead of looking for an icon as a quick mockup)
Or do you prefer having it float on the graph?

Screen Shot 2020-12-25 at 4 59 19 AM

Happy holidays!

@rbrott
Copy link
Member

rbrott commented Dec 26, 2020

Do you mean how the main content scrolls on overflow separately from the heading?

Yes, exactly.

What are your thoughts on putting the play/pause button there? (Ignore the offset. That's because I used unicode characters instead of looking for an icon as a quick mockup)
Or do you prefer having it float on the graph?

I like it best on the right with the close button, but I don't really mind it beside the "Graph" text.

Happy holidays as well!

@rbrott rbrott merged commit 62924ea into acmerobotics:master Jan 3, 2021
@NoahBres NoahBres deleted the drag-n-drop-layout branch January 3, 2021 08:25
j5155 pushed a commit to jdhs-ftc/ftc-dashboard-record that referenced this pull request Jul 22, 2024
* Replace Skystone field image with Ultimate Goal field image

* Add improved Ultimate Goal Field

* Bump react-scripts to 4.0.1

* Bump react to 17.0.1

* Bump redux to 4.0.5

* Add eslintcache to gitignore

* Add typescript

* Convert LayoutPreset to typescript

* Install react-grid-layout

* Implement basics of a draggable grid layout

* Convert LayoutPreset to tsx

* Add default layout in the event that local storage saved layout is corrupt

Moving to a typescript enum for LayoutPreset changed how it was encoded (went from object mapping to typescript encoding the enum using integer keys). This threw an error when loading the saved layout.
Just set a default one in case the getter returns null and it should handle any future layout changes.

* Replace ternary with optional chaining and nullish coalescing

* Remove file extensions from default eslint

* Implement layout based grab handles for draggable widgets

* Add uuid lib

* Replace AutoFitCanvas window listener with ResizeObserver

* Add grid view map with uuids

* Add padding to views

* Replace Object.assign with spread operator

* Fix misplaced optional chaining operator

* Remove duplicated react

* Change to string enum

* Turn off react-in-jsx-scope rule

Not required in React 17

See:
https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

Supposed to be in an upstream version of CRA but not merged yet it seems

* Turn off default eslint file extensions rule

* Give LayoutPreset enums string values

* Increase padding on grab handles

* Add types for ResizeObserver

* Fix missing dependency from git merge

* Add dynamic (on mount) layout presets for different viewport heights

* Apply border-box to every element

* Increase default height in medium grid layout

* Add containerHeight override to AutoFitCanvas

* Fix bug where component re-renders on every state change

* Add styled-components dependency

* Move ConfigurableLayout into sub-folder and add Fab component

* Add new FAB icons

* Add red line to dashboard header

* Move ConfigurableLayout back & rename RadialFab

* Change icon fills to white

* Implement base FAB functionality

* Change header colors to tailwind color palette

* Implement locking button

* Fix locked grid state bugs

Grid state in the react-grid-layout wouldn't match the ConfigurableLayout grid state. Now they're synced.

* Add delete button functionality

* Change configurable grid delete button style

* Remove smaller breakpoints. Add delete mode color

* Move configurable view enum to its own file

* Install tailwind. Convert to tailwind

- Remove Heading and Header classes
  - Unnecessary abstraction

* Add camera view to ConfigurableLayout enum

* Refactor RadialFabChild to take children svg components instead of icon prop

* Add important to fab outline: none

* Replace manual style paddings in views with tailwind classes

* Implement base view picker functionality

* Implement persistent local storage configurable layouts

* Add custom layout empty message

* Fix add item packing bug

* Convert cursor header from layout based to prop based

* Implement smart view insertion

* Add OpModeView to configurable layout

* Add dot grid background to ConfigurableLayout

* Style opmode view

* Increase opmode view spacing

* Add tailwind forms

* Style config form inputs

* Fix layout select styling

* Adjust other grid sizes to account for increased padding

* Improve grid contrast

* Change tailwind default font to robot and update robot font weights

* Implement BaseView styles shared by other views

* Add for label to MultipleCheckbox

* Add labels to GraphView

* Fix locked grid item bug

* Create a useMouseIdleListener hook

* Lock layout changes and hide fab on idle

* Add types to GridItems

* Fix config view scrolling bug and mismatched bg bug

* Add no variables selected indicator to GraphView

* Decrease GraphView bottom indicator

* Add dependency to useEffect

* Stylistic code changes

* Extract repeated BaseView headings

* Extract OpModeView action buttons

* Revert incorrect prop in Dashboard.jsx

* Change font-bold to font-medium

* Consistent body colors

* Improve no content to graph label

* Add stylewind css linter dependency

Default vscode linter did not like the tailwind apply function

* Run index.css through stylelint

* Add rounded outline hover state to other icon buttons

* More formal copy

* Center graph text

* Turn off declaration empty line in stylelint

* Remove stylelint as it was annoying

* Add new icons

* Add dynamic classes to RadialFab

* Change FAB behavior

* Create useDelayedTooltip hook

* Add tooltips to the FAB buttons

* Implement colored shadows in tailwind

* Change the view picker to a smaller design

* Reverse FAB state

* Turn off text selection when unlocked and rename showShadow to isUnlocked

* Change ConfigurableLayout name to Custom in dropdown

* Implement grid undo/redo system

* Fix camera via crashing on resize

* Remove debug variable

* Add pause indicator to graph

* Make number inputs way more forgiving

* Red invalid indicator

* Revert "Make number inputs way more forgiving"

This reverts commit 711dfd3.

* Change grid to normal grid and tweak delete mode indicator

* Replace arrEquals with lodash isEqual

* Remove shouldAppend flag and use cleaner add algo

* Add triple equals prettier and eslint rules

* Triple equals lint. Navigator platform check. Rid of hoisting.

* Alias currentHead as gridItems

* Convert undo/redo to hook

* Add custom icons to the view picker

* ViewPicker field icon adjustment

* Remove custom colors in RadialFabChild

* Optimize for keyboard navigation

* Implement improved insertion algo

* Remove default case to enforce exhaustive check

* Reset history on init dispatch

* Reset actionHistory on init

* Simplify undo history

* Move utility function to the top

* Move around variables and functions in a more logical mannger

* Lock grid on window load

* Fix graph text being off

* Actionable copy

* Bump node version in FtcDashboard/build.gradle

* Change 'variables' to 'telemetry'

* Fix opmode select arrow on text

* Make text indicators in graph and opmode view bigger

* Center opmode/graph view indicator text

* Separate heading scroll from body scroll

* Add flex-center class. Remove unused css styles

* Turn off delete mode when locking layout

* Add graph pause button. Move pause logic to GraphView

* Add a tiny padding because focus ring was being cut off

* Increase grid columns to 12 and add min grid width

* Background dot grid resizes to align with the actual grid

* Code and visual styling tweaks

Courtesy of Ryan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants