web: Move web app to ‘web’ directory.

Ever since we started bundling the app with webpack, there’s been less
and less overlap between our ‘static’ directory (files belonging to
the frontend app) and Django’s interpretation of the ‘static’
directory (files served directly to the web).

Split the app out to its own ‘web’ directory outside of ‘static’, and
remove all the custom collectstatic --ignore rules.  This makes it
much clearer what’s actually being served to the web, and what’s being
bundled by webpack.  It also shrinks the release tarball by 3%.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-02-22 14:03:47 -08:00
parent be0098146c
commit c1675913a2
866 changed files with 978 additions and 993 deletions

47
web/src/scroll_util.js Normal file
View File

@@ -0,0 +1,47 @@
import * as ui from "./ui";
export function scroll_delta(opts) {
const elem_top = opts.elem_top;
const container_height = opts.container_height;
const elem_bottom = opts.elem_bottom;
let delta = 0;
if (elem_top < 0) {
delta = Math.max(elem_top, elem_bottom - container_height);
delta = Math.min(0, delta);
} else {
if (elem_bottom > container_height) {
delta = Math.min(elem_top, elem_bottom - container_height);
delta = Math.max(0, delta);
}
}
return delta;
}
export function scroll_element_into_container($elem, $container, sticky_header_height = 0) {
// This does the minimum amount of scrolling that is needed to make
// the element visible. It doesn't try to center the element, so
// this will be non-intrusive to users when they already have
// the element visible.
$container = ui.get_scroll_element($container);
const elem_top = $elem.position().top - sticky_header_height;
const elem_bottom = elem_top + $elem.innerHeight();
const container_height = $container.height() - sticky_header_height;
const opts = {
elem_top,
elem_bottom,
container_height,
};
const delta = scroll_delta(opts);
if (delta === 0) {
return;
}
$container.scrollTop($container.scrollTop() + delta);
}