modal.css 12 KB

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