forked from tsai/budibase
1 changed files with 28 additions and 194 deletions
@ -1,212 +1,46 @@ |
|||||
<script> |
<script> |
||||
export let primary = false, |
import "@spectrum-css/button/dist/index-vars.css" |
||||
secondary = false, |
|
||||
blue = false, |
|
||||
disabled = false, |
|
||||
translucent = false, |
export let href = false |
||||
text = false, |
export let disabled = false |
||||
red = false, |
|
||||
yellow = false, |
/** @type {('S', 'M', 'L', 'XL')} Size of button */ |
||||
orange = false, |
export let size = "M"; |
||||
green = false, |
/** @type {('cta','primary','secondary','warning', 'overBackground')} Type of button */ |
||||
purple = false, |
export let type = "primary" |
||||
small = false, |
|
||||
medium = false, |
export let icon = undefined; |
||||
wide = false, |
|
||||
large = false, |
|
||||
href = false |
|
||||
</script> |
</script> |
||||
|
|
||||
|
|
||||
{#if href} |
{#if href} |
||||
<a |
<a |
||||
|
class="spectrum-Button spectrum-Button--{type} spectrum-Button--size{size.toUpperCase()}" |
||||
{href} |
{href} |
||||
class:primary |
|
||||
class:secondary |
|
||||
class:translucent |
|
||||
class:blue |
|
||||
class:red |
|
||||
class:yellow |
|
||||
class:orange |
|
||||
class:green |
|
||||
class:purple |
|
||||
class:small |
|
||||
class:medium |
|
||||
class:wide |
|
||||
class:large |
|
||||
class:text |
|
||||
{disabled}> |
{disabled}> |
||||
<slot /> |
{#if icon} |
||||
|
<svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true" aria-label="{icon}"> |
||||
|
<use xlink:href="#spectrum-icon-18-{icon}" /> |
||||
|
</svg> |
||||
|
{/if} |
||||
|
<span class="spectrum-Button-label"><slot /></span> |
||||
</a> |
</a> |
||||
{:else} |
{:else} |
||||
<button |
<button |
||||
class:primary |
class="spectrum-Button spectrum-Button--{type} spectrum-Button--size{size.toUpperCase()}" |
||||
class:secondary |
|
||||
class:translucent |
|
||||
class:blue |
|
||||
class:red |
|
||||
class:yellow |
|
||||
class:orange |
|
||||
class:green |
|
||||
class:purple |
|
||||
class:small |
|
||||
class:medium |
|
||||
class:wide |
|
||||
class:large |
|
||||
class:text |
|
||||
{disabled} |
{disabled} |
||||
on:click|preventDefault> |
on:click|preventDefault> |
||||
<slot /> |
{#if icon} |
||||
|
<svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true" aria-label="{icon}"> |
||||
|
<use xlink:href="#spectrum-icon-18-{icon}" /> |
||||
|
</svg> |
||||
|
{/if} |
||||
|
<span class="spectrum-Button-label"><slot /></span> |
||||
</button> |
</button> |
||||
{/if} |
{/if} |
||||
|
|
||||
<style> |
<style> |
||||
button, |
|
||||
a { |
|
||||
font-family: var(--font-sans); |
|
||||
cursor: pointer; |
|
||||
font-weight: 600; |
|
||||
box-sizing: border-box; |
|
||||
overflow: hidden; |
|
||||
border-radius: var(--border-radius-s); |
|
||||
color: white; |
|
||||
padding: var(--spacing-s) var(--spacing-l); |
|
||||
transition: all 0.2s ease 0s; |
|
||||
display: inline-flex; |
|
||||
text-rendering: optimizeLegibility; |
|
||||
text-decoration: none; |
|
||||
min-width: auto; |
|
||||
outline: none; |
|
||||
font-feature-settings: "case" 1, "rlig" 1, "calt" 0; |
|
||||
-webkit-box-align: center; |
|
||||
user-select: none; |
|
||||
flex-shrink: 0; |
|
||||
align-items: center; |
|
||||
justify-content: center; |
|
||||
margin: 0; |
|
||||
border-width: 2px; |
|
||||
border-style: solid; |
|
||||
border-color: transparent; |
|
||||
} |
|
||||
|
|
||||
.primary { |
|
||||
color: var(--background); |
|
||||
border-color: var(--ink); |
|
||||
background-color: var(--ink); |
|
||||
} |
|
||||
button.primary:hover:not([disabled]) { |
|
||||
background-color: var(--background); |
|
||||
color: var(--ink); |
|
||||
} |
|
||||
.secondary { |
|
||||
border-color: var(--grey-4); |
|
||||
background-color: var(--background); |
|
||||
color: var(--grey-8); |
|
||||
font-weight: 500; |
|
||||
} |
|
||||
button.secondary:hover:not([disabled]) { |
|
||||
background-color: var(--grey-2); |
|
||||
color: var(--ink); |
|
||||
} |
|
||||
.translucent { |
|
||||
border-color: rgba(0, 0, 0, 0.1); |
|
||||
background-color: rgba(255, 255, 255, 0.1); |
|
||||
color: var(--grey-6); |
|
||||
font-weight: 500; |
|
||||
} |
|
||||
button.translucent:hover:not([disabled]) { |
|
||||
background-color: var(--grey-2); |
|
||||
color: var(--ink); |
|
||||
} |
|
||||
.blue { |
|
||||
background-color: var(--blue); |
|
||||
border-color: var(--blue); |
|
||||
} |
|
||||
button.blue:hover:not([disabled]) { |
|
||||
background-color: var(--blue-light); |
|
||||
color: var(--blue); |
|
||||
} |
|
||||
.red { |
|
||||
border-color: var(--red); |
|
||||
background-color: var(--red); |
|
||||
color: white; |
|
||||
} |
|
||||
button.red:hover:not([disabled]) { |
|
||||
background-color: var(--red-light); |
|
||||
color: var(--red); |
|
||||
} |
|
||||
.yellow { |
|
||||
border-color: var(--yellow); |
|
||||
background-color: var(--yellow); |
|
||||
color: white; |
|
||||
} |
|
||||
button.yellow:hover:not([disabled]) { |
|
||||
background-color: var(--yellow-light); |
|
||||
color: var(--yellow); |
|
||||
} |
|
||||
.orange { |
|
||||
border-color: var(--orange); |
|
||||
background-color: var(--orange); |
|
||||
color: white; |
|
||||
} |
|
||||
button.orange:hover:not([disabled]) { |
|
||||
background-color: var(--orange-light); |
|
||||
color: var(--orange); |
|
||||
} |
|
||||
.green { |
|
||||
border-color: var(--green); |
|
||||
background-color: var(--green); |
|
||||
color: white; |
|
||||
} |
|
||||
button.green:hover:not([disabled]) { |
|
||||
background-color: var(--green-light); |
|
||||
color: var(--green); |
|
||||
} |
|
||||
.purple { |
|
||||
border-color: var(--purple); |
|
||||
background-color: var(--purple); |
|
||||
color: white; |
|
||||
} |
|
||||
button.purple:hover:not([disabled]) { |
|
||||
background-color: var(--purple-light); |
|
||||
color: var(--purple); |
|
||||
} |
|
||||
.text { |
|
||||
background-color: transparent; |
|
||||
color: var(--grey-7); |
|
||||
border: none; |
|
||||
padding: 0; |
|
||||
font-weight: 500; |
|
||||
} |
|
||||
button.text:hover:not([disabled]) { |
|
||||
color: var(--ink); |
|
||||
} |
|
||||
button.text:active:not([disabled]) { |
|
||||
color: var(--blue); |
|
||||
} |
|
||||
|
|
||||
.small { |
|
||||
font-size: var(--font-size-xs); |
|
||||
padding: var(--spacing-xs) var(--spacing-m); |
|
||||
} |
|
||||
|
|
||||
.medium { |
|
||||
font-size: var(--font-size-m); |
|
||||
padding: var(--spacing-s) var(--spacing-l); |
|
||||
} |
|
||||
|
|
||||
.large { |
|
||||
font-size: var(--font-size-l); |
|
||||
padding: var(--spacing-m) var(--layout-l); |
|
||||
} |
|
||||
.wide { |
|
||||
width: 100%; |
|
||||
display: flex; |
|
||||
} |
|
||||
|
|
||||
button:disabled { |
|
||||
background-color: var(--grey-4); |
|
||||
cursor: not-allowed; |
|
||||
border-color: var(--grey-4); |
|
||||
color: var(--grey-5); |
|
||||
} |
|
||||
</style> |
</style> |
||||
|
|||||
Loading…
Reference in new issue