buttons.less 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. //
  2. // Buttons
  3. // --------------------------------------------------
  4. // Base styles
  5. // --------------------------------------------------
  6. .btn when(@is-new-css = false) {
  7. display: inline-block;
  8. margin-bottom: 0; // For input.btn
  9. font-weight: @btn-font-weight;
  10. text-align: center;
  11. vertical-align: middle;
  12. cursor: pointer;
  13. background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
  14. border: @btn-border-width solid transparent;
  15. border-bottom: @btn-border-bottom-width solid transparent;
  16. white-space: nowrap;
  17. .button-size(
  18. @padding-base-vertical; @padding-base-horizontal; @font-size-base;
  19. @line-height-base; @btn-border-radius-base
  20. );
  21. .user-select(none);
  22. &,
  23. &:active,
  24. &.active {
  25. &:focus {
  26. .tab-focus();
  27. }
  28. }
  29. &:hover,
  30. &:focus {
  31. color: @btn-default-color;
  32. text-decoration: none;
  33. }
  34. &:active,
  35. &.active {
  36. outline: 0;
  37. background-image: none;
  38. .box-shadow(inset 0 3px 5px rgba(0, 0, 0, 0.125));
  39. }
  40. &.disabled,
  41. &[disabled],
  42. fieldset[disabled] & {
  43. cursor: not-allowed;
  44. pointer-events: none; // Future-proof disabling of clicks
  45. .opacity(0.65);
  46. .box-shadow(none);
  47. }
  48. }
  49. .btn when(@is-new-css = true) {
  50. display: inline-block;
  51. margin-bottom: 0; // For input.btn
  52. font-weight: @btn-font-weight;
  53. text-align: center;
  54. vertical-align: middle;
  55. cursor: pointer;
  56. border: @border-size solid transparent;
  57. white-space: nowrap;
  58. .button-size(
  59. @padding-base-vertical; @padding-base-horizontal; @font-size-base;
  60. @line-height-base; @btn-border-radius-base
  61. );
  62. .user-select(none);
  63. &,
  64. &:active,
  65. &.active {
  66. &:focus {
  67. .tab-focus();
  68. }
  69. }
  70. &:hover,
  71. &:focus {
  72. color: @btn-default-color;
  73. text-decoration: none;
  74. }
  75. // &:active,
  76. // &.active {
  77. // }
  78. &.disabled,
  79. &[disabled],
  80. fieldset[disabled] & {
  81. &,
  82. &:hover,
  83. &:focus,
  84. &:active,
  85. &.active {
  86. cursor: not-allowed;
  87. opacity: 1; //needed to override deprecated styling in individual classes
  88. .box-shadow(none);
  89. }
  90. }
  91. }
  92. // Alternate buttons
  93. // --------------------------------------------------
  94. .btn-default {
  95. .button-variant(@btn-default-color; @btn-default-bg; @btn-default-border);
  96. }
  97. .btn-default-outline {
  98. .button-outline-variant(@btn-default-bg);
  99. }
  100. .btn-primary when (@is-new-css = false) {
  101. .button-variant(@btn-primary-color; @btn-primary-bg; @btn-primary-border);
  102. }
  103. .btn-primary when (@is-new-css = true) {
  104. .btn-borderless();
  105. }
  106. .btn-primary-on-primary-bg {
  107. .button-variant(@white; @ol-dark-green; @ol-dark-green);
  108. }
  109. // Success appears as green
  110. .btn-success {
  111. .btn-primary;
  112. }
  113. // Info appears as blue-green
  114. .btn-info {
  115. .button-variant(@btn-info-color; @btn-info-bg; @btn-info-border);
  116. }
  117. // Warning appears as orange
  118. .btn-warning {
  119. .button-variant(@btn-warning-color; @btn-warning-bg; @btn-warning-border);
  120. }
  121. // Danger and error appear as red
  122. .btn-danger {
  123. .button-variant(@btn-danger-color; @btn-danger-bg; @btn-danger-border);
  124. }
  125. // btn-secondary
  126. .btn-secondary when(@is-new-css = false) {
  127. &:not(.btn-secondary-info) {
  128. .btn-default;
  129. }
  130. }
  131. .btn-secondary when(@is-new-css = true) {
  132. .btn-bordered();
  133. }
  134. // btn-info for old and btn-secondary for new
  135. .btn-secondary-info when(@is-new-css = false) {
  136. .btn-info;
  137. }
  138. .btn-secondary-info when(@is-new-css = true) {
  139. .btn-secondary;
  140. }
  141. .reset-btns {
  142. // reset all buttons back to their original colors
  143. .btn-danger {
  144. .btn-danger;
  145. }
  146. .btn-default {
  147. .btn-default;
  148. }
  149. .btn-default-outline {
  150. .btn-default-outline;
  151. }
  152. .btn-info {
  153. .btn-info;
  154. }
  155. .btn-primary {
  156. .btn-primary;
  157. }
  158. .btn-success {
  159. .btn-success;
  160. }
  161. .btn-warning {
  162. .btn-warning;
  163. }
  164. .btn-secondary {
  165. .btn-secondary;
  166. }
  167. }
  168. // Link buttons
  169. // -------------------------
  170. // Make a button look and behave like a link
  171. .btn-link {
  172. color: @link-color;
  173. font-weight: normal;
  174. cursor: pointer;
  175. border-radius: 0;
  176. &,
  177. &:active,
  178. &[disabled],
  179. fieldset[disabled] & {
  180. background-color: transparent;
  181. .box-shadow(none);
  182. }
  183. &,
  184. &:hover,
  185. &:focus,
  186. &:active {
  187. border-color: transparent;
  188. }
  189. &:hover,
  190. &:focus {
  191. color: @link-hover-color;
  192. text-decoration: underline;
  193. background-color: transparent;
  194. }
  195. &[disabled],
  196. fieldset[disabled] & {
  197. &:hover,
  198. &:focus {
  199. color: @btn-link-disabled-color;
  200. text-decoration: none;
  201. }
  202. }
  203. &.btn-danger {
  204. color: @ol-red;
  205. &:hover,
  206. &:focus {
  207. color: @ol-dark-red;
  208. }
  209. }
  210. }
  211. .btn-inline-link {
  212. .btn-link();
  213. padding: 0;
  214. font-size: inherit;
  215. vertical-align: inherit;
  216. }
  217. // Button Sizes
  218. // --------------------------------------------------
  219. .btn-xl {
  220. .button-size(
  221. @padding-large-vertical; @padding-large-horizontal; @font-size-h2;
  222. @line-height-large; @btn-border-radius-large
  223. );
  224. }
  225. .btn-lg {
  226. // line-height: ensure even-numbered height of button next to large input
  227. .button-size(
  228. @padding-large-vertical; @padding-large-horizontal; @font-size-large;
  229. @line-height-large; @btn-border-radius-large
  230. );
  231. }
  232. .btn-sm {
  233. // line-height: ensure proper height of button next to small input
  234. .button-size(
  235. @padding-small-vertical; @padding-small-horizontal; @font-size-small;
  236. @line-height-small; @btn-border-radius-small
  237. );
  238. }
  239. .btn-xs {
  240. .button-size(
  241. @padding-xs-vertical; @padding-xs-horizontal; @font-size-small;
  242. @line-height-small; @btn-border-radius-small
  243. );
  244. }
  245. // Block button
  246. // --------------------------------------------------
  247. .btn-block {
  248. display: block;
  249. width: 100%;
  250. padding-left: 0;
  251. padding-right: 0;
  252. }
  253. // Vertically space out multiple block buttons
  254. .btn-block + .btn-block {
  255. margin-top: 5px;
  256. }
  257. // Specificity overrides
  258. input[type='submit'],
  259. input[type='reset'],
  260. input[type='button'] {
  261. &.btn-block {
  262. width: 100%;
  263. }
  264. }