Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(UIShell): export ref for all shell components #297

Merged
merged 3 commits into from
Oct 1, 2020
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
14 changes: 13 additions & 1 deletion src/UIShell/GlobalHeader/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
*/
export let platformName = undefined;

/**
* Obtain a reference to the HTML anchor element
* @type {null | HTMLAnchorElement} [ref=null]
*/
export let ref = null;

import HamburgerMenu from "../SideNav/HamburgerMenu.svelte";

let winWidth = undefined;
Expand All @@ -53,7 +59,13 @@
{#if winWidth < 1056}
<HamburgerMenu bind:isOpen="{isSideNavOpen}" />
{/if}
<a href="{href}" class:bx--header__name="{true}" {...$$restProps} on:click>
<a
href="{href}"
class:bx--header__name="{true}"
bind:this="{ref}"
{...$$restProps}
on:click
>
{#if company}
<span class:bx--header__name--prefix="{true}">{company}&nbsp;</span>
{/if}
Expand Down
7 changes: 7 additions & 0 deletions src/UIShell/GlobalHeader/HeaderActionLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
*/
export let icon = undefined;

/**
* Obtain a reference to the HTML anchor element
* @type {null | HTMLAnchorElement} [ref=null]
*/
export let ref = null;

import { Icon } from "../../Icon";
</script>

Expand All @@ -31,6 +37,7 @@
</style>

<a
bind:this="{ref}"
class:bx--header__action="{true}"
class:bx--header__action--active="{linkIsActive}"
class:action-link="{true}"
Expand Down
7 changes: 7 additions & 0 deletions src/UIShell/GlobalHeader/HeaderNavItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
* @type {string} [text]
*/
export let text = undefined;

/**
* Obtain a reference to the HTML anchor element
* @type {null | HTMLAnchorElement} [ref=null]
*/
export let ref = null;
</script>

<li>
<a
bind:this="{ref}"
role="menuitem"
tabindex="0"
href="{href}"
Expand Down
8 changes: 6 additions & 2 deletions src/UIShell/GlobalHeader/HeaderNavMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@
*/
export let text = undefined;

/**
* Obtain a reference to the HTML anchor element
* @type {null | HTMLAnchorElement} [ref=null]
*/
export let ref = null;

/**
* Specify the ARIA label for the chevron icon
* @type {string} [iconDescription="Expand/Collapse"]
*/
export let iconDescription = "Expand/Collapse";

import ChevronDown16 from "carbon-icons-svelte/lib/ChevronDown16";

let ref = null;
</script>

<svelte:window
Expand Down
14 changes: 13 additions & 1 deletion src/UIShell/GlobalHeader/HeaderPanelLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@
* @type {string} [href]
*/
export let href = undefined;

/**
* Obtain a reference to the HTML anchor element
* @type {null | HTMLAnchorElement} [ref=null]
*/
export let ref = null;
</script>

<li class:bx--switcher__item="{true}">
<a href="{href}" class:bx--switcher__item-link="{true}" {...$$restProps} on:click>
<a
bind:this="{ref}"
href="{href}"
class:bx--switcher__item-link="{true}"
{...$$restProps}
on:click
>
<slot />
</a>
</li>
2 changes: 1 addition & 1 deletion src/UIShell/HeaderGlobalAction.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<button
type="button"
ref="{ref}"
bind:this="{ref}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good eyes

class:bx--header__action="{true}"
class:bx--header__action--active="{isActive}"
{...$$restProps}
Expand Down
7 changes: 7 additions & 0 deletions src/UIShell/SideNav/HamburgerMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
*/
export let isOpen = false;

/**
* Obtain a reference to the HTML button element
* @type {null | HTMLButtonElement} [ref=null]
*/
export let ref = null;

import { fly } from "svelte/transition";
import Close20 from "carbon-icons-svelte/lib/Close20";
import Menu20 from "carbon-icons-svelte/lib/Menu20";
Expand All @@ -19,6 +25,7 @@

<button
type="button"
bind:this="{ref}"
title="Open menu"
aria-label="{ariaLabel}"
class:bx--header__action="{true}"
Expand Down
7 changes: 7 additions & 0 deletions src/UIShell/SideNav/SideNavLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@
*/
export let icon = undefined;

/**
* Obtain a reference to the HTML anchor element
* @type {null | HTMLAnchorElement} [ref=null]
*/
export let ref = null;

import { Icon } from "../../Icon";
</script>

<li class:bx--side-nav__item="{true}">
<a
bind:this="{ref}"
aria-current="{isSelected ? 'page' : undefined}"
href="{href}"
class:bx--side-nav__link="{true}"
Expand Down
7 changes: 7 additions & 0 deletions src/UIShell/SideNav/SideNavMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@
*/
export let icon = undefined;

/**
* Obtain a reference to the HTML button element
* @type {null | HTMLButtonElement} [ref=null]
*/
export let ref = null;

import ChevronDown16 from "carbon-icons-svelte/lib/ChevronDown16";
import { Icon } from "../../Icon";
</script>

<li class:bx--side-nav__item="{true}" class:bx--side-nav__item--icon="{icon}">
<button
type="button"
bind:this="{ref}"
aria-expanded="{expanded}"
class:bx--side-nav__submenu="{true}"
{...$$restProps}
Expand Down
7 changes: 7 additions & 0 deletions src/UIShell/SideNav/SideNavMenuItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@
* @type {string} [text]
*/
export let text = undefined;

/**
* Obtain a reference to the HTML anchor element
* @type {null | HTMLAnchorElement} [ref=null]
*/
export let ref = null;
</script>

<li class:bx--side-nav__menu-item="{true}">
<a
bind:this="{ref}"
aria-current="{isSelected ? 'page' : undefined}"
href="{href}"
class:bx--side-nav__link="{true}"
Expand Down