Skip to content

Commit

Permalink
feat(icon-button): added priority (#2156)
Browse files Browse the repository at this point in the history
  • Loading branch information
agliga committed Apr 15, 2024
1 parent 3c1cb8e commit 3322847
Show file tree
Hide file tree
Showing 17 changed files with 400 additions and 41 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-islands-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ebay/ebayui-core": minor
---

icon-button: added priority attribute
1 change: 1 addition & 0 deletions src/components/ebay-icon-button/component-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface IconButtonInput extends Omit<Marko.Input<"button">, `on${string}`> {
"badge-number"?: number | string;
href?: string;
transparent?: boolean;
priority?: "primary" | "secondary" | "tertiary" | "none";
size?: "small" | "large";
partiallyDisabled?: ButtonInput["partiallyDisabled"];
"badge-aria-label"?: AttrString;
Expand Down
16 changes: 13 additions & 3 deletions src/components/ebay-icon-button/icon-button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ export default {
},
},
},
priority: {
options: ["primary", "secondary", "tertiary", "none"],
description: "Priority of the button. Toggle the color and border of the button",
table: {
defaultValue: {
summary: "none",
},
},
type: { category: "Options" },
},
partiallyDisabled: {
description:
"programmatically disabled, but remains keyboard focusable",
Expand Down Expand Up @@ -128,15 +138,15 @@ export default {
},
};

export const Standard = Template.bind({});
Standard.args = {
export const Default = Template.bind({});
Default.args = {
href: "",
disabled: false,
partiallyDisabled: false,
badgeNumber: 0,
"aria-label": "menu",
};
Standard.parameters = {
Default.parameters = {
docs: {
source: {
code,
Expand Down
8 changes: 8 additions & 0 deletions src/components/ebay-icon-button/index.marko
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { processHtmlAttributes } from "../../common/html-attributes"

static const VALID_SIZES = ['small', 'large']
static var validPriorities = [
'primary',
'secondary',
'tertiary'
];

static function toJSON(this: any) {
return {
Expand All @@ -13,6 +18,7 @@ $ const {
badgeAriaLabel,
badgeNumber,
href,
priority = "none",
partiallyDisabled,
renderBody,
size,
Expand All @@ -38,6 +44,8 @@ $ const tagType = href ? "a" : "button";
'icon-btn',
badgeNumber && `icon-btn--badged`,
transparent && 'icon-btn--transparent',
(validPriorities.includes(priority) &&
`icon-btn--${priority}`),
size && VALID_SIZES.includes(size) && `icon-btn--${size}`
]
data-ebayui=true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<DocumentFragment>
<button
class="icon-btn"
data-ebayui=""
href=""
type="button"
>
<svg
aria-hidden="true"
class="icon icon--menu-24"
focusable="false"
>
<defs>
<symbol
id="icon-menu-24"
viewBox="0 0 24 24"
>
<path
d="M3 5h18a1 1 0 0 0 0-2H3a1 1 0 0 0 0 2Zm18 6H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2ZM3 19h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2Z"
/>
</symbol>
</defs>
<use
href="#icon-menu-24"
/>
</svg>
</button>
</DocumentFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<DocumentFragment>
<button
aria-label="Badged button"
class="icon-btn icon-btn--badged"
data-ebayui=""
href=""
type="button"
>
<svg
aria-hidden="true"
class="icon icon--menu-24"
focusable="false"
>
<defs>
<symbol
id="icon-menu-24"
viewBox="0 0 24 24"
>
<path
d="M3 5h18a1 1 0 0 0 0-2H3a1 1 0 0 0 0 2Zm18 6H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2ZM3 19h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2Z"
/>
</symbol>
</defs>
<use
href="#icon-menu-24"
/>
</svg>
<span
aria-hidden="true"
aria-label="5 Items"
class="badge"
>
5
</span>
</button>
</DocumentFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<DocumentFragment>
<button
class="icon-btn"
data-ebayui=""
href=""
type="button"
>
<svg
aria-hidden="true"
class="icon icon--menu-24"
focusable="false"
>
<defs>
<symbol
id="icon-menu-24"
viewBox="0 0 24 24"
>
<path
d="M3 5h18a1 1 0 0 0 0-2H3a1 1 0 0 0 0 2Zm18 6H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2ZM3 19h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2Z"
/>
</symbol>
</defs>
<use
href="#icon-menu-24"
/>
</svg>
</button>
</DocumentFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<DocumentFragment>
<button
class="icon-btn icon-btn--primary"
data-ebayui=""
href=""
type="button"
>
<svg
aria-hidden="true"
class="icon icon--menu-24"
focusable="false"
>
<defs>
<symbol
id="icon-menu-24"
viewBox="0 0 24 24"
>
<path
d="M3 5h18a1 1 0 0 0 0-2H3a1 1 0 0 0 0 2Zm18 6H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2ZM3 19h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2Z"
/>
</symbol>
</defs>
<use
href="#icon-menu-24"
/>
</svg>
</button>
</DocumentFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<DocumentFragment>
<button
class="icon-btn icon-btn--secondary"
data-ebayui=""
href=""
type="button"
>
<svg
aria-hidden="true"
class="icon icon--menu-24"
focusable="false"
>
<defs>
<symbol
id="icon-menu-24"
viewBox="0 0 24 24"
>
<path
d="M3 5h18a1 1 0 0 0 0-2H3a1 1 0 0 0 0 2Zm18 6H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2ZM3 19h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2Z"
/>
</symbol>
</defs>
<use
href="#icon-menu-24"
/>
</svg>
</button>
</DocumentFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<DocumentFragment>
<button
class="icon-btn icon-btn--large"
data-ebayui=""
href=""
type="button"
>
<svg
aria-hidden="true"
class="icon icon--menu-24"
focusable="false"
>
<defs>
<symbol
id="icon-menu-24"
viewBox="0 0 24 24"
>
<path
d="M3 5h18a1 1 0 0 0 0-2H3a1 1 0 0 0 0 2Zm18 6H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2ZM3 19h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2Z"
/>
</symbol>
</defs>
<use
href="#icon-menu-24"
/>
</svg>
</button>
</DocumentFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<DocumentFragment>
<button
class="icon-btn icon-btn--small"
data-ebayui=""
href=""
type="button"
>
<svg
aria-hidden="true"
class="icon icon--menu-24"
focusable="false"
>
<defs>
<symbol
id="icon-menu-24"
viewBox="0 0 24 24"
>
<path
d="M3 5h18a1 1 0 0 0 0-2H3a1 1 0 0 0 0 2Zm18 6H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2ZM3 19h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2Z"
/>
</symbol>
</defs>
<use
href="#icon-menu-24"
/>
</svg>
</button>
</DocumentFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<DocumentFragment>
<button
class="icon-btn"
data-ebayui=""
disabled=""
href=""
type="button"
>
<svg
aria-hidden="true"
class="icon icon--menu-24"
focusable="false"
>
<defs>
<symbol
id="icon-menu-24"
viewBox="0 0 24 24"
>
<path
d="M3 5h18a1 1 0 0 0 0-2H3a1 1 0 0 0 0 2Zm18 6H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2ZM3 19h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2Z"
/>
</symbol>
</defs>
<use
href="#icon-menu-24"
/>
</svg>
</button>
</DocumentFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<DocumentFragment>
<a
aria-label="fake button"
class="icon-btn"
data-ebayui=""
href="#"
>
<svg
aria-hidden="true"
class="icon icon--menu-24"
focusable="false"
>
<defs>
<symbol
id="icon-menu-24"
viewBox="0 0 24 24"
>
<path
d="M3 5h18a1 1 0 0 0 0-2H3a1 1 0 0 0 0 2Zm18 6H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2ZM3 19h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2Z"
/>
</symbol>
</defs>
<use
href="#icon-menu-24"
/>
</svg>
</a>
</DocumentFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<DocumentFragment>
<button
aria-label="icon button"
class="icon-btn"
data-ebayui=""
href=""
type="button"
>
<svg
aria-hidden="true"
class="icon icon--menu-24"
focusable="false"
>
<defs>
<symbol
id="icon-menu-24"
viewBox="0 0 24 24"
>
<path
d="M3 5h18a1 1 0 0 0 0-2H3a1 1 0 0 0 0 2Zm18 6H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2ZM3 19h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2Z"
/>
</symbol>
</defs>
<use
href="#icon-menu-24"
/>
</svg>
</button>
</DocumentFragment>

0 comments on commit 3322847

Please sign in to comment.