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