_button.scss 13 KB

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