modal.css 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. /* mixins & extensions */
  2. @keyframes in {
  3. 0% {
  4. opacity: 0;
  5. }
  6. 100% {
  7. opacity: 1;
  8. }
  9. }
  10. @keyframes in-down {
  11. 0% {
  12. opacity: 0;
  13. transform: translate3D(0, -5px, 0);
  14. }
  15. 100% {
  16. opacity: 1;
  17. transform: translate3D(0, 0, 0);
  18. }
  19. }
  20. @keyframes in-up {
  21. 0% {
  22. opacity: 0;
  23. transform: translate3D(0, 5px, 0);
  24. }
  25. 100% {
  26. opacity: 1;
  27. transform: translate3D(0, 0, 0);
  28. }
  29. }
  30. @keyframes in-scale {
  31. 0% {
  32. opacity: 0;
  33. transform: scale3D(0.95, 0.95, 1);
  34. }
  35. 100% {
  36. opacity: 1;
  37. transform: scale3D(1, 1, 1);
  38. }
  39. }
  40. :root {
  41. --calcite-animation-timing: calc(150ms * var(--calcite-internal-duration-factor));
  42. --calcite-internal-duration-factor: var(--calcite-duration-factor, 1);
  43. --calcite-internal-animation-timing-fast: calc(100ms * var(--calcite-internal-duration-factor));
  44. --calcite-internal-animation-timing-medium: calc(200ms * var(--calcite-internal-duration-factor));
  45. --calcite-internal-animation-timing-slow: calc(300ms * var(--calcite-internal-duration-factor));
  46. }
  47. .calcite-animate {
  48. opacity: 0;
  49. animation-fill-mode: both;
  50. animation-duration: var(--calcite-animation-timing);
  51. }
  52. .calcite-animate__in {
  53. animation-name: in;
  54. }
  55. .calcite-animate__in-down {
  56. animation-name: in-down;
  57. }
  58. .calcite-animate__in-up {
  59. animation-name: in-up;
  60. }
  61. .calcite-animate__in-scale {
  62. animation-name: in-scale;
  63. }
  64. /**
  65. * Currently only used in Checkbox.
  66. */
  67. :root {
  68. --calcite-popper-transition: var(--calcite-animation-timing);
  69. }
  70. :host([hidden]) {
  71. display: none;
  72. }
  73. /**
  74. * CSS Custom Properties
  75. *
  76. * These properties can be overridden using the component's tag as selector.
  77. *
  78. * @prop --calcite-modal-content-text: the font-size of the modal content
  79. * @prop --calcite-modal-padding: the top/bottom padding around items in the modal
  80. * @prop --calcite-modal-padding-large: the left/right padding around items in the modal
  81. * @prop --calcite-modal-title-text: the font-size of the modal title
  82. * @prop --calcite-scrim-background: the semi-transparent background color behind modal
  83. */
  84. :host {
  85. position: fixed;
  86. top: 0px;
  87. right: 0px;
  88. bottom: 0px;
  89. left: 0px;
  90. display: flex;
  91. align-items: center;
  92. justify-content: center;
  93. overflow-y: hidden;
  94. color: var(--calcite-ui-text-2);
  95. opacity: 0;
  96. visibility: hidden !important;
  97. transition: visibility 0ms linear 300ms, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);
  98. z-index: 101;
  99. }
  100. :host([scale=s]) {
  101. --calcite-modal-padding: 0.75rem;
  102. --calcite-modal-padding-large: 1rem;
  103. --calcite-modal-title-text: var(--calcite-font-size-1);
  104. --calcite-modal-content-text: var(--calcite-font-size--1);
  105. }
  106. :host([scale=m]) {
  107. --calcite-modal-padding: 1rem;
  108. --calcite-modal-padding-large: 1.25rem;
  109. --calcite-modal-title-text: var(--calcite-font-size-2);
  110. --calcite-modal-content-text: var(--calcite-font-size-0);
  111. }
  112. :host([scale=l]) {
  113. --calcite-modal-padding: 1.25rem;
  114. --calcite-modal-padding-large: 1.5rem;
  115. --calcite-modal-title-text: var(--calcite-font-size-3);
  116. --calcite-modal-content-text: var(--calcite-font-size-1);
  117. }
  118. .scrim {
  119. --calcite-scrim-background: rgba(0, 0, 0, 0.75);
  120. position: fixed;
  121. top: 0px;
  122. right: 0px;
  123. bottom: 0px;
  124. left: 0px;
  125. display: flex;
  126. overflow-y: hidden;
  127. }
  128. .modal {
  129. pointer-events: none;
  130. float: none;
  131. margin: 1.5rem;
  132. box-sizing: border-box;
  133. display: flex;
  134. width: 100%;
  135. flex-direction: column;
  136. overflow: hidden;
  137. border-radius: 0.25rem;
  138. background-color: var(--calcite-ui-foreground-1);
  139. opacity: 0;
  140. --tw-shadow: 0 2px 12px -4px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.16);
  141. --tw-shadow-colored: 0 2px 12px -4px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);
  142. box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
  143. z-index: 102;
  144. -webkit-overflow-scrolling: touch;
  145. visibility: hidden;
  146. transition: transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), visibility 0ms linear 300ms, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);
  147. transform: translate3d(0, 20px, 0);
  148. }
  149. :host([active]) {
  150. opacity: 1;
  151. visibility: visible !important;
  152. transition-delay: 0ms;
  153. }
  154. :host([active]) .modal {
  155. pointer-events: auto;
  156. visibility: visible;
  157. opacity: 1;
  158. transform: translate3d(0, 0, 0);
  159. transition: transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), visibility 0ms linear, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), max-width var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), max-height var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);
  160. transition-delay: 0ms;
  161. }
  162. /**
  163. * Header
  164. */
  165. .header {
  166. display: flex;
  167. min-width: 0px;
  168. max-width: 100%;
  169. border-top-left-radius: 0.25rem;
  170. border-top-right-radius: 0.25rem;
  171. border-width: 0px;
  172. border-bottom-width: 1px;
  173. border-style: solid;
  174. border-color: var(--calcite-ui-border-3);
  175. background-color: var(--calcite-ui-foreground-1);
  176. flex: 0 0 auto;
  177. z-index: 2;
  178. }
  179. .close {
  180. order: 2;
  181. margin: 0px;
  182. cursor: pointer;
  183. -webkit-appearance: none;
  184. appearance: none;
  185. border-style: none;
  186. background-color: transparent;
  187. color: var(--calcite-ui-text-3);
  188. outline-offset: 0;
  189. outline-color: transparent;
  190. transition: outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;
  191. transition-property: all;
  192. transition-duration: var(--calcite-animation-timing);
  193. transition-timing-function: ease-in-out;
  194. transition-delay: 0s;
  195. border-start-end-radius: 0.25rem;
  196. padding: var(--calcite-modal-padding);
  197. flex: 0 0 auto;
  198. }
  199. .close calcite-icon {
  200. pointer-events: none;
  201. vertical-align: -2px;
  202. }
  203. .close:focus {
  204. outline: 2px solid var(--calcite-ui-brand);
  205. outline-offset: -2px;
  206. }
  207. .close:hover, .close:focus, .close:active {
  208. background-color: var(--calcite-ui-foreground-2);
  209. color: var(--calcite-ui-text-1);
  210. }
  211. .title {
  212. order: 1;
  213. display: flex;
  214. min-width: 0px;
  215. align-items: center;
  216. flex: 1 1 auto;
  217. padding: var(--calcite-modal-padding) var(--calcite-modal-padding-large);
  218. }
  219. slot[name=header]::slotted(*), *::slotted([slot=header]) {
  220. margin: 0px;
  221. font-weight: var(--calcite-font-weight-normal);
  222. color: var(--calcite-ui-text-1);
  223. font-size: var(--calcite-modal-title-text);
  224. }
  225. /**
  226. * Content area
  227. */
  228. .content {
  229. position: relative;
  230. box-sizing: border-box;
  231. display: block;
  232. height: 100%;
  233. overflow: auto;
  234. background-color: var(--calcite-ui-foreground-1);
  235. padding: 0px;
  236. max-height: calc(100vh - 12rem);
  237. z-index: 1;
  238. }
  239. .content--spaced {
  240. padding: var(--calcite-modal-padding) var(--calcite-modal-padding-large);
  241. }
  242. .content--no-footer {
  243. border-bottom-right-radius: 0.25rem;
  244. border-bottom-left-radius: 0.25rem;
  245. }
  246. slot[name=content]::slotted(*),
  247. *::slotted([slot=content]) {
  248. font-size: var(--calcite-modal-content-text);
  249. }
  250. :host([background-color=grey]) .content {
  251. background-color: var(--calcite-ui-background);
  252. }
  253. /**
  254. * Footer
  255. */
  256. .footer {
  257. margin-top: auto;
  258. box-sizing: border-box;
  259. display: flex;
  260. width: 100%;
  261. justify-content: space-between;
  262. border-bottom-right-radius: 0.25rem;
  263. border-bottom-left-radius: 0.25rem;
  264. border-width: 0px;
  265. border-top-width: 1px;
  266. border-style: solid;
  267. border-color: var(--calcite-ui-border-3);
  268. background-color: var(--calcite-ui-foreground-1);
  269. flex: 0 0 auto;
  270. padding: var(--calcite-modal-padding) var(--calcite-modal-padding-large);
  271. z-index: 2;
  272. }
  273. .footer--hide-back .back, .footer--hide-secondary .secondary {
  274. display: none;
  275. }
  276. .back {
  277. display: block;
  278. margin-inline-end: auto;
  279. }
  280. .secondary {
  281. margin-left: 0.25rem;
  282. margin-right: 0.25rem;
  283. display: block;
  284. }
  285. slot[name=primary] {
  286. display: block;
  287. }
  288. /**
  289. * Sizes
  290. */
  291. :host([width=small]) .modal {
  292. width: auto;
  293. }
  294. :host([width=s]) .modal {
  295. max-width: 32rem;
  296. }
  297. @media screen and (max-width: 35rem) {
  298. :host([width=s]) .modal {
  299. margin: 0px;
  300. height: 100%;
  301. max-height: 100%;
  302. width: 100%;
  303. max-width: 100%;
  304. border-radius: 0px;
  305. }
  306. :host([width=s]) .content {
  307. flex: 1 1 auto;
  308. max-height: unset;
  309. }
  310. :host([width=s][docked]) {
  311. align-items: flex-end;
  312. }
  313. }
  314. :host([width=m]) .modal {
  315. max-width: 48rem;
  316. }
  317. @media screen and (max-width: 51rem) {
  318. :host([width=m]) .modal {
  319. margin: 0px;
  320. height: 100%;
  321. max-height: 100%;
  322. width: 100%;
  323. max-width: 100%;
  324. border-radius: 0px;
  325. }
  326. :host([width=m]) .content {
  327. flex: 1 1 auto;
  328. max-height: unset;
  329. }
  330. :host([width=m][docked]) {
  331. align-items: flex-end;
  332. }
  333. }
  334. :host([width=l]) .modal {
  335. max-width: 94rem;
  336. }
  337. @media screen and (max-width: 97rem) {
  338. :host([width=l]) .modal {
  339. margin: 0px;
  340. height: 100%;
  341. max-height: 100%;
  342. width: 100%;
  343. max-width: 100%;
  344. border-radius: 0px;
  345. }
  346. :host([width=l]) .content {
  347. flex: 1 1 auto;
  348. max-height: unset;
  349. }
  350. :host([width=l][docked]) {
  351. align-items: flex-end;
  352. }
  353. }
  354. /**
  355. * Fullscreen
  356. */
  357. :host([fullscreen]) {
  358. background-color: transparent;
  359. }
  360. :host([fullscreen]) .modal {
  361. margin: 0px;
  362. height: 100%;
  363. max-height: 100%;
  364. width: 100%;
  365. max-width: 100%;
  366. transform: translate3D(0, 20px, 0) scale(0.95);
  367. }
  368. :host([fullscreen]) .content {
  369. max-height: 100%;
  370. flex: 1 1 auto;
  371. }
  372. :host([active][fullscreen]) .modal {
  373. transform: translate3D(0, 0, 0) scale(1);
  374. }
  375. :host([active][fullscreen]) .header {
  376. border-radius: 0;
  377. }
  378. :host([active][fullscreen]) .footer {
  379. border-radius: 0;
  380. }
  381. /**
  382. * Docked
  383. */
  384. :host([docked]) .modal {
  385. height: auto;
  386. }
  387. :host([docked]) .content {
  388. height: auto;
  389. flex: 1 1 auto;
  390. }
  391. @media screen and (max-width: 860px) {
  392. :host([docked]) .modal {
  393. border-radius: var(--calcite-border-radius) var(--calcite-border-radius) 0 0;
  394. }
  395. :host([docked]) .close {
  396. border-start-end-radius: var(--calcite-border-radius);
  397. }
  398. }
  399. /**
  400. * Colors
  401. */
  402. :host([color=red]) .modal {
  403. border-color: var(--calcite-ui-danger);
  404. }
  405. :host([color=blue]) .modal {
  406. border-color: var(--calcite-ui-info);
  407. }
  408. :host([color=red]) .modal, :host([color=blue]) .modal {
  409. border-width: 0px;
  410. border-top-width: 4px;
  411. border-style: solid;
  412. }
  413. :host([color=red]) .header, :host([color=blue]) .header {
  414. border-radius: 0.25rem;
  415. border-bottom-right-radius: 0px;
  416. border-bottom-left-radius: 0px;
  417. }
  418. /**
  419. * Tablet
  420. */
  421. @media screen and (max-width: 860px) {
  422. slot[name=header]::slotted(*), *::slotted([slot=header]) {
  423. font-size: var(--calcite-font-size-1);
  424. }
  425. .footer {
  426. position: sticky;
  427. bottom: 0px;
  428. }
  429. }
  430. /**
  431. * Mobile
  432. */
  433. @media screen and (max-width: 480px) {
  434. .footer {
  435. flex-direction: column;
  436. }
  437. .back, .secondary {
  438. margin: 0px;
  439. margin-bottom: 0.25rem;
  440. }
  441. }