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-bar, action-pad, action-group): Add label properties for group context #7415

Merged
merged 19 commits into from
Aug 23, 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 @@ -2,12 +2,12 @@ Renders a group of `calcite-action`s contained in a `calcite-action-group`. Acti

```html
<calcite-action-bar>
<calcite-action-group>
<calcite-action-group label="Manage Item">
<calcite-action text="Add" icon="plus"></calcite-action>
<calcite-action text="Save" icon="save"></calcite-action>
</calcite-action-group>

<calcite-action-group>
<calcite-action-group label="Item types">
<calcite-action text="Layers" icon="layers"></calcite-action>
<calcite-action text="Basemaps" icon="layer-basemap"></calcite-action>
</calcite-action-group>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { newE2EPage } from "@stencil/core/testing";
import { accessible, defaults, focusable, hidden, renders, slots, t9n } from "../../tests/commonTests";
import { SLOTS } from "./resources";
import { CSS, SLOTS } from "./resources";

const actionGroupHTML = `<calcite-action-group scale="l">
<calcite-action id="plus" slot="menu-actions" text="Add" icon="plus"></calcite-action>
Expand Down Expand Up @@ -58,6 +58,17 @@ describe("calcite-action-group", () => {
expect(await menu.getProperty("overlayPositioning")).toBe("fixed");
});

it("should honor label", async () => {
const page = await newE2EPage();
await page.setContent(`<calcite-action-group label="test">
<calcite-action id="plus" slot="menu-actions" text="Add" icon="plus"></calcite-action>
<calcite-action id="banana" slot="menu-actions" text="Banana" icon="banana"></calcite-action>
</calcite-action-group>`);
await page.waitForChanges();
const container = await page.find(`calcite-action-group >>> .${CSS.container}`);
expect(await container.getProperty("ariaLabel")).toBe("test");
});

describe("translation support", () => {
t9n("calcite-action-group");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
--calcite-action-group-columns: 3;
}

.container {
@apply flex flex-col;
}

:host([columns="1"]) {
--calcite-action-group-columns: 1;
}
Expand All @@ -39,11 +43,16 @@
@apply pt-0;
}

