win98window.astro 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. ---
  2. const { title, layout = {} } = Astro.props;
  3. const defaultLayout = {
  4. mobile: { left: '2%', top: '5%', width: '96%', height: 'auto' },
  5. // tablet: { left: '10%', top: '10%', width: '80%', height: 'auto' },
  6. desktop: { left: '12%', top: '22%', width: '30%', height: 'auto' }
  7. };
  8. const mergedLayout = {
  9. mobile: { ...defaultLayout.mobile, ...(layout.mobile || {}) },
  10. // tablet: { ...defaultLayout.tablet, ...(layout.tablet || {}) },
  11. desktop: { ...defaultLayout.desktop, ...(layout.desktop || {}) }
  12. };
  13. ---
  14. <div
  15. id={title}
  16. class="window"
  17. data-redirectUrl="test"
  18. style="display: none;"
  19. >
  20. <div id={`${title}header`} class="title-bar">
  21. <div class="title-bar-text">{title}</div>
  22. <div class="title-bar-controls">
  23. <button class="close" aria-label="Minimize" style="background-color: silver;"></button>
  24. <button class="close" aria-label="Close" style="background-color: silver;"></button>
  25. </div>
  26. </div>
  27. <div class="window-body">
  28. <slot/>
  29. </div>
  30. </div>
  31. <style define:vars={{
  32. mobileLeft: mergedLayout.mobile.left,
  33. mobileTop: mergedLayout.mobile.top,
  34. mobileWidth: mergedLayout.mobile.width,
  35. mobileHeight: mergedLayout.mobile.height,
  36. desktopLeft: mergedLayout.desktop.left,
  37. desktopTop: mergedLayout.desktop.top,
  38. desktopWidth: mergedLayout.desktop.width,
  39. desktopHeight: mergedLayout.desktop.height
  40. }}>
  41. .title-bar-text {
  42. font-size: 14px;
  43. }
  44. .window {
  45. animation: createBox 0.15s;
  46. position: absolute;
  47. }
  48. .closed {
  49. animation: destroyBox 0.15s;
  50. }
  51. @keyframes createBox {
  52. from { transform: scale(0); }
  53. to { transform: scale(1); }
  54. }
  55. @keyframes destroyBox {
  56. from { transform: scale(1); }
  57. to { transform: scale(0); }
  58. }
  59. /* Mobile */
  60. @media (max-width: 510px) {
  61. .window {
  62. left: var(--mobileLeft);
  63. top: var(--mobileTop);
  64. max-width: var(--mobileWidth);
  65. max-height: var(--mobileHeight);
  66. }
  67. .window-body {
  68. height: var(--desktopHeight);
  69. max-height: calc(var(--desktopHeight) - 45px);
  70. }
  71. }
  72. /* Desktop */
  73. @media (min-width: 511px) {
  74. .window {
  75. left: var(--desktopLeft);
  76. top: var(--desktopTop);
  77. /*width: var(--desktopWidth);*/
  78. max-width: var(--desktopWidth);
  79. /*height: calc(var(--desktopHeight));*/
  80. max-height: calc(var(--desktopHeight));
  81. }
  82. .window-body {
  83. height: var(--desktopHeight);
  84. max-height: calc(var(--desktopHeight) - 45px);
  85. width: var(--desktopWitdth);
  86. max-widtH: (var--desktopWidth);
  87. }
  88. }
  89. </style>