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): Add appearance property to configure trigger appearance #7867

Merged
merged 3 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -36,6 +36,10 @@ describe("calcite-action-menu", () => {

describe("defaults", () => {
defaults("calcite-action-menu", [
{
propertyName: "appearance",
defaultValue: "solid",
},
{
propertyName: "expanded",
defaultValue: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
:host {
@apply bg-foreground-1
text-color-2
@apply text-color-2
text-1
box-border
flex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ export const simple = (): string =>
</calcite-action-menu>
`;

export const simpleSolid_TestOnly = (): string =>
html`<div style="background-color:#99ccff">
<calcite-action-menu>
<calcite-action text="Plus" icon="plus" text-enabled></calcite-action>
<calcite-action text="Minus" icon="minus" text-enabled></calcite-action>
<calcite-action text="Table" icon="table" text-enabled></calcite-action>
</calcite-action-menu>
</div> `;
Copy link
Member

Choose a reason for hiding this comment

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

Does the background color need to be #99ccff for this test? If not the simple one above should cover the solid use case so we should be able to remove this one.

Copy link
Member

Choose a reason for hiding this comment

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

Woah, TIL GitHub renders a little color icon next to color codes

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 the background needs to be set to something to test that the transparent appearance is working correctly. I can switch it to just red to be a little more obvious.


export const simpleTransparent_TestOnly = (): string =>
html`<div style="background-color:#99ccff">
<calcite-action-menu appearance="transparent">
<calcite-action text="Plus" icon="plus" text-enabled></calcite-action>
<calcite-action text="Minus" icon="minus" text-enabled></calcite-action>
<calcite-action text="Table" icon="table" text-enabled></calcite-action>
</calcite-action-menu>
</div> `;

export const open = (): string =>
html`
<calcite-action-menu open>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
setComponentLoaded,
setUpLoadableComponent,
} from "../../utils/loadable";
import { Scale } from "../interfaces";
import { Appearance, Scale } from "../interfaces";
import { CSS, ICONS, SLOTS } from "./resources";

const SUPPORTED_MENU_NAV_KEYS = ["ArrowUp", "ArrowDown", "End", "Home"];
Expand Down Expand Up @@ -62,6 +62,9 @@ export class ActionMenu implements LoadableComponent {
//
// --------------------------------------------------------------------------

/** Specifies the appearance of the component. */
@Prop({ reflect: true }) appearance: Extract<"solid" | "transparent", Appearance> = "solid";

/**
* When `true`, the component is expanded.
*/
Expand Down Expand Up @@ -263,11 +266,12 @@ export class ActionMenu implements LoadableComponent {
};

renderMenuButton(): VNode {
const { label, scale, expanded } = this;
const { appearance, label, scale, expanded } = this;

const menuButtonSlot = (
<slot name={SLOTS.trigger} onSlotchange={this.setMenuButtonEl}>
<calcite-action
appearance={appearance}
class={CSS.defaultTrigger}
icon={ICONS.menu}
scale={scale}
Expand Down
Loading