settings.html.twig 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <style>
  2. #open-settings {
  3. color: var(--color-muted);
  4. display: block;
  5. margin: 15px 15px 5px;
  6. }
  7. .modal-wrap {
  8. -webkit-transition: all 0.3s ease-in-out;
  9. align-items: center;
  10. background: rgba(0, 0, 0, 0.8);
  11. display: flex;
  12. height: 100%;
  13. justify-content: center;
  14. left: 0;
  15. opacity: 1;
  16. overflow: auto;
  17. position: fixed;
  18. top: 0;
  19. transition: all 0.3s ease-in-out;
  20. visibility: hidden;
  21. width: 100%;
  22. z-index: 100000;
  23. }
  24. .modal-wrap.visible {
  25. opacity: 1;
  26. visibility: visible;
  27. }
  28. .modal-wrap .modal-container {
  29. box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.5);
  30. color: var(--base-6);
  31. margin: 1em;
  32. max-width: 94%;
  33. width: 600px;
  34. }
  35. .modal-wrap .modal-header {
  36. align-items: center;
  37. background: var(--table-header);
  38. display: flex;
  39. justify-content: space-between;
  40. padding: 15px 30px;
  41. }
  42. .modal-wrap .modal-header h3 {
  43. color: var(--base-6);
  44. margin: 0;
  45. }
  46. .modal-wrap .modal-header .close-modal {
  47. background: transparent;
  48. border: 0;
  49. color: var(--base-4);
  50. cursor: pointer;
  51. font-size: 28px;
  52. line-height: 1;
  53. }
  54. .modal-wrap .modal-header .close-modal:hover { opacity: 1; }
  55. .modal-wrap .modal-content {
  56. background: var(--base-1);
  57. margin: 0;
  58. padding: 15px 30px;
  59. width: 100%;
  60. z-index: 100000;
  61. }
  62. .modal-content h4 {
  63. border-bottom: var(--border);
  64. margin: 0 0 15px;
  65. padding: 0 0 5px;
  66. }
  67. .modal-content input, .modal-content .form-help {
  68. margin-left: 15px;
  69. }
  70. .modal-content label {
  71. cursor: pointer;
  72. font-size: 16px;
  73. margin-left: 3px;
  74. }
  75. .modal-content .form-help {
  76. color: var(--color-muted);
  77. font-size: 14px;
  78. margin: 5px 0 15px 33px;
  79. }
  80. .modal-content .form-help + h4 {
  81. margin-top: 45px;
  82. }
  83. @media (max-width: 768px) {
  84. #open-settings {
  85. color: transparent;
  86. }
  87. #sidebar:hover #open-settings, #sidebar.expanded #open-settings {
  88. color: var(--color-muted);
  89. }
  90. #open-settings:before {
  91. content: '\2699';
  92. font-weight: bold;
  93. font-size: 25px;
  94. color: var(--color-muted);
  95. }
  96. #sidebar:hover #open-settings:before, #sidebar.expanded #open-settings:before {
  97. content: '';
  98. }
  99. }
  100. </style>
  101. <a href="#" id="open-settings">Settings</a>
  102. <div class="modal-wrap" id="profiler-settings">
  103. <div class="modal-container">
  104. <div class="modal-header">
  105. <h3>Configuration Settings</h3>
  106. <button class="close-modal">&times;</button>
  107. </div>
  108. <div class="modal-content">
  109. <h4>Theme</h4>
  110. <input class="config-option" type="radio" name="theme" value="light" id="settings-theme-light">
  111. <label for="settings-theme-light">Light</label>
  112. <p class="form-help">Default theme. Improves readability.</p>
  113. <input class="config-option" type="radio" name="theme" value="dark" id="settings-theme-dark">
  114. <label for="settings-theme-dark">Dark</label>
  115. <p class="form-help">Reduces eye fatigue. Ideal for low light conditions.</p>
  116. <h4>Page Width</h4>
  117. <input class="config-option" type="radio" name="width" value="light" id="settings-width-normal">
  118. <label for="settings-width-normal">Normal</label>
  119. <p class="form-help">Fixed page width. Improves readability.</p>
  120. <input class="config-option" type="radio" name="width" value="dark" id="settings-width-full">
  121. <label for="settings-width-full">Full-page</label>
  122. <p class="form-help">Dynamic page width. As wide as the browser window.</p>
  123. </div>
  124. </div>
  125. </div>
  126. <script>
  127. (function() {
  128. let configOptions = document.querySelectorAll('.config-option');
  129. let oppositeValues = { 'light': 'dark', 'dark': 'light', 'normal': 'full', 'full': 'normal' };
  130. [...configOptions].forEach(option => {
  131. option.addEventListener('click', function (event) {
  132. let optionParts = option.id.split('-');
  133. let optionName = optionParts[1];
  134. let optionValue = optionParts[2];
  135. document.body.classList.remove(optionName + '-' + oppositeValues[optionValue]);
  136. document.body.classList.add(optionName + '-' + optionValue);
  137. localStorage.setItem('symfony/profiler/' + optionName, optionName + '-' + optionValue);
  138. });
  139. });
  140. let openModalButton = document.getElementById('open-settings');
  141. let modalWindow = document.getElementById('profiler-settings');
  142. let closeModalButton = document.getElementsByClassName('close-modal')[0];
  143. let modalWrapper = document.getElementsByClassName('modal-wrap')[0]
  144. openModalButton.addEventListener('click', function(event) {
  145. document.getElementById('settings-' + (localStorage.getItem('symfony/profiler/theme') || 'theme-light')).checked = 'checked';
  146. document.getElementById('settings-' + (localStorage.getItem('symfony/profiler/width') || 'width-normal')).checked = 'checked';
  147. modalWindow.classList.toggle('visible');
  148. event.preventDefault();
  149. });
  150. closeModalButton.addEventListener('click', function() {
  151. modalWindow.classList.remove('visible');
  152. });
  153. modalWrapper.addEventListener('click', function(event) {
  154. if (event.target == event.currentTarget) {
  155. modalWindow.classList.remove('visible');
  156. }
  157. });
  158. })();
  159. </script>