bulma/sass/elements/button.sass

502 lines
16 KiB
Sass
Raw Normal View History

2017-07-28 20:05:15 +00:00
$button-color: $grey-darker !default
2019-09-20 19:02:53 +00:00
$button-color-invert: $white !default
2017-07-28 20:05:15 +00:00
$button-background-color: $white !default
2019-05-17 13:02:12 +00:00
$button-family: false !default
2017-07-28 20:05:15 +00:00
$button-border-color: $grey-lighter !default
$button-border-width: $control-border-width !default
2019-09-19 19:59:21 +00:00
$button-padding-vertical: calc(0.5em - #{$button-border-width}) !default
$button-padding-horizontal: 1em !default
2016-10-30 10:41:53 +00:00
2017-07-28 20:05:15 +00:00
$button-hover-color: $link-hover !default
$button-hover-border-color: $link-hover-border !default
2016-10-29 20:51:13 +00:00
2017-07-28 20:05:15 +00:00
$button-focus-color: $link-focus !default
$button-focus-border-color: $link-focus-border !default
2017-08-30 16:29:01 +00:00
$button-focus-box-shadow-size: 0 0 0 0.125em !default
$button-focus-box-shadow-color: rgba($link, 0.25) !default
2016-10-29 20:51:13 +00:00
2017-07-28 20:05:15 +00:00
$button-active-color: $link-active !default
$button-active-border-color: $link-active-border !default
2016-10-29 20:51:13 +00:00
2017-10-07 19:52:39 +00:00
$button-text-color: $text !default
$button-text-hover-background-color: $background !default
$button-text-hover-color: $text-strong !default
2019-09-20 19:02:53 +00:00
$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
2017-07-28 20:05:15 +00:00
$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
2017-05-28 15:07:29 +00:00
2016-10-30 10:41:53 +00:00
// The button sizes use mixins so they can be used at different breakpoints
2016-01-24 00:03:43 +00:00
=button-small
2016-06-29 22:25:27 +00:00
border-radius: $radius-small
2016-10-29 17:53:30 +00:00
font-size: $size-small
2018-10-31 19:22:21 +00:00
=button-normal
font-size: $size-normal
2016-01-24 00:03:43 +00:00
=button-medium
2016-10-29 17:53:30 +00:00
font-size: $size-medium
2016-01-24 00:03:43 +00:00
=button-large
2016-10-29 17:53:30 +00:00
font-size: $size-large
2016-01-24 00:03:43 +00:00
.button
2018-10-02 06:04:19 +00:00
@extend %control
2018-09-04 13:24:50 +00:00
@extend %unselectable
2017-07-28 20:05:15 +00:00
background-color: $button-background-color
border-color: $button-border-color
border-width: $button-border-width
2017-07-28 20:05:15 +00:00
color: $button-color
2016-09-22 22:14:18 +00:00
cursor: pointer
2019-05-17 13:02:12 +00:00
@if $button-family
font-family: $button-family
2016-03-26 17:28:43 +00:00
justify-content: center
padding-bottom: $button-padding-vertical
padding-left: $button-padding-horizontal
padding-right: $button-padding-horizontal
padding-top: $button-padding-vertical
2016-01-30 11:53:41 +00:00
text-align: center
white-space: nowrap
2016-01-24 00:03:43 +00:00
strong
color: inherit
2017-03-12 14:13:08 +00:00
.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})
2017-03-13 12:05:02 +00:00
margin-right: 0.1875em
2017-03-12 14:13:08 +00:00
&:last-child:not(:first-child)
2017-03-13 12:05:02 +00:00
margin-left: 0.1875em
margin-right: calc(-0.375em - #{$button-border-width})
2017-03-12 14:13:08 +00:00
&:first-child:last-child
margin-left: calc(-0.375em - #{$button-border-width})
margin-right: calc(-0.375em - #{$button-border-width})
2016-10-29 20:51:13 +00:00
// States
2016-05-30 18:41:54 +00:00
&:hover,
2016-10-29 20:51:13 +00:00
&.is-hovered
2017-07-28 20:05:15 +00:00
border-color: $button-hover-border-color
color: $button-hover-color
2016-05-30 18:41:54 +00:00
&:focus,
2016-10-29 20:51:13 +00:00
&.is-focused
2017-07-28 20:05:15 +00:00
border-color: $button-focus-border-color
color: $button-focus-color
2017-08-30 16:29:01 +00:00
&:not(:active)
box-shadow: $button-focus-box-shadow-size $button-focus-box-shadow-color
2016-10-29 20:51:13 +00:00
&:active,
2016-05-30 18:41:54 +00:00
&.is-active
2017-07-28 20:05:15 +00:00
border-color: $button-active-border-color
color: $button-active-color
2016-04-10 15:00:32 +00:00
// Colors
2017-10-07 19:52:39 +00:00
&.is-text
2016-10-29 20:51:13 +00:00
background-color: transparent
2016-10-30 10:41:53 +00:00
border-color: transparent
2017-10-07 19:52:39 +00:00
color: $button-text-color
2016-10-29 20:51:13 +00:00
text-decoration: underline
&:hover,
&.is-hovered,
&:focus,
2017-08-30 16:29:01 +00:00
&.is-focused
2017-10-07 19:52:39 +00:00
background-color: $button-text-hover-background-color
color: $button-text-hover-color
2016-10-29 20:51:13 +00:00
&:active,
&.is-active
2017-10-07 19:52:39 +00:00
background-color: darken($button-text-hover-background-color, 5%)
color: $button-text-hover-color
&[disabled],
fieldset[disabled] &
2017-03-31 21:25:53 +00:00
background-color: transparent
border-color: transparent
box-shadow: none
2016-01-24 00:03:43 +00:00
@each $name, $pair in $colors
$color: nth($pair, 1)
$color-invert: nth($pair, 2)
&.is-#{$name}
2016-06-29 22:59:48 +00:00
background-color: $color
2016-10-30 10:41:53 +00:00
border-color: transparent
2016-01-24 00:03:43 +00:00
color: $color-invert
&:hover,
2016-10-29 20:51:13 +00:00
&.is-hovered
background-color: darken($color, 2.5%)
border-color: transparent
color: $color-invert
2016-05-30 18:41:54 +00:00
&:focus,
2016-10-29 20:51:13 +00:00
&.is-focused
border-color: transparent
color: $color-invert
2017-08-30 16:29:01 +00:00
&:not(:active)
box-shadow: $button-focus-box-shadow-size rgba($color, 0.25)
2016-10-29 20:51:13 +00:00
&:active,
2016-05-30 18:41:54 +00:00
&.is-active
2016-09-22 18:48:42 +00:00
background-color: darken($color, 5%)
2016-01-24 00:03:43 +00:00
border-color: transparent
color: $color-invert
&[disabled],
fieldset[disabled] &
2017-03-31 21:25:53 +00:00
background-color: $color
border-color: transparent
box-shadow: none
2016-01-24 00:03:43 +00:00
&.is-inverted
2016-06-29 22:59:48 +00:00
background-color: $color-invert
2016-01-24 00:03:43 +00:00
color: $color
2019-05-18 21:06:52 +00:00
&:hover,
&.is-hovered
2016-06-29 22:59:48 +00:00
background-color: darken($color-invert, 5%)
&[disabled],
fieldset[disabled] &
2017-03-31 21:25:53 +00:00
background-color: $color-invert
border-color: transparent
box-shadow: none
color: $color
2016-04-10 15:00:32 +00:00
&.is-loading
2018-04-08 18:08:39 +00:00
&::after
2016-04-10 15:00:32 +00:00
border-color: transparent transparent $color-invert $color-invert !important
&.is-outlined
2016-06-29 22:59:48 +00:00
background-color: transparent
2016-04-10 15:00:32 +00:00
border-color: $color
color: $color
&:hover,
2019-05-18 21:06:52 +00:00
&.is-hovered,
&:focus,
&.is-focused
2016-06-29 22:59:48 +00:00
background-color: $color
border-color: $color
color: $color-invert
&.is-loading
2018-04-08 18:08:39 +00:00
&::after
border-color: transparent transparent $color $color !important
2019-05-18 21:06:52 +00:00
&:hover,
&.is-hovered,
&:focus,
&.is-focused
&::after
border-color: transparent transparent $color-invert $color-invert !important
&[disabled],
fieldset[disabled] &
2017-03-31 21:25:53 +00:00
background-color: transparent
border-color: $color
box-shadow: none
color: $color
2016-10-30 20:24:23 +00:00
&.is-inverted.is-outlined
background-color: transparent
border-color: $color-invert
color: $color-invert
&:hover,
2019-05-18 21:06:52 +00:00
&.is-hovered,
&:focus,
&.is-focused
2016-10-30 20:24:23 +00:00
background-color: $color-invert
color: $color
2019-05-18 21:06:52 +00:00
&.is-loading
&:hover,
&.is-hovered,
&:focus,
&.is-focused
&::after
border-color: transparent transparent $color $color !important
&[disabled],
fieldset[disabled] &
2017-03-31 21:25:53 +00:00
background-color: transparent
border-color: $color-invert
box-shadow: none
color: $color-invert
2016-04-10 15:00:32 +00:00
// Sizes
2016-01-24 00:03:43 +00:00
&.is-small
+button-small
2018-10-31 19:22:21 +00:00
&.is-normal
+button-normal
2016-01-24 00:03:43 +00:00
&.is-medium
+button-medium
&.is-large
+button-large
2016-04-10 15:00:32 +00:00
// Modifiers
&[disabled],
fieldset[disabled] &
2017-07-28 20:05:15 +00:00
background-color: $button-disabled-background-color
border-color: $button-disabled-border-color
box-shadow: $button-disabled-shadow
opacity: $button-disabled-opacity
&.is-fullwidth
2016-05-29 12:16:09 +00:00
display: flex
width: 100%
2016-01-24 00:03:43 +00:00
&.is-loading
color: transparent !important
2016-01-24 00:03:43 +00:00
pointer-events: none
2018-04-08 18:08:39 +00:00
&::after
2018-09-04 13:24:50 +00:00
@extend %loader
2017-03-12 17:49:24 +00:00
+center(1em)
2016-01-24 00:03:43 +00:00
position: absolute !important
2017-05-28 15:07:29 +00:00
&.is-static
2017-07-28 20:05:15 +00:00
background-color: $button-static-background-color
border-color: $button-static-border-color
color: $button-static-color
2017-05-28 15:07:29 +00:00
box-shadow: none
pointer-events: none
&.is-rounded
border-radius: $radius-rounded
2019-09-19 20:27:14 +00:00
padding-left: 1.25em
padding-right: 1.25em
2017-10-17 10:53:44 +00:00
.buttons
align-items: center
display: flex
flex-wrap: wrap
justify-content: flex-start
.button
margin-bottom: 0.5rem
2018-10-02 05:51:11 +00:00
&:not(:last-child):not(.is-fullwidth)
2017-10-17 10:53:44 +00:00
margin-right: 0.5rem
&:last-child
margin-bottom: -0.5rem
&:not(:last-child)
margin-bottom: 1rem
// Sizes
&.are-small
2018-10-31 19:22:21 +00:00
.button:not(.is-normal):not(.is-medium):not(.is-large)
+button-small
&.are-medium
2018-10-31 19:22:21 +00:00
.button:not(.is-small):not(.is-normal):not(.is-large)
+button-medium
&.are-large
2018-10-31 19:22:21 +00:00
.button:not(.is-small):not(.is-normal):not(.is-medium)
+button-large
2017-10-17 10:53:44 +00:00
&.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
2018-02-18 04:28:28 +00:00
&.is-expanded
flex-grow: 1
2019-05-17 12:50:39 +00:00
flex-shrink: 1
2017-10-17 10:53:44 +00:00
&.is-centered
justify-content: center
2019-05-17 12:50:39 +00:00
&:not(.has-addons)
.button:not(.is-fullwidth)
margin-left: 0.25rem
margin-right: 0.25rem
2017-10-17 10:53:44 +00:00
&.is-right
justify-content: flex-end
2019-05-17 12:50:39 +00:00
&:not(.has-addons)
.button:not(.is-fullwidth)
margin-left: 0.25rem
margin-right: 0.25rem
2019-09-20 10:40:21 +00:00
.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}
2019-09-20 19:02:53 +00:00
--cssvar-focus-border-color: #{$button-focus-border-color}
--cssvar-focus-color: #{$button-focus-color}
--cssvar-focus-box-shadow-color: #{$button-focus-box-shadow-color}
2019-09-20 10:40:21 +00:00
--cssvar-active-border-color: #{$button-active-border-color}
--cssvar-active-color: #{$button-active-color}
2019-09-20 19:02:53 +00:00
--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
2019-09-20 10:40:21 +00:00
background-color: var(--cssvar-background-color)
border-color: var(--cssvar-border-color)
2019-09-20 19:02:53 +00:00
border-width: $button-border-width
2019-09-20 10:40:21 +00:00
color: var(--cssvar-color)
2019-09-20 19:02:53 +00:00
cursor: pointer
2019-09-20 10:40:21 +00:00
font-size: 1rem
outline: none
2019-09-20 19:02:53 +00:00
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
2019-09-20 10:40:21 +00:00
background-color: var(--cssvar-hover-background-color)
border-color: var(--cssvar-hover-border-color)
color: var(--cssvar-hover-color)
2019-09-20 19:02:53 +00:00
&: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
2019-09-20 10:40:21 +00:00
background-color: var(--cssvar-active-background-color)
2019-09-20 19:02:53 +00:00
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
2019-09-20 10:40:21 +00:00
&.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
2019-09-20 19:02:53 +00:00
--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}
2019-09-20 10:40:21 +00:00
text-decoration: underline
2019-09-20 19:02:53 +00:00
&[disabled],
fieldset[disabled] &
background-color: transparent
border-color: transparent
box-shadow: none
2019-09-20 10:40:21 +00:00
@each $name, $trio in $colors
$base: "#{$prefix}#{$name}"
&.is-#{$name}
--cssvar-background-color: var(--#{$base})
2019-09-20 19:02:53 +00:00
--cssvar-border-color: transparent
2019-09-20 10:40:21 +00:00
--cssvar-color: var(--#{$base}-invert)
--cssvar-hover-background-color: var(--#{$base}-hover)
2019-09-20 19:02:53 +00:00
--cssvar-hover-border-color: transparent
2019-09-20 10:40:21 +00:00
--cssvar-hover-color: var(--#{$base}-invert)
2019-09-20 19:02:53 +00:00
--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%)
2019-09-20 10:40:21 +00:00
--cssvar-active-background-color: var(--#{$base}-active)
2019-09-20 19:02:53 +00:00
--cssvar-active-border-color: transparent
2019-09-20 10:40:21 +00:00
--cssvar-active-color: var(--#{$base}-invert)
2019-09-20 19:02:53 +00:00
--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)