bulma/sass/elements/button.sass
2019-09-20 20:02:53 +01:00

502 lines
16 KiB
Sass

$button-color: $grey-darker !default
$button-color-invert: $white !default
$button-background-color: $white !default
$button-family: false !default
$button-border-color: $grey-lighter !default
$button-border-width: $control-border-width !default
$button-padding-vertical: calc(0.5em - #{$button-border-width}) !default
$button-padding-horizontal: 1em !default
$button-hover-color: $link-hover !default
$button-hover-border-color: $link-hover-border !default
$button-focus-color: $link-focus !default
$button-focus-border-color: $link-focus-border !default
$button-focus-box-shadow-size: 0 0 0 0.125em !default
$button-focus-box-shadow-color: rgba($link, 0.25) !default
$button-active-color: $link-active !default
$button-active-border-color: $link-active-border !default
$button-text-color: $text !default
$button-text-hover-background-color: $background !default
$button-text-hover-color: $text-strong !default
$button-text-focus-background-color: $border-light !default
$button-text-focus-border-color: $border !default
$button-text-focus-color: $text-strong !default
$button-text-focus-box-shadow-color: $border-light !default
$button-text-active-background-color: $border-light !default
$button-text-active-color: $text-strong !default
$button-disabled-background-color: $white !default
$button-disabled-border-color: $grey-lighter !default
$button-disabled-shadow: none !default
$button-disabled-opacity: 0.5 !default
$button-static-color: $grey !default
$button-static-background-color: $white-ter !default
$button-static-border-color: $grey-lighter !default
// The button sizes use mixins so they can be used at different breakpoints
=button-small
border-radius: $radius-small
font-size: $size-small
=button-normal
font-size: $size-normal
=button-medium
font-size: $size-medium
=button-large
font-size: $size-large
.button
@extend %control
@extend %unselectable
background-color: $button-background-color
border-color: $button-border-color
border-width: $button-border-width
color: $button-color
cursor: pointer
@if $button-family
font-family: $button-family
justify-content: center
padding-bottom: $button-padding-vertical
padding-left: $button-padding-horizontal
padding-right: $button-padding-horizontal
padding-top: $button-padding-vertical
text-align: center
white-space: nowrap
strong
color: inherit
.icon
&,
&.is-small,
&.is-medium,
&.is-large
height: 1.5em
width: 1.5em
&:first-child:not(:last-child)
margin-left: calc(-0.375em - #{$button-border-width})
margin-right: 0.1875em
&:last-child:not(:first-child)
margin-left: 0.1875em
margin-right: calc(-0.375em - #{$button-border-width})
&:first-child:last-child
margin-left: calc(-0.375em - #{$button-border-width})
margin-right: calc(-0.375em - #{$button-border-width})
// States
&:hover,
&.is-hovered
border-color: $button-hover-border-color
color: $button-hover-color
&:focus,
&.is-focused
border-color: $button-focus-border-color
color: $button-focus-color
&:not(:active)
box-shadow: $button-focus-box-shadow-size $button-focus-box-shadow-color
&:active,
&.is-active
border-color: $button-active-border-color
color: $button-active-color
// Colors
&.is-text
background-color: transparent
border-color: transparent
color: $button-text-color
text-decoration: underline
&:hover,
&.is-hovered,
&:focus,
&.is-focused
background-color: $button-text-hover-background-color
color: $button-text-hover-color
&:active,
&.is-active
background-color: darken($button-text-hover-background-color, 5%)
color: $button-text-hover-color
&[disabled],
fieldset[disabled] &
background-color: transparent
border-color: transparent
box-shadow: none
@each $name, $pair in $colors
$color: nth($pair, 1)
$color-invert: nth($pair, 2)
&.is-#{$name}
background-color: $color
border-color: transparent
color: $color-invert
&:hover,
&.is-hovered
background-color: darken($color, 2.5%)
border-color: transparent
color: $color-invert
&:focus,
&.is-focused
border-color: transparent
color: $color-invert
&:not(:active)
box-shadow: $button-focus-box-shadow-size rgba($color, 0.25)
&:active,
&.is-active
background-color: darken($color, 5%)
border-color: transparent
color: $color-invert
&[disabled],
fieldset[disabled] &
background-color: $color
border-color: transparent
box-shadow: none
&.is-inverted
background-color: $color-invert
color: $color
&:hover,
&.is-hovered
background-color: darken($color-invert, 5%)
&[disabled],
fieldset[disabled] &
background-color: $color-invert
border-color: transparent
box-shadow: none
color: $color
&.is-loading
&::after
border-color: transparent transparent $color-invert $color-invert !important
&.is-outlined
background-color: transparent
border-color: $color
color: $color
&:hover,
&.is-hovered,
&:focus,
&.is-focused
background-color: $color
border-color: $color
color: $color-invert
&.is-loading
&::after
border-color: transparent transparent $color $color !important
&:hover,
&.is-hovered,
&:focus,
&.is-focused
&::after
border-color: transparent transparent $color-invert $color-invert !important
&[disabled],
fieldset[disabled] &
background-color: transparent
border-color: $color
box-shadow: none
color: $color
&.is-inverted.is-outlined
background-color: transparent
border-color: $color-invert
color: $color-invert
&:hover,
&.is-hovered,
&:focus,
&.is-focused
background-color: $color-invert
color: $color
&.is-loading
&:hover,
&.is-hovered,
&:focus,
&.is-focused
&::after
border-color: transparent transparent $color $color !important
&[disabled],
fieldset[disabled] &
background-color: transparent
border-color: $color-invert
box-shadow: none
color: $color-invert
// Sizes
&.is-small
+button-small
&.is-normal
+button-normal
&.is-medium
+button-medium
&.is-large
+button-large
// Modifiers
&[disabled],
fieldset[disabled] &
background-color: $button-disabled-background-color
border-color: $button-disabled-border-color
box-shadow: $button-disabled-shadow
opacity: $button-disabled-opacity
&.is-fullwidth
display: flex
width: 100%
&.is-loading
color: transparent !important
pointer-events: none
&::after
@extend %loader
+center(1em)
position: absolute !important
&.is-static
background-color: $button-static-background-color
border-color: $button-static-border-color
color: $button-static-color
box-shadow: none
pointer-events: none
&.is-rounded
border-radius: $radius-rounded
padding-left: 1.25em
padding-right: 1.25em
.buttons
align-items: center
display: flex
flex-wrap: wrap
justify-content: flex-start
.button
margin-bottom: 0.5rem
&:not(:last-child):not(.is-fullwidth)
margin-right: 0.5rem
&:last-child
margin-bottom: -0.5rem
&:not(:last-child)
margin-bottom: 1rem
// Sizes
&.are-small
.button:not(.is-normal):not(.is-medium):not(.is-large)
+button-small
&.are-medium
.button:not(.is-small):not(.is-normal):not(.is-large)
+button-medium
&.are-large
.button:not(.is-small):not(.is-normal):not(.is-medium)
+button-large
&.has-addons
.button
&:not(:first-child)
border-bottom-left-radius: 0
border-top-left-radius: 0
&:not(:last-child)
border-bottom-right-radius: 0
border-top-right-radius: 0
margin-right: -1px
&:last-child
margin-right: 0
&:hover,
&.is-hovered
z-index: 2
&:focus,
&.is-focused,
&:active,
&.is-active,
&.is-selected
z-index: 3
&:hover
z-index: 4
&.is-expanded
flex-grow: 1
flex-shrink: 1
&.is-centered
justify-content: center
&:not(.has-addons)
.button:not(.is-fullwidth)
margin-left: 0.25rem
margin-right: 0.25rem
&.is-right
justify-content: flex-end
&:not(.has-addons)
.button:not(.is-fullwidth)
margin-left: 0.25rem
margin-right: 0.25rem
.vbuttons
display: flex
flex-wrap: wrap
.vbutton
margin: 0 1em 1em 0
.vbutton
--cssvar-background-color: #{$button-background-color}
--cssvar-border-color: #{$button-border-color}
--cssvar-color: #{$button-color}
--cssvar-hover-border-color: #{$button-hover-border-color}
--cssvar-hover-color: #{$button-hover-color}
--cssvar-focus-border-color: #{$button-focus-border-color}
--cssvar-focus-color: #{$button-focus-color}
--cssvar-focus-box-shadow-color: #{$button-focus-box-shadow-color}
--cssvar-active-border-color: #{$button-active-border-color}
--cssvar-active-color: #{$button-active-color}
--cssvar-outlined-color: #{$button-color}
--cssvar-outlined-hover-background-color: #{$button-color}
--cssvar-outlined-hover-color: #{$button-color-invert}
--cssvar-outlined-active-background-color: #{darken($button-color, 5%)}
--cssvar-outlined-active-color: #{$button-color-invert}
--cssvar-outlined-focus-box-shadow-color: #{$border}
@extend %control
@extend %unselectable
background-color: var(--cssvar-background-color)
border-color: var(--cssvar-border-color)
border-width: $button-border-width
color: var(--cssvar-color)
cursor: pointer
font-size: 1rem
outline: none
padding: 1em 2em
@if $button-family
font-family: $button-family
justify-content: center
padding-bottom: $button-padding-vertical
padding-left: $button-padding-horizontal
padding-right: $button-padding-horizontal
padding-top: $button-padding-vertical
text-align: center
white-space: nowrap
strong
color: inherit
.icon
&,
&.is-small,
&.is-medium,
&.is-large
height: 1.5em
width: 1.5em
&:first-child:not(:last-child)
margin-left: calc(-0.375em - #{$button-border-width})
margin-right: 0.1875em
&:last-child:not(:first-child)
margin-left: 0.1875em
margin-right: calc(-0.375em - #{$button-border-width})
&:first-child:last-child
margin-left: calc(-0.375em - #{$button-border-width})
margin-right: calc(-0.375em - #{$button-border-width})
&:hover,
&.is-hovered
background-color: var(--cssvar-hover-background-color)
border-color: var(--cssvar-hover-border-color)
color: var(--cssvar-hover-color)
&:focus,
&.is-focused
border-color: var(--cssvar-focus-border-color)
// color: var(--cssvar-focus-color)
&:not(:active)
box-shadow: $button-focus-box-shadow-size #{var(--cssvar-focus-box-shadow-color)}
&:active,
&.is-active
background-color: var(--cssvar-active-background-color)
border-color: var(--cssvar-active-border-color)
color: var(--cssvar-active-color)
// &.is-outlined
// background-color: transparent
// border-color: var(--cssvar-outlined-color)
// color: var(--cssvar-outlined-color)
// &:hover,
// &.is-hovered
// background-color: var(--cssvar-outlined-hover-background-color)
// border-color: transparent
// color: var(--cssvar-outlined-hover-color)
// &:active,
// &.is-active
// background-color: var(--cssvar-outlined-active-background-color)
// border-color: transparent
// color: var(--cssvar-outlined-active-color)
&.is-outlined
--cssvar-border-color: #{$button-color}
--cssvar-color: #{$button-color}
--cssvar-hover-background-color: #{$button-color}
--cssvar-hover-color: #{$button-color-invert}
--cssvar-active-background-color: #{darken($button-color, 5%)}
--cssvar-active-color: #{$button-color-invert}
--cssvar-focus-border-color: #{$button-color}
--cssvar-focus-box-shadow-color: #{$border}
&:not(:hover):not(.is-hovered):not(:active):not(.is-active)
background-color: transparent
&:hover,
&.is-hovered,
&:active,
&.is-active
border-color: transparent
&.is-light
--cssvar-background-color: var(--cssvar-light-background-color)
--cssvar-border-color: var(--cssvar-light-border-color)
--cssvar-color: var(--cssvar-light-color)
--cssvar-hover-background-color: var(--cssvar-light-hover-background-color)
--cssvar-hover-border-color: var(--cssvar-light-hover-border-color)
--cssvar-hover-color: var(--cssvar-light-hover-color)
--cssvar-active-background-color: var(--cssvar-light-active-background-color)
--cssvar-active-border-color: var(--cssvar-light-active-border-color)
--cssvar-active-color: var(--cssvar-light-active-color)
&.is-dark
--cssvar-background-color: var(--cssvar-dark-background-color)
--cssvar-border-color: var(--cssvar-dark-border-color)
--cssvar-color: var(--cssvar-dark-color)
--cssvar-hover-background-color: var(--cssvar-dark-hover-background-color)
--cssvar-hover-border-color: var(--cssvar-dark-hover-border-color)
--cssvar-hover-color: var(--cssvar-dark-hover-color)
--cssvar-active-background-color: var(--cssvar-dark-active-background-color)
--cssvar-active-border-color: var(--cssvar-dark-active-border-color)
--cssvar-active-color: var(--cssvar-dark-active-color)
&.is-text
--cssvar-background-color: transparent
--cssvar-border-color: transparent
--cssvar-color: #{$text}
--cssvar-hover-background-color: #{$button-text-hover-background-color}
--cssvar-hover-border-color: transparent
--cssvar-hover-color: #{$button-text-hover-color}
--cssvar-focus-background-color: #{$button-text-focus-background-color}
--cssvar-focus-border-color: transparent
--cssvar-focus-border-color: #{$button-text-focus-border-color}
--cssvar-focus-color: #{$button-text-focus-color}
--cssvar-focus-box-shadow-color: #{$button-text-focus-box-shadow-color}
--cssvar-active-background-color: #{$button-text-active-background-color}
--cssvar-active-border-color: transparent
--cssvar-active-color: #{$button-text-active-color}
text-decoration: underline
&[disabled],
fieldset[disabled] &
background-color: transparent
border-color: transparent
box-shadow: none
@each $name, $trio in $colors
$base: "#{$prefix}#{$name}"
&.is-#{$name}
--cssvar-background-color: var(--#{$base})
--cssvar-border-color: transparent
--cssvar-color: var(--#{$base}-invert)
--cssvar-hover-background-color: var(--#{$base}-hover)
--cssvar-hover-border-color: transparent
--cssvar-hover-color: var(--#{$base}-invert)
--cssvar-focus-background-color: var(--#{$base})
--cssvar-focus-border-color: transparent
--cssvar-focus-color: var(--#{$base}-invert)
--cssvar-focus-box-shadow-color: hsl(var(--#{$base}-h), calc(var(--#{$base}-s)), 86%)
--cssvar-active-background-color: var(--#{$base}-active)
--cssvar-active-border-color: transparent
--cssvar-active-color: var(--#{$base}-invert)
--cssvar-outlined-color: var(--#{$base})
&.is-outlined
--cssvar-border-color: var(--#{$base})
--cssvar-color: var(--#{$base})
--cssvar-hover-background-color: var(--#{$base})
// --cssvar-hover-color: var(--#{$base}-invert)
// --cssvar-active-background-color: var(--#{$base}-active)
// --cssvar-active-color: var(--#{$base}-invert)
// --cssvar-focus-border-color: var(--#{$base})
// --cssvar-focus-box-shadow-color: var(--#{$base})
&.is-#{$name}-light
--cssvar-background-color: var(--#{$base}-light)
--cssvar-border-color: transparent
--cssvar-color: var(--#{$base}-dark)
--cssvar-hover-background-color: var(--#{$base}-light-hover)
--cssvar-hover-border-color: transparent
--cssvar-hover-color: var(--#{$base}-dark)
--cssvar-focus-background-color: var(--#{$base}-light)
--cssvar-focus-border-color: transparent
--cssvar-focus-color: var(--#{$base}-dark)
--cssvar-focus-box-shadow-color: hsl(var(--#{$base}-h), calc(var(--#{$base}-s)), 86%)
--cssvar-active-background-color: var(--#{$base}-light-active)
--cssvar-active-border-color: transparent
--cssvar-active-color: var(--#{$base}-dark)