From 90b6a9182ecca6d615b564fc1a128005e49def94 Mon Sep 17 00:00:00 2001
From: 3y3k0 <3y3k0@yandex-team.ru>
Date: Fri, 23 Jun 2023 02:55:32 +0300
Subject: [PATCH] fix: Optimize build size
---
assets/icons/eng.svg | 9 ---------
assets/icons/rus.svg | 9 ---------
src/components/Controls/Controls.scss | 1 +
.../Controls/single-controls/LangControl.tsx | 10 ++++------
src/components/ErrorBoundary/ErrorBoundary.tsx | 4 ++--
src/components/Scrollspy/Scrollspy.tsx | 8 ++++----
src/components/SearchBar/hooks.ts | 4 ++--
7 files changed, 13 insertions(+), 32 deletions(-)
delete mode 100644 assets/icons/eng.svg
delete mode 100644 assets/icons/rus.svg
diff --git a/assets/icons/eng.svg b/assets/icons/eng.svg
deleted file mode 100644
index 9e016b90..00000000
--- a/assets/icons/eng.svg
+++ /dev/null
@@ -1,9 +0,0 @@
-
diff --git a/assets/icons/rus.svg b/assets/icons/rus.svg
deleted file mode 100644
index b50842e4..00000000
--- a/assets/icons/rus.svg
+++ /dev/null
@@ -1,9 +0,0 @@
-
diff --git a/src/components/Controls/Controls.scss b/src/components/Controls/Controls.scss
index 17aeddbb..5348578c 100644
--- a/src/components/Controls/Controls.scss
+++ b/src/components/Controls/Controls.scss
@@ -21,6 +21,7 @@
&__list-icon {
margin-right: 8px;
+ font-size: 22px;
}
&__lang-item {
diff --git a/src/components/Controls/single-controls/LangControl.tsx b/src/components/Controls/single-controls/LangControl.tsx
index 64a3e25d..22eb1c00 100644
--- a/src/components/Controls/single-controls/LangControl.tsx
+++ b/src/components/Controls/single-controls/LangControl.tsx
@@ -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';
@@ -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: },
- {value: Lang.Ru, text: 'Русский', icon: },
+ {value: Lang.En, text: 'English', icon: '🇬🇧'},
+ {value: Lang.Ru, text: 'Русский', icon: '🇷🇺'},
];
const b = block('dc-controls');
@@ -35,7 +33,7 @@ interface ControlProps {
interface ListItem {
value: string;
text: string;
- icon?: ReactElement;
+ icon?: string;
}
const LIST_ITEM_HEIGHT = 36;
diff --git a/src/components/ErrorBoundary/ErrorBoundary.tsx b/src/components/ErrorBoundary/ErrorBoundary.tsx
index f2605ee2..413ee890 100644
--- a/src/components/ErrorBoundary/ErrorBoundary.tsx
+++ b/src/components/ErrorBoundary/ErrorBoundary.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import _ from 'lodash';
+import {isEqual} from 'lodash';
import {ErrorPage} from '../ErrorPage';
@@ -12,7 +12,7 @@ class ErrorBoundary extends React.Component {
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});
}
}
diff --git a/src/components/Scrollspy/Scrollspy.tsx b/src/components/Scrollspy/Scrollspy.tsx
index a0736b8f..c35b9f7d 100644
--- a/src/components/Scrollspy/Scrollspy.tsx
+++ b/src/components/Scrollspy/Scrollspy.tsx
@@ -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';
@@ -68,11 +68,11 @@ export class Scrollspy extends React.Component {
if (searchBarIsVisible) {