Skip to content

Commit

Permalink
refactor: use style directive where applicable
Browse files Browse the repository at this point in the history
Closes #1604
  • Loading branch information
metonym committed Jul 4, 2023
1 parent ab21c89 commit 8cc5398
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 25 deletions.
4 changes: 3 additions & 1 deletion src/CodeSnippet/CodeSnippet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@
tabindex="{type === 'single' && !disabled ? '0' : undefined}"
aria-label="{$$restProps['aria-label'] || copyLabel || 'code-snippet'}"
class:bx--snippet-container="{true}"
style="width: 100%; min-height: {minHeight}px; max-height: {maxHeight}"
style:width="100%"
style:min-height="{minHeight}px"
style:max-height="{maxHeight}"
>
<pre bind:this="{ref}"><code><slot>{code}</slot></code></pre>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/ContextMenu/ContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@
class:bx--menu--open="{open}"
class:bx--menu--invisible="{open && x === 0 && y === 0}"
class:bx--menu--root="{level === 1}"
style:left="{x}px"
style:top="{y}px"
{...$$restProps}
style="left: {x}px; top: {y}px; {$$restProps.style}"
on:click
on:click="{({ target }) => {
const closestOption = target.closest('[tabindex]');
Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/Toolbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
class:bx--table-toolbar="{true}"
class:bx--table-toolbar--small="{size === 'sm'}"
class:bx--table-toolbar--normal="{size === 'default'}"
style:z-index="{1}"
{...$$restProps}
style="z-index: 1; {$$restProps.style}"
>
<slot />
</section>
4 changes: 2 additions & 2 deletions src/ImageLoader/ImageLoader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
{/if}
{#if loaded}
<img
style:width="100%"
{...$$restProps}
style="width: 100%;{$$restProps.style}"
src="{src}"
alt="{alt}"
transition:fade|local="{{ duration: fadeIn ? fast02 : 0 }}"
Expand All @@ -99,8 +99,8 @@
{/if}
{#if loaded}
<img
style:width="100%"
{...$$restProps}
style="width: 100%;{$$restProps.style}"
src="{src}"
alt="{alt}"
transition:fade|local="{{ duration: fadeIn ? fast02 : 0 }}"
Expand Down
2 changes: 1 addition & 1 deletion src/Notification/ToastNotification.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
class:bx--toast-notification--success="{kind === 'success'}"
class:bx--toast-notification--warning="{kind === 'warning'}"
class:bx--toast-notification--warning-alt="{kind === 'warning-alt'}"
style:width="{fullWidth ? "100%" : undefined}"
{...$$restProps}
style="{fullWidth && 'width: 100%;'}{$$restProps.style}"
on:click
on:mouseover
on:mouseenter
Expand Down
2 changes: 1 addition & 1 deletion src/Popover/Popover.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
class:bx--popover--right-top="{align === 'right-top'}"
class:bx--popover--open="{open}"
class:bx--popover--relative="{relative}"
style:position="{relative ? "relative" : undefined}"
{...$$restProps}
style="{$$restProps.style}; {relative && 'position: relative'}"
>
<div class:bx--popover-contents="{true}">
<slot />
Expand Down
4 changes: 2 additions & 2 deletions src/SkeletonText/SkeletonText.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
<p
class:bx--skeleton__text="{true}"
class:bx--skeleton__heading="{heading}"
style="width: {width}"
style:width="{width}"
></p>
{/each}
</div>
{:else}
<p
class:bx--skeleton__text="{true}"
class:bx--skeleton__heading="{heading}"
style:width="{width}"
{...$$restProps}
style="width: {width};{$$restProps.style}"
on:click
on:mouseover
on:mouseenter
Expand Down
11 changes: 4 additions & 7 deletions src/Slider/Slider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,15 @@
{labelText}
</slot>
</label>
<div
class:bx--slider-container="{true}"
style="{fullWidth ? 'width: 100%' : undefined}"
>
<div class:bx--slider-container="{true}" style:width="{fullWidth && "100%"}">
<span class:bx--slider__range-label="{true}">{minLabel || min}</span>
<div
bind:this="{ref}"
role="presentation"
tabindex="-1"
class:bx--slider="{true}"
class:bx--slider--disabled="{disabled}"
style="{fullWidth ? 'max-width: none' : undefined}"
style:max-width="{fullWidth ? "none" : undefined}"
on:mousedown="{startDragging}"
on:mousedown="{startHolding}"
on:touchstart="{startHolding}"
Expand All @@ -181,7 +178,7 @@
role="slider"
tabindex="0"
class:bx--slider__thumb="{true}"
style="left: {left}%"
style:left="{left}%"
aria-valuemax="{max}"
aria-valuemin="{min}"
aria-valuenow="{value}"
Expand All @@ -191,7 +188,7 @@
<div bind:this="{trackRef}" class:bx--slider__track="{true}"></div>
<div
class:bx--slider__filled-track="{true}"
style="transform: translate(0, -50%) scaleX({left / 100})"
style:transform="translate(0, -50%) scaleX({left / 100})"
></div>
</div>
<span class:bx--slider__range-label="{true}">{maxLabel || max}</span>
Expand Down
2 changes: 1 addition & 1 deletion src/Tabs/Tab.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
id="{id}"
href="{href}"
class:bx--tabs__nav-link="{true}"
style="{$useAutoWidth ? 'width: auto' : undefined}"
style:width="{$useAutoWidth ? "auto" : undefined}"
>
<slot>{label}</slot>
</a>
Expand Down
4 changes: 2 additions & 2 deletions src/Toggle/Toggle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
<div
class:bx--form-item="{true}"
style:user-select="none"
{...$$restProps}
style="{$$restProps['style']}; user-select: none"
on:click
on:mouseover
on:mouseenter
Expand Down Expand Up @@ -89,7 +89,7 @@
</span>
<span
class:bx--toggle__switch="{true}"
style="{hideLabel && 'margin-top: 0'}"
style:margin-top="{hideLabel ? 0 : undefined}"
>
<span aria-hidden="true" class:bx--toggle__text--off="{true}">
<slot name="labelA">
Expand Down
3 changes: 2 additions & 1 deletion src/Tooltip/Tooltip.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@
/>
<div
style:position="relative"
style:z-index="{open ? 1 : undefined}"
{...$$restProps}
style="{open ? 'z-index: 1;' : ''}{$$restProps.style}; position: relative;"
>
{#if !hideIcon}
<div bind:this="{ref}" id="{triggerId}" class:bx--tooltip__label="{true}">
Expand Down
2 changes: 1 addition & 1 deletion src/TooltipIcon/TooltipIcon.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
class:bx--tooltip--align-start="{align === 'start'}"
class:bx--tooltip--align-center="{align === 'center'}"
class:bx--tooltip--align-end="{align === 'end'}"
style:cursor="{disabled ? "not-allowed" : "default"}"
{...$$restProps}
style="cursor: {disabled ? 'not-allowed' : 'default'}; {$$restProps.style}"
on:click
on:mouseover
on:mouseenter
Expand Down
2 changes: 1 addition & 1 deletion src/UIShell/Content.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<main
id="{id}"
class:bx--content="{true}"
style:margin-left="{unsetLeftMargin ? 0 : undefined}"
{...$$restProps}
style="{unsetLeftMargin ? 'margin-left: 0;' : ''} {$$restProps.style}"
>
<slot />
</main>
2 changes: 1 addition & 1 deletion src/UIShell/HeaderNavMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
href="{href}"
class:bx--header__menu-item="{true}"
class:bx--header__menu-title="{true}"
style:z-index="{1}"
{...$$restProps}
style="{$$restProps.style}; z-index: 1"
on:keydown
on:keydown="{(e) => {
if (e.key === ' ') e.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion src/UIShell/SideNav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
}}"
class:bx--side-nav__overlay="{true}"
class:bx--side-nav__overlay-active="{isOpen}"
style="{isOpen && 'z-index: 6000'}"
style:z-index="{isOpen ? 6000 : undefined}"
></div>
{/if}
<nav
Expand Down
2 changes: 1 addition & 1 deletion src/UIShell/SideNavMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<ul
role="menu"
class:bx--side-nav__menu="{true}"
style="{expanded && 'max-height: none'}"
style:max-height="{expanded ? "none" : undefined}"
>
<slot />
</ul>
Expand Down

0 comments on commit 8cc5398

Please sign in to comment.