Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -289,3 +289,21 @@ export const bosnianLocale_TestOnly = (): string => `<calcite-action-bar expande
<calcite-action text-enabled text="Information" icon="information"></calcite-action>
<calcite-action text-enabled text="Feedback" slot="actions-end" icon="mega-phone"></calcite-action>
</calcite-action-bar>`;

export const fullWidthActions = (): string => html`
<style>
.container {
display: flex;
flex-flow: column;
width: 800px;
margin-block: 2rem;
}
</style>
<div class="container">
<calcite-action-bar layout="horizontal">
<calcite-action text="Add" icon="plus" width="full"> </calcite-action>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add at least one more full width action here just to improve the demo?

<calcite-action text="Remove" icon="minus" width="full"> </calcite-action>
<calcite-action text="Copy" icon="plus" width="full"> </calcite-action>
</calcite-action-bar>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ describe("calcite-action", () => {
propertyName: "textEnabled",
defaultValue: false,
},
{
propertyName: "width",
defaultValue: "auto",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you add a reflects test as well?

},
]);
});

Expand Down Expand Up @@ -88,6 +92,10 @@ describe("calcite-action", () => {
propertyName: "textEnabled",
value: true,
},
{
propertyName: "width",
value: "full",
},
]);
});

Expand Down
12 changes: 12 additions & 0 deletions packages/calcite-components/src/components/action/action.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
border-radius: inherit;
}

:host([width="full"]) {
flex: 1 0 auto;

.button {
justify-content: center;

.text-container--visible {
flex: none;
}
}
}

:host([drag-handle]) {
@apply cursor-move;
--calcite-internal-action-text-color: var(--calcite-color-border-input);
Expand Down
9 changes: 8 additions & 1 deletion packages/calcite-components/src/components/action/action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { componentFocusable } from "../../utils/component";
import { createObserver } from "../../utils/observers";
import { getIconScale } from "../../utils/component";
import { Alignment, Appearance, Scale } from "../interfaces";
import { Alignment, Appearance, Scale, Width } from "../interfaces";
import { IconNameOrString } from "../icon/interfaces";
import { useT9n } from "../../controllers/useT9n";
import type { Tooltip } from "../tooltip/tooltip";
Expand Down Expand Up @@ -105,6 +105,13 @@ export class Action extends LitElement implements InteractiveComponent {
/** Specifies the size of the component. */
@property({ reflect: true }) scale: Scale = "m";

/**
* When `full`, the component's width spans all its parent's available space
*
* @private
*/
@property({ reflect: true }) width: Extract<"auto" | "full", Width> = "auto";

/**
* Specifies text that accompanies the icon.
*
Expand Down
Loading