buttons.less 6.9 KB

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