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

resize project panel & canvas zone extended (93%) #1622

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

oliviermgx
Copy link
Contributor

No description provided.

@oliviermgx oliviermgx requested a review from lexoyo December 21, 2024 12:14
Copy link
Member

@lexoyo lexoyo left a comment

Choose a reason for hiding this comment

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

Bug report

there is a little bug:

  1. open silex
  2. open the layers panel
  3. click the "expand" arrow button => it expands the width of the panel
  4. open the pages panel
  5. click the "expand" arrow button again

what I expect: the panel should go back to the original width

what it does: nothing the 1st time, I have to click again to go back to the original width

Implementation details

2 things are bothering me

1/ 2 plugins for the same feature

The 2 "panes", the "project" pane on the left and the "views" pane on the right (which should be named "element" or "selection" instead of "views" btw) have the same "expand" feature and should be implemented the same way.

There should be only 1 plugin instead of both resize-project-panel and resize-panel

2/ Toggle not set

The code uses a grapesjs command cmdResizePanel with run and stop wich use setProperty to set the css variable --viewsPanelWidth.

I believe this could be a litlle simpler: use a command with just a function (this does a "stateless command", see grapesjs docs about commands). Without a state, it will not be a problem to have different buttons to call the same command - e.g the button in the layers panel and the button in the pages panel.

In the function you can use javascript classList.toggle to toggle a class on the panel. This class will have a css rule to set the width of the panel. This way you don't need to use setProperty and you don't need to use stop to reset the css variable. This will make the code easier to read and debug. Also this means you will have 2 variables, one for each size.

With this implementation we give up the button state (expanded or not) but I think it's not a big deal. Also we can add a CSS class to the container of the panel to style the button (e.g. arrow pointing left or right).

@oliviermgx oliviermgx changed the title resize project panel resize project panel & canvas zone extended (93%) Dec 28, 2024
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.

2 participants