Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

blueslip: Move blueslip related code to its own files.

Sayam Samalb90b5f404777
diff --git a/web/src/alert_popup.ts b/web/src/alert_popup.ts
index 04ea1024370..4a04b538129 100644
--- a/web/src/alert_popup.ts
+++ b/web/src/alert_popup.ts
@@ -8,15 +8,3 @@ $("body").on("click", ".alert-box .exit", function () {
$stack_trace.removeClass("fade-out show");
}, 300);
});
-
-$(".blueslip-error-container").on("click", ".stackframe", function () {
- $(this).siblings(".code-context").toggle("fast");
-});
-
-$(".blueslip-error-container").on("click", ".exit", function () {
- const $stacktrace = $(this).closest(".stacktrace");
- $stacktrace.addClass("fade-out");
- setTimeout(() => {
- $stacktrace.removeClass("fade-out show");
- }, 300);
-});
diff --git a/web/src/blueslip.ts b/web/src/blueslip.ts
index f68d4158ee3..3e923ff453f 100644
--- a/web/src/blueslip.ts
+++ b/web/src/blueslip.ts
@@ -129,3 +129,16 @@ if (DEVELOPMENT) {
}
});
}
+
+// Click handlers for the blueslip overlay.
+$(".blueslip-error-container").on("click", ".stackframe", function () {
+ $(this).siblings(".code-context").toggle("fast");
+});
+
+$(".blueslip-error-container").on("click", ".exit", function () {
+ const $stacktrace = $(this).closest(".stacktrace");
+ $stacktrace.addClass("fade-out");
+ setTimeout(() => {
+ $stacktrace.removeClass("fade-out show");
+ }, 300);
+});
diff --git a/web/src/bundles/common.ts b/web/src/bundles/common.ts
index 9f13aa74d1d..8959d6d24ac 100644
--- a/web/src/bundles/common.ts
+++ b/web/src/bundles/common.ts
@@ -1,6 +1,5 @@
import "../sentry.ts";
import "../../debug-require.cjs";
-import "../alert_popup.ts";
import "../csrf.ts";
import "../blueslip.ts";
import "simplebar/dist/simplebar.css";
@@ -10,6 +9,7 @@ import "source-sans/source-sans-3VF.css";
import "source-code-pro/source-code-pro.css";
import "@fontsource-variable/open-sans";
import "../../styles/alerts.css";
+import "../../styles/blueslip.css";
import "../../styles/modal.css";
import "../../styles/progress_bar.css";
import "../../styles/pygments.css";
diff --git a/web/styles/alerts.css b/web/styles/alerts.css
index bafa7d9a39c..c593062adf4 100644
--- a/web/styles/alerts.css
+++ b/web/styles/alerts.css
@@ -135,138 +135,6 @@
}
}
-.blueslip-error-container {
- /* We define this variable here since this is shared
- with portico. */
- --blueslip-overlay-translate-y-distance: 100px;
- position: fixed;
- /* Offset to account for the top padding + 5px from the top. */
- top: calc(5px + (-1 * var(--blueslip-overlay-translate-y-distance)));
- left: 50%;
- transform: translateX(-50%);
- width: 100%;
- max-width: 900px;
- z-index: 230;
- /* Subtract 5px to account for the bottom margin and another
- 5px to account for the top. */
- max-height: calc(100vh - 10px);
- overflow-y: auto;
- overscroll-behavior: contain;
- /* Set top padding to account for the translate-y motion of the
- animation to prevent the vertical scroll bar from appearing. */
- padding-top: var(--blueslip-overlay-translate-y-distance);
- display: flex;
- /* Using column-reverse flex direction enables a stack-like
- behavior where the most recent error is always on top. */
- flex-direction: column-reverse;
- gap: 5px;
-}
-
-.stacktrace {
- @extend .alert-display, .alert-animations;
-
- box-sizing: border-box;
- width: 100%;
- pointer-events: auto;
- font-size: 1rem;
- color: hsl(0deg 80% 40%);
-
- padding: 1rem 0;
-
- background-color: hsl(0deg 100% 98%);
- border-radius: 4px;
- border: 1px solid hsl(0deg 80% 40%);
- box-shadow: 0 0 2px hsl(0deg 80% 40%);
-
- .stacktrace-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
-
- .message {
- flex: 1 1 auto;
- }
-
- .warning-symbol,
- .exit {
- flex: 0 0 auto;
- font-size: 1.3rem;
- padding: 0 1rem;
- }
-
- .exit::after {
- cursor: pointer;
- font-size: 2.3rem;
- content: "\d7";
- line-height: 0.5;
- }
- }
-
- .stacktrace-more-info {
- font-size: 0.85rem;
- white-space: pre;
- font-family: "Source Code Pro", monospace;
- margin-left: 3.3rem;
- margin-bottom: 0.5rem;
- padding: 0.5rem;
- background-color: hsl(0deg 7% 98%);
- }
-
- .stacktrace-content {
- font-family: "Source Code Pro", monospace;
- font-size: 0.85rem;
-
- margin-bottom: 0.5rem;
-
- .stackframe {
- padding-left: calc(3.3rem - 14px);
- padding-right: 1rem;
- }
- }
-
- .expand {
- cursor: pointer;
- color: hsl(0deg 32% 83%);
-
- &:hover {
- color: hsl(0deg 0% 20%);
- }
- }
-
- .subtle {
- color: hsl(0deg 7% 45%);
- }
-
- .code-context {
- color: hsl(0deg 7% 15%);
- background-color: hsl(0deg 7% 98%);
- box-shadow:
- inset 0 11px 10px -10px hsl(0deg 7% 70%),
- inset 0 -11px 10px -10px hsl(0deg 7% 70%);
-
- margin-top: 1em;
- margin-bottom: 1em;
-
- .code-context-content {
- padding: 1rem 0;
- white-space: pre;
- overflow-x: auto;
- }
-
- .line-number {
- width: 3rem;
- display: inline-block;
- text-align: right;
- color: hsl(0deg 7% 35%);
- }
-
- .focus-line {
- background-color: hsl(0deg 7% 90%);
- width: 100%;
- }
- }
-}
-
/* animation section */
@keyframes fadeIn {
0% {
diff --git a/web/styles/blueslip.css b/web/styles/blueslip.css
new file mode 100644
index 00000000000..bb2fcf59bc6
--- /dev/null
+++ b/web/styles/blueslip.css
@@ -0,0 +1,153 @@
+.blueslip-display {
+ display: none;
+
+ &.show {
+ display: block;
+ }
+}
+
+.blueslip-animations {
+ &.show {
+ animation-name: fadeIn;
+ animation-duration: 0.3s;
+ animation-fill-mode: forwards;
+ }
+
+ &.fade-out {
+ animation-name: fadeOut;
+ animation-duration: 0.3s;
+ animation-fill-mode: forwards;
+ }
+}
+
+.blueslip-error-container {
+ /* We define this variable here since this is shared
+ with portico. */
+ --blueslip-overlay-translate-y-distance: 100px;
+ position: fixed;
+ /* Offset to account for the top padding + 5px from the top. */
+ top: calc(5px + (-1 * var(--blueslip-overlay-translate-y-distance)));
+ left: 50%;
+ transform: translateX(-50%);
+ width: 100%;
+ max-width: 900px;
+ z-index: 230;
+ /* Subtract 5px to account for the bottom margin and another
+ 5px to account for the top. */
+ max-height: calc(100vh - 10px);
+ overflow-y: auto;
+ overscroll-behavior: contain;
+ /* Set top padding to account for the translate-y motion of the
+ animation to prevent the vertical scroll bar from appearing. */
+ padding-top: var(--blueslip-overlay-translate-y-distance);
+ display: flex;
+ /* Using column-reverse flex direction enables a stack-like
+ behavior where the most recent error is always on top. */
+ flex-direction: column-reverse;
+ gap: 5px;
+}
+
+.stacktrace {
+ @extend .blueslip-display, .blueslip-animations;
+
+ box-sizing: border-box;
+ width: 100%;
+ pointer-events: auto;
+ font-size: 1rem;
+ color: hsl(0deg 80% 40%);
+
+ padding: 1rem 0;
+
+ background-color: hsl(0deg 100% 98%);
+ border-radius: 4px;
+ border: 1px solid hsl(0deg 80% 40%);
+ box-shadow: 0 0 2px hsl(0deg 80% 40%);
+
+ .stacktrace-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ .message {
+ flex: 1 1 auto;
+ }
+
+ .warning-symbol,
+ .exit {
+ flex: 0 0 auto;
+ font-size: 1.3rem;
+ padding: 0 1rem;
+ }
+
+ .exit::after {
+ cursor: pointer;
+ font-size: 2.3rem;
+ content: "\d7";
+ line-height: 0.5;
+ }
+ }
+
+ .stacktrace-more-info {
+ font-size: 0.85rem;
+ white-space: pre;
+ font-family: "Source Code Pro", monospace;
+ margin-left: 3.3rem;
+ margin-bottom: 0.5rem;
+ padding: 0.5rem;
+ background-color: hsl(0deg 7% 98%);
+ }
+
+ .stacktrace-content {
+ font-family: "Source Code Pro", monospace;
+ font-size: 0.85rem;
+
+ margin-bottom: 0.5rem;
+
+ .stackframe {
+ padding-left: calc(3.3rem - 14px);
+ padding-right: 1rem;
+ }
+ }
+
+ .expand {
+ cursor: pointer;
+ color: hsl(0deg 32% 83%);
+
+ &:hover {
+ color: hsl(0deg 0% 20%);
+ }
+ }
+
+ .subtle {
+ color: hsl(0deg 7% 45%);
+ }
+
+ .code-context {
+ color: hsl(0deg 7% 15%);
+ background-color: hsl(0deg 7% 98%);
+ box-shadow:
+ inset 0 11px 10px -10px hsl(0deg 7% 70%),
+ inset 0 -11px 10px -10px hsl(0deg 7% 70%);
+
+ margin-top: 1em;
+ margin-bottom: 1em;
+
+ .code-context-content {
+ padding: 1rem 0;
+ white-space: pre;
+ overflow-x: auto;
+ }
+
+ .line-number {
+ width: 3rem;
+ display: inline-block;
+ text-align: right;
+ color: hsl(0deg 7% 35%);
+ }
+
+ .focus-line {
+ background-color: hsl(0deg 7% 90%);
+ width: 100%;
+ }
+ }
+}