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

Visual/dynamic layout #2039

Closed
wants to merge 27 commits into from
Closed

Visual/dynamic layout #2039

wants to merge 27 commits into from

Conversation

yeze322
Copy link
Contributor

@yeze322 yeze322 commented Feb 21, 2020

Description

fixes #1701

Make the node block size-sensitive in Visual Editor: action flow's layout will change along with a single node block's size automatically.
(leverages the react-measure lib as a new dependency)

demo-multiline-node

More Context

Why we need this functionality?

In new action design, some $types have dynamic sizes. For example, when the prompt content inside a SendActivity node becomes very long, the node will have 2 or more lines to show full content.
image
image

This is a challenge to our layouter, we need to make the layout size-sensitive.

How it works?

  1. Wrap a child node with the 'react-measure' lib, it will fire an onResize event whenever its DOM size changes;
  2. Visual Editor maintains a layout computing chain, layout will be updated bottom-up via the onResize chain;
  3. A size-sensitive parent node do several things:
    • remembers child nodes' size and position
    • observes child nodes' size & recompute the layout once it receives new size
    • recompute its layout (node positions, edge length) & report its new size to higher level
    • redraw itself with the new layout (saved as states)

What's changed?

  1. style: update the css of FormCard to make basic node blocks can show multiline text
  2. fix: reconnect the boundary propagation chain (onResize chain), it had been outdated for a while
  3. refactor: extract common layout logic as a new hook useSmartLayout, used to observe node sizes and recompute new layout when needed
  4. refactor: migrate widgets StepGroup, IfCondition, SwitchCondition, Foreach, Prompt to the new hook to make them size-sensitive

What's next?

  1. Alan is working on new node design, we will have a PR for new version of visual nodes
  2. I will keep optimizing UISchema especially the schema of ChoiceInput, hopefully in my next PR.
  3. I plan to optimize the before-render size measurer to avoid flickering

Task Item

#1701

Screenshots

image

@yeze322 yeze322 closed this Feb 21, 2020
@github-actions
Copy link

Coverage Status

Coverage increased (+0.3%) to 42.777% when pulling 9af7281 on visual/dynamic-layout into b58fa5b on master.

@cwhitten cwhitten deleted the visual/dynamic-layout branch July 10, 2020 21:27
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.

1 participant