button.sass 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. $button-color: $grey-darker !default
  2. $button-background-color: $white !default
  3. $button-border-color: $grey-lighter !default
  4. $button-hover-color: $link-hover !default
  5. $button-hover-border-color: $link-hover-border !default
  6. $button-focus-color: $link-focus !default
  7. $button-focus-border-color: $link-focus-border !default
  8. $button-focus-box-shadow-size: 0 0 0 0.125em !default
  9. $button-focus-box-shadow-color: rgba($link, 0.25) !default
  10. $button-active-color: $link-active !default
  11. $button-active-border-color: $link-active-border !default
  12. $button-text-color: $text !default
  13. $button-text-hover-background-color: $background !default
  14. $button-text-hover-color: $text-strong !default
  15. $button-disabled-background-color: $white !default
  16. $button-disabled-border-color: $grey-lighter !default
  17. $button-disabled-shadow: none !default
  18. $button-disabled-opacity: 0.5 !default
  19. $button-static-color: $grey !default
  20. $button-static-background-color: $white-ter !default
  21. $button-static-border-color: $grey-lighter !default
  22. // The button sizes use mixins so they can be used at different breakpoints
  23. =button-small
  24. border-radius: $radius-small
  25. font-size: $size-small
  26. =button-medium
  27. font-size: $size-medium
  28. =button-large
  29. font-size: $size-large
  30. .button
  31. +control
  32. +unselectable
  33. background-color: $button-background-color
  34. border-color: $button-border-color
  35. color: $button-color
  36. cursor: pointer
  37. justify-content: center
  38. padding-left: 0.75em
  39. padding-right: 0.75em
  40. text-align: center
  41. white-space: nowrap
  42. strong
  43. color: inherit
  44. .icon
  45. &,
  46. &.is-small,
  47. &.is-medium,
  48. &.is-large
  49. height: 1.5em
  50. width: 1.5em
  51. &:first-child:not(:last-child)
  52. margin-left: calc(-0.375em - 1px)
  53. margin-right: 0.1875em
  54. &:last-child:not(:first-child)
  55. margin-left: 0.1875em
  56. margin-right: calc(-0.375em - 1px)
  57. &:first-child:last-child
  58. margin-left: calc(-0.375em - 1px)
  59. margin-right: calc(-0.375em - 1px)
  60. // States
  61. &:hover,
  62. &.is-hovered
  63. border-color: $button-hover-border-color
  64. color: $button-hover-color
  65. &:focus,
  66. &.is-focused
  67. border-color: $button-focus-border-color
  68. color: $button-focus-color
  69. &:not(:active)
  70. box-shadow: $button-focus-box-shadow-size $button-focus-box-shadow-color
  71. &:active,
  72. &.is-active
  73. border-color: $button-active-border-color
  74. color: $button-active-color
  75. // Colors
  76. &.is-text
  77. background-color: transparent
  78. border-color: transparent
  79. color: $button-text-color
  80. text-decoration: underline
  81. &:hover,
  82. &.is-hovered,
  83. &:focus,
  84. &.is-focused
  85. background-color: $button-text-hover-background-color
  86. color: $button-text-hover-color
  87. &:active,
  88. &.is-active
  89. background-color: darken($button-text-hover-background-color, 5%)
  90. color: $button-text-hover-color
  91. &[disabled]
  92. background-color: transparent
  93. border-color: transparent
  94. box-shadow: none
  95. @each $name, $pair in $colors
  96. $color: nth($pair, 1)
  97. $color-invert: nth($pair, 2)
  98. &.is-#{$name}
  99. background-color: $color
  100. border-color: transparent
  101. color: $color-invert
  102. &:hover,
  103. &.is-hovered
  104. background-color: darken($color, 2.5%)
  105. border-color: transparent
  106. color: $color-invert
  107. &:focus,
  108. &.is-focused
  109. border-color: transparent
  110. color: $color-invert
  111. &:not(:active)
  112. box-shadow: $button-focus-box-shadow-size rgba($color, 0.25)
  113. &:active,
  114. &.is-active
  115. background-color: darken($color, 5%)
  116. border-color: transparent
  117. color: $color-invert
  118. &[disabled]
  119. background-color: $color
  120. border-color: transparent
  121. box-shadow: none
  122. &.is-inverted
  123. background-color: $color-invert
  124. color: $color
  125. &:hover
  126. background-color: darken($color-invert, 5%)
  127. &[disabled]
  128. background-color: $color-invert
  129. border-color: transparent
  130. box-shadow: none
  131. color: $color
  132. &.is-loading
  133. &:after
  134. border-color: transparent transparent $color-invert $color-invert !important
  135. &.is-outlined
  136. background-color: transparent
  137. border-color: $color
  138. color: $color
  139. &:hover,
  140. &:focus
  141. background-color: $color
  142. border-color: $color
  143. color: $color-invert
  144. &.is-loading
  145. &:after
  146. border-color: transparent transparent $color $color !important
  147. &[disabled]
  148. background-color: transparent
  149. border-color: $color
  150. box-shadow: none
  151. color: $color
  152. &.is-inverted.is-outlined
  153. background-color: transparent
  154. border-color: $color-invert
  155. color: $color-invert
  156. &:hover,
  157. &:focus
  158. background-color: $color-invert
  159. color: $color
  160. &[disabled]
  161. background-color: transparent
  162. border-color: $color-invert
  163. box-shadow: none
  164. color: $color-invert
  165. // Sizes
  166. &.is-small
  167. +button-small
  168. &.is-medium
  169. +button-medium
  170. &.is-large
  171. +button-large
  172. // Modifiers
  173. &[disabled]
  174. background-color: $button-disabled-background-color
  175. border-color: $button-disabled-border-color
  176. box-shadow: $button-disabled-shadow
  177. opacity: $button-disabled-opacity
  178. &.is-fullwidth
  179. display: flex
  180. width: 100%
  181. &.is-loading
  182. color: transparent !important
  183. pointer-events: none
  184. &:after
  185. +loader
  186. +center(1em)
  187. position: absolute !important
  188. &.is-static
  189. background-color: $button-static-background-color
  190. border-color: $button-static-border-color
  191. color: $button-static-color
  192. box-shadow: none
  193. pointer-events: none
  194. .buttons
  195. align-items: center
  196. display: flex
  197. flex-wrap: wrap
  198. justify-content: flex-start
  199. .button
  200. margin-bottom: 0.5rem
  201. &:not(:last-child)
  202. margin-right: 0.5rem
  203. &:last-child
  204. margin-bottom: -0.5rem
  205. &:not(:last-child)
  206. margin-bottom: 1rem
  207. &.has-addons
  208. .button
  209. &:not(:first-child)
  210. border-bottom-left-radius: 0
  211. border-top-left-radius: 0
  212. &:not(:last-child)
  213. border-bottom-right-radius: 0
  214. border-top-right-radius: 0
  215. margin-right: -1px
  216. &:last-child
  217. margin-right: 0
  218. &:hover,
  219. &.is-hovered
  220. z-index: 2
  221. &:focus,
  222. &.is-focused,
  223. &:active,
  224. &.is-active,
  225. &.is-selected
  226. z-index: 3
  227. &:hover
  228. z-index: 4
  229. &.is-centered
  230. justify-content: center
  231. &.is-right
  232. justify-content: flex-end