fix(header-action-link): align icon with HeaderAction (#1161)

This commit is contained in:
metonym 2022-03-12 14:14:22 -08:00 committed by GitHub
commit 5d153601b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 40 deletions

View file

@ -54,43 +54,41 @@
}}"
/>
<div>
<button
bind:this="{ref}"
type="button"
class:bx--header__action="{true}"
class:bx--header__action--active="{isOpen}"
class:action-text="{text}"
{...$$restProps}
on:click
on:click="{() => {
isOpen = !isOpen;
dispatch(isOpen ? 'open' : 'close');
<button
bind:this="{ref}"
type="button"
class:bx--header__action="{true}"
class:bx--header__action--active="{isOpen}"
class:action-text="{text}"
{...$$restProps}
on:click
on:click="{() => {
isOpen = !isOpen;
dispatch(isOpen ? 'open' : 'close');
}}"
>
<svelte:component this="{icon}" style="{isOpen ? 'display: none' : ''}" />
<svelte:component
this="{closeIcon}"
style="{!isOpen ? 'display: none' : ''}"
/>
<slot name="text">
{#if text}<span>{text}</span>{/if}
</slot>
</button>
{#if isOpen}
<div
bind:this="{refPanel}"
class:bx--header-panel="{true}"
class:bx--header-panel--expanded="{true}"
transition:slide="{{
...transition,
duration: transition === false ? 0 : transition.duration,
}}"
>
<svelte:component this="{icon}" style="{isOpen ? 'display: none' : ''}" />
<svelte:component
this="{closeIcon}"
style="{!isOpen ? 'display: none' : ''}"
/>
<slot name="text">
{#if text}<span>{text}</span>{/if}
</slot>
</button>
{#if isOpen}
<div
bind:this="{refPanel}"
class:bx--header-panel="{true}"
class:bx--header-panel--expanded="{true}"
transition:slide="{{
...transition,
duration: transition === false ? 0 : transition.duration,
}}"
>
<slot />
</div>
{/if}
</div>
<slot />
</div>
{/if}
<style>
.action-text {

View file

@ -22,7 +22,6 @@
bind:this="{ref}"
class:bx--header__action="{true}"
class:bx--header__action--active="{linkIsActive}"
class:action-link="{true}"
href="{href}"
rel="{$$restProps.target === '_blank' ? 'noopener noreferrer' : undefined}"
{...$$restProps}
@ -31,11 +30,11 @@
</a>
<style>
.action-link {
text-align: center;
.bx--header__action {
display: flex;
align-items: center;
vertical-align: middle;
justify-content: center;
padding-top: 10px;
/** Hot fix to align icon with `HeaderAction` */
padding-bottom: 2px;
}
</style>