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.

css: Consolidate shake animation into shared .input-validation-shake class.

Tanaya Pawar97bf0e78fc7c
diff --git a/web/src/compose_setup.ts b/web/src/compose_setup.ts
index 88acd389fd4..9c78509e954 100644
--- a/web/src/compose_setup.ts
+++ b/web/src/compose_setup.ts
@@ -752,12 +752,12 @@ export function initialize(): void {
if (topic.length > realm.max_topic_length) {
topic = topic.slice(0, realm.max_topic_length);
compose_state.topic(topic);
- $("input#stream_message_recipient_topic").addClass("shake");
+ $("input#stream_message_recipient_topic").addClass("input-validation-shake");
}
}
$("input#stream_message_recipient_topic").on("animationend", function () {
- $(this).removeClass("shake");
+ $(this).removeClass("input-validation-shake");
});
$("input#stream_message_recipient_topic").on("input", () => {
diff --git a/web/src/input_pill.ts b/web/src/input_pill.ts
index 902897cc1d2..5cb8403bd0e 100644
--- a/web/src/input_pill.ts
+++ b/web/src/input_pill.ts
@@ -150,7 +150,7 @@ export function create<ItemType extends {type: string}>(
const existing_items = funcs.items();
const item = store.create_item_from_text(text, existing_items, store.pill_config);
if (!item) {
- store.$input.addClass("shake");
+ store.$input.addClass("input-validation-shake");
if (store.show_outline_on_invalid_input) {
store.$parent.addClass("invalid");
@@ -474,7 +474,7 @@ export function create<ItemType extends {type: string}>(
// when the shake animation is applied to the ".input" on invalid input,
// we want to remove the class when finished automatically.
store.$parent.on("animationend", ".input", function () {
- $(this).removeClass("shake");
+ $(this).removeClass("input-validation-shake");
});
// replace formatted input with plaintext to allow for sane copy-paste
diff --git a/web/src/search.ts b/web/src/search.ts
index e436e756525..0f7c6354772 100644
--- a/web/src/search.ts
+++ b/web/src/search.ts
@@ -111,7 +111,7 @@ function convert_search_text_to_terms(
if (shake_pill_if_invalid) {
// The shake animation will show if there is any invalid term in the,
// search bar, even if it's not what the user just typed or selected.
- $("#search_query").addClass("shake");
+ $("#search_query").addClass("input-validation-shake");
}
return undefined;
}
diff --git a/web/src/search_pill.ts b/web/src/search_pill.ts
index 79a4f6bf462..484384bd329 100644
--- a/web/src/search_pill.ts
+++ b/web/src/search_pill.ts
@@ -538,7 +538,7 @@ export function set_search_bar_contents(
}
set_search_bar_text(search_bar_text_strings.join(" "));
if (invalid_inputs.length > 0) {
- $("#search_query").addClass("shake");
+ $("#search_query").addClass("input-validation-shake");
}
}
diff --git a/web/src/stream_create.ts b/web/src/stream_create.ts
index 9bdc976dfae..c9363e1f3d0 100644
--- a/web/src/stream_create.ts
+++ b/web/src/stream_create.ts
@@ -651,12 +651,12 @@ export function set_up_handlers(): void {
if (channel_name.length > realm.max_stream_name_length) {
channel_name = channel_name.slice(0, realm.max_stream_name_length);
$channel_input.val(channel_name);
- $channel_input.addClass("shake");
+ $channel_input.addClass("input-validation-shake");
}
stream_name_error.pre_validate(channel_name);
}
$("input#create_stream_name").on("animationend", function () {
- $(this).removeClass("shake");
+ $(this).removeClass("input-validation-shake");
});
$container.on("input", "#create_stream_name", () => {
handle_channel_name_length_limit();
diff --git a/web/src/user_profile.ts b/web/src/user_profile.ts
index 2722d938aed..d8980f3bb84 100644
--- a/web/src/user_profile.ts
+++ b/web/src/user_profile.ts
@@ -1641,7 +1641,7 @@ export function initialize(): void {
const $alert_box = $("#user-profile-groups-tab .user-profile-group-list-alert");
const item = $("#user-group-to-add .pill-container .input").text().trim();
if (item) {
- $("#user-group-to-add .pill-container .input").addClass("shake");
+ $("#user-group-to-add .pill-container .input").addClass("input-validation-shake");
if (
$("#user-group-to-add .pill-container .input").hasClass(
"show-outline-on-invalid-input",
diff --git a/web/styles/compose.css b/web/styles/compose.css
index b9800201b5c..7841593d7ce 100644
--- a/web/styles/compose.css
+++ b/web/styles/compose.css
@@ -1184,13 +1184,6 @@ textarea.new_message_textarea {
&.empty-topic-display::placeholder {
color: var(--color-compose-recipient-box-text-color);
}
-
- &.shake {
- animation: shake 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
- transform: translate3d(0, 0, 0);
- backface-visibility: hidden;
- perspective: 1000px;
- }
}
#topic-not-mandatory-placeholder {
diff --git a/web/styles/input_pill.css b/web/styles/input_pill.css
index 89e2f7dc51b..ce7869de3e7 100644
--- a/web/styles/input_pill.css
+++ b/web/styles/input_pill.css
@@ -217,13 +217,6 @@
flex: 1 1 auto;
outline: none;
-
- &.shake {
- animation: shake 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
- transform: translate3d(0, 0, 0);
- backface-visibility: hidden;
- perspective: 1000px;
- }
}
&.not-editable-by-user {
@@ -475,26 +468,3 @@
align-items: center;
justify-content: center;
}
-
-@keyframes shake {
- 10%,
- 90% {
- transform: translate3d(-1px, 0, 0);
- }
-
- 20%,
- 80% {
- transform: translate3d(2px, 0, 0);
- }
-
- 30%,
- 50%,
- 70% {
- transform: translate3d(-3px, 0, 0);
- }
-
- 40%,
- 60% {
- transform: translate3d(3px, 0, 0);
- }
-}
diff --git a/web/styles/subscriptions.css b/web/styles/subscriptions.css
index 3d0b5dc435d..47347f18fb1 100644
--- a/web/styles/subscriptions.css
+++ b/web/styles/subscriptions.css
@@ -1775,10 +1775,3 @@
}
}
}
-
-#create_stream_name.shake {
- animation: shake 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
- transform: translate3d(0, 0, 0);
- backface-visibility: hidden;
- perspective: 1000px;
-}
diff --git a/web/styles/zulip.css b/web/styles/zulip.css
index 4ff950d50c6..2aaee6491ab 100644
--- a/web/styles/zulip.css
+++ b/web/styles/zulip.css
@@ -2572,3 +2572,33 @@ body:not(.spectator-view) {
outline: none;
}
}
+
+.input-validation-shake {
+ animation: shake 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
+ transform: translate3d(0, 0, 0);
+ backface-visibility: hidden;
+ perspective: 1000px;
+}
+
+@keyframes shake {
+ 10%,
+ 90% {
+ transform: translate3d(-1px, 0, 0);
+ }
+
+ 20%,
+ 80% {
+ transform: translate3d(2px, 0, 0);
+ }
+
+ 30%,
+ 50%,
+ 70% {
+ transform: translate3d(-4px, 0, 0);
+ }
+
+ 40%,
+ 60% {
+ transform: translate3d(4px, 0, 0);
+ }
+}
diff --git a/web/tests/input_pill.test.cjs b/web/tests/input_pill.test.cjs
index 8eac9195d2b..21cbbe552bc 100644
--- a/web/tests/input_pill.test.cjs
+++ b/web/tests/input_pill.test.cjs
@@ -521,7 +521,7 @@ run_test("misc things", () => {
const input_stub = {
to_$: () => ({
removeClass(cls) {
- assert.equal(cls, "shake");
+ assert.equal(cls, "input-validation-shake");
shake_class_removed = true;
},
}),