feat(block-group, block): add block-group component#11319
Conversation
…roup.tsx Co-authored-by: Kitty Hurley <khurley@esri.com>
macandcheese
left a comment
There was a problem hiding this comment.
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).
| * @prop --calcite-loader-track-color: Specifies the component's track color. | ||
| */ | ||
|
|
||
| @import "../../assets/styles/animation"; |
There was a problem hiding this comment.
Nitpick: These style import removals could be done in a separate PR.
There was a problem hiding this comment.
Agreed. Let's remove these separately. Applies to other non-block-related Sass files.
| @property({ reflect: true }) disabled = false; | ||
|
|
||
| /** When `true`, `calcite-block`s are sortable via a draggable button. */ | ||
| @property({ reflect: true }) dragEnabled = false; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)?
| export function updateBlockChildren(slotEl: HTMLSlotElement): void { | ||
| const blockChildren = slotEl | ||
| .assignedElements({ flatten: true }) | ||
| .filter((el): el is Block["el"] => el?.matches(blockSelector)); |
There was a problem hiding this comment.
el is guaranteed here, so ? is not needed.
There was a problem hiding this comment.
Side note: we can start using Lit query decorators to simplify (e.g., https://lit.dev/docs/api/decorators/#queryAssignedElements).
There was a problem hiding this comment.
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.
| * @prop --calcite-loader-track-color: Specifies the component's track color. | ||
| */ | ||
|
|
||
| @import "../../assets/styles/animation"; |
There was a problem hiding this comment.
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"]) => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Can you create an issue to tackle it in both List and BlockGroup components?
We should give a heads up to teams about this.
I think that's fine since nested blocks aren't supported at the moment. |
**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-block`s 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` --------- Co-authored-by: Kitty Hurley <khurley@esri.com>
Related Issue: #10382
Summary
calcite-block-groupcalcite-blockelementscalcite-blockcalcite-sort-handleinstead ofcalcite-handledragDisabledsortHandleOpencalcite-sort-handleopening/closingcalciteBlockSortHandleBeforeClosecalciteBlockSortHandleBeforeOpencalciteBlockSortHandleClosecalciteBlockSortHandleOpencalcite-sort-handleto work without asetSizeandsetPositionfor use withcalcite-sortable-list.Notes:
calcite-sortable-listwithcalcite-blockwill no longer just work. A user would need to set thecalcite-sortable-list'shandleSelectorproperty to becalcite-sort-handleinstead ofcalcite-handle.BlockGroup API Documentation
Properties
canPull(detail: BlockDragDetail) => booleancanPut(detail: BlockDragDetail) => booleandisabledbooleanfalsetruetrue, interaction is prevented and the component is displayed with lower opacity.dragEnabledbooleanfalsetruetrue,calcite-blocks are sortable via a draggable button.groupstringlabelstringdragEnabledistrueand multiple block-group sorting is enabled withgroup, specifies the component's name for dragging between block-groups.trueloadingbooleanfalsetruetrue, a busy indicator is displayed.Methods
setFocusvoid