buttons.less 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. // btn-secondary
  138. .btn-secondary when(@is-new-css = false) {
  139. &:not(.btn-secondary-info) {
  140. .btn-default;
  141. }
  142. }
  143. .btn-secondary when(@is-new-css = true) {
  144. .btn-bordered();
  145. }
  146. // btn-info for old and btn-secondary for new
  147. .btn-secondary-info when(@is-new-css = false) {
  148. .btn-info;
  149. }
  150. .btn-secondary-info when(@is-new-css = true) {
  151. .btn-secondary;
  152. }
  153. .reset-btns {
  154. // reset all buttons back to their original colors
  155. .btn-danger {
  156. .btn-danger;
  157. }
  158. .btn-default {
  159. .btn-default;
  160. }
  161. .btn-default-outline {
  162. .btn-default-outline;
  163. }
  164. .btn-info {
  165. .btn-info;
  166. }
  167. .btn-primary {
  168. .btn-primary;
  169. }
  170. .btn-success {
  171. .btn-success;
  172. }
  173. .btn-warning {
  174. .btn-warning;
  175. }
  176. .btn-secondary {
  177. .btn-secondary;
  178. }
  179. }
  180. // Link buttons
  181. // -------------------------
  182. // Make a button look and behave like a link
  183. .btn-link {
  184. color: @link-color;
  185. font-weight: normal;
  186. cursor: pointer;
  187. border-radius: 0;
  188. &,
  189. &:active,
  190. &[disabled],
  191. fieldset[disabled] & {
  192. background-color: transparent;
  193. .box-shadow(none);
  194. }
  195. &,
  196. &:hover,
  197. &:focus,
  198. &:active {
  199. border-color: transparent;
  200. }
  201. &:hover,
  202. &:focus {
  203. color: @link-hover-color;
  204. text-decoration: underline;
  205. background-color: transparent;
  206. }
  207. &[disabled],
  208. fieldset[disabled] & {
  209. &:hover,
  210. &:focus {
  211. color: @btn-link-disabled-color;
  212. text-decoration: none;
  213. }
  214. }
  215. &.btn-danger {
  216. color: @ol-red;
  217. &:hover,
  218. &:focus {
  219. color: @ol-dark-red;
  220. }
  221. }
  222. }
  223. .btn-inline-link {
  224. .btn-link();
  225. padding: 0;
  226. font-size: inherit;
  227. vertical-align: inherit;
  228. }
  229. // Button Sizes
  230. // --------------------------------------------------
  231. .btn-xl {
  232. .button-size(
  233. @padding-large-vertical; @padding-large-horizontal; @font-size-h2;
  234. @line-height-large; @btn-border-radius-large
  235. );
  236. }
  237. .btn-lg {
  238. // line-height: ensure even-numbered height of button next to large input
  239. .button-size(
  240. @padding-large-vertical; @padding-large-horizontal; @font-size-large;
  241. @line-height-large; @btn-border-radius-large
  242. );
  243. }
  244. .btn-sm {
  245. // line-height: ensure proper height of button next to small input
  246. .button-size(
  247. @padding-small-vertical; @padding-small-horizontal; @font-size-small;
  248. @line-height-small; @btn-border-radius-small
  249. );
  250. }
  251. .btn-xs {
  252. .button-size(
  253. @padding-xs-vertical; @padding-xs-horizontal; @font-size-small;
  254. @line-height-small; @btn-border-radius-small
  255. );
  256. }
  257. // Block button
  258. // --------------------------------------------------
  259. .btn-block {
  260. display: block;
  261. width: 100%;
  262. padding-left: 0;
  263. padding-right: 0;
  264. }
  265. // Vertically space out multiple block buttons
  266. .btn-block + .btn-block {
  267. margin-top: 5px;
  268. }
  269. // Specificity overrides
  270. input[type='submit'],
  271. input[type='reset'],
  272. input[type='button'] {
  273. &.btn-block {
  274. width: 100%;
  275. }
  276. }
  277. .login-btn when(@is-new-css = true) {
  278. .btn;
  279. .btn-secondary;
  280. position: relative;
  281. padding-left: 20px;
  282. padding-right: 0;
  283. }
  284. .login-btn when(@is-new-css = false) {
  285. .btn;
  286. .btn-default;
  287. position: relative;
  288. padding-left: 20px;
  289. padding-right: 0;
  290. }