Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions client/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import cls from "classnames";
import s from "./Button.css";
import * as s from "./Button.css";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default all classnames in named export (for better tree shaking)

import PureComponent from "../lib/PureComponent";

export default class Button extends PureComponent {
render({ active, toggle, className, children, ...props }) {
render({ active, className, children, ...props }) {
const classes = cls(className, {
[s.button]: true,
[s.active]: active,
[s.toggle]: toggle,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have toggle class

});

return (
Expand Down
2 changes: 1 addition & 1 deletion client/components/Checkbox.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from "preact";
import cls from "classnames";

import s from "./Checkbox.css";
import * as s from "./Checkbox.css";

export default class Checkbox extends Component {
render() {
Expand Down
2 changes: 1 addition & 1 deletion client/components/CheckboxList.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CheckboxListItem from "./CheckboxListItem";
import s from "./CheckboxList.css";
import * as s from "./CheckboxList.css";
import PureComponent from "../lib/PureComponent";

const ALL_ITEM = Symbol("ALL_ITEM");
Expand Down
2 changes: 1 addition & 1 deletion client/components/CheckboxListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component } from "preact";

import Checkbox from "./Checkbox";
import CheckboxList from "./CheckboxList";
import s from "./CheckboxList.css";
import * as s from "./CheckboxList.css";

export default class CheckboxListItem extends Component {
render() {
Expand Down
2 changes: 1 addition & 1 deletion client/components/ContextMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PureComponent from "../lib/PureComponent";
import { store } from "../store";
import { elementIsOutside } from "../utils";

import s from "./ContextMenu.css";
import * as s from "./ContextMenu.css";

export default class ContextMenu extends PureComponent {
componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion client/components/ContextMenuItem.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cls from "classnames";
import s from "./ContextMenuItem.css";
import * as s from "./ContextMenuItem.css";

function noop() {
return false;
Expand Down
4 changes: 2 additions & 2 deletions client/components/Dropdown.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createRef } from "preact";
import PureComponent from "../lib/PureComponent";

import s from "./Dropdown.css";
import * as s from "./Dropdown.css";

export default class Dropdown extends PureComponent {
input = createRef();
Expand Down Expand Up @@ -41,7 +41,7 @@ export default class Dropdown extends PureComponent {
onFocus={this.handleFocus}
/>
{this.state.showOptions ? (
<div className={s.options}>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have options class in CSS

<div>
{filteredOptions.map((option) => (
<div
key={option}
Expand Down
2 changes: 1 addition & 1 deletion client/components/Icon.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cls from "classnames";
import s from "./Icon.css";
import * as s from "./Icon.css";
import PureComponent from "../lib/PureComponent";

import iconArrowRight from "../assets/icon-arrow-right.svg";
Expand Down
4 changes: 2 additions & 2 deletions client/components/ModuleItem.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import escapeRegExp from "escape-string-regexp";
import { escape } from "html-escaper";
import filesize from "filesize";
import { filesize } from "filesize";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we need to use named export

import cls from "classnames";

import PureComponent from "../lib/PureComponent";
import s from "./ModuleItem.css";
import * as s from "./ModuleItem.css";

export default class ModuleItem extends PureComponent {
state = {
Expand Down
2 changes: 1 addition & 1 deletion client/components/ModulesList.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cls from "classnames";
import s from "./ModulesList.css";
import * as s from "./ModulesList.css";
import ModuleItem from "./ModuleItem";
import PureComponent from "../lib/PureComponent";

Expand Down
33 changes: 23 additions & 10 deletions client/components/ModulesTreemap.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from "preact";
import filesize from "filesize";
import { computed } from "mobx";
import { filesize } from "filesize";
import { computed, makeObservable } from "mobx";
import { observer } from "mobx-react";

import { isChunkParsed } from "../utils";
Expand All @@ -13,7 +13,7 @@ import Checkbox from "./Checkbox";
import CheckboxList from "./CheckboxList";
import ContextMenu from "./ContextMenu";

import s from "./ModulesTreemap.css";
import * as s from "./ModulesTreemap.css";
import Search from "./Search";
import { store } from "../store";
import ModulesList from "./ModulesList";
Expand All @@ -37,8 +37,7 @@ function getSizeSwitchItems() {
return items;
}

@observer
export default class ModulesTreemap extends Component {
class ModulesTreemap extends Component {
mouseCoords = {
x: 0,
y: 0,
Expand All @@ -53,6 +52,18 @@ export default class ModulesTreemap extends Component {
tooltipContent: null,
};

constructor() {
super();

makeObservable(this, {
sizeSwitchItems: computed,
activeSizeItem: computed,
chunkItems: computed,
highlightedModules: computed,
foundModulesInfo: computed,
});
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using decorators (they are deprecated in mobx too)


componentDidMount() {
document.addEventListener("mousemove", this.handleMouseMove, true);
}
Expand Down Expand Up @@ -192,17 +203,17 @@ export default class ModulesTreemap extends Component {
return [`${label} (`, <strong>{filesize(size)}</strong>, ")"];
};

@computed get sizeSwitchItems() {
get sizeSwitchItems() {
return store.hasParsedSizes
? getSizeSwitchItems()
: getSizeSwitchItems().slice(0, 1);
}

@computed get activeSizeItem() {
get activeSizeItem() {
return this.sizeSwitchItems.find((item) => item.prop === store.activeSize);
}

@computed get chunkItems() {
get chunkItems() {
const { allChunks, activeSize } = store;
let chunkItems = [...allChunks];

Expand All @@ -217,11 +228,11 @@ export default class ModulesTreemap extends Component {
return chunkItems;
}

@computed get highlightedModules() {
get highlightedModules() {
return new Set(store.foundModules);
}

@computed get foundModulesInfo() {
get foundModulesInfo() {
if (!store.isSearching) {
// `&nbsp;` to reserve space
return "\u00A0";
Expand Down Expand Up @@ -383,3 +394,5 @@ export default class ModulesTreemap extends Component {
);
}
}

export default observer(ModulesTreemap);
2 changes: 1 addition & 1 deletion client/components/Search.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// TODO: switch to a more modern debounce package once we drop Node.js 10 support
import debounce from "debounce";

import s from "./Search.css";
import * as s from "./Search.css";
import Button from "./Button";
import PureComponent from "../lib/PureComponent";

Expand Down
4 changes: 4 additions & 0 deletions client/components/Sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,7 @@
top: 0;
width: 7px;
}

:export {
toggleTime: 200ms;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using this in JS, so let's export this value using ICSS :export

2 changes: 1 addition & 1 deletion client/components/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from "preact";
import cls from "classnames";

import s from "./Sidebar.css";
import * as s from "./Sidebar.css";
import Button from "./Button";
import Icon from "./Icon";
import ThemeToggle from "./ThemeToggle";
Expand Down
2 changes: 1 addition & 1 deletion client/components/Switcher.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SwitcherItem from "./SwitcherItem";
import s from "./Switcher.css";
import * as s from "./Switcher.css";
import PureComponent from "../lib/PureComponent";

export default class Switcher extends PureComponent {
Expand Down
7 changes: 4 additions & 3 deletions client/components/ThemeToggle.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Component } from "preact";
import { observer } from "mobx-react";

import s from "./ThemeToggle.css";
import * as s from "./ThemeToggle.css";
import Button from "./Button";
import Icon from "./Icon";
import { store } from "../store";

@observer
export default class ThemeToggle extends Component {
class ThemeToggle extends Component {
render() {
const { darkMode } = store;

Expand All @@ -27,3 +26,5 @@ export default class ThemeToggle extends Component {
store.toggleDarkMode();
};
}

export default observer(ThemeToggle);
2 changes: 1 addition & 1 deletion client/components/Tooltip.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from "preact";
import cls from "classnames";

import s from "./Tooltip.css";
import * as s from "./Tooltip.css";

export default class Tooltip extends Component {
static marginX = 10;
Expand Down
Loading