Skip to content

Commit

Permalink
fix: icon sizes and colors with svgr lib
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Apr 17, 2024
1 parent 0a0efef commit e3f82aa
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = {
],
},
],
'react/jsx-max-props-per-line': ['error', { maximum: 3 }],
'react/jsx-max-props-per-line': ['error', { maximum: 4 }],
},
globals: {
__IS_DEV__: true,
Expand Down
28 changes: 22 additions & 6 deletions config/build/buildLoaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,33 @@ export function buildLoaders(options: BuildOptions): webpack.RuleSetRule[] {
paths,

Check warning on line 13 in config/build/buildLoaders.ts

View workflow job for this annotation

GitHub Actions / checks (17.x)

'paths' is assigned a value but never used
} = options;

const svgLoader = {
test: /\.svg$/,
use: ['@svgr/webpack'],
};
const svgLoader = {
test: /\.svg$/,
use: [{
loader: '@svgr/webpack',
options: {
icon: true,
svgoConfig: {
plugins: [
{
name: 'convertColors',
params: {
currentColor: true,
}
}
]
}
}
}],
};


const codeBabelLoader = buildBabelLoader({ ...options, isTsx: false });
const codeBabelLoader = buildBabelLoader({ ...options, isTsx: false });
const tsxCodeBabelLoader = buildBabelLoader({ ...options, isTsx: true });

const cssLoader = buildCssLoader(isDev);

// Если не используем тайпскрипт - нужен babel-loader
// if not using ts - babel-loader needed
// const typescriptLoader = {
// test: /\.tsx?$/,
// use: 'ts-loader',
Expand Down
2 changes: 1 addition & 1 deletion src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { Sidebar } from '@/widgets/Sidebar';
import { getUserInited, initAuthData } from '@/entities/User';
import { useTheme } from '@/shared/lib/hook/useTheme/useTheme';
import { useAppDispatch } from '@/shared/lib/hook/useAppDispatch/useAppDispatch';
import { PageLoader } from '@/features/PageLoader';
import { ToggleFeatures } from '@/shared/lib/features';
import { MainLayout } from '@/shared/layouts/MainLayout';
import { PageLoader } from '@/features/PageLoader';

function App() {
const { theme } = useTheme();
Expand Down
4 changes: 1 addition & 3 deletions src/entities/User/model/slice/userSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ export const userSlice = createSlice({
},
);
builder.addCase(initAuthData.rejected, (state) => {
if (state.authData) {
state._inited = true;
}
state._inited = true;
});
},
});
Expand Down
2 changes: 2 additions & 0 deletions src/features/ArticleViewSelector/ui/ArticleViewSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export const ArticleViewSelector = memo((props: ArticleViewSelectorProps) => {
[cls.notSelected]: viewType.view !== view,
})}
Svg={viewType.icon}
width={24}
height={24}
/>
</Button>
))}
Expand Down
7 changes: 3 additions & 4 deletions src/features/ThemeSwitcher/ui/ThemeSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { useCallback } from 'react';
import { classNames } from '@/shared/lib/classNames/classNames';
import { Button, ButtonTheme } from '@/shared/ui/Button';
import LightIcon from '../../../shared/assets/icons/theme-light.svg';
import DarkIcon from '../../../shared/assets/icons/theme-dark.svg';
import { Theme } from '@/shared/const/theme';
import ThemeIcon from '../../../shared/assets/icons/theme-light.svg';
import { useTheme } from '@/shared/lib/hook/useTheme/useTheme';
import { saveJsonSettings } from '@/entities/User';
import { useAppDispatch } from '@/shared/lib/hook/useAppDispatch/useAppDispatch';
import { Icon } from '@/shared/ui/Icon';

interface ThemeSwitcherProps {
className?: string;
Expand All @@ -29,7 +28,7 @@ export const ThemeSwitcher = ({ className }: ThemeSwitcherProps) => {
className={classNames('', {}, [className])}
onClick={onToggleHandler}
>
{theme === Theme.DARK ? <DarkIcon /> : <LightIcon />}
<Icon Svg={ThemeIcon} width={40} height={40} inverted />
</Button>
);
};
4 changes: 2 additions & 2 deletions src/shared/lib/features/setGetFeatures.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FeatureFlags } from '@/shared/types/featureFlags';

// features does not change on session, only after
let featureFlags: FeatureFlags;
let featureFlags: FeatureFlags = {};

export function setFeatureFlags(newFeatureFlags?: FeatureFlags) {
if (newFeatureFlags) {
Expand All @@ -10,5 +10,5 @@ export function setFeatureFlags(newFeatureFlags?: FeatureFlags) {
}

export function getFeatureFlag(flag: keyof FeatureFlags) {
return featureFlags[flag] ?? false;
return featureFlags?.[flag];
}

0 comments on commit e3f82aa

Please sign in to comment.