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(block-group, block): add block-group component #11319

Merged
merged 35 commits into from
Feb 3, 2025
Merged

Conversation

driskull
Copy link
Member

@driskull driskull commented Jan 16, 2025

Related Issue: #10382

Summary

  • add new component calcite-block-group
    • allows dragging/sorting calcite-block elements
    • add tests
    • add story
    • add demo html
  • calcite-block
    • uses calcite-sort-handle instead of calcite-handle
    • new property dragDisabled
    • new property sortHandleOpen
    • new events for calcite-sort-handle opening/closing
      • calciteBlockSortHandleBeforeClose
      • calciteBlockSortHandleBeforeOpen
      • calciteBlockSortHandleClose
      • calciteBlockSortHandleOpen
    • adds tests
  • calcite-sort-handle to work without a setSize and setPosition for use with calcite-sortable-list.
  • remove unnecessary imports in css files (these are already apart of includes)

Notes:

  • Using calcite-sortable-list with calcite-block will no longer just work. A user would need to set the calcite-sortable-list's handleSelector property to be calcite-sort-handle instead of calcite-handle.
  • When we drag over a list-item, it will open. However, i'm not sure if we want to do that for block. Do we expect nested blocks? Would it be weird to open a collapsed block when dragging another block over it?

BlockGroup API Documentation

Properties

canPull

  • Type: (detail: BlockDragDetail) => boolean
  • Description: When provided, the method will be called to determine whether the element can move from the component.

canPut

  • Type: (detail: BlockDragDetail) => boolean
  • Description: When provided, the method will be called to determine whether the element can be added from another component.

disabled

  • Type: boolean
  • Default: false
  • Reflect: true
  • Description: When true, interaction is prevented and the component is displayed with lower opacity.

dragEnabled

  • Type: boolean
  • Default: false
  • Reflect: true
  • Description: When true, calcite-blocks are sortable via a draggable button.

group

  • Type: string
  • Description: The group identifier for the block group.

label

  • Type: string
  • Description: Specifies an accessible name for the component. When dragEnabled is true and multiple block-group sorting is enabled with group, specifies the component's name for dragging between block-groups.
  • Required: true

loading

  • Type: boolean
  • Default: false
  • Reflect: true
  • Description: When true, a busy indicator is displayed.

Methods

setFocus

  • Description: Sets focus on the component.
  • Returns: void

@github-actions github-actions bot added the enhancement Issues tied to a new feature or request. label Jan 16, 2025
@driskull driskull added pr ready for visual snapshots Adding this label will run visual snapshot testing. new component Issues tied to a new component. labels Jan 17, 2025
@driskull driskull added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Jan 17, 2025
@driskull driskull added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Jan 17, 2025
@driskull driskull added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Jan 17, 2025
@driskull driskull marked this pull request as ready for review January 17, 2025 18:32
Copy link
Member

@geospatialem geospatialem left a comment

Choose a reason for hiding this comment

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

Awesome! Works great with mouse, keyboard, JAWS, and NVDA! 💪🏻

Some doc-related suggestions for consistency, otherwise lookin' great! 🏆

@driskull driskull requested a review from geospatialem January 24, 2025 21:56
Copy link
Contributor

@macandcheese macandcheese left a comment

Choose a reason for hiding this comment

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

Awesome! Mostly just some doc and naming nitpick / questions.

Only real feedback from design perspective would be thinking about some auto-collapsing when dragging open Blocks, but that could follow as further improvement (and, looking at these events, maybe be handled by a dev if they wanted to).

@@ -15,8 +15,6 @@
* @prop --calcite-loader-track-color: Specifies the component's track color.
*/

@import "../../assets/styles/animation";
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: These style import removals could be done in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. Let's remove these separately. Applies to other non-block-related Sass files.

packages/calcite-components/src/components/block/block.tsx Outdated Show resolved Hide resolved
packages/calcite-components/src/components/block/block.tsx Outdated Show resolved Hide resolved
@property({ reflect: true }) disabled = false;

