_button.scss 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  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. &.text-notransform {
  298. text-transform: initial;
  299. }
  300. &.button--icon {
  301. .icon {
  302. @include svg-icon(1.5em);
  303. }
  304. }
  305. @include media-breakpoint-up(sm) {
  306. font-size: 0.95em;
  307. padding: 0 1.4em;
  308. height: 3em;
  309. &.bicolor {
  310. padding-inline-start: 3.7em;
  311. &:before {
  312. width: 2em;
  313. line-height: 2.2em;
  314. font-size: 1.1rem;
  315. }
  316. }
  317. &.button-small.bicolor {
  318. // line-height: 2.2em;
  319. padding-inline-start: 3em;
  320. &:before {
  321. width: 1.8em;
  322. line-height: 1.65em;
  323. }
  324. }
  325. }
  326. }
  327. .button-small {
  328. padding: 0 0.8em;
  329. height: 2em;
  330. font-size: 0.95em;
  331. }
  332. .button-secondary {
  333. color: $color-button;
  334. background-color: transparent;
  335. }
  336. // Buttons which are only an icon
  337. .button.icon.text-replace {
  338. // iconfont
  339. font-size: 0; // unavoidable duplication of setting in icons.scss
  340. width: 1.8rem;
  341. height: 1.8rem;
  342. &:before {
  343. line-height: 1.7em;
  344. }
  345. @include media-breakpoint-up(sm) {
  346. width: 2.2rem;
  347. height: 2.2rem;
  348. &:before {
  349. line-height: 2.1em;
  350. }
  351. &.button-small {
  352. height: 1.8rem;
  353. width: 1.8rem;
  354. // stylelint-disable-next-line max-nesting-depth
  355. &:before {
  356. line-height: 1.7em;
  357. }
  358. }
  359. }
  360. }
  361. .button--icon.text-replace {
  362. font-size: 0;
  363. text-align: center;
  364. .icon {
  365. font-size: initial;
  366. @include svg-icon(1rem, middle);
  367. padding: 0.5em;
  368. }
  369. &.button-small {
  370. line-height: 1.7rem;
  371. height: 1.8rem;
  372. width: 1.8rem;
  373. .icon {
  374. padding: 0.25em;
  375. }
  376. }
  377. @include media-breakpoint-up(sm) {
  378. width: 2.2rem;
  379. height: 2.2rem;
  380. }
  381. }
  382. button.button.bicolor .icon-wrapper {
  383. line-height: 1.65em; // work around differences in a and button elements
  384. }
  385. .button-neutral {
  386. color: $color-grey-2;
  387. &:hover {
  388. color: $color-teal;
  389. }
  390. }
  391. .yes {
  392. background-color: $color-button-yes;
  393. border: 1px solid $color-button-yes;
  394. &.button-secondary {
  395. border: 1px solid $color-button-yes;
  396. color: $color-button-yes;
  397. background-color: transparent;
  398. }
  399. &:hover {
  400. color: $color-white;
  401. border-color: transparent;
  402. background-color: $color-button-yes-hover;
  403. }
  404. &.button-nobg:hover {
  405. color: $color-button-yes;
  406. background-color: transparent;
  407. }
  408. }
  409. .no,
  410. .serious {
  411. background-color: $color-button-no;
  412. border: 1px solid $color-button-no;
  413. &.button-secondary {
  414. border: 1px solid $color-button-no;
  415. color: $color-button-no;
  416. background-color: transparent;
  417. }
  418. &:hover {
  419. color: $color-white;
  420. border-color: transparent;
  421. background-color: $color-button-no-hover;
  422. }
  423. &.button-nobg:hover {
  424. color: $color-button-no;
  425. background-color: transparent;
  426. }
  427. }
  428. .button-nobg {
  429. border: 0;
  430. background-color: transparent;
  431. }
  432. .bicolor {
  433. border: 0;
  434. padding-inline-start: 3.5em;
  435. &:before {
  436. font-size: 1rem;
  437. position: absolute;
  438. // Remove once we drop support for Safari 13.
  439. // stylelint-disable-next-line property-disallowed-list
  440. left: 0;
  441. inset-inline-start: 0;
  442. top: 0;
  443. width: 2em;
  444. line-height: 1.85em;
  445. height: 100%;
  446. text-align: center;
  447. background-color: rgba(0, 0, 0, 0.2);
  448. display: block;
  449. }
  450. }
  451. .button-small.bicolor {
  452. padding-inline-start: 3.5em;
  453. &:before {
  454. width: 2em;
  455. font-size: 0.8rem;
  456. line-height: 1.65em;
  457. }
  458. }
  459. a.button {
  460. line-height: 2.4em;
  461. height: auto;
  462. &.button-small {
  463. line-height: 1.85em;
  464. }
  465. @include media-breakpoint-up(sm) {
  466. line-height: 2.9em;
  467. }
  468. }
  469. // Special styles to counteract Firefox's completely unwarranted assumptions about button styles
  470. input[type='submit'],
  471. input[type='reset'],
  472. input[type='button'],
  473. button {
  474. padding: 0 1em;
  475. @include media-breakpoint-up(sm) {
  476. &.button-small {
  477. height: 2em;
  478. }
  479. }
  480. }
  481. .button-group {
  482. @include clearfix;
  483. input[type='submit'],
  484. input[type='reset'],
  485. input[type='button'],
  486. .button,
  487. button {
  488. border-radius: 0;
  489. float: left;
  490. margin-inline-end: 1px;
  491. margin-inline-start: 0;
  492. &:only-child {
  493. border-radius: 3px;
  494. }
  495. &:first-child {
  496. border-radius: 3px 0 0 3px;
  497. }
  498. &:last-child {
  499. border-radius: 0 3px 3px 0;
  500. margin-inline-end: 0;
  501. }
  502. }
  503. &.button-group-square {
  504. &,
  505. input[type='submit'],
  506. input[type='reset'],
  507. input[type='button'],
  508. .button,
  509. button {
  510. border-radius: 0;
  511. }
  512. }
  513. }
  514. .multiple {
  515. padding: 0;
  516. max-width: 1024px - 50px;
  517. overflow: hidden;
  518. > li {
  519. @include row();
  520. border-radius: 2px;
  521. position: relative;
  522. overflow: hidden;
  523. background-color: $color-white;
  524. padding: 1em 10em 1em 1.5em; // 10em padding leaves room for controls
  525. margin-bottom: 1em;
  526. 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
  527. }
  528. &.moving {
  529. position: relative;
  530. }
  531. li.moving {
  532. position: absolute;
  533. width: 100%;
  534. }
  535. fieldset {
  536. padding-top: 0;
  537. padding-bottom: 0;
  538. }
  539. // Object controls
  540. .controls {
  541. position: absolute;
  542. z-index: 1;
  543. // Remove once we drop support for Safari 13.
  544. // stylelint-disable-next-line property-disallowed-list
  545. right: 1em;
  546. inset-inline-end: 1em;
  547. top: 1em;
  548. color: $color-white;
  549. li {
  550. float: left;
  551. margin-inline-end: 1px;
  552. &:last-child {
  553. margin-inline-end: 0;
  554. }
  555. }
  556. .disabled {
  557. display: none;
  558. visibility: hidden;
  559. }
  560. }
  561. }
  562. // wrapper around add button for multiple objects
  563. .add {
  564. font-weight: 700;
  565. cursor: pointer;
  566. margin-top: 0;
  567. margin-bottom: 0;
  568. padding-top: 1em;
  569. padding-bottom: 2em;
  570. clear: both;
  571. }