Skip to content

Panel refactor#4138

Closed
barklund wants to merge 29 commits intodevelop-storiesfrom
feature/3853-layer-panel
Closed

Panel refactor#4138
barklund wants to merge 29 commits intodevelop-storiesfrom
feature/3853-layer-panel

Conversation

@barklund
Copy link
Copy Markdown
Contributor

@barklund barklund commented Jan 20, 2020

Summary

This PR includes some general changes to design and architecture for panels necessary for future work.

  • Componentize panels and panel elements
  • Add context and collapse/expand to panel title
  • Add resizable to panels
  • Create general layer panel always visible at bottom
  • Dummy content for new layer and color preset panel
  • Add relevant testing

This PR will not address:

  • Changing the contents of any panels besides what's needed for the refactor
  • Organizing any panels correctly
  • Styling any panel elements correctly
  • Actual layer and color preset panel contents.

Partially fixes #3853.

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@googlebot googlebot added the cla: yes Signed the Google CLA label Jan 20, 2020
@barklund barklund changed the title Feature/3853 layer panel New layer panel Jan 20, 2020
@barklund
Copy link
Copy Markdown
Contributor Author

Here's a demo of current progress:

panelstuff

@barklund barklund self-assigned this Jan 20, 2020
@barklund barklund added the Stories Stories Editor label Jan 20, 2020
@spacedmonkey
Copy link
Copy Markdown
Contributor

Screenshot 2020-01-20 at 11 19 35
Unable to see some of the side panels here. Shouldn't there be some scrolling?

@spacedmonkey
Copy link
Copy Markdown
Contributor

I have noticed that none of the values of the panels are working, as in there are not saving to the elements state or updating the display. Is this just me?

@swissspidy
Copy link
Copy Markdown
Collaborator

swissspidy commented Jan 20, 2020

@spacedmonkey Not just you! Looks like it's because the onSubmit prop is passed to Panel (which used to be a <form>) instead of PanelContent (which now holds a form)

Edit: confirmed that moving that prop fixes it.

@barklund
Copy link
Copy Markdown
Contributor Author

@spacedmonkey Not just you! Looks like it's because the onSubmit prop is passed to Panel (which used to be a <form>) instead of PanelContent (which now holds a form)

Edit: confirmed that moving that prop fixes it.

I didn't notice. Will fix - it's fairly simple.

@barklund
Copy link
Copy Markdown
Contributor Author

Unable to see some of the side panels here. Shouldn't there be some scrolling?

Works for me - overflow is set to auto. However the whole editor is scrolling weirdly because it's sized wrong overall, that might interfere.

Copy link
Copy Markdown
Contributor

@spacedmonkey spacedmonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barklund Just noticed that titles are clickable. Number 1, this felt wrong as seems like it should be. It will also be a weird UX for WP users. See this video. https://youtu.be/CRR6ac68Q5M

);

return (
<Header isPrimary={ isPrimary }>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think now would a good time to add some accessibility to these panels. You can see what I have done already here. I can also see more detail on accessible accordions here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the necessary aria- attributes sounds easy enough for now 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've more or less done what the W3 guide recommends. I don't know how important it is for IDs to be semantic (as in: is 'panel_123' as good as 'panel_size' as it's never read out loud, just linking items), but I've added that now too.

const { state: { isCollapsed, height } } = useContext( panelContext );

if ( isCollapsed ) {
return null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wonder, if this doesn't render, does it have accessibility impacts here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be a problem because users would never be able to tab into a non-expanded area.

Gutenberg also doesn't have any special handling in this regard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hadn't thought about this. Will leave the comment open for discussion. I haven't seen any recommendations in this regard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The W3 example add hidden attribute and hides with CSS. Replicated here now.

@spacedmonkey
Copy link
Copy Markdown
Contributor

Screenshot 2020-01-24 at 11 34 22

I shouldn't be able to drag this over like this. It looks really weird.

}, [ isDragging, handleMouseUp, handleMouseMove, handleMouseDown ] );

return (
<Handle ref={ handle }>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What accessibility could we add here? CC @pbakaus as he has done a lot of accessibility with drag and drop.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking:

  • Keyboard shortcuts to go toggle resize mode and do resizing. Example:
    Space to toggle resize mode, Up and Down to resize
  • Screenreader messages (aria-live) to announce state changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I've done it as follows:

<Handle
ref={ handle }
role="slider"
aria-orientation="vertical"
aria-valuenow={ height }
aria-valuemin={ minHeight }
aria-valuemax={ maxHeight }
>
<Bar>
{ __( 'Set panel height', 'amp' ) }
</Bar>

Plus it has a keyboard handler reacting to up and down arrow presses, that then change the height up and down.

This is partly informed by this question, but I'm using role="slider" actively going against one of the recommendations there, as it allows me to announce the range and current value with other attributes. Thus I don't think it needs aria-live, which could be a bit weird here.

I was considering whether to use aria-valuetext to announce the height in relative terms - e.g. "Panel is 55% of maximum height" or something similar. That might be a bit too much?

I've also included the information about what the button does as actual textual content of the button (but hidden it for browser display with text-indent). I tihnk this is recommended over using aria-label.

height: height === null ? 'auto' : `${ height }px`,
};

return (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note from here

@swissspidy
Copy link
Copy Markdown
Collaborator

Just noticed that titles are clickable

The design seems to indicate that it's intended behavior, but to be sure on the way forward we'd need to get confirmation from UX.

I shouldn't be able to drag this over like this. It looks really weird.

I cannot exactly reproduce this. It stops here:

Screenshot 2020-01-24 at 14 37 00

However, as I continue dragging, the height increases, causing some weird behavior in the canvas area (i.e. the canvas and carousel move down due to lots of additional space):

Screenshot 2020-01-24 at 14 39 07

Seems some kind of limit needs to be respected here.

@spacedmonkey
Copy link
Copy Markdown
Contributor

spacedmonkey commented Jan 24, 2020

@swissspidy I cannot exactly reproduce this. It stops here:

I am seeing this in Chrome and Firefox. See this video.

Note that this does not reset on resize. useResizeObserver should be used once merged in to the same branch as this code.
@barklund
Copy link
Copy Markdown
Contributor Author

Seems some kind of limit needs to be respected here.

I've now added sensible limits in b03fc39.

@barklund barklund requested a review from spacedmonkey January 24, 2020 22:27
@swissspidy swissspidy self-requested a review January 27, 2020 09:49
@@ -0,0 +1,11 @@
/**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be with other buttons in edit-story\components\button

@swissspidy swissspidy closed this Jan 29, 2020
@swissspidy swissspidy added AMP Stories (obsolete) and removed Stories Stories Editor labels Feb 18, 2020
@schlessera schlessera deleted the feature/3853-layer-panel branch March 7, 2020 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Signed the Google CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants