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

feat: modernize angular split #444

Merged
merged 14 commits into from
Jul 10, 2024

Conversation

Harpush
Copy link
Collaborator

@Harpush Harpush commented May 27, 2024

Features

  1. Using css grid instead of flex allows for fraction usage in calculations and percent based on areas without gutters. In addition it will allow later to add fraction unit type for easy 1/3 size splitting and maybe will allow mixing percent and pixels sizes too.
  2. Fully signal based (data, inputs, outputs, effects)
  3. Using the new control flow
  4. No more order problems when hiding and showing areas (that's why the input order was created before)
  5. Easier algorithm for dragging which also solves some bugs
  6. Everything is standalone
  7. Global defaults provider now use the new provideX pattern and adds type safety
  8. Aria values are now updating live while dragging
  9. Delta pixel now accurately delay drag start by the delta specified unless going out of gutter
  10. Interface names are finally without the initial I which isn't recommended for typescript
  11. No more imperative style update and validation thanks to signals
  12. Gutter now stays (with zero size) while area is invisible which allows for gutter transitions as well

Breaking(ish) changes

  1. Aria values are now updating live while dragging
  2. Delta pixel now accurately delay drag start by the delta specified unless going out of gutter
  3. Only left mouse click will start dragging compared to right click too previously
  4. CSS grid and not flex is used
  5. When passing wrong data previously it would silently "fix" itself. Now in dev mode it will also write console warnings as this is unexpected usage
  6. As we are now using CSS grid - the minimum browser requirement is higher especially for transitions.
  7. Four fast clicks will only emit one double click event and not two. Same for more clicks.
  8. Invisible area gutter is still in the DOM but with zero size

Breaking changes

  1. Order input is now gone as order is taken strictly from DOM order. Can be added back if required but seems like larger API surface with low benefit
  2. Split area is now a component and not a directive - that means no more attribute selector
  3. Interface names changed
  4. ANGULAR_SPLIT_DEFAULT_OPTIONS is no longer exported - use the new provideAngularSplitOptions
  5. Due to signal inputs, altering the inputs using component TS reference is no longer possible (see access from class demo)

Tests

  1. Cypress has been updated as electron didn't support CSS grid transitions
  2. Gutter step was somehow rounding 15px to 10px and not to 20px - tests changed but I can investigate further why it happened
  3. I added rounding to sub pixel (1 number after dot) in all tests as sizes vary a bit from old way and between live/ci test runs

Missing features (require discussion)

  1. expand/collapse feature + demo (currently broken) - I really don't understand this feature... it resizes the area and disable the gutter (making it smaller too). I don't really see how this is a split feature.
  2. getVisibleAreaSizes - easy to implement but I think make sense only when set exists
  3. setVisibleAreaSizes - Allows altering the size from outside without the component binding. I am not sure this is desirable. The only benefit I can see is less change detection on parent component when using drag progress (see sync split demo)

Out of scope

  1. Tests pixels fixing and adding new tests
  2. Demos transition to signals, standalone, etc...

I might have forgotten some features or breaking changes....

Closes #135
Closes #426
Closes #378
Closes #439
Closes #433
Closes #267

@bastienmoulia
Copy link

Is it possible to add more scss variables with default value in order to customize:

  • the background-color of the bar (#eeeeee => $as-background)
  • the images in the center of the bar (url('data:image/png;base64,...') => $as-horizontal-icon)

Or to use css variable, it can also work :)

@Harpush
Copy link
Collaborator Author

Harpush commented Jun 3, 2024

Is it possible to add more scss variables with default value in order to customize:

  • the background-color of the bar (#eeeeee => $as-background)
  • the images in the center of the bar (url('data:image/png;base64,...') => $as-horizontal-icon)

Or to use css variable, it can also work :)

That's unrelated to this PR and already got merged in #367

@Harpush
Copy link
Collaborator Author

Harpush commented Jun 3, 2024

@SanderElias @Jefiozie the merge conflicts are only due to CSS variables PR.
You can still go over this one even though there are merge conflicts which I will solve only next week unfortunately.

@godind
Copy link

godind commented Jun 7, 2024

Anxious to see this new version. I was in the process of updating my dashboard app to try and include cdk drag & drop. I'll not waist time and wait a bit so I'll be available as a beta tester if needed.

Thanks for all the great work you are doing!!!

@mrentmeister-tt
Copy link

mrentmeister-tt commented Jun 11, 2024

I currently use [order] on split areas that are included/excluded from the dom with an @if/ngIf. Without setting the order, the areas included by the @if/ngIf always get rendered after the static area(s). Would this PR break this functionality?

Example:

<as-split
  direction="horizontal"
  unit="percent"
  [gutterSize]="8"
>
  @if (currentHelp()) {
    <as-split-area class="tt-help-split-area" [order]="0">
      ...
    </as-split-area>
  }
  <as-split-area size="*" [order]="1"><ng-content></ng-content></as-split-area>
</as-split>

@Harpush
Copy link
Collaborator Author

Harpush commented Jun 11, 2024

I currently use [order] on split areas that are included/excluded from the dom with an @if/ngIf. Without setting the order, the areas included by the @if/ngIf always get rendered after the static area(s). Would this PR break this functionality?

Example:

<as-split
  direction="horizontal"
  unit="percent"
  [gutterSize]="8"
>
  @if (currentHelp()) {
    <as-split-area class="tt-help-split-area" [order]="0">
      ...
    </as-split-area>
  }
  <as-split-area size="*" [order]="1"><ng-content></ng-content></as-split-area>
</as-split>

With this PR the order is based on DOM order. That means if the ngIf adds the area before the static ones it will work as expected.

@SanderElias
Copy link
Contributor

@Jefiozie Would you have time to review this?
This would be a breaking version, but it takes care of quite some things we have on our list. I did review it lightly, but currently don't have time to go in deeper.
I'm ok with the changes, have discussed most of my concerns with @Harpush , and I think he has addressed those.

Copy link
Member

@Jefiozie Jefiozie left a comment

Choose a reason for hiding this comment

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

I left some questions but nothing serious. My main concern is that I would like to have a deprecation notice before we remove the old types OR we need to have a schematic in place to migrate everything.

Im not against either one but backwars compatibily is something i would appriciate.

@@ -35,32 +35,32 @@ context('Gutter click example page tests', () => {

it('Click gutters to switch area sizes between 0 and X', () => {
cy.get('.as-split-gutter').eq(0).click()
cy.wait(1500)
cy.wait(2000)
Copy link
Member

Choose a reason for hiding this comment

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

WHy is this change needed for cypress?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can't seem to figure out how it worked before. The transition is 1.5s and the delay is 1.5s. When running live it works well but fails in CI run.
At 1500 it fails on 9 pixels instead of 0
At 1600 it fails on 5 pixels instead of 0
At 2000 it passes

Not sure what to do about it...

@@ -62,10 +58,14 @@
"@types/node": "20.5.4",
"@typescript-eslint/eslint-plugin": "6.19.0",
"@typescript-eslint/parser": "6.19.0",
"cypress": "12.17.4",
"angular-cli-ghpages": "^2.0.0-beta.2",
Copy link
Member

Choose a reason for hiding this comment

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

Can we use a none beta version or is there a issue with this version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a great question. I don't know why this is beta. If you look at line 43 before my changes it was beta to begin with. The cypress update just moved those dependencies around (ABC order)

Copy link
Member

Choose a reason for hiding this comment

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

Could we make the old types depracted and not delete them straight away? It would be nice if we could make it so that people can use both for a period of time.
What do you think of this?

@Harpush
Copy link
Collaborator Author

Harpush commented Jun 20, 2024

I left some questions but nothing serious. My main concern is that I would like to have a deprecation notice before we remove the old types OR we need to have a schematic in place to migrate everything.

Im not against either one but backwars compatibily is something i would appriciate.

@Jefiozie Concerning deprecation and migrations - let's review what needs discussion:

  1. expand/collapse feature - Should I add it back as it was but deprecated? Should we replace it with some kind of snap feature like vscode? Maybe delete altogether (breaking)?
  2. getVisibleAreaSizes/setVisibleAreaSizes - What do we want to do about those? Deprecate maybe? Delete (breaking)?
  3. Order input - Not needed anymore so we can either migrate or deprecate. I don't really think we want to keep supporting it. The problem is when someone used it not in the same order as the DOM.
  4. split-area used as directive can be migrated with schematics. Deprecation isn't possible here.
  5. ANGULAR_SPLIT_DEFAULT_OPTIONS can be deprecated or migrated.
  6. component TS reference input changing - nothing we can really do about it... that's just not supported anymore with signal inputs.
  7. Interface names - either migrate or export old names as type aliases of new names with deprecation.

If we go the schematics direction - we need to create the required infra as there is no schematics collection project in this repo.

@ranitg
Copy link

ranitg commented Jun 27, 2024

When will this be available?

@Harpush
Copy link
Collaborator Author

Harpush commented Jun 27, 2024

@Jefiozie I wrote some considerations above - can you share your opinion on them?

@ranitg
Copy link

ranitg commented Jun 27, 2024

@Harpush I actually am using the collapse/expand for snapping like in the vscode. Can you please maybe add a snap option? I had to sortof implement it with the collapse/expand feature. Don't remove it please.

@Harpush
Copy link
Collaborator Author

Harpush commented Jun 27, 2024

@Harpush I actually am using the collapse/expand for snapping like in the vscode. Can you please maybe add a snap option? I had to sortof implement it with the collapse/expand feature. Don't remove it please.

Can you please elaborate how you would expect the snap to work? Visible vs @if and size restoration.
The main reason why collapse seemed like a weird feature to me is the ability to collapse to non zero values. A snap feature is indeed expected from a split component imo.

@godind
Copy link

godind commented Jul 9, 2024

Is this great upgrade planned to be available soon? Can't wait to try it out!

@Jefiozie
Copy link
Member

@Harpush we've decided to leave it as is and merge it. We will do a beta release of the package soon.

@Jefiozie Jefiozie merged commit d8ce04a into angular-split:main Jul 10, 2024
5 checks passed
@Harpush
Copy link
Collaborator Author

Harpush commented Jul 10, 2024

@Jefiozie I wrote some considerations above - can you share your opinion on them?

In that case how about an RFC on a snap feature to replace expand/collapse?

@Jefiozie
Copy link
Member

That is a good idea, would you be interested in writing the first draft/ iteration?

@Harpush
Copy link
Collaborator Author

Harpush commented Jul 10, 2024

That is a good idea, would you be interested in writing the first draft/ iteration?

Sure I have something in mind that should also answer most of the collapse/expand intended usage hopefully.
I just need guidance as to where to send you the draft or should I publish it as a GitHub issue directly?

@Harpush Harpush deleted the modernize-angular-split-refactor branch July 10, 2024 05:38
@Jefiozie
Copy link
Member

Hi everyone,

We just released a beta version of angular-split, you can find it angular-split 18.0.0-beta.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment