mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
Updated HeaderAction component with slot & scoped styling
This commit is contained in:
parent
7f1a769889
commit
f7714c721b
4 changed files with 34 additions and 11 deletions
|
@ -19,18 +19,39 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.action-text {
|
||||
font-size: 16px;
|
||||
line-height: 20px;
|
||||
text-decoration: none;
|
||||
color: #fff;
|
||||
width: 100%;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.action-text > span {
|
||||
margin-left: 0.75rem;
|
||||
vertical-align: top;
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:window on:mouseup={mouseUp} />
|
||||
|
||||
<div>
|
||||
<button
|
||||
aria-label={type}
|
||||
class={cx('--header__action', isOpen && '--header__action--active', text && '--header__action--text')}
|
||||
class={cx('--header__action', isOpen && '--header__action--active')}
|
||||
class:action-text={text}
|
||||
type="button"
|
||||
on:click={() => {
|
||||
isOpen = true;
|
||||
}}>
|
||||
<Icon {...icon} />
|
||||
{optional(text)}
|
||||
<slot name="custom-el">
|
||||
{#if text}
|
||||
<span>{text}</span>
|
||||
{/if}
|
||||
</slot>
|
||||
</button>
|
||||
{#if isOpen}
|
||||
<div
|
||||
|
|
|
@ -3,12 +3,18 @@
|
|||
export let type = undefined;
|
||||
export let icon = undefined;
|
||||
export let linkIsActive = undefined;
|
||||
export let text = undefined;
|
||||
import { cx, optional } from '../../../lib';
|
||||
import { cx } from '../../../lib';
|
||||
import Icon from '../../Icon/Icon.svelte';
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.action-link {
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
vertical-align: middle;
|
||||
justify-content: center;
|
||||
padding-top: 10px;
|
||||
}
|
||||
.subject-divider {
|
||||
color: #525252;
|
||||
padding-bottom: 4px;
|
||||
|
@ -19,8 +25,8 @@
|
|||
|
||||
<a
|
||||
aria-label={type}
|
||||
class={cx('--header__action', linkIsActive && '--header__action--active', text && '--header__action--text')}
|
||||
class={cx('--header__action', linkIsActive && '--header__action--active')}
|
||||
class:action-link={true}
|
||||
{href}>
|
||||
<Icon {...icon} />
|
||||
{optional(text)}
|
||||
</a>
|
||||
</a>
|
|
@ -1,4 +1,3 @@
|
|||
export { cx } from './cx';
|
||||
export { css } from './css';
|
||||
export { fillArray } from './fill-array';
|
||||
export { optional } from './optional';
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
const optional = x => x || '';
|
||||
|
||||
export { optional };
|
Loading…
Add table
Add a link
Reference in a new issue