Skip to content

Commit

Permalink
fix: Optimize build size
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3k0 authored and 3y3 committed Jun 29, 2023
1 parent 78f9a2a commit 90b6a91
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 32 deletions.
9 changes: 0 additions & 9 deletions assets/icons/eng.svg

This file was deleted.

9 changes: 0 additions & 9 deletions assets/icons/rus.svg

This file was deleted.

1 change: 1 addition & 0 deletions src/components/Controls/Controls.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

&__list-icon {
margin-right: 8px;
font-size: 22px;
}

&__lang-item {
Expand Down
10 changes: 4 additions & 6 deletions src/components/Controls/single-controls/LangControl.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useEffect, useState, useRef, ReactElement} from 'react';
import React, {useCallback, useEffect, useState, useRef} from 'react';
import {WithTranslation, withTranslation, WithTranslationProps} from 'react-i18next';
import allLangs from 'langs';
import {Popup, Icon as IconComponent, List} from '@gravity-ui/uikit';
Expand All @@ -10,14 +10,12 @@ import {getPopupPosition} from './utils';
import {PopperPosition} from '../../../hooks';

import LangIcon from '../../../../assets/icons/lang.svg';
import RusIcon from '../../../../assets/icons/rus.svg';
import EngIcon from '../../../../assets/icons/eng.svg';

import '../Controls.scss';

const LEGACY_LANG_ITEMS = [
{value: Lang.En, text: 'English', icon: <EngIcon />},
{value: Lang.Ru, text: 'Русский', icon: <RusIcon />},
{value: Lang.En, text: 'English', icon: '🇬🇧'},
{value: Lang.Ru, text: 'Русский', icon: '🇷🇺'},
];

const b = block('dc-controls');
Expand All @@ -35,7 +33,7 @@ interface ControlProps {
interface ListItem {
value: string;
text: string;
icon?: ReactElement;
icon?: string;
}

const LIST_ITEM_HEIGHT = 36;
Expand Down
4 changes: 2 additions & 2 deletions src/components/ErrorBoundary/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import _ from 'lodash';
import {isEqual} from 'lodash';

import {ErrorPage} from '../ErrorPage';

Expand All @@ -12,7 +12,7 @@ class ErrorBoundary extends React.Component<ErrorBoundaryState> {
state: ErrorBoundaryState = {};

componentDidUpdate(prevProps: ErrorBoundaryState) {
if (this.state.error && !_.isEqual(this.props, prevProps)) {
if (this.state.error && !isEqual(this.props, prevProps)) {
this.setState({error: undefined, errorInfo: undefined});
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/Scrollspy/Scrollspy.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {ReactElement} from 'react';
import _ from 'lodash';
import {isEqual, debounce} from 'lodash';
import scrollIntoView from 'scroll-into-view-if-needed';

import {InnerProps} from '../../utils';
Expand Down Expand Up @@ -68,11 +68,11 @@ export class Scrollspy extends React.Component<ScrollspyInnerProps, ScrollspySta
const {items, router} = this.props;
const {inViewState} = this.state;

if (!_.isEqual(inViewState, prevState.inViewState)) {
if (!isEqual(inViewState, prevState.inViewState)) {
this.scrollToListItem();
}

if (!_.isEqual(items, prevProps.items) || prevProps.router.pathname !== router.pathname) {
if (!isEqual(items, prevProps.items) || prevProps.router.pathname !== router.pathname) {
this.initItems();
}

Expand Down Expand Up @@ -293,7 +293,7 @@ export class Scrollspy extends React.Component<ScrollspyInnerProps, ScrollspySta
};

// eslint-disable-next-line @typescript-eslint/member-ordering, react/sort-comp
private handleScrollDebounced = _.debounce(this.handleScroll, 100);
private handleScrollDebounced = debounce(this.handleScroll, 100);

private pauseScrollHandler() {
// wait for the end of smooth auto-scroll
Expand Down
4 changes: 2 additions & 2 deletions src/components/SearchBar/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useEffect, useRef, useState, useCallback} from 'react';
import _ from 'lodash';
import {throttle} from 'lodash';

import {getHighlightedItemIndexInView, highlight, scrollToItem} from './utils';
import {CLASSNAME, CLASSNAME_SELECTED, HIGHLIGHT_OPTIONS} from './constants';
Expand Down Expand Up @@ -369,7 +369,7 @@ export function useCurrentWordSelectionSyncScrollEffect({
headerHeight,
]);

const handleScrollThrottled = _.throttle(handleScroll, 50);
const handleScrollThrottled = throttle(handleScroll, 50);

useEffect(() => {
if (searchBarIsVisible) {
Expand Down

0 comments on commit 90b6a91

Please sign in to comment.