_button.scss 13 KB

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