-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(overflow-menu): bring out as internal component and refactor…
… breadcrumb
- Loading branch information
Showing
12 changed files
with
133 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
cypress/apps/angular-app/src/components/icon/icon.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<sgds-icon name="placeholder"></sgds-icon> |
7 changes: 7 additions & 0 deletions
7
cypress/apps/angular-app/src/components/icon/icon.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from "@angular/core"; | ||
|
||
@Component({ | ||
selector: "icon-component", | ||
templateUrl: "./icon.component.html" | ||
}) | ||
export class Icon {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { SgdsOverflowMenu } from "./sgds-overflow-menu"; | ||
import { register } from "../../utils/ce-registry"; | ||
|
||
register("sgds-overflow-menu", SgdsOverflowMenu); | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
"sgds-overflow-menu": SgdsOverflowMenu; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.overflow-btn { | ||
width: var(--sgds-dimension-32); | ||
height: var(--sgds-dimension-32); | ||
background-color: var(--sgds-default-bg-transparent); | ||
border-radius: var(--sgds-border-radius-sm); | ||
border: 0; | ||
padding: 0; | ||
position: relative; | ||
cursor: pointer; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
.overflow-btn:hover { | ||
background-color: var(--sgds-default-bg-translucent); | ||
} | ||
|
||
.overflow-btn:focus, | ||
.overflow-btn:focus-visible { | ||
outline: 0; | ||
box-shadow: var(--sgds-box-shadow-focus); | ||
background-color: var(--sgds-default-bg-translucent); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { html } from "lit"; | ||
import SgdsElement from "../../base/sgds-element"; | ||
import overflowMenuStyles from "./overflow-menu.css"; | ||
import { property } from "lit/decorators.js"; | ||
import { SgdsDropdown } from "../../components/Dropdown/sgds-dropdown"; | ||
import { SgdsDropdownItem } from "../../components/Dropdown/sgds-dropdown-item"; | ||
import { SgdsIcon } from "../../components/Icon/sgds-icon"; | ||
/** | ||
* @summary An overflow menu is a UI element, often represented by three dots (⋮ or …), that opens a menu with additional actions or options. | ||
* @slot default - The overflow menu items. Pass in sgds-dropdown-items in this slot | ||
*/ | ||
export class SgdsOverflowMenu extends SgdsElement { | ||
static styles = [...SgdsElement.styles, overflowMenuStyles]; | ||
static dependencies = { | ||
"sgds-dropdown": SgdsDropdown, | ||
"sgds-dropdown-item": SgdsDropdownItem, | ||
"sgds-icon": SgdsIcon | ||
}; | ||
/** Specifies a large or small button */ | ||
@property({ type: String, reflect: true }) size: "sm" | "md" = "md"; | ||
|
||
render() { | ||
return html` | ||
<sgds-dropdown> | ||
<button slot="toggler" class="overflow-btn"> | ||
<sgds-icon name="three-dots" size=${this.size}></sgds-icon> | ||
</button> | ||
<slot></slot> | ||
</sgds-dropdown> | ||
`; | ||
} | ||
} | ||
|
||
export default SgdsOverflowMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { assert, fixture } from "@open-wc/testing"; | ||
import { html } from "lit"; | ||
import "../src/internals/OverflowMenu"; | ||
|
||
describe("<sgds-overflow-menu>", () => { | ||
it("semantically matches the DOM", async () => { | ||
const el = await fixture(html`<sgds-overflow-menu></sgds-overflow-menu>`); | ||
assert.shadowDom.equal( | ||
el, | ||
` | ||
<sgds-dropdown drop="down"> | ||
<button slot="toggler" class="overflow-btn"> | ||
<sgds-icon name="three-dots" size="md" style="display: none;"></sgds-icon> | ||
</button> | ||
<slot></slot> | ||
</sgds-dropdown> | ||
` | ||
); | ||
}); | ||
}); |