mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
refactor(ui-shell): use $$restProps, remove cx
This commit is contained in:
parent
e886d772c7
commit
1e5333dd64
26 changed files with 230 additions and 425 deletions
|
@ -2,6 +2,6 @@
|
||||||
export let id = "main-content";
|
export let id = "main-content";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main {...$$props} {id} class:bx--content={true}>
|
<main {id} class:bx--content={true} {...$$restProps}>
|
||||||
<slot />
|
<slot />
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<script>
|
|
||||||
import TextInput from "../TextInput/TextInput.svelte";
|
|
||||||
import Toggle from "../Toggle/Toggle.svelte";
|
|
||||||
import { Button } from "../Button/Button.svelte";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<label>Test Field</label>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<TextInput />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<Toggle labelText="Test toggler" />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<Button>Test Button</Button>
|
|
|
@ -5,23 +5,23 @@
|
||||||
export let platformName = undefined;
|
export let platformName = undefined;
|
||||||
export let isSideNavOpen = undefined;
|
export let isSideNavOpen = undefined;
|
||||||
|
|
||||||
import { cx } from '../../../lib';
|
import HamburgerMenu from "../SideNav/HamburgerMenu.svelte";
|
||||||
import HamburgerMenu from '../SideNav/HamburgerMenu.svelte';
|
|
||||||
|
|
||||||
let winWidth = undefined;
|
let winWidth = undefined;
|
||||||
$: isSideNavOpen = winWidth >= 1056;
|
|
||||||
|
|
||||||
$: ariaLabel = company + (uiShellAriaLabel || $$props['aria-label'] || platformName);
|
$: isSideNavOpen = winWidth >= 1056;
|
||||||
|
$: ariaLabel =
|
||||||
|
company + (uiShellAriaLabel || $$props["aria-label"] || platformName);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window bind:innerWidth={winWidth} />
|
<svelte:window bind:innerWidth={winWidth} />
|
||||||
|
|
||||||
<header aria-label={ariaLabel} class={cx('--header')} role="banner">
|
<header role="banner" aria-label={ariaLabel} class:bx--header={true}>
|
||||||
{#if winWidth < 1056}
|
{#if winWidth < 1056}
|
||||||
<HamburgerMenu bind:isOpen={isSideNavOpen} />
|
<HamburgerMenu bind:isOpen={isSideNavOpen} />
|
||||||
{/if}
|
{/if}
|
||||||
<a class={cx('--header__name')} {href} on:click>
|
<a {href} class:bx--header__name={true} {...$$restProps} on:click>
|
||||||
<span class={cx('--header__name--prefix')}>{company}</span>
|
<span class:bx--header__name--prefix={true}>{company}</span>
|
||||||
{platformName}
|
{platformName}
|
||||||
</a>
|
</a>
|
||||||
<slot />
|
<slot />
|
||||||
|
|
|
@ -4,45 +4,46 @@
|
||||||
export let isOpen = undefined;
|
export let isOpen = undefined;
|
||||||
export let text = undefined;
|
export let text = undefined;
|
||||||
|
|
||||||
let elRigthPanel = undefined;
|
import { Icon } from "../../Icon";
|
||||||
|
import { slide } from "svelte/transition";
|
||||||
|
|
||||||
import { cx } from '../../../lib';
|
let refPanel = null;
|
||||||
import Icon from '../../Icon/Icon.svelte';
|
|
||||||
import { slide } from 'svelte/transition';
|
|
||||||
|
|
||||||
function mouseUp({ target }) {
|
|
||||||
if (target && elRigthPanel) {
|
|
||||||
if (!elRigthPanel.contains(target)) {
|
|
||||||
isOpen = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.action-text {
|
.action-text {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0 1rem;
|
padding: 0 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-text > span {
|
.action-text > span {
|
||||||
margin-left: 0.75rem;
|
margin-left: 0.75rem;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<svelte:window on:mouseup={mouseUp} />
|
<svelte:window
|
||||||
|
on:mouseup={({ target }) => {
|
||||||
|
if (target && refPanel) {
|
||||||
|
if (!refPanel.contains(target)) {
|
||||||
|
isOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}} />
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
aria-label={type}
|
|
||||||
class={cx('--header__action', isOpen && '--header__action--active')}
|
|
||||||
class:action-text={text}
|
|
||||||
type="button"
|
type="button"
|
||||||
|
aria-label={type}
|
||||||
|
class:bx--header__action={true}
|
||||||
|
class:bx--header__action--active={isOpen}
|
||||||
|
class:action-text={text}
|
||||||
|
{...$$restProps}
|
||||||
|
on:click
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
isOpen = true;
|
isOpen = true;
|
||||||
}}>
|
}}>
|
||||||
|
@ -55,8 +56,9 @@
|
||||||
</button>
|
</button>
|
||||||
{#if isOpen}
|
{#if isOpen}
|
||||||
<div
|
<div
|
||||||
bind:this={elRigthPanel}
|
bind:this={refPanel}
|
||||||
class={cx('--header-panel', '--header-panel--expanded')}
|
class:bx--header-panel={true}
|
||||||
|
class:bx--header-panel--expanded={true}
|
||||||
transition:slide={{ duration: 200 }}>
|
transition:slide={{ duration: 200 }}>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
export let type = undefined;
|
export let type = undefined;
|
||||||
export let icon = undefined;
|
export let icon = undefined;
|
||||||
export let linkIsActive = undefined;
|
export let linkIsActive = undefined;
|
||||||
import { cx } from '../../../lib';
|
|
||||||
import Icon from '../../Icon/Icon.svelte';
|
import { Icon } from "../../Icon";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -15,17 +15,12 @@
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
.subject-divider {
|
|
||||||
color: #525252;
|
|
||||||
padding-bottom: 4px;
|
|
||||||
border-bottom: 1px solid #525252;
|
|
||||||
margin: 32px 1rem 8px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
aria-label={type}
|
aria-label={type}
|
||||||
class={cx('--header__action', linkIsActive && '--header__action--active')}
|
class:bx--header__action={true}
|
||||||
|
class:bx--header__action--active={linkIsActive}
|
||||||
class:action-link={true}
|
class:action-link={true}
|
||||||
{href}>
|
{href}>
|
||||||
<Icon {...icon} />
|
<Icon {...icon} />
|
||||||
|
|
|
@ -1,48 +1,40 @@
|
||||||
<script>
|
<script>
|
||||||
export let searchIsActive = undefined;
|
export let searchIsActive = undefined;
|
||||||
|
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from "svelte";
|
||||||
import { cx } from '../../../lib';
|
import Close20 from "carbon-icons-svelte/lib/Close20";
|
||||||
import Icon from '../../Icon/Icon.svelte';
|
import Search20 from "carbon-icons-svelte/lib/Search20";
|
||||||
import { closeIcon, searchIcon } from '../constants';
|
import { Icon } from "../../Icon";
|
||||||
import searchStore from '../searchStore';
|
import searchStore from "../searchStore";
|
||||||
|
|
||||||
let searchTabIndex = '0';
|
const dispatch = createEventDispatcher();
|
||||||
let closeTabIndex = '-1';
|
|
||||||
|
let searchTabIndex = "0";
|
||||||
|
let closeTabIndex = "-1";
|
||||||
let elInput = undefined;
|
let elInput = undefined;
|
||||||
let elTypeSearch = undefined;
|
let elTypeSearch = undefined;
|
||||||
let isSearchFocus = false;
|
let isSearchFocus = false;
|
||||||
const dispatch = createEventDispatcher();
|
|
||||||
|
|
||||||
function dispatchInputs(event) {
|
function dispatchInputs(event) {
|
||||||
const params = {
|
const params = {
|
||||||
action: 'search',
|
action: "search",
|
||||||
textInput: event.target.value
|
textInput: event.target.value
|
||||||
};
|
};
|
||||||
dispatch('inputSearch', params);
|
dispatch("inputSearch", params);
|
||||||
}
|
|
||||||
|
|
||||||
function mouseUp({ target }) {
|
|
||||||
if (target && elTypeSearch) {
|
|
||||||
if (!elTypeSearch.contains(target)) {
|
|
||||||
searchIsActive = false;
|
|
||||||
isSearchFocus = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (!searchIsActive) {
|
$: if (!searchIsActive) {
|
||||||
if (elInput) {
|
if (elInput) {
|
||||||
elInput.value = '';
|
elInput.value = "";
|
||||||
}
|
}
|
||||||
searchStore.clear();
|
searchStore.clear();
|
||||||
}
|
}
|
||||||
$: if (searchIsActive) {
|
$: if (searchIsActive) {
|
||||||
searchTabIndex = '-1';
|
searchTabIndex = "-1";
|
||||||
closeTabIndex = '0';
|
closeTabIndex = "0";
|
||||||
} else {
|
} else {
|
||||||
searchTabIndex = '0';
|
searchTabIndex = "0";
|
||||||
closeTabIndex = '-1';
|
closeTabIndex = "-1";
|
||||||
}
|
}
|
||||||
$: if (isSearchFocus) {
|
$: if (isSearchFocus) {
|
||||||
elInput.focus();
|
elInput.focus();
|
||||||
|
@ -63,19 +55,23 @@
|
||||||
transition: max-width 0.11s cubic-bezier(0.2, 0, 0.38, 0.9),
|
transition: max-width 0.11s cubic-bezier(0.2, 0, 0.38, 0.9),
|
||||||
background 0.11s cubic-bezier(0.2, 0, 0.38, 0.9);
|
background 0.11s cubic-bezier(0.2, 0, 0.38, 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-wrapper-hidden {
|
.search-wrapper-hidden {
|
||||||
max-width: 3rem;
|
max-width: 3rem;
|
||||||
background-color: #161616;
|
background-color: #161616;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-focus {
|
.search-focus {
|
||||||
outline: 2px solid #fff;
|
outline: 2px solid #fff;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-wrapper-2 {
|
.search-wrapper-2 {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
border-bottom: 1px solid #393939;
|
border-bottom: 1px solid #393939;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-search {
|
.btn-search {
|
||||||
width: 3rem;
|
width: 3rem;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
@ -85,10 +81,12 @@
|
||||||
transition: background-color 0.11s cubic-bezier(0.2, 0, 0.38, 0.9),
|
transition: background-color 0.11s cubic-bezier(0.2, 0, 0.38, 0.9),
|
||||||
opacity 0.11s cubic-bezier(0.2, 0, 0.38, 0.9);
|
opacity 0.11s cubic-bezier(0.2, 0, 0.38, 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-search-disabled {
|
.btn-search-disabled {
|
||||||
border: none;
|
border: none;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-search {
|
.input-search {
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
@ -104,10 +102,12 @@
|
||||||
padding: 0;
|
padding: 0;
|
||||||
transition: opacity 0.11s cubic-bezier(0.2, 0, 0.38, 0.9);
|
transition: opacity 0.11s cubic-bezier(0.2, 0, 0.38, 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-hidden {
|
.input-hidden {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-clear {
|
.btn-clear {
|
||||||
width: 3rem;
|
width: 3rem;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
@ -118,35 +118,33 @@
|
||||||
transition: background-color 0.11s cubic-bezier(0.2, 0, 0.38, 0.9),
|
transition: background-color 0.11s cubic-bezier(0.2, 0, 0.38, 0.9),
|
||||||
opacity 0.11s cubic-bezier(0.2, 0, 0.38, 0.9);
|
opacity 0.11s cubic-bezier(0.2, 0, 0.38, 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-clear:hover {
|
.btn-clear:hover {
|
||||||
background-color: #4c4c4c;
|
background-color: #4c4c4c;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-clear-hidden {
|
.btn-clear-hidden {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.search-list {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 10000;
|
|
||||||
padding: 1rem 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
top: 3rem;
|
|
||||||
background-color: #161616;
|
|
||||||
border: 1px solid #393939;
|
|
||||||
border-top: none;
|
|
||||||
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.5);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<svelte:window on:mouseup={mouseUp} />
|
<svelte:window
|
||||||
|
on:mouseup={({ target }) => {
|
||||||
|
if (target && elTypeSearch) {
|
||||||
|
if (!elTypeSearch.contains(target)) {
|
||||||
|
searchIsActive = false;
|
||||||
|
isSearchFocus = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}} />
|
||||||
|
|
||||||
<div
|
<div
|
||||||
bind:this={elTypeSearch}
|
bind:this={elTypeSearch}
|
||||||
|
role="search"
|
||||||
class="search-wrapper"
|
class="search-wrapper"
|
||||||
class:search-wrapper-hidden={!searchIsActive}
|
class:search-wrapper-hidden={!searchIsActive}
|
||||||
class:search-focus={isSearchFocus || searchIsActive}
|
class:search-focus={isSearchFocus || searchIsActive}>
|
||||||
role="search">
|
|
||||||
<div
|
<div
|
||||||
id="right-panel-action-search"
|
id="right-panel-action-search"
|
||||||
class="search-wrapper-2"
|
class="search-wrapper-2"
|
||||||
|
@ -155,7 +153,7 @@
|
||||||
<button
|
<button
|
||||||
tabindex={searchTabIndex}
|
tabindex={searchTabIndex}
|
||||||
aria-label="Search"
|
aria-label="Search"
|
||||||
class={cx('--header__action')}
|
class:bx--header__action={true}
|
||||||
class:btn-search={true}
|
class:btn-search={true}
|
||||||
class:btn-search-disabled={searchIsActive}
|
class:btn-search-disabled={searchIsActive}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
@ -169,7 +167,7 @@
|
||||||
searchIsActive = !searchIsActive;
|
searchIsActive = !searchIsActive;
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Icon {...searchIcon} />
|
<Icon title="Search" tabindex="0" render={Search20} />
|
||||||
</button>
|
</button>
|
||||||
<input
|
<input
|
||||||
bind:this={elInput}
|
bind:this={elInput}
|
||||||
|
@ -186,7 +184,7 @@
|
||||||
<button
|
<button
|
||||||
id="right-panel-close-search"
|
id="right-panel-close-search"
|
||||||
tabindex={closeTabIndex}
|
tabindex={closeTabIndex}
|
||||||
class={cx('--header__action')}
|
class:bx--header__action={true}
|
||||||
class:btn-clear={true}
|
class:btn-clear={true}
|
||||||
class:btn-clear-hidden={!searchIsActive}
|
class:btn-clear-hidden={!searchIsActive}
|
||||||
type="button"
|
type="button"
|
||||||
|
@ -201,7 +199,7 @@
|
||||||
searchIsActive = !searchIsActive;
|
searchIsActive = !searchIsActive;
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Icon {...closeIcon} />
|
<Icon title="Close" tabindex="0" render={Close20} />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
export let ariaLabel = undefined;
|
export let ariaLabel = undefined;
|
||||||
import { cx } from '../../../lib';
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav aria-label={ariaLabel} class={cx('--header__nav')}>
|
<nav aria-label={ariaLabel} class:bx--header__nav={true} {...$$restProps}>
|
||||||
<ul aria-label={ariaLabel} class={cx('--header__menu-bar')} role="menubar">
|
<ul role="menubar" aria-label={ariaLabel} class:bx--header__menu-bar={true}>
|
||||||
<slot />
|
<slot />
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
<script>
|
<script>
|
||||||
export let href = undefined;
|
export let href = undefined;
|
||||||
export let text = undefined;
|
export let text = undefined;
|
||||||
import { cx } from '../../../lib';
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
class={cx('--header__menu-item')}
|
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
{href}
|
||||||
|
class:bx--header__menu-item={true}
|
||||||
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
on:mouseover
|
on:mouseover
|
||||||
on:mouseenter
|
on:mouseenter
|
||||||
|
@ -16,8 +17,7 @@
|
||||||
on:keyup
|
on:keyup
|
||||||
on:keydown
|
on:keydown
|
||||||
on:focus
|
on:focus
|
||||||
on:blur
|
on:blur>
|
||||||
{href}>
|
<span class:bx--text-truncate--end={true}>{text}</span>
|
||||||
<span class={cx('--text-truncate--end')}>{text}</span>
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,39 +1,37 @@
|
||||||
<script>
|
<script>
|
||||||
export let text = undefined;
|
|
||||||
export let iconDescription = 'Expand/Collapse';
|
|
||||||
export let expanded = false;
|
export let expanded = false;
|
||||||
export let href = '/';
|
export let href = "/";
|
||||||
|
export let text = undefined;
|
||||||
|
export let iconDescription = "Expand/Collapse";
|
||||||
|
|
||||||
import ChevronDown16 from 'carbon-icons-svelte/lib/ChevronDown16';
|
import ChevronDown16 from "carbon-icons-svelte/lib/ChevronDown16";
|
||||||
import { cx } from '../../../lib';
|
|
||||||
|
|
||||||
let listItemSubMenu = undefined;
|
let ref = null;
|
||||||
|
|
||||||
const mouseUp = ({ target }) => {
|
|
||||||
if (listItemSubMenu) {
|
|
||||||
if (listItemSubMenu.contains(target) || target === listItemSubMenu) {
|
|
||||||
expanded = !expanded;
|
|
||||||
} else {
|
|
||||||
if (expanded) {
|
|
||||||
expanded = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:mouseup={mouseUp} />
|
<svelte:window
|
||||||
|
on:mouseup={({ target }) => {
|
||||||
|
if (ref.contains(target) || target === ref) {
|
||||||
|
expanded = !expanded;
|
||||||
|
} else {
|
||||||
|
if (expanded) {
|
||||||
|
expanded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}} />
|
||||||
|
|
||||||
<li class={cx('--header__submenu')} title={iconDescription}>
|
<li class:bx--header__submenu={true} title={iconDescription}>
|
||||||
<a
|
<a
|
||||||
bind:this={listItemSubMenu}
|
bind:this={ref}
|
||||||
aria-haspopup="menu"
|
|
||||||
aria-expanded={expanded}
|
|
||||||
class={cx('--header__menu-item', '--header__menu-title')}
|
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
aria-haspopup="menu"
|
||||||
|
aria-expanded={expanded}
|
||||||
aria-label={text}
|
aria-label={text}
|
||||||
{href}
|
{href}
|
||||||
|
class:bx--header__menu-item={true}
|
||||||
|
class:bx--header__menu-title={true}
|
||||||
|
{...$$restProps}
|
||||||
on:keydown
|
on:keydown
|
||||||
on:keydown={({ key }) => {
|
on:keydown={({ key }) => {
|
||||||
if (key === 'Enter') {
|
if (key === 'Enter') {
|
||||||
|
@ -48,9 +46,11 @@
|
||||||
on:focus
|
on:focus
|
||||||
on:blur>
|
on:blur>
|
||||||
{text}
|
{text}
|
||||||
<ChevronDown16 class={cx('--header__menu-arrow')} aria-label={iconDescription} />
|
<ChevronDown16
|
||||||
|
aria-label={iconDescription}
|
||||||
|
class="bx--header__menu-arrow" />
|
||||||
</a>
|
</a>
|
||||||
<ul aria-label={text} class={cx('--header__menu')} role="menu">
|
<ul role="menu" aria-label={text} class:bx--header__menu={true}>
|
||||||
<slot />
|
<slot />
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
border-bottom: 1px solid #525252;
|
border-bottom: 1px solid #525252;
|
||||||
margin: 32px 1rem 8px;
|
margin: 32px 1rem 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subject-divider span {
|
.subject-divider span {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
export let href;
|
export let href = undefined;
|
||||||
|
|
||||||
import { cx } from '../../../lib';
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li class={cx('--switcher__item')}>
|
<li class:bx--switcher__item={true}>
|
||||||
<a class={cx('--switcher__item-link')} {href}>
|
<a {href} class:bx--switcher__item-link={true} {...$$restProps}>
|
||||||
<slot />
|
<slot />
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
<script>
|
<ul class:bx--switcher__item={true}>
|
||||||
import { cx } from '../../../lib';
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<ul class={cx('--switcher__item')}>
|
|
||||||
<slot />
|
<slot />
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
<script>
|
<div class:bx--header__global={true}>
|
||||||
import { cx } from '../../../lib';
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class={cx('--header__global')}>
|
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,31 +2,24 @@
|
||||||
export let ariaLabel = undefined;
|
export let ariaLabel = undefined;
|
||||||
export let isOpen = false;
|
export let isOpen = false;
|
||||||
|
|
||||||
import { cx } from '../../../lib';
|
import { fly } from "svelte/transition";
|
||||||
import Menu20 from 'carbon-icons-svelte/lib/Menu20';
|
import Close20 from "carbon-icons-svelte/lib/Close20";
|
||||||
import Icon from '../../Icon/Icon.svelte';
|
import Menu20 from "carbon-icons-svelte/lib/Menu20";
|
||||||
import { fly } from 'svelte/transition';
|
import { Icon } from "../../Icon";
|
||||||
import { closeIcon } from '../constants';
|
|
||||||
|
|
||||||
$: iconProps = !isOpen
|
|
||||||
? {
|
|
||||||
class: undefined,
|
|
||||||
skeleton: false,
|
|
||||||
render: Menu20,
|
|
||||||
title: 'Open Menu',
|
|
||||||
tabindex: '0',
|
|
||||||
focusable: false,
|
|
||||||
style: undefined
|
|
||||||
}
|
|
||||||
: closeIcon;
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
transition:fly={{ x: -200, delay: 50, duration: 250 }}
|
|
||||||
aria-label={ariaLabel}
|
|
||||||
class={cx('--header__action', '--header__menu-trigger', '--header__menu-toggle')}
|
|
||||||
title="Open menu"
|
|
||||||
type="button"
|
type="button"
|
||||||
|
title="Open menu"
|
||||||
|
aria-label={ariaLabel}
|
||||||
|
class:bx--header__action={true}
|
||||||
|
class:bx--header__menu-trigger={true}
|
||||||
|
class:bx--header__menu-toggle={true}
|
||||||
|
{...$$restProps}
|
||||||
|
transition:fly={{ x: -200, delay: 50, duration: 250 }}
|
||||||
|
on:click
|
||||||
on:click={() => (isOpen = !isOpen)}>
|
on:click={() => (isOpen = !isOpen)}>
|
||||||
<Icon {...iconProps} />
|
<Icon
|
||||||
|
title={isOpen ? 'Close' : 'Open Menu'}
|
||||||
|
render={isOpen ? Close20 : Menu20} />
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<script>
|
<script>
|
||||||
export let ariaLabel = undefined;
|
export let ariaLabel = undefined;
|
||||||
export let isOpen = undefined;
|
export let isOpen = undefined;
|
||||||
|
|
||||||
import { cx } from '../../../lib';
|
|
||||||
|
|
||||||
$: footerSpanText = isOpen ? 'Open' : 'Close';
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav
|
<nav
|
||||||
class={cx('--side-nav__navigation', '--side-nav', '--side-nav--ux', isOpen && '--side-nav--expanded')}
|
aria-label={ariaLabel}
|
||||||
aria-label={ariaLabel}>
|
class:bx--side-nav__navigation={true}
|
||||||
|
class:bx--side-nav={true}
|
||||||
|
class:bx--side-nav--ux={true}
|
||||||
|
class:bx--side-nav--expanded={isOpen}
|
||||||
|
{...$$restProps}>
|
||||||
<slot />
|
<slot />
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
<script>
|
<ul class:bx--side-nav__items={true}>
|
||||||
import { cx } from '../../../lib';
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<ul class={cx('--side-nav__items')}>
|
|
||||||
<slot />
|
<slot />
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,24 +1,25 @@
|
||||||
<script>
|
<script>
|
||||||
|
export let isSelected = false;
|
||||||
export let href = undefined;
|
export let href = undefined;
|
||||||
export let text = undefined;
|
export let text = undefined;
|
||||||
export let icon = undefined;
|
export let icon = undefined;
|
||||||
export let isSelected = false;
|
|
||||||
|
|
||||||
import { cx } from '../../../lib';
|
import { Icon } from "../../Icon";
|
||||||
import Icon from '../../Icon/Icon.svelte';
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li class={cx('--side-nav__item')}>
|
<li class:bx--side-nav__item={true}>
|
||||||
<a
|
<a
|
||||||
{href}
|
|
||||||
class={cx('--side-nav__link', isSelected && '--side-nav__link--current')}
|
|
||||||
aria-current={isSelected ? 'page' : ''}
|
aria-current={isSelected ? 'page' : ''}
|
||||||
|
{href}
|
||||||
|
class:bx--side-nav__link={true}
|
||||||
|
class:bx--side-nav__link--current={isSelected}
|
||||||
|
{...$$restProps}
|
||||||
on:click>
|
on:click>
|
||||||
<div class={cx('--side-nav__icon', '--side-nav__icon--small')}>
|
<div class:bx--side-nav__icon={true} class:bx--side-nav__icon--small={true}>
|
||||||
{#if icon}
|
{#if icon}
|
||||||
<Icon {...icon} />
|
<Icon {...icon} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<span class={cx('--side-nav__link-text')}>{text}</span>
|
<span class:bx--side-nav__link-text={true}>{text}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,43 +1,37 @@
|
||||||
<script>
|
<script>
|
||||||
|
export let expanded = false;
|
||||||
export let text = undefined;
|
export let text = undefined;
|
||||||
export let icon = undefined;
|
export let icon = undefined;
|
||||||
export let expanded = false;
|
|
||||||
|
|
||||||
import { cx } from '../../../lib';
|
import ChevronDown16 from "carbon-icons-svelte/lib/ChevronDown16";
|
||||||
import Icon from '../../Icon/Icon.svelte';
|
import { Icon } from "../../Icon";
|
||||||
import ChevronDown16 from 'carbon-icons-svelte/lib/ChevronDown16';
|
|
||||||
|
|
||||||
let iconProps = {
|
|
||||||
class: undefined,
|
|
||||||
skeleton: false,
|
|
||||||
render: ChevronDown16,
|
|
||||||
title: 'Open Menu',
|
|
||||||
tabindex: '0',
|
|
||||||
focusable: false,
|
|
||||||
style: undefined
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li class={cx('--side-nav__item', '--side-nav__item--icon')}>
|
<li class:bx--side-nav__item={true} class:bx--side-nav__item--icon={true}>
|
||||||
<button
|
<button
|
||||||
|
type="button"
|
||||||
aria-haspopup="true"
|
aria-haspopup="true"
|
||||||
aria-expanded={expanded}
|
aria-expanded={expanded}
|
||||||
class={cx('--side-nav__submenu')}
|
class:bx--side-nav__submenu={true}
|
||||||
type="button"
|
{...$$restProps}
|
||||||
|
on:click
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
expanded = !expanded;
|
expanded = !expanded;
|
||||||
}}>
|
}}>
|
||||||
<div class={cx('--side-nav__icon')}>
|
<div class:bx--side-nav__icon={true}>
|
||||||
{#if icon}
|
{#if icon}
|
||||||
<Icon {...icon} />
|
<Icon {...icon} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<span class={cx('--side-nav__submenu-title')}>{text}</span>
|
<span class:bx--side-nav__submenu-title={true}>{text}</span>
|
||||||
<div class={cx('--side-nav__icon', '--side-nav__icon--small', '--side-nav__submenu-chevron')}>
|
<div
|
||||||
<Icon {...iconProps} />
|
class:bx--side-nav__icon={true}
|
||||||
|
class:bx--side-nav__icon--small={true}
|
||||||
|
class:bx--side-nav__submenu-chevron={true}>
|
||||||
|
<Icon title="Open Menu" tabindex="0" render={ChevronDown16} />
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<ul class={cx('--side-nav__menu')} role="menu">
|
<ul role="menu" class:bx--side-nav__menu={true}>
|
||||||
<slot />
|
<slot />
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
<script>
|
<script>
|
||||||
|
export let isSelected = undefined;
|
||||||
export let href = undefined;
|
export let href = undefined;
|
||||||
export let text = undefined;
|
export let text = undefined;
|
||||||
export let isSelected = undefined;
|
|
||||||
|
|
||||||
import { cx } from '../../../lib';
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li class={cx('--side-nav__menu-item')} role="none">
|
<li role="none" class:bx--side-nav__menu-item={true}>
|
||||||
<a
|
<a
|
||||||
{href}
|
|
||||||
class={cx('--side-nav__link')}
|
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
aria-current={isSelected ? 'page' : ''}
|
aria-current={isSelected ? 'page' : ''}
|
||||||
|
{href}
|
||||||
|
class:bx--side-nav__link={true}
|
||||||
|
{...$$restProps}
|
||||||
on:click>
|
on:click>
|
||||||
<span class={cx('--side-nav__link-text')}>{text}</span>
|
<span class:bx--side-nav__link-text={true}>{text}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,64 +1,64 @@
|
||||||
import { withKnobs, text } from '@storybook/addon-knobs';
|
import { withKnobs, text } from "@storybook/addon-knobs";
|
||||||
import Component from './UIShell.Story.svelte';
|
import Component from "./UIShell.Story.svelte";
|
||||||
|
|
||||||
export default { title: 'UIShell', decorators: [withKnobs] };
|
export default { title: "UIShell", decorators: [withKnobs] };
|
||||||
|
|
||||||
export const Header = () => ({
|
export const Header = () => ({
|
||||||
Component,
|
Component,
|
||||||
props: {
|
props: {
|
||||||
story: 'header',
|
story: "header",
|
||||||
href: text('The link href (href)', '#'),
|
href: text("The link href (href)", "#"),
|
||||||
company: text('Company name', 'IBM'),
|
company: text("Company name", "IBM"),
|
||||||
platformName: text('Platform name', 'Platform Name')
|
platformName: text("Platform name", "Platform Name"),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Sidenav = () => ({
|
export const Sidenav = () => ({
|
||||||
Component,
|
Component,
|
||||||
props: {
|
props: {
|
||||||
story: 'sidenav',
|
story: "sidenav",
|
||||||
href: text('The link href (href)', '#'),
|
href: text("The link href (href)", "#"),
|
||||||
company: text('Company name', 'IBM'),
|
company: text("Company name", "IBM"),
|
||||||
platformName: text('Platform name', 'Platform Name')
|
platformName: text("Platform name", "Platform Name"),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const HeaderWithNav = () => ({
|
export const HeaderWithNav = () => ({
|
||||||
Component,
|
Component,
|
||||||
props: {
|
props: {
|
||||||
story: 'header-with-nav',
|
story: "header-with-nav",
|
||||||
href: text('The link href (href)', '#'),
|
href: text("The link href (href)", "#"),
|
||||||
company: text('Company name', 'IBM'),
|
company: text("Company name", "IBM"),
|
||||||
platformName: text('Platform name', 'Platform Name')
|
platformName: text("Platform name", "Platform Name"),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const HeaderWithUtilities = () => ({
|
export const HeaderWithUtilities = () => ({
|
||||||
Component,
|
Component,
|
||||||
props: {
|
props: {
|
||||||
story: 'header-with-utilities',
|
story: "header-with-utilities",
|
||||||
href: text('The link href (href)', '#'),
|
href: text("The link href (href)", "#"),
|
||||||
company: text('Company name', 'IBM'),
|
company: text("Company name", "IBM"),
|
||||||
platformName: text('Platform name', 'Platform Name')
|
platformName: text("Platform name", "Platform Name"),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const HeaderWithSwitcher = () => ({
|
export const HeaderWithSwitcher = () => ({
|
||||||
Component,
|
Component,
|
||||||
props: {
|
props: {
|
||||||
story: 'header-with-switcher',
|
story: "header-with-switcher",
|
||||||
href: text('The link href (href)', '#'),
|
href: text("The link href (href)", "#"),
|
||||||
company: text('Company name', 'IBM'),
|
company: text("Company name", "IBM"),
|
||||||
platformName: text('Platform name', 'Platform Name')
|
platformName: text("Platform name", "Platform Name"),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const HeaderAndSidenav = () => ({
|
export const HeaderAndSidenav = () => ({
|
||||||
Component,
|
Component,
|
||||||
props: {
|
props: {
|
||||||
story: 'header-and-sidenav',
|
story: "header-and-sidenav",
|
||||||
href: text('The link href (href)', '#'),
|
href: text("The link href (href)", "#"),
|
||||||
company: text('Company name', 'IBM'),
|
company: text("Company name", "IBM"),
|
||||||
platformName: text('Platform name', 'Platform Name')
|
platformName: text("Platform name", "Platform Name"),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,96 +0,0 @@
|
||||||
import Search20 from 'carbon-icons-svelte/lib/Search20';
|
|
||||||
import Help20 from 'carbon-icons-svelte/lib/Help20';
|
|
||||||
import Notification20 from 'carbon-icons-svelte/lib/Notification20';
|
|
||||||
import UserAvatar20 from 'carbon-icons-svelte/lib/UserAvatar20';
|
|
||||||
import AppSwitcher20 from 'carbon-icons-svelte/lib/AppSwitcher20';
|
|
||||||
import Close20 from 'carbon-icons-svelte/lib/Close20';
|
|
||||||
|
|
||||||
export const leftPanelActions = {
|
|
||||||
search: {
|
|
||||||
actionString: 'Search',
|
|
||||||
iconProps: {
|
|
||||||
class: undefined,
|
|
||||||
skeleton: false,
|
|
||||||
render: Search20,
|
|
||||||
title: 'Search',
|
|
||||||
tabindex: '0',
|
|
||||||
focusable: false,
|
|
||||||
style: undefined
|
|
||||||
}
|
|
||||||
},
|
|
||||||
help: {
|
|
||||||
actionString: 'Help',
|
|
||||||
iconProps: {
|
|
||||||
class: undefined,
|
|
||||||
skeleton: false,
|
|
||||||
render: Help20,
|
|
||||||
title: 'Help',
|
|
||||||
tabindex: '0',
|
|
||||||
focusable: false,
|
|
||||||
style: undefined
|
|
||||||
}
|
|
||||||
},
|
|
||||||
notifications: {
|
|
||||||
actionString: 'Notifications',
|
|
||||||
iconProps: {
|
|
||||||
class: undefined,
|
|
||||||
skeleton: false,
|
|
||||||
render: Notification20,
|
|
||||||
title: 'Notifications',
|
|
||||||
tabindex: '0',
|
|
||||||
focusable: false,
|
|
||||||
style: undefined
|
|
||||||
}
|
|
||||||
},
|
|
||||||
account: {
|
|
||||||
actionString: 'Account',
|
|
||||||
iconProps: {
|
|
||||||
class: undefined,
|
|
||||||
skeleton: false,
|
|
||||||
render: UserAvatar20,
|
|
||||||
title: 'Account',
|
|
||||||
tabindex: '0',
|
|
||||||
focusable: false,
|
|
||||||
style: undefined
|
|
||||||
}
|
|
||||||
},
|
|
||||||
switcher: {
|
|
||||||
actionString: 'Switcher',
|
|
||||||
iconProps: {
|
|
||||||
class: undefined,
|
|
||||||
skeleton: false,
|
|
||||||
render: AppSwitcher20,
|
|
||||||
title: 'App Switcher',
|
|
||||||
tabindex: '0',
|
|
||||||
focusable: false,
|
|
||||||
style: undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const leftPanelTypes = {
|
|
||||||
search: 'Search',
|
|
||||||
component: 'Component',
|
|
||||||
link: 'Link',
|
|
||||||
links: 'Links'
|
|
||||||
};
|
|
||||||
|
|
||||||
export const closeIcon = {
|
|
||||||
class: undefined,
|
|
||||||
skeleton: false,
|
|
||||||
render: Close20,
|
|
||||||
title: 'Close',
|
|
||||||
tabindex: '0',
|
|
||||||
focusable: false,
|
|
||||||
style: undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
export const searchIcon = {
|
|
||||||
class: undefined,
|
|
||||||
skeleton: false,
|
|
||||||
render: Search20,
|
|
||||||
title: 'Search',
|
|
||||||
tabindex: '0',
|
|
||||||
focusable: false,
|
|
||||||
style: undefined
|
|
||||||
};
|
|
|
@ -1,21 +0,0 @@
|
||||||
export function isChildOf(target, parentId) {
|
|
||||||
if (target.id) {
|
|
||||||
if (target.id == parentId) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.parentNode) {
|
|
||||||
if (target.parentNode.id) {
|
|
||||||
if (target.parentNode.id == parentId) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return isChildOf(target.parentNode, parentId);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return isChildOf(target.parentNode, parentId);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +1,18 @@
|
||||||
export { default as Header } from './GlobalHeader/Header.svelte';
|
export { default as Header } from "./GlobalHeader/Header.svelte";
|
||||||
export { default as HeaderAction } from './GlobalHeader/HeaderAction.svelte';
|
export { default as HeaderAction } from "./GlobalHeader/HeaderAction.svelte";
|
||||||
export { default as HeaderActionLink } from './GlobalHeader/HeaderActionLink.svelte';
|
export { default as HeaderActionLink } from "./GlobalHeader/HeaderActionLink.svelte";
|
||||||
export { default as HeaderActionSearch } from './GlobalHeader/HeaderActionSearch.svelte';
|
export { default as HeaderActionSearch } from "./GlobalHeader/HeaderActionSearch.svelte";
|
||||||
export { default as HeaderNav } from './GlobalHeader/HeaderNav.svelte';
|
export { default as HeaderNav } from "./GlobalHeader/HeaderNav.svelte";
|
||||||
export { default as HeaderNavItem } from './GlobalHeader/HeaderNavItem.svelte';
|
export { default as HeaderNavItem } from "./GlobalHeader/HeaderNavItem.svelte";
|
||||||
export { default as HeaderNavMenu } from './GlobalHeader/HeaderNavMenu.svelte';
|
export { default as HeaderNavMenu } from "./GlobalHeader/HeaderNavMenu.svelte";
|
||||||
export { default as HeaderPanelDivider } from './GlobalHeader/HeaderPanelDivider.svelte';
|
export { default as HeaderPanelDivider } from "./GlobalHeader/HeaderPanelDivider.svelte";
|
||||||
export { default as HeaderPanelLink } from './GlobalHeader/HeaderPanelLink.svelte';
|
export { default as HeaderPanelLink } from "./GlobalHeader/HeaderPanelLink.svelte";
|
||||||
export { default as HeaderPanelLinks } from './GlobalHeader/HeaderPanelLinks.svelte';
|
export { default as HeaderPanelLinks } from "./GlobalHeader/HeaderPanelLinks.svelte";
|
||||||
export { default as HeaderUtilities } from './GlobalHeader/HeaderUtilities.svelte';
|
export { default as HeaderUtilities } from "./GlobalHeader/HeaderUtilities.svelte";
|
||||||
export { default as SideNav } from './SideNav/SideNav.svelte';
|
export { default as SideNav } from "./SideNav/SideNav.svelte";
|
||||||
export { default as SideNavItems } from './SideNav/SideNavItems.svelte';
|
export { default as SideNavItems } from "./SideNav/SideNavItems.svelte";
|
||||||
export { default as SideNavLink } from './SideNav/SideNavLink.svelte';
|
export { default as SideNavLink } from "./SideNav/SideNavLink.svelte";
|
||||||
export { default as SideNavMenu } from './SideNav/SideNavMenu.svelte';
|
export { default as SideNavMenu } from "./SideNav/SideNavMenu.svelte";
|
||||||
export { default as SideNavMenuItem } from './SideNav/SideNavMenuItem.svelte';
|
export { default as SideNavMenuItem } from "./SideNav/SideNavMenuItem.svelte";
|
||||||
export { default as Content } from './Content.svelte';
|
export { default as Content } from "./Content.svelte";
|
||||||
export { default as SkipToContent } from './SkipToContent.svelte';
|
export { default as SkipToContent } from "./SkipToContent.svelte";
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
import { cx } from '../cx';
|
|
||||||
|
|
||||||
test('cx', () => {
|
|
||||||
expect(cx(null)).toEqual('');
|
|
||||||
expect(cx(undefined)).toEqual('');
|
|
||||||
expect(cx('--')).toEqual('bx--');
|
|
||||||
expect(cx('--', null)).toEqual('bx--');
|
|
||||||
expect(cx(0, undefined, '--', null, 1)).toEqual('bx--');
|
|
||||||
expect(cx(1 && '1', 0 && '0')).toEqual('1');
|
|
||||||
});
|
|
|
@ -1,19 +0,0 @@
|
||||||
const prefix = 'bx';
|
|
||||||
|
|
||||||
function cx(...items) {
|
|
||||||
const classes = [];
|
|
||||||
|
|
||||||
items.forEach(item => {
|
|
||||||
if (typeof item === 'string') {
|
|
||||||
if (item.slice(0, 2) === '--') {
|
|
||||||
classes.push(`${prefix}${item}`);
|
|
||||||
} else {
|
|
||||||
classes.push(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return classes.join(' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
export { cx };
|
|
|
@ -1 +0,0 @@
|
||||||
export { cx } from "./cx";
|
|
Loading…
Add table
Add a link
Reference in a new issue