:host([layout="horizontal"]) {
:host([layout="horizontal"]),
:host([layout="horizontal"]) .container {
@apply flex-row;
}

:host([layout="grid"]) {
@apply grid;
}

:host([layout="grid"]) .container {
@apply bg-background
grid
place-content-stretch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Element, Fragment, h, Method, Prop, State, VNode, Watch } from "@stencil/core";
import { Component, Element, h, Method, Prop, State, VNode, Watch } from "@stencil/core";
import { CalciteActionMenuCustomEvent } from "../../components";
import {
ConditionalSlotComponent,
Expand All @@ -23,7 +23,7 @@ import {
import { SLOTS as ACTION_MENU_SLOTS } from "../action-menu/resources";
import { Columns, Layout, Scale } from "../interfaces";
import { ActionGroupMessages } from "./assets/action-group/t9n";
import { ICONS, SLOTS } from "./resources";
import { ICONS, SLOTS, CSS } from "./resources";
import { OverlayPositioning } from "../../utils/floating-ui";

/**
Expand Down Expand Up @@ -58,6 +58,11 @@ export class ActionGroup
this.menuOpen = false;
}

/**
* Specifies the label of the component.
*/
@Prop() label: string;

/**
* Indicates the layout of the component.
*
Expand Down Expand Up @@ -207,10 +212,10 @@ export class ActionGroup

render(): VNode {
return (
<Fragment>
<div aria-label={this.label} class={CSS.container} role="group">
<slot />
{this.renderMenu()}
</Fragment>
</div>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ export const SLOTS = {
export const ICONS = {
menu: "ellipsis",
};

export const CSS = {
container: "container",
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Renders a group of `calcite-action`s contained in a `calcite-action-group`. Acti

```html
<calcite-action-pad>
<calcite-action-group>
<calcite-action-group label="Manage Item">
<calcite-action text="Home" icon="home"></calcite-action>
<calcite-action text="Styles" icon="add-in-edit"></calcite-action>
</calcite-action-group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Renders a shell with leading and trailing floating panels, action bar/pad, block
<calcite-shell>
<calcite-shell-panel slot="panel-start" position="start" display-mode="float">
<calcite-action-bar slot="action-bar">
<calcite-action-group>
<calcite-action-group label="Manage item">
<calcite-action text="Add" icon="plus"></calcite-action>
<calcite-action text="Save" disabled icon="save"></calcite-action>
<calcite-action text="Layers" active indicator icon="layers"></calcite-action>
</calcite-action-group>
<calcite-action-group>
<calcite-action-group label="Item types">
<calcite-action text="Add" icon="plus"></calcite-action>
<calcite-action text="Layers" indicator icon="layers"></calcite-action>
</calcite-action-group>
Expand All @@ -30,12 +30,12 @@ Renders a shell with leading and trailing floating panels, action bar/pad, block

<calcite-shell-panel slot="panel-end" position="end" display-mode="float" height-scale="l">
<calcite-action-bar slot="action-bar">
<calcite-action-group>
<calcite-action-group label="Manage item">
<calcite-action text="Add" active icon="plus"></calcite-action>
<calcite-action text="Save" disabled icon="save"></calcite-action>
<calcite-action text="Layers" icon="layers"></calcite-action>
</calcite-action-group>
<calcite-action-group>
<calcite-action-group label="Item types">
<calcite-action text="Add" icon="plus"></calcite-action>
<calcite-action text="Save" disabled icon="save"></calcite-action>
<calcite-action text="Layers" icon="layers"></calcite-action>
Expand Down
32 changes: 16 additions & 16 deletions packages/calcite-components/src/demos/action.html
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
alignment center when enclosed within group (grid layout, text-enabled)
</div>
<div class="child">
<calcite-action-group layout="grid">
<calcite-action-group layout="grid" label="Shapes">
<calcite-action alignment="center" scale="s" appearance="solid" icon="polygon" text="polygon" text-enabled>
</calcite-action>
<calcite-action
Expand All @@ -336,7 +336,7 @@
<div class="parent">
<div class="child right-aligned-text">alignment center when enclosed within group (grid layout, no text)</div>
<div class="child">
<calcite-action-group layout="grid">
<calcite-action-group layout="grid" label="More shapes">
<calcite-action alignment="center" scale="s" appearance="solid" icon="polygon"></calcite-action>
<calcite-action alignment="center" scale="s" appearance="solid" icon="rectangle"></calcite-action>
<calcite-action alignment="center" scale="s" appearance="solid" icon="trash"></calcite-action>
Expand Down Expand Up @@ -428,11 +428,11 @@
<div class="child-action-bar">
<div>grouping</div>
<calcite-action-bar>
<calcite-action-group>
<calcite-action-group label="Item things">
<calcite-action text="Add" icon="plus"> </calcite-action>
<calcite-action text="Save" icon="save"> </calcite-action>
</calcite-action-group>
<calcite-action-group>
<calcite-action-group label="Layer things">
<calcite-action text="Layers" icon="layers"> </calcite-action>
</calcite-action-group>
</calcite-action-bar>
Expand All @@ -450,12 +450,12 @@
<div class="child-action-bar">
<div>tall container</div>
<calcite-action-bar>
<calcite-action-group>
<calcite-action-group label="Manage">
<calcite-action text="Add" icon="plus"> </calcite-action>
<calcite-action text="Save" icon="save"> </calcite-action>
<calcite-action text="Layers" icon="layers"> </calcite-action>
</calcite-action-group>
<calcite-action-group>
<calcite-action-group label="Tinker">
<calcite-action text="Add" icon="plus"> </calcite-action>
<calcite-action text="Save" active icon="save"> </calcite-action>
<calcite-action text="Layers" icon="layers"> </calcite-action>
Expand Down Expand Up @@ -531,11 +531,11 @@
<div class="child-action-bar" style="flex: 1">
<div>grouping</div>
<calcite-action-bar layout="horizontal">
<calcite-action-group>
<calcite-action-group label="Fiddle">
<calcite-action text="Add" icon="plus"> </calcite-action>
<calcite-action text="Save" icon="save"> </calcite-action>
</calcite-action-group>
<calcite-action-group>
<calcite-action-group label="Tasks">
<calcite-action text="Layers" icon="layers"> </calcite-action>
</calcite-action-group>
</calcite-action-bar>
Expand All @@ -553,12 +553,12 @@
<div class="child-action-bar" style="flex: 1">
<div>tall container</div>
<calcite-action-bar layout="horizontal">
<calcite-action-group>
<calcite-action-group label="Tweak">
<calcite-action text="Add" icon="plus"> </calcite-action>
<calcite-action text="Save" icon="save"> </calcite-action>
<calcite-action text="Layers" icon="layers"> </calcite-action>
</calcite-action-group>
<calcite-action-group>
<calcite-action-group label="Daddle">
<calcite-action text="Add" icon="plus"> </calcite-action>
<calcite-action text="Save" active icon="save"> </calcite-action>
<calcite-action text="Layers" icon="layers"> </calcite-action>
Expand All @@ -580,12 +580,12 @@
<div class="child-action-bar" style="flex: 1">
<div>Full width</div>
<calcite-action-bar layout="horizontal" style="width: 100%">
<calcite-action-group>
<calcite-action-group label="Poke around">
<calcite-action text="Add" icon="plus"> </calcite-action>
<calcite-action text="Save" icon="save"> </calcite-action>
<calcite-action text="Layers" icon="layers"> </calcite-action>
</calcite-action-group>
<calcite-action-group>
<calcite-action-group label="Mess with">
<calcite-action text="Add" icon="plus"> </calcite-action>
<calcite-action text="Save" active icon="save"> </calcite-action>
<calcite-action text="Layers" icon="layers"> </calcite-action>
Expand All @@ -609,23 +609,23 @@

<div class="child-action-bar">
<calcite-action-pad scale="s">
<calcite-action-group>
<calcite-action-group label="test">
<calcite-action scale="s" text="Undo" icon="undo"> </calcite-action>
<calcite-action scale="s" text="Cool" icon="redo"> </calcite-action>
</calcite-action-group>
<calcite-action-group scale="s">
<calcite-action-group label="test2" scale="s">
<calcite-action scale="s" text="Add" icon="trash"> </calcite-action>
</calcite-action-group>
</calcite-action-pad>
</div>

<div class="child-action-bar">
<calcite-action-pad scale="m">
<calcite-action-group>
<calcite-action-group label="Revert">
<calcite-action scale="m" text="Undo" icon="undo"> </calcite-action>
<calcite-action scale="m" text="Cool" icon="redo"> </calcite-action>
</calcite-action-group>
<calcite-action-group scale="m">
<calcite-action-group label="Add things" scale="m">
<calcite-action scale="m" text="Add" icon="trash"> </calcite-action>
</calcite-action-group>
</calcite-action-pad>
Expand Down