refactor: use style directive where applicable (#1760)

Closes #1604
This commit is contained in:
Eric Liu 2023-07-23 12:26:46 -07:00 committed by GitHub
commit bc7f5821b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 26 additions and 25 deletions

View file

@ -228,7 +228,9 @@
tabindex="{type === 'single' && !disabled ? '0' : undefined}" tabindex="{type === 'single' && !disabled ? '0' : undefined}"
aria-label="{$$restProps['aria-label'] || copyLabel || 'code-snippet'}" aria-label="{$$restProps['aria-label'] || copyLabel || 'code-snippet'}"
class:bx--snippet-container="{true}" 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> <pre bind:this="{ref}"><code><slot>{code}</slot></code></pre>
</div> </div>

View file

@ -164,8 +164,9 @@
class:bx--menu--open="{open}" class:bx--menu--open="{open}"
class:bx--menu--invisible="{open && x === 0 && y === 0}" class:bx--menu--invisible="{open && x === 0 && y === 0}"
class:bx--menu--root="{level === 1}" class:bx--menu--root="{level === 1}"
style:left="{x}px"
style:top="{y}px"
{...$$restProps} {...$$restProps}
style="left: {x}px; top: {y}px; {$$restProps.style}"
on:click on:click
on:click="{({ target }) => { on:click="{({ target }) => {
const closestOption = target.closest('[tabindex]'); const closestOption = target.closest('[tabindex]');

View file

@ -27,8 +27,8 @@
class:bx--table-toolbar="{true}" class:bx--table-toolbar="{true}"
class:bx--table-toolbar--small="{size === 'sm'}" class:bx--table-toolbar--small="{size === 'sm'}"
class:bx--table-toolbar--normal="{size === 'default'}" class:bx--table-toolbar--normal="{size === 'default'}"
style:z-index="{1}"
{...$$restProps} {...$$restProps}
style="z-index: 1; {$$restProps.style}"
> >
<slot /> <slot />
</section> </section>

View file

@ -82,8 +82,8 @@
{/if} {/if}
{#if loaded} {#if loaded}
<img <img
style:width="100%"
{...$$restProps} {...$$restProps}
style="width: 100%;{$$restProps.style}"
src="{src}" src="{src}"
alt="{alt}" alt="{alt}"
transition:fade|local="{{ duration: fadeIn ? fast02 : 0 }}" transition:fade|local="{{ duration: fadeIn ? fast02 : 0 }}"
@ -99,8 +99,8 @@
{/if} {/if}
{#if loaded} {#if loaded}
<img <img
style:width="100%"
{...$$restProps} {...$$restProps}
style="width: 100%;{$$restProps.style}"
src="{src}" src="{src}"
alt="{alt}" alt="{alt}"
transition:fade|local="{{ duration: fadeIn ? fast02 : 0 }}" transition:fade|local="{{ duration: fadeIn ? fast02 : 0 }}"

View file

@ -89,8 +89,8 @@
class:bx--toast-notification--success="{kind === 'success'}" class:bx--toast-notification--success="{kind === 'success'}"
class:bx--toast-notification--warning="{kind === 'warning'}" class:bx--toast-notification--warning="{kind === 'warning'}"
class:bx--toast-notification--warning-alt="{kind === 'warning-alt'}" class:bx--toast-notification--warning-alt="{kind === 'warning-alt'}"
style:width="{fullWidth ? "100%" : undefined}"
{...$$restProps} {...$$restProps}
style="{fullWidth && 'width: 100%;'}{$$restProps.style}"
on:click on:click
on:mouseover on:mouseover
on:mouseenter on:mouseenter

View file

@ -64,8 +64,8 @@
class:bx--popover--right-top="{align === 'right-top'}" class:bx--popover--right-top="{align === 'right-top'}"
class:bx--popover--open="{open}" class:bx--popover--open="{open}"
class:bx--popover--relative="{relative}" class:bx--popover--relative="{relative}"
style:position="{relative ? "relative" : undefined}"
{...$$restProps} {...$$restProps}
style="{$$restProps.style}; {relative && 'position: relative'}"
> >
<div class:bx--popover-contents="{true}"> <div class:bx--popover-contents="{true}">
<slot /> <slot />

View file

@ -34,7 +34,7 @@
<p <p
class:bx--skeleton__text="{true}" class:bx--skeleton__text="{true}"
class:bx--skeleton__heading="{heading}" class:bx--skeleton__heading="{heading}"
style="width: {width}" style:width="{width}"
></p> ></p>
{/each} {/each}
</div> </div>
@ -43,8 +43,8 @@
<p <p
class:bx--skeleton__text="{true}" class:bx--skeleton__text="{true}"
class:bx--skeleton__heading="{heading}" class:bx--skeleton__heading="{heading}"
style:width="{width}"
{...$$restProps} {...$$restProps}
style="width: {width};{$$restProps.style}"
on:click on:click
on:mouseover on:mouseover
on:mouseenter on:mouseenter

View file

@ -157,10 +157,7 @@
{labelText} {labelText}
</slot> </slot>
</label> </label>
<div <div class:bx--slider-container="{true}" style:width="{fullWidth && "100%"}">
class:bx--slider-container="{true}"
style="{fullWidth ? 'width: 100%' : undefined}"
>
<span class:bx--slider__range-label="{true}">{minLabel || min}</span> <span class:bx--slider__range-label="{true}">{minLabel || min}</span>
<div <div
bind:this="{ref}" bind:this="{ref}"
@ -168,7 +165,7 @@
tabindex="-1" tabindex="-1"
class:bx--slider="{true}" class:bx--slider="{true}"
class:bx--slider--disabled="{disabled}" class:bx--slider--disabled="{disabled}"
style="{fullWidth ? 'max-width: none' : undefined}" style:max-width="{fullWidth ? "none" : undefined}"
on:mousedown="{startDragging}" on:mousedown="{startDragging}"
on:mousedown="{startHolding}" on:mousedown="{startHolding}"
on:touchstart="{startHolding}" on:touchstart="{startHolding}"
@ -189,7 +186,7 @@
role="slider" role="slider"
tabindex="0" tabindex="0"
class:bx--slider__thumb="{true}" class:bx--slider__thumb="{true}"
style="left: {left}%" style:left="{left}%"
aria-valuemax="{max}" aria-valuemax="{max}"
aria-valuemin="{min}" aria-valuemin="{min}"
aria-valuenow="{value}" aria-valuenow="{value}"
@ -199,7 +196,7 @@
<div bind:this="{trackRef}" class:bx--slider__track="{true}"></div> <div bind:this="{trackRef}" class:bx--slider__track="{true}"></div>
<div <div
class:bx--slider__filled-track="{true}" class:bx--slider__filled-track="{true}"
style="transform: translate(0, -50%) scaleX({left / 100})" style:transform="translate(0, -50%) scaleX({left / 100})"
></div> ></div>
</div> </div>
<span class:bx--slider__range-label="{true}">{maxLabel || max}</span> <span class:bx--slider__range-label="{true}">{maxLabel || max}</span>

View file

@ -67,7 +67,7 @@
id="{id}" id="{id}"
href="{href}" href="{href}"
class:bx--tabs__nav-link="{true}" class:bx--tabs__nav-link="{true}"
style="{$useAutoWidth ? 'width: auto' : undefined}" style:width="{$useAutoWidth ? "auto" : undefined}"
> >
<slot>{label}</slot> <slot>{label}</slot>
</a> </a>

View file

@ -47,8 +47,8 @@
<!-- svelte-ignore a11y-no-static-element-interactions --> <!-- svelte-ignore a11y-no-static-element-interactions -->
<div <div
class:bx--form-item="{true}" class:bx--form-item="{true}"
style:user-select="none"
{...$$restProps} {...$$restProps}
style="{$$restProps['style']}; user-select: none"
on:click on:click
on:mouseover on:mouseover
on:mouseenter on:mouseenter
@ -90,7 +90,7 @@
</span> </span>
<span <span
class:bx--toggle__switch="{true}" 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}"> <span aria-hidden="true" class:bx--toggle__text--off="{true}">
<slot name="labelA"> <slot name="labelA">

View file

@ -200,8 +200,9 @@
/> />
<div <div
style:position="relative"
style:z-index="{open ? 1 : undefined}"
{...$$restProps} {...$$restProps}
style="{open ? 'z-index: 1;' : ''}{$$restProps.style}; position: relative;"
> >
{#if !hideIcon} {#if !hideIcon}
<div bind:this="{ref}" id="{triggerId}" class:bx--tooltip__label="{true}"> <div bind:this="{ref}" id="{triggerId}" class:bx--tooltip__label="{true}">

View file

@ -57,8 +57,8 @@
class:bx--tooltip--align-start="{align === 'start'}" class:bx--tooltip--align-start="{align === 'start'}"
class:bx--tooltip--align-center="{align === 'center'}" class:bx--tooltip--align-center="{align === 'center'}"
class:bx--tooltip--align-end="{align === 'end'}" class:bx--tooltip--align-end="{align === 'end'}"
style:cursor="{disabled ? "not-allowed" : "default"}"
{...$$restProps} {...$$restProps}
style="cursor: {disabled ? 'not-allowed' : 'default'}; {$$restProps.style}"
on:click on:click
on:mouseover on:mouseover
on:mouseenter on:mouseenter

View file

@ -17,8 +17,8 @@
<main <main
id="{id}" id="{id}"
class:bx--content="{true}" class:bx--content="{true}"
style:margin-left="{unsetLeftMargin ? 0 : undefined}"
{...$$restProps} {...$$restProps}
style="{unsetLeftMargin ? 'margin-left: 0;' : ''} {$$restProps.style}"
> >
<slot /> <slot />
</main> </main>

View file

@ -74,8 +74,8 @@
href="{href}" href="{href}"
class:bx--header__menu-item="{true}" class:bx--header__menu-item="{true}"
class:bx--header__menu-title="{true}" class:bx--header__menu-title="{true}"
style:z-index="{1}"
{...$$restProps} {...$$restProps}
style="{$$restProps.style}; z-index: 1"
on:keydown on:keydown
on:keydown="{(e) => { on:keydown="{(e) => {
if (e.key === ' ') e.preventDefault(); if (e.key === ' ') e.preventDefault();

View file

@ -64,7 +64,7 @@
}}" }}"
class:bx--side-nav__overlay="{true}" class:bx--side-nav__overlay="{true}"
class:bx--side-nav__overlay-active="{isOpen}" class:bx--side-nav__overlay-active="{isOpen}"
style="{isOpen && 'z-index: 6000'}" style:z-index="{isOpen ? 6000 : undefined}"
></div> ></div>
{/if} {/if}
<nav <nav

View file

@ -52,7 +52,7 @@
<ul <ul
role="menu" role="menu"
class:bx--side-nav__menu="{true}" class:bx--side-nav__menu="{true}"
style="{expanded && 'max-height: none'}" style:max-height="{expanded ? "none" : undefined}"
> >
<slot /> <slot />
</ul> </ul>