/** When `true`, `calcite-block`s are sortable via a draggable button. */
@property({ reflect: true }) dragEnabled = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: the "via a draggable button" part of the doc could be cleaned up.... follow up - we use drag / sort in a lot of different places - is there any benefit to consolidating nomenclature there?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that would be good to come up with a preferred way to phrase these. It depends on context, it could be a drag, a sort/reorder or a transfer. cc @geospatialem

@driskull driskull removed the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Jan 30, 2025
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️
↕️🔲↕️↕️↕️🔲↕️↕️🔲🔲↕️↕️🔲🔲🔲↕️↕️🔲🔲🔲↕️🔲🔲🔲🔲↕️🔲↕️
↕️🔲🔲↕️↕️🔲↕️🔲↕️↕️🔲↕️↕️🔲↕️↕️🔲↕️↕️↕️↕️🔲↕️↕️↕️↕️🔲↕️
↕️🔲↕️🔲↕️🔲↕️🔲↕️↕️🔲↕️↕️🔲↕️↕️🔲↕️↕️↕️↕️🔲🔲🔲↕️↕️🔲↕️
↕️🔲↕️↕️🔲🔲↕️🔲↕️↕️🔲↕️↕️🔲↕️↕️🔲↕️↕️↕️↕️🔲↕️↕️↕️↕️↕️↕️
↕️🔲↕️↕️↕️🔲↕️↕️🔲🔲↕️↕️🔲🔲🔲↕️↕️🔲🔲🔲↕️🔲🔲🔲🔲↕️🔲↕️
↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️↕️

Aside from some comments, this LGTM!

Since this is deprecating some items, can you use the commit override to add a separate note per deprecation (example)?

packages/calcite-components/src/components/block/block.tsx Outdated Show resolved Hide resolved
export function updateBlockChildren(slotEl: HTMLSlotElement): void {
const blockChildren = slotEl
.assignedElements({ flatten: true })
.filter((el): el is Block["el"] => el?.matches(blockSelector));
Copy link
Member

Choose a reason for hiding this comment

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

el is guaranteed here, so ? is not needed.

Copy link
Member

Choose a reason for hiding this comment

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

Side note: we can start using Lit query decorators to simplify (e.g., https://lit.dev/docs/api/decorators/#queryAssignedElements).

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we have a follow up issue to start using queryAssignedElements? If not, can you create one? I think it would be nice to do this everywhere.

@@ -15,8 +15,6 @@
* @prop --calcite-loader-track-color: Specifies the component's track color.
*/

@import "../../assets/styles/animation";
Copy link
Member

Choose a reason for hiding this comment

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

Agreed. Let's remove these separately. Applies to other non-block-related Sass files.

});

// Workaround for page.spyOnEvent() failing due to drag event payload being serialized and there being circular JSON structures from the payload elements. See: https://github.com/Esri/calcite-design-system/issues/7643
await page.$eval("#component2", (blockGroup: BlockGroup["el"]) => {
Copy link
Member

Choose a reason for hiding this comment

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

You might be able to use the new createEventTimePropValuesAsserter for some of these assertions.

I'll create a refactor issue to wire it up in more tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you create an issue to tackle it in both List and BlockGroup components?

packages/calcite-components/src/components/block/utils.ts Outdated Show resolved Hide resolved
@jcfranco
Copy link
Member

jcfranco commented Feb 3, 2025

Using calcite-sortable-list with calcite-block will no longer just work. A user would need to set the calcite-sortable-list's handleSelector property to be calcite-sort-handle instead of calcite-handle.

We should give a heads up to teams about this. sortable-list isn't supported as it is not public, but it is being used internally.

When we drag over a list-item, it will open. However, i'm not sure if we want to do that for block. Do we expect nested blocks? Would it be weird to open a collapsed block when dragging another block over it?

I think that's fine since nested blocks aren't supported at the moment.

@driskull driskull added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Feb 3, 2025
@driskull driskull merged commit 8bbeaf5 into dev Feb 3, 2025
15 checks passed
@driskull driskull deleted the dris0000/block-group branch February 3, 2025 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issues tied to a new feature or request. new component Issues tied to a new component. pr ready for visual snapshots Adding this label will run visual snapshot testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants