-
Notifications
You must be signed in to change notification settings - Fork 4
Button Specification
- Button Specification
Team Name: CodeX
Developer Name: Diyan Dimitrov
Designer Name:
- Peer Developer Name | Date:
- Design Manager Name | Date:
- Radoslav Mirchev| Date:
- Radoslav Karaivanov | Date:
Version | Users | Date | Notes |
---|---|---|---|
1 | Diyan Dimitrov | 2021-07-12 | |
2 | Radoslav Karaivanov | 2023-08-28 |
The igc-button
is an interactive component that wraps a native <button>
or an <a>
element depending on the its configuration.
- The component should act as either a button or an anchor element depending on the passed configuration.
- It must support different visual variants according to the guidelines of Material, Fluent, etc.
- It must support sizing through a CSS variable.
- It must support projecting user provided content.
- It must support distinct visual styles based on its state (focused, disabled, etc.) and the guidelines set by the active theme.
- It must follow the WAI-ARIA guidelines as closely as possible and be accessible with both keyboard and mouse devices.
Developer stories:
As a developer I expect to be able to:
- initialize an
igc-button
as a button - initialize an
igc-button
as an anchor - set a variant to control the visual appearance of the element
- control the disabled state of the component
- set a button type (reset, submit) when using the component as a button
- set various anchor attributes (href, download, target, rel) when using the component as an anchor element
- slot content in the exposed component slots so I can achieve customization in scenarios where additional visual indication is needed or certain design guidelines are required
End-user stories:
As an end-user I expect to be able to:
- click a button which performs an action
- click a button which navigates to a URL
- have distinct visual indication reflecting the different states the component is in (disabled, focused, etc.)
- interact with the element with keyboard and with a pointer device
End-users must be able to interact with the component through pointer device and/or keyboard.
Developers must be able to configure the component to act as either a button or an anchor element.
Design hand-off
By default, the igc-button
wraps and renders a native <button>
element. In order to emulate
an anchor button that wraps a native <a>
underneath, one has to set the href property of the component.
When an igc-button
is rendered as a button inside a form element and its type is set to either submit or reset, interacting with it will perform the relevant form action, i.e. submit or reset.
If the component is rendered as an anchor the type attributes and its default behavior are ignored.
<!-- Button -->
<igc-button>OK</igc-button>
<!-- Anchor button -->
<igc-button href="...">Follow</igc-button>
<form>
...
<!-- A raised submit button -->
<igc-button variant="raised" type="submit">Submit form</igc-button>
</form>
<igc-button variant="flat">Button</igc-button>
<!-- An anchor that opens the passed `href` in a new window/tab -->
<igc-button variant="outlined" href="..." target="_blank"
>Open in new tab</igc-button
>
<!-- An anchor that initiates a download of the passed `href` as 'report.pdf' -->
<igc-button variant="outlined" href="..." download="report.pdf"
>Get report</igc-button
>
<igc-button>
<igc-icon slot="prefix" name="github"></igc-icon>
Clone
</igc-button>
<igc-button href="...">
<igc-icon slot="suffix" name="open-in-new"></igc-icon>
</igc-button>
No specific points are applicable for localization.
No additional implementation is required.
Property | Attribute | Modifiers | Type | Default | Description |
---|---|---|---|---|---|
disabled |
disabled |
boolean |
false | The disabled state of the component | |
download |
download |
string |
Prompts to save the linked URL instead of navigating to it. | ||
form |
readonly | Returns the HTMLFormElement associated with this element. | |||
href |
href |
string |
The URL the button points to. | ||
rel |
rel |
string |
The relationship of the linked URL. See https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types |
||
size |
size |
"small" | "medium" | "large" |
"medium" | Determines the size of the component. | |
target |
target |
"_blank" | "_parent" | "_self" | "_top" | undefined |
Where to display the linked URL, as the name for a browsing context. | ||
type |
type |
"button" | "reset" | "submit" |
The type of the button. Defaults to undefined. | ||
variant |
variant |
"flat" | "contained" | "outlined" | "fab" |
"contained" | Sets the variant of the button. |
Method | Type | Description |
---|---|---|
blur |
(): void |
Removes focus from the button. |
click |
(): void |
Simulates a mouse click on the element |
focus |
(options?: FocusOptions | undefined): void |
Sets focus in the button. |
Event | Description |
---|---|
igcBlur |
Emitted when the button loses focus. |
igcFocus |
Emitted when the button gains focus. |
Name | Description |
---|---|
Renders the label of the button. | |
prefix |
Renders content before the label of the button. |
suffix |
Renders content after the label of the button. |
Part | Description |
---|---|
base |
The native button element. |
prefix |
The prefix container. |
suffix |
The suffix container. |
- Should render
<igc-button>
with<button>
/<a>
element inside - Should render the content, prefix and suffix in the correct slots
- Should apply correct CSS classes to the native element for all variants (flat, raised, outlined, icon, fab)
- Should apply correct CSS classes to the native element for all sizes (small, medium, large)
- Should apply correct CSS classes and attributes to the native element when the button is disabled
- Should apply all
<button>
specific properties to the wrapped native element - Should apply all
<a>
specific properties to the wrapped native element - Should focus/blur the native element when focus/blur methods are called
- Should emit igcFocus/igcBlur events
- if
aria-label
is present on theigc-button
, it is copied to the underlyingbutton
/a
element. - when the
igc-button
is rendered as an anchor button the underlying anchor element has its role set to button:role="button"
- when the
igc-button
is rendered as an anchor button and it is disabled, the underlying anchor element hasaria-disabled="true"
The component should work in a Right-To-Left context without additional setup or configuration.