buttons.less 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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-info-ghost when (@is-new-css = true) {
  146. .btn-borderless(@blue-50, @btn-info-ghost-bg, @blue-10);
  147. }
  148. // Info Ghost appear as info blue with no border
  149. .btn-info-ghost when (@is-new-css = false) {
  150. .button-variant(@btn-info-ghost-color; @btn-info-ghost-bg; @btn-info-ghost-border);
  151. // hover for ghost acts different from typical variants, as it's default state has no bg
  152. &:hover {
  153. background-color: @blue-10;
  154. }
  155. }
  156. // Inline button to fit text, without link styling.
  157. // TODO: generic class for other styles
  158. .btn-info-ghost-inline when (@is-new-css = true) {
  159. .btn-borderless(@blue-50, @btn-info-ghost-bg, @blue-10);
  160. padding: 0 !important;
  161. font-size: inherit !important;
  162. vertical-align: inherit;
  163. }
  164. .btn-info-ghost-inline when (@is-new-css = false) {
  165. .button-variant(@btn-info-ghost-color; @btn-info-ghost-bg; @btn-info-ghost-border);
  166. // hover for ghost acts different from typical variants, as it's default state has no bg
  167. &:hover {
  168. background-color: @blue-10;
  169. }
  170. padding: 0 !important;
  171. font-size: inherit !important;
  172. vertical-align: inherit;
  173. }
  174. .btn-danger-ghost when (@is-new-css = true) {
  175. .btn-borderless(@red-50, @btn-danger-ghost-bg, @red-10);
  176. }
  177. // btn-secondary
  178. .btn-secondary when(@is-new-css = false) {
  179. &:not(.btn-secondary-info) {
  180. .btn-default;
  181. }
  182. }
  183. .btn-secondary when(@is-new-css = true) {
  184. .btn-bordered();
  185. }
  186. // btn-info for old and btn-secondary for new
  187. .btn-secondary-info when(@is-new-css = false) {
  188. .btn-info;
  189. }
  190. .btn-secondary-info when(@is-new-css = true) {
  191. .btn-secondary;
  192. }
  193. // Buttons relating to premium features have a special background
  194. .btn-premium {
  195. .premium-background;
  196. color: @white;
  197. }
  198. .reset-btns {
  199. // reset all buttons back to their original colors
  200. .btn-danger {
  201. .btn-danger;
  202. }
  203. .btn-default {
  204. .btn-default;
  205. }
  206. .btn-default-outline {
  207. .btn-default-outline;
  208. }
  209. .btn-info {
  210. .btn-info;
  211. }
  212. .btn-primary {
  213. .btn-primary;
  214. }
  215. .btn-success {
  216. .btn-success;
  217. }
  218. .btn-warning {
  219. .btn-warning;
  220. }
  221. .btn-secondary {
  222. .btn-secondary;
  223. }
  224. }
  225. // Link buttons
  226. // -------------------------
  227. // Make a button look and behave like a link
  228. .btn-link {
  229. color: @link-color;
  230. font-weight: normal;
  231. cursor: pointer;
  232. border-radius: 0;
  233. &,
  234. &:active,
  235. &[disabled],
  236. fieldset[disabled] & {
  237. background-color: transparent;
  238. .box-shadow(none);
  239. }
  240. &,
  241. &:hover,
  242. &:focus,
  243. &:active {
  244. border-color: transparent;
  245. }
  246. &:hover,
  247. &:focus {
  248. color: @link-hover-color;
  249. text-decoration: underline;
  250. background-color: transparent;
  251. }
  252. &[disabled],
  253. fieldset[disabled] & {
  254. &:hover,
  255. &:focus {
  256. color: @btn-link-disabled-color;
  257. text-decoration: none;
  258. }
  259. }
  260. &.btn-danger {
  261. color: @ol-red;
  262. &:hover,
  263. &:focus {
  264. color: @ol-dark-red;
  265. }
  266. }
  267. }
  268. .btn-inline-link {
  269. .btn-link();
  270. padding: 0;
  271. font-size: inherit;
  272. vertical-align: inherit;
  273. }
  274. // Button Sizes
  275. // --------------------------------------------------
  276. .btn-xl {
  277. .button-size(
  278. @padding-large-vertical; @padding-large-horizontal; @font-size-h2;
  279. @line-height-large; @btn-border-radius-large
  280. );
  281. }
  282. .btn-lg {
  283. // line-height: ensure even-numbered height of button next to large input
  284. .button-size(
  285. @padding-large-vertical; @padding-large-horizontal; @font-size-large;
  286. @line-height-large; @btn-border-radius-large
  287. );
  288. }
  289. .btn-sm {
  290. // line-height: ensure proper height of button next to small input
  291. .button-size(
  292. @padding-small-vertical; @padding-small-horizontal; @font-size-small;
  293. @line-height-small; @btn-border-radius-small
  294. );
  295. }
  296. .btn-xs {
  297. .button-size(
  298. @padding-xs-vertical; @padding-xs-horizontal; @font-size-small;
  299. @line-height-small; @btn-border-radius-small
  300. );
  301. }
  302. // Block button
  303. // --------------------------------------------------
  304. .btn-block {
  305. display: block;
  306. width: 100%;
  307. padding-left: 0;
  308. padding-right: 0;
  309. }
  310. // Vertically space out multiple block buttons
  311. .btn-block + .btn-block {
  312. margin-top: 5px;
  313. }
  314. // Specificity overrides
  315. input[type='submit'],
  316. input[type='reset'],
  317. input[type='button'] {
  318. &.btn-block {
  319. width: 100%;
  320. }
  321. }
  322. .login-btn when(@is-new-css = true) {
  323. .btn;
  324. .btn-secondary;
  325. position: relative;
  326. padding-left: 20px;
  327. padding-right: 0;
  328. }
  329. .login-btn when(@is-new-css = false) {
  330. .btn;
  331. .btn-default;
  332. position: relative;
  333. padding-left: 20px;
  334. padding-right: 0;
  335. }
  336. .login-expand-more-btn {
  337. display: list-item;
  338. }