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(action-menu): support action-groups #8273

Merged
merged 8 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,14 @@
grid-template-columns: repeat(var(--calcite-action-group-columns), auto);
}

::slotted(calcite-action) {
@apply focus-base
flex;
}

::slotted(calcite-action[data-active]) {
@apply focus-outset;
outline-offset: 0px;
}

@include base-component();
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
outline-offset: 0px;
}

::slotted(calcite-action-group) {
border-block-end: 1px solid var(--calcite-ui-border-3);
}

::slotted(calcite-action-group:last-child) {
border-block-end: 0;
}

.default-trigger {
@apply relative
h-full
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ export const open = (): string =>
</calcite-action-menu>
`;

export const openWithGroups = (): string =>
html`
<calcite-action-menu open>
<calcite-action slot="trigger" text="Add" icon="banana"></calcite-action>
<calcite-action-group>
<calcite-action text="Plus" icon="plus" text-enabled></calcite-action
><calcite-action text="Minus" icon="minus" text-enabled></calcite-action>
</calcite-action-group>
<calcite-action-group>
<calcite-action text="Table" icon="table" text-enabled></calcite-action
></calcite-action-group>
<calcite-action-group>
<calcite-action text="Save" icon="save" text-enabled></calcite-action>
</calcite-action-group>
</calcite-action-menu>
`;

export const keyDownOpen_TestOnly = (): string =>
html`
<calcite-action-menu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,21 @@ export class ActionMenu implements LoadableComponent {
.assignedElements({
flatten: true,
})
.filter((el) => el?.matches("calcite-action")) as HTMLCalciteActionElement[];
.reduce((previousValue: HTMLCalciteActionElement[], currentValue) => {
if (currentValue?.matches("calcite-action")) {
return [...previousValue, currentValue];
driskull marked this conversation as resolved.
Show resolved Hide resolved
}

if (currentValue?.matches("calcite-action-group")) {
const groupActions = Array.from(
currentValue.querySelectorAll("calcite-action")
) as HTMLCalciteActionElement[];

return [...previousValue, ...groupActions];
driskull marked this conversation as resolved.
Show resolved Hide resolved
}

return previousValue;
}, []) as HTMLCalciteActionElement[];

this.actionElements = actions;
};
Expand Down
Loading