_button.scss 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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. &-active {
  214. display: inline-flex;
  215. justify-content: center;
  216. align-items: center;
  217. }
  218. &-active span {
  219. // iconfont
  220. transform: scale(1);
  221. visibility: visible;
  222. width: 1em;
  223. height: 1em;
  224. opacity: 0.8;
  225. padding-right: 0.5em;
  226. }
  227. span.icon-spinner:after {
  228. // iconfont
  229. text-align: center;
  230. position: absolute;
  231. left: 0;
  232. margin: 0;
  233. line-height: 1em;
  234. display: inline-block;
  235. font-size: 1em;
  236. }
  237. svg.icon-spinner {
  238. @include transition(all 0.3s ease);
  239. display: none;
  240. }
  241. &-active svg.icon-spinner {
  242. @include svg-icon();
  243. display: inline-block;
  244. opacity: 0.8;
  245. padding: 0;
  246. }
  247. &-active .button-longrunning__icon {
  248. display: none;
  249. }
  250. }
  251. &:disabled,
  252. &[disabled],
  253. &.disabled {
  254. background-color: $color-grey-3;
  255. border-color: $color-grey-3;
  256. color: $color-grey-2;
  257. cursor: default;
  258. }
  259. &.button-secondary:disabled,
  260. &.button-secondary[disabled],
  261. &.button-secondary.disabled {
  262. background-color: $color-white;
  263. border-color: $color-grey-3;
  264. color: $color-grey-3;
  265. }
  266. &.button-nostroke {
  267. border: 0;
  268. }
  269. &.button-strokeonhover {
  270. border: 1px solid transparent;
  271. &:hover {
  272. border-color: $color-grey-2;
  273. }
  274. &.button-nobg:hover {
  275. background-color: transparent;
  276. }
  277. }
  278. &.text-notransform {
  279. text-transform: initial;
  280. }
  281. &.button--icon {
  282. .icon {
  283. @include svg-icon(1.5em);
  284. }
  285. }
  286. @include media-breakpoint-up(sm) {
  287. font-size: 0.95em;
  288. padding: 0 1.4em;
  289. height: 3em;
  290. &.bicolor {
  291. padding-left: 3.7em;
  292. &:before {
  293. width: 2em;
  294. line-height: 2.2em;
  295. font-size: 1.1rem;
  296. }
  297. }
  298. &.button-small.bicolor {
  299. // line-height: 2.2em;
  300. padding-left: 3em;
  301. &:before {
  302. width: 1.8em;
  303. line-height: 1.65em;
  304. }
  305. }
  306. }
  307. }
  308. .button-small {
  309. padding: 0 0.8em;
  310. height: 2em;
  311. font-size: 0.95em;
  312. }
  313. .button-secondary {
  314. color: $color-button;
  315. background-color: transparent;
  316. }
  317. // Buttons which are only an icon
  318. .button.icon.text-replace {
  319. // iconfont
  320. font-size: 0; // unavoidable duplication of setting in icons.scss
  321. width: 1.8rem;
  322. height: 1.8rem;
  323. &:before {
  324. line-height: 1.7em;
  325. }
  326. @include media-breakpoint-up(sm) {
  327. width: 2.2rem;
  328. height: 2.2rem;
  329. &:before {
  330. line-height: 2.1em;
  331. }
  332. &.button-small {
  333. height: 1.8rem;
  334. width: 1.8rem;
  335. // stylelint-disable-next-line max-nesting-depth
  336. &:before {
  337. line-height: 1.7em;
  338. }
  339. }
  340. }
  341. }
  342. .button--icon.text-replace {
  343. font-size: 0;
  344. text-align: center;
  345. .icon {
  346. font-size: initial;
  347. @include svg-icon(1rem, middle);
  348. padding: 0.5em;
  349. }
  350. &.button-small {
  351. line-height: 1.7rem;
  352. height: 1.8rem;
  353. width: 1.8rem;
  354. .icon {
  355. padding: 0.25em;
  356. }
  357. }
  358. @include media-breakpoint-up(sm) {
  359. width: 2.2rem;
  360. height: 2.2rem;
  361. }
  362. }
  363. button.button.bicolor .icon-wrapper {
  364. line-height: 1.65em; // work around differences in a and button elements
  365. }
  366. .button-neutral {
  367. color: $color-grey-2;
  368. &:hover {
  369. color: $color-teal;
  370. }
  371. }
  372. .yes {
  373. background-color: $color-button-yes;
  374. border: 1px solid $color-button-yes;
  375. &.button-secondary {
  376. border: 1px solid $color-button-yes;
  377. color: $color-button-yes;
  378. background-color: transparent;
  379. }
  380. &:hover {
  381. color: $color-white;
  382. border-color: transparent;
  383. background-color: $color-button-yes-hover;
  384. }
  385. &.button-nobg:hover {
  386. color: $color-button-yes;
  387. background-color: transparent;
  388. }
  389. }
  390. .no,
  391. .serious {
  392. background-color: $color-button-no;
  393. border: 1px solid $color-button-no;
  394. &.button-secondary {
  395. border: 1px solid $color-button-no;
  396. color: $color-button-no;
  397. background-color: transparent;
  398. }
  399. &:hover {
  400. color: $color-white;
  401. border-color: transparent;
  402. background-color: $color-button-no-hover;
  403. }
  404. &.button-nobg:hover {
  405. color: $color-button-no;
  406. background-color: transparent;
  407. }
  408. }
  409. .button-nobg {
  410. border: 0;
  411. background-color: transparent;
  412. }
  413. .bicolor {
  414. border: 0;
  415. padding-left: 3.5em;
  416. &:before {
  417. font-size: 1rem;
  418. position: absolute;
  419. left: 0;
  420. top: 0;
  421. width: 2em;
  422. line-height: 1.85em;
  423. height: 100%;
  424. text-align: center;
  425. background-color: rgba(0, 0, 0, 0.2);
  426. display: block;
  427. }
  428. }
  429. .button-small.bicolor {
  430. padding-left: 3.5em;
  431. &:before {
  432. width: 2em;
  433. font-size: 0.8rem;
  434. line-height: 1.65em;
  435. }
  436. }
  437. a.button {
  438. line-height: 2.4em;
  439. height: auto;
  440. &.button-small {
  441. line-height: 1.85em;
  442. }
  443. @include media-breakpoint-up(sm) {
  444. line-height: 2.9em;
  445. }
  446. }
  447. // Special styles to counteract Firefox's completely unwarranted assumptions about button styles
  448. input[type='submit'],
  449. input[type='reset'],
  450. input[type='button'],
  451. button {
  452. padding: 0 1em;
  453. @include media-breakpoint-up(sm) {
  454. &.button-small {
  455. height: 2em;
  456. }
  457. }
  458. }
  459. .button-group {
  460. @include clearfix;
  461. input[type='submit'],
  462. input[type='reset'],
  463. input[type='button'],
  464. .button,
  465. button {
  466. border-radius: 0;
  467. float: left;
  468. margin-right: 1px;
  469. margin-left: 0;
  470. &:only-child {
  471. border-radius: 3px;
  472. }
  473. &:first-child {
  474. border-radius: 3px 0 0 3px;
  475. }
  476. &:last-child {
  477. border-radius: 0 3px 3px 0;
  478. margin-right: 0;
  479. }
  480. }
  481. &.button-group-square {
  482. &,
  483. input[type='submit'],
  484. input[type='reset'],
  485. input[type='button'],
  486. .button,
  487. button {
  488. border-radius: 0;
  489. }
  490. }
  491. }
  492. .multiple {
  493. padding: 0;
  494. max-width: 1024px - 50px;
  495. overflow: hidden;
  496. > li {
  497. @include row();
  498. border-radius: 2px;
  499. position: relative;
  500. overflow: hidden;
  501. background-color: $color-white;
  502. padding: 1em 10em 1em 1.5em; // 10em padding leaves room for controls
  503. margin-bottom: 1em;
  504. 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
  505. }
  506. &.moving {
  507. position: relative;
  508. }
  509. li.moving {
  510. position: absolute;
  511. width: 100%;
  512. }
  513. fieldset {
  514. padding-top: 0;
  515. padding-bottom: 0;
  516. }
  517. // Object controls
  518. .controls {
  519. position: absolute;
  520. z-index: 1;
  521. right: 1em;
  522. top: 1em;
  523. color: $color-white;
  524. li {
  525. float: left;
  526. margin-right: 1px;
  527. &:last-child {
  528. margin-right: 0;
  529. }
  530. }
  531. .disabled {
  532. display: none;
  533. visibility: hidden;
  534. }
  535. }
  536. }
  537. // wrapper around add button for multiple objects
  538. .add {
  539. font-weight: 700;
  540. cursor: pointer;
  541. margin-top: 0;
  542. margin-bottom: 0;
  543. padding-top: 1em;
  544. padding-bottom: 2em;
  545. clear: both;
  546. }