_button.scss 12 KB

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