buttons.less 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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: 0 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. &.disabled.btn-info,
  92. &.disabled.btn-default,
  93. &[disabled].btn-info,
  94. &[disabled].btn-default,
  95. fieldset[disabled].btn-info,
  96. fieldset[disabled].btn-default & {
  97. // style only for deprecated classes
  98. .opacity(0.65);
  99. }
  100. }
  101. // Alternate buttons
  102. // --------------------------------------------------
  103. .btn-default {
  104. .button-variant(@btn-default-color; @btn-default-bg; @btn-default-border);
  105. }
  106. .btn-default-outline {
  107. .button-outline-variant(@btn-default-bg);
  108. }
  109. .btn-primary when (@is-new-css = false) {
  110. .button-variant(@btn-primary-color; @btn-primary-bg; @btn-primary-border);
  111. }
  112. .btn-primary when (@is-new-css = true) {
  113. .btn-borderless();
  114. }
  115. .btn-primary-on-primary-bg {
  116. .button-variant(@white; @ol-dark-green; @ol-dark-green);
  117. }
  118. // Success appears as green
  119. .btn-success {
  120. .btn-primary;
  121. }
  122. // Info appears as blue-green
  123. .btn-info {
  124. .button-variant(@btn-info-color; @btn-info-bg; @btn-info-border);
  125. }
  126. // Warning appears as orange
  127. .btn-warning {
  128. .button-variant(@btn-warning-color; @btn-warning-bg; @btn-warning-border);
  129. }
  130. // Danger and error appear as red
  131. .btn-danger when(@is-new-css = false) {
  132. .button-variant(@btn-danger-color; @btn-danger-bg; @btn-danger-border);
  133. }
  134. .btn-danger when(@is-new-css = true) {
  135. .btn-borderless(@white, @red, @red-60);
  136. }
  137. // Danger Ghost and error appear as light red with no border
  138. .btn-danger-ghost when (@is-new-css = false) {
  139. .button-variant(@btn-danger-ghost-color; @btn-danger-ghost-bg; @btn-danger-ghost-border);
  140. // hover for ghost acts different from typical variants, as it's default state has no bg
  141. &:hover {
  142. background-color: @red-10;
  143. }
  144. }
  145. .btn-danger-ghost when (@is-new-css = true) {
  146. .btn-borderless(@red-50, @btn-danger-ghost-bg, @red-10);
  147. }
  148. // btn-secondary
  149. .btn-secondary when(@is-new-css = false) {
  150. &:not(.btn-secondary-info) {
  151. .btn-default;
  152. }
  153. }
  154. .btn-secondary when(@is-new-css = true) {
  155. .btn-bordered();
  156. }
  157. // btn-info for old and btn-secondary for new
  158. .btn-secondary-info when(@is-new-css = false) {
  159. .btn-info;
  160. }
  161. .btn-secondary-info when(@is-new-css = true) {
  162. .btn-secondary;
  163. }
  164. .reset-btns {
  165. // reset all buttons back to their original colors
  166. .btn-danger {
  167. .btn-danger;
  168. }
  169. .btn-default {
  170. .btn-default;
  171. }
  172. .btn-default-outline {
  173. .btn-default-outline;
  174. }
  175. .btn-info {
  176. .btn-info;
  177. }
  178. .btn-primary {
  179. .btn-primary;
  180. }
  181. .btn-success {
  182. .btn-success;
  183. }
  184. .btn-warning {
  185. .btn-warning;
  186. }
  187. .btn-secondary {
  188. .btn-secondary;
  189. }
  190. }
  191. // Link buttons
  192. // -------------------------
  193. // Make a button look and behave like a link
  194. .btn-link {
  195. color: @link-color;
  196. font-weight: normal;
  197. cursor: pointer;
  198. border-radius: 0;
  199. &,
  200. &:active,
  201. &[disabled],
  202. fieldset[disabled] & {
  203. background-color: transparent;
  204. .box-shadow(none);
  205. }
  206. &,
  207. &:hover,
  208. &:focus,
  209. &:active {
  210. border-color: transparent;
  211. }
  212. &:hover,
  213. &:focus {
  214. color: @link-hover-color;
  215. text-decoration: underline;
  216. background-color: transparent;
  217. }
  218. &[disabled],
  219. fieldset[disabled] & {
  220. &:hover,
  221. &:focus {
  222. color: @btn-link-disabled-color;
  223. text-decoration: none;
  224. }
  225. }
  226. &.btn-danger {
  227. color: @ol-red;
  228. &:hover,
  229. &:focus {
  230. color: @ol-dark-red;
  231. }
  232. }
  233. }
  234. .btn-inline-link {
  235. .btn-link();
  236. padding: 0;
  237. font-size: inherit;
  238. vertical-align: inherit;
  239. }
  240. // Button Sizes
  241. // --------------------------------------------------
  242. .btn-xl {
  243. .button-size(
  244. @padding-large-vertical; @padding-large-horizontal; @font-size-h2;
  245. @line-height-large; @btn-border-radius-large
  246. );
  247. }
  248. .btn-lg {
  249. // line-height: ensure even-numbered height of button next to large input
  250. .button-size(
  251. @padding-large-vertical; @padding-large-horizontal; @font-size-large;
  252. @line-height-large; @btn-border-radius-large
  253. );
  254. }
  255. .btn-sm {
  256. // line-height: ensure proper height of button next to small input
  257. .button-size(
  258. @padding-small-vertical; @padding-small-horizontal; @font-size-small;
  259. @line-height-small; @btn-border-radius-small
  260. );
  261. }
  262. .btn-xs {
  263. .button-size(
  264. @padding-xs-vertical; @padding-xs-horizontal; @font-size-small;
  265. @line-height-small; @btn-border-radius-small
  266. );
  267. }
  268. // Block button
  269. // --------------------------------------------------
  270. .btn-block {
  271. display: block;
  272. width: 100%;
  273. padding-left: 0;
  274. padding-right: 0;
  275. }
  276. // Vertically space out multiple block buttons
  277. .btn-block + .btn-block {
  278. margin-top: 5px;
  279. }
  280. // Specificity overrides
  281. input[type='submit'],
  282. input[type='reset'],
  283. input[type='button'] {
  284. &.btn-block {
  285. width: 100%;
  286. }
  287. }
  288. .login-btn when(@is-new-css = true) {
  289. .btn;
  290. .btn-secondary;
  291. position: relative;
  292. padding-left: 20px;
  293. padding-right: 0;
  294. }
  295. .login-btn when(@is-new-css = false) {
  296. .btn;
  297. .btn-default;
  298. position: relative;
  299. padding-left: 20px;
  300. padding-right: 0;
  301. }