_button.scss 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. @use 'sass:color';
  2. // Core button style
  3. // Note that these styles include methods to render buttons the same x-browser, described here:
  4. // http: //cbjdigital.com/blog/2010/08/bulletproof_css_input_button_heights
  5. // input[type=submit],
  6. // input[type=reset],
  7. // input[type=button],
  8. .button {
  9. border-radius: 3px;
  10. font-family: $font-sans;
  11. width: auto;
  12. height: 2.4em;
  13. padding: 0 1em;
  14. font-size: 0.9em;
  15. font-weight: normal;
  16. vertical-align: middle;
  17. display: inline-block;
  18. background-color: $color-button;
  19. border: 1px solid $color-button;
  20. color: $color-white;
  21. text-decoration: none;
  22. text-transform: uppercase;
  23. white-space: nowrap;
  24. position: relative;
  25. overflow: hidden;
  26. box-sizing: border-box;
  27. -webkit-font-smoothing: auto;
  28. // stylelint-disable-next-line property-no-vendor-prefix
  29. -moz-appearance: none;
  30. transition: background-color 0.1s ease;
  31. &:hover {
  32. color: $color-teal;
  33. }
  34. &.yes {
  35. background-color: $color-button-yes;
  36. border: 1px solid $color-button-yes;
  37. &.button-secondary {
  38. border: 1px solid $color-button-yes;
  39. color: $color-button-yes;
  40. background-color: transparent;
  41. }
  42. &:hover {
  43. color: $color-white;
  44. border-color: transparent;
  45. background-color: $color-button-yes-hover;
  46. }
  47. &.button-nobg:hover {
  48. color: $color-button-yes;
  49. background-color: transparent;
  50. }
  51. }
  52. &.warning {
  53. background-color: $color-button-warning;
  54. border: 1px solid $color-button-warning;
  55. &.button-secondary {
  56. border: 1px solid $color-button-warning;
  57. color: $color-button-warning;
  58. background-color: transparent;
  59. }
  60. &:hover {
  61. color: $color-white;
  62. border-color: transparent;
  63. background-color: $color-button-warning-hover;
  64. }
  65. &.button-nobg:hover {
  66. color: $color-button-warning;
  67. background-color: transparent;
  68. }
  69. }
  70. &.no,
  71. &.serious {
  72. background-color: $color-button-no;
  73. border: 1px solid $color-button-no;
  74. &.button-secondary {
  75. border: 1px solid $color-button-no;
  76. color: $color-button-no;
  77. background-color: transparent;
  78. }
  79. &:hover {
  80. color: $color-white;
  81. border-color: transparent;
  82. background-color: $color-button-no-hover;
  83. }
  84. &.button-nobg:hover {
  85. color: $color-button-no;
  86. background-color: transparent;
  87. }
  88. }
  89. &.button-nobg {
  90. border: 0;
  91. background-color: transparent;
  92. }
  93. &.bicolor {
  94. border: 1px solid transparent;
  95. padding-left: 3.5em;
  96. &:before {
  97. // iconfont
  98. font-size: 1rem;
  99. position: absolute;
  100. left: 0;
  101. top: 0;
  102. width: 2em;
  103. line-height: 1.85em;
  104. height: 100%;
  105. text-align: center;
  106. background-color: rgba(0, 0, 0, 0.2);
  107. display: block;
  108. border-top-left-radius: inherit;
  109. border-bottom-left-radius: inherit;
  110. }
  111. .icon-wrapper {
  112. background-color: rgba(0, 0, 0, 0.2);
  113. display: block;
  114. position: absolute;
  115. left: 0;
  116. top: 0;
  117. width: 3em;
  118. line-height: 1.85em;
  119. height: 100%;
  120. text-align: center;
  121. border-top-left-radius: inherit;
  122. border-bottom-left-radius: inherit;
  123. }
  124. &.button--icon {
  125. &:before {
  126. display: none; // TODO: remove once the icon font styles are gone
  127. }
  128. .icon {
  129. @include svg-icon(1rem);
  130. padding: 0.75em;
  131. }
  132. }
  133. &.button--icon-flipped {
  134. .icon {
  135. transform: scaleX(-1);
  136. }
  137. }
  138. &.button-secondary {
  139. border: 1px solid rgba(0, 0, 0, 0.2);
  140. }
  141. }
  142. &.button-small.bicolor {
  143. padding-left: 3.5em;
  144. .icon-wrapper {
  145. width: 2em;
  146. }
  147. &.button--icon .icon {
  148. @include svg-icon(0.9rem);
  149. padding: 0.25em;
  150. }
  151. }
  152. // + input[type=submit],
  153. // + input[type=reset],
  154. // + input[type=button],
  155. + .button {
  156. // + button {
  157. margin-left: 1em;
  158. }
  159. // A completely unstyled button
  160. &.unbutton {
  161. border-radius: 0;
  162. width: auto;
  163. height: auto;
  164. padding: 0;
  165. font-size: inherit;
  166. font-weight: normal;
  167. vertical-align: middle;
  168. display: inline;
  169. background-color: transparent;
  170. border: 0;
  171. color: inherit;
  172. text-decoration: none;
  173. text-transform: uppercase;
  174. white-space: nowrap;
  175. position: relative;
  176. overflow: hidden;
  177. box-sizing: border-box;
  178. -webkit-font-smoothing: auto;
  179. // stylelint-disable-next-line property-no-vendor-prefix
  180. -moz-appearance: none;
  181. &:hover,
  182. &:focus,
  183. &:active {
  184. background-color: transparent;
  185. }
  186. }
  187. // stylelint-disable-next-line no-duplicate-selectors
  188. &:hover {
  189. background-color: $color-button-hover;
  190. color: $color-white;
  191. border-color: transparent;
  192. &.hover-no {
  193. background-color: $color-button-no;
  194. }
  195. }
  196. &.button-longrunning {
  197. span {
  198. // iconfont
  199. @include transition(all 0.3s ease);
  200. transform: scale(0.9);
  201. display: inline-block;
  202. height: 0.9em;
  203. position: relative;
  204. opacity: 0;
  205. width: 0;
  206. visibility: hidden;
  207. text-align: center;
  208. padding-right: 0;
  209. }
  210. em {
  211. font-style: normal;
  212. }
  213. &.button-longrunning-active span {
  214. // iconfont
  215. transform: scale(1);
  216. visibility: visible;
  217. width: 1em;
  218. height: 1em;
  219. opacity: 0.8;
  220. padding-right: 0.5em;
  221. }
  222. span.icon-spinner:after {
  223. // iconfont
  224. text-align: center;
  225. position: absolute;
  226. left: 0;
  227. margin: 0;
  228. line-height: 1em;
  229. display: inline-block;
  230. font-size: 1em;
  231. }
  232. svg.icon-spinner {
  233. @include transition(all 0.3s ease);
  234. display: none;
  235. }
  236. &.button-longrunning-active svg.icon-spinner {
  237. @include svg-icon();
  238. transform: scale(1);
  239. display: inline-block;
  240. opacity: 0.8;
  241. padding: 0;
  242. margin-right: 0.5em;
  243. }
  244. &.button-longrunning-active .button-longrunning__icon {
  245. display: none;
  246. }
  247. }
  248. &:disabled,
  249. &[disabled],
  250. &.disabled {
  251. background-color: $color-grey-3;
  252. border-color: $color-grey-3;
  253. color: $color-grey-2;
  254. cursor: default;
  255. }
  256. &.button-secondary:disabled,
  257. &.button-secondary[disabled],
  258. &.button-secondary.disabled {
  259. background-color: $color-white;
  260. border-color: $color-grey-3;
  261. color: $color-grey-3;
  262. }
  263. &.button-nostroke {
  264. border: 0;
  265. }
  266. &.button-strokeonhover {
  267. border: 1px solid transparent;
  268. &:hover {
  269. border-color: $color-grey-2;
  270. }
  271. &.button-nobg:hover {
  272. background-color: transparent;
  273. }
  274. }
  275. &.text-notransform {
  276. text-transform: initial;
  277. }
  278. &.button--icon {
  279. .icon {
  280. @include svg-icon(1.5em);
  281. }
  282. }
  283. @include media-breakpoint-up(sm) {
  284. font-size: 0.95em;
  285. padding: 0 1.4em;
  286. height: 3em;
  287. &.bicolor {
  288. padding-left: 3.7em;
  289. &:before {
  290. width: 2em;
  291. line-height: 2.2em;
  292. font-size: 1.1rem;
  293. }
  294. }
  295. &.button-small.bicolor {
  296. // line-height: 2.2em;
  297. padding-left: 3em;
  298. &:before {
  299. width: 1.8em;
  300. line-height: 1.65em;
  301. }
  302. }
  303. }
  304. }
  305. .button-small {
  306. padding: 0 0.8em;
  307. height: 2em;
  308. font-size: 0.95em;
  309. }
  310. .button-secondary {
  311. color: $color-button;
  312. background-color: transparent;
  313. }
  314. // Buttons which are only an icon
  315. .button.icon.text-replace {
  316. // iconfont
  317. font-size: 0; // unavoidable duplication of setting in icons.scss
  318. width: 1.8rem;
  319. height: 1.8rem;
  320. &:before {
  321. line-height: 1.7em;
  322. }
  323. @include media-breakpoint-up(sm) {
  324. width: 2.2rem;
  325. height: 2.2rem;
  326. &:before {
  327. line-height: 2.1em;
  328. }
  329. &.button-small {
  330. height: 1.8rem;
  331. width: 1.8rem;
  332. // stylelint-disable-next-line max-nesting-depth
  333. &:before {
  334. line-height: 1.7em;
  335. }
  336. }
  337. }
  338. }
  339. .button--icon.text-replace {
  340. font-size: 0;
  341. text-align: center;
  342. .icon {
  343. font-size: initial;
  344. @include svg-icon(1rem, middle);
  345. padding: 0.5em;
  346. }
  347. &.button-small {
  348. line-height: 1.7rem;
  349. height: 1.8rem;
  350. width: 1.8rem;
  351. .icon {
  352. padding: 0.25em;
  353. }
  354. }
  355. @include media-breakpoint-up(sm) {
  356. width: 2.2rem;
  357. height: 2.2rem;
  358. }
  359. }
  360. button.button.bicolor .icon-wrapper {
  361. line-height: 1.65em; // work around differences in a and button elements
  362. }
  363. .button-neutral {
  364. color: $color-grey-2;
  365. &:hover {
  366. color: $color-teal;
  367. }
  368. }
  369. .yes {
  370. background-color: $color-button-yes;
  371. border: 1px solid $color-button-yes;
  372. &.button-secondary {
  373. border: 1px solid $color-button-yes;
  374. color: $color-button-yes;
  375. background-color: transparent;
  376. }
  377. &:hover {
  378. color: $color-white;
  379. border-color: transparent;
  380. background-color: $color-button-yes-hover;
  381. }
  382. &.button-nobg:hover {
  383. color: $color-button-yes;
  384. background-color: transparent;
  385. }
  386. }
  387. .no,
  388. .serious {
  389. background-color: $color-button-no;
  390. border: 1px solid $color-button-no;
  391. &.button-secondary {
  392. border: 1px solid $color-button-no;
  393. color: $color-button-no;
  394. background-color: transparent;
  395. }
  396. &:hover {
  397. color: $color-white;
  398. border-color: transparent;
  399. background-color: $color-button-no-hover;
  400. }
  401. &.button-nobg:hover {
  402. color: $color-button-no;
  403. background-color: transparent;
  404. }
  405. }
  406. .button-nobg {
  407. border: 0;
  408. background-color: transparent;
  409. }
  410. .bicolor {
  411. border: 0;
  412. padding-left: 3.5em;
  413. &:before {
  414. font-size: 1rem;
  415. position: absolute;
  416. left: 0;
  417. top: 0;
  418. width: 2em;
  419. line-height: 1.85em;
  420. height: 100%;
  421. text-align: center;
  422. background-color: rgba(0, 0, 0, 0.2);
  423. display: block;
  424. }
  425. }
  426. .button-small.bicolor {
  427. padding-left: 3.5em;
  428. &:before {
  429. width: 2em;
  430. font-size: 0.8rem;
  431. line-height: 1.65em;
  432. }
  433. }
  434. a.button {
  435. line-height: 2.4em;
  436. height: auto;
  437. &.button-small {
  438. line-height: 1.85em;
  439. }
  440. @include media-breakpoint-up(sm) {
  441. line-height: 2.9em;
  442. }
  443. }
  444. // Special styles to counteract Firefox's completely unwarranted assumptions about button styles
  445. input[type='submit'],
  446. input[type='reset'],
  447. input[type='button'],
  448. button {
  449. padding: 0 1em;
  450. @include media-breakpoint-up(sm) {
  451. &.button-small {
  452. height: 2em;
  453. }
  454. }
  455. }
  456. .button-group {
  457. @include clearfix;
  458. input[type='submit'],
  459. input[type='reset'],
  460. input[type='button'],
  461. .button,
  462. button {
  463. border-radius: 0;
  464. float: left;
  465. margin-right: 1px;
  466. margin-left: 0;
  467. &:only-child {
  468. border-radius: 3px;
  469. }
  470. &:first-child {
  471. border-radius: 3px 0 0 3px;
  472. }
  473. &:last-child {
  474. border-radius: 0 3px 3px 0;
  475. margin-right: 0;
  476. }
  477. }
  478. &.button-group-square {
  479. &,
  480. input[type='submit'],
  481. input[type='reset'],
  482. input[type='button'],
  483. .button,
  484. button {
  485. border-radius: 0;
  486. }
  487. }
  488. }
  489. .multiple {
  490. padding: 0;
  491. max-width: 1024px - 50px;
  492. overflow: hidden;
  493. > li {
  494. @include row();
  495. border-radius: 2px;
  496. position: relative;
  497. overflow: hidden;
  498. background-color: $color-white;
  499. padding: 1em 10em 1em 1.5em; // 10em padding leaves room for controls
  500. margin-bottom: 1em;
  501. border: 1px solid color.adjust($color-grey-4, $lightness: 3%); // really trying to avoid creating more greys, but this one is better than grey 4 or 5
  502. }
  503. &.moving {
  504. position: relative;
  505. }
  506. li.moving {
  507. position: absolute;
  508. width: 100%;
  509. }
  510. fieldset {
  511. padding-top: 0;
  512. padding-bottom: 0;
  513. }
  514. // Object controls
  515. .controls {
  516. position: absolute;
  517. z-index: 1;
  518. right: 1em;
  519. top: 1em;
  520. color: $color-white;
  521. li {
  522. float: left;
  523. margin-right: 1px;
  524. &:last-child {
  525. margin-right: 0;
  526. }
  527. }
  528. .disabled {
  529. display: none;
  530. visibility: hidden;
  531. }
  532. }
  533. }
  534. // wrapper around add button for multiple objects
  535. .add {
  536. font-weight: 700;
  537. cursor: pointer;
  538. margin-top: 0;
  539. margin-bottom: 0;
  540. padding-top: 1em;
  541. padding-bottom: 2em;
  542. clear: both;
  543. }