Skip to content

Commit

Permalink
feat(action-menu): update spectrum css input
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook Johnson authored and Westbrook committed Jan 6, 2021
1 parent 8c888aa commit 62a5065
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/action-menu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"license": "Apache-2.0",
"dependencies": {
"@spectrum-web-components/base": "^0.1.3",
"@spectrum-web-components/button": "^0.9.4",
"@spectrum-web-components/action-button": "^0.0.1",
"@spectrum-web-components/dropdown": "^0.8.5",
"@spectrum-web-components/icon": "^0.6.3",
"@spectrum-web-components/icons-workflow": "^0.3.6",
Expand Down
12 changes: 8 additions & 4 deletions packages/action-menu/src/ActionMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import {
PropertyValues,
html,
ifDefined,
property,
} from '@spectrum-web-components/base';
import { DropdownBase } from '@spectrum-web-components/dropdown';
import '@spectrum-web-components/button/sp-action-button.js';
import '@spectrum-web-components/action-button/sp-action-button.js';
import { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';
import { MoreIcon } from '@spectrum-web-components/icons-workflow';
import actionMenuStyles from './action-menu.css.js';
Expand All @@ -28,9 +29,12 @@ import actionMenuStyles from './action-menu.css.js';
*/
export class ActionMenu extends ObserveSlotText(DropdownBase, 'label') {
public static get styles(): CSSResultArray {
return [...super.styles, actionMenuStyles];
return [actionMenuStyles];
}

@property({ type: String, reflect: true })
public size = 'm';

protected listRole = 'menu';
protected itemRole = 'menuitem';
private get hasLabel(): boolean {
Expand All @@ -40,12 +44,12 @@ export class ActionMenu extends ObserveSlotText(DropdownBase, 'label') {
protected get buttonContent(): TemplateResult[] {
return [
html`
<slot name="icon" slot="icon">
<slot name="icon" slot="icon" ?icon-only=${!this.hasLabel}>
<sp-icon size="m" class="icon">
${MoreIcon({ hidden: this.hasLabel })}
</sp-icon>
</slot>
<slot name="label"></slot>
<slot name="label" ?hidden=${!this.hasLabel}></slot>
`,
];
}
Expand Down
38 changes: 34 additions & 4 deletions packages/action-menu/src/action-menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

:host,
.button {
min-width: 0;
width: auto;
:host {
display: inline-flex;
}

:host([quiet]) {
Expand All @@ -35,4 +33,36 @@ governing permissions and limitations under the License.
#popover {
width: auto;
max-width: none;
display: none;
}

:host([dir='ltr']) ::slotted([slot='icon']),
:host([dir='ltr']) sp-icon {
/* [dir=ltr] .spectrum-ActionButton .spectrum-Icon */
margin-left: calc(
-1 * (var(--spectrum-actionbutton-textonly-padding-left-adjusted) -
var(--spectrum-actionbutton-padding-left-adjusted))
);
}
:host([dir='rtl']) ::slotted([slot='icon']),
:host([dir='rtl']) sp-icon {
/* [dir=rtl] .spectrum-ActionButton .spectrum-Icon */
margin-right: calc(
-1 * (var(--spectrum-actionbutton-textonly-padding-left-adjusted) -
var(--spectrum-actionbutton-padding-left-adjusted))
);
}

:host([dir]) slot[icon-only]::slotted([slot='icon']),
:host([dir]) slot[icon-only] sp-icon {
/* .spectrum-ActionButton .spectrum-ActionButton-hold+.spectrum-Icon,
* .spectrum-ActionButton .spectrum-Icon:only-child */
margin-left: calc(
-1 * (var(--spectrum-actionbutton-textonly-padding-left-adjusted) -
var(--spectrum-actionbutton-icononly-padding-left-adjusted))
);
margin-right: calc(
-1 * (var(--spectrum-actionbutton-textonly-padding-right-adjusted) -
var(--spectrum-actionbutton-icononly-padding-right-adjusted))
);
}
1 change: 1 addition & 0 deletions packages/action-menu/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"include": ["*.ts", "src/*.ts"],
"exclude": ["test/*.ts", "stories/*.ts"],
"references": [
{ "path": "../action-button" },
{ "path": "../dropdown" },
{ "path": "../icons-workflow" },
{ "path": "../shared" }
Expand Down

0 comments on commit 62a5065

Please sign in to comment.