From eee78d5705f63878170edc3a313e3d4063df299f Mon Sep 17 00:00:00 2001 From: Bohdan Shcherbyna Date: Mon, 4 Nov 2024 13:30:44 +0200 Subject: [PATCH] refactor: 628 - remove unused env variables --- .env | 4 ---- src/shared/constants.ts | 3 --- src/shared/helpers/generateSizes.ts | 9 --------- src/shared/helpers/generateSrcSet.ts | 13 ------------- src/widgets/about-video/ui/about-video.test.tsx | 4 ++-- src/widgets/about-video/ui/about-video.tsx | 2 +- 6 files changed, 3 insertions(+), 32 deletions(-) delete mode 100644 .env delete mode 100644 src/shared/helpers/generateSizes.ts delete mode 100644 src/shared/helpers/generateSrcSet.ts diff --git a/.env b/.env deleted file mode 100644 index 9f48d54ba..000000000 --- a/.env +++ /dev/null @@ -1,4 +0,0 @@ -NEXT_PUBLIC_TABLET=768 -NEXT_PUBLIC_MOBILE=425 -NEXT_PUBLIC_COMPRESS_QUALITY=80 -NEXT_PUBLIC_DEV=true diff --git a/src/shared/constants.ts b/src/shared/constants.ts index ca7580ed7..4b880add4 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -1,6 +1,3 @@ -export const TABLET_W = Number(process.env.NEXT_PUBLIC_TABLET); -export const MOBILE_W = Number(process.env.NEXT_PUBLIC_MOBILE); -export const DESKTOP_W = 1280; export const RS_INTRO_URL = 'https://www.youtube.com/embed/n4unZLVpnaU'; export const RS_FOUNDATION_YEAR = '2013'; diff --git a/src/shared/helpers/generateSizes.ts b/src/shared/helpers/generateSizes.ts deleted file mode 100644 index a2224b54b..000000000 --- a/src/shared/helpers/generateSizes.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { DESKTOP_W, MOBILE_W, TABLET_W } from '@/shared/constants'; - -/** - * Generates responsive sizes for Img element, based on the env breakpoints - * @returns {string} - Returns the sizes string - */ -export const generateSizes = () => { - return `(max-width: ${MOBILE_W}px) ${MOBILE_W}px, (max-width: ${TABLET_W}px) ${TABLET_W}px, ${DESKTOP_W}px`; -}; diff --git a/src/shared/helpers/generateSrcSet.ts b/src/shared/helpers/generateSrcSet.ts deleted file mode 100644 index 292a6db34..000000000 --- a/src/shared/helpers/generateSrcSet.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { DESKTOP_W, MOBILE_W, TABLET_W } from '@/shared/constants'; - -/** - * Generates the srcset for the given src image, based on the env breakpoints - * @param {string} src - An src value to generate the srcset from - * @returns {string} - Returns the processed srcset - */ -export const generateSrcSet = (src: string) => { - const srcNoExtension = src.slice(0, src.lastIndexOf('.')); - const srcSet = `${srcNoExtension}-${MOBILE_W}.webp ${MOBILE_W}w, ${srcNoExtension}-${TABLET_W}.webp ${TABLET_W}w, ${src} ${DESKTOP_W}w`; - - return srcSet; -}; diff --git a/src/widgets/about-video/ui/about-video.test.tsx b/src/widgets/about-video/ui/about-video.test.tsx index 71af006aa..0ad53e473 100644 --- a/src/widgets/about-video/ui/about-video.test.tsx +++ b/src/widgets/about-video/ui/about-video.test.tsx @@ -22,7 +22,7 @@ describe('AboutVideo component', () => { }); it('renders the placeholder in development mode', () => { - vi.stubEnv('NEXT_PUBLIC_DEV', 'true'); + vi.stubEnv('NODE_ENV', 'development'); render(); const placeholder = screen.getByText('Video Placeholder'); @@ -30,7 +30,7 @@ describe('AboutVideo component', () => { }); it('renders the YouTube embed in production mode', () => { - vi.stubEnv('NEXT_PUBLIC_DEV', 'false'); + vi.stubEnv('NODE_ENV', 'production'); render(); const video = screen.getByTitle('Introduction to The Rolling Scopes School Online Courses'); diff --git a/src/widgets/about-video/ui/about-video.tsx b/src/widgets/about-video/ui/about-video.tsx index 99f8848dd..60da1b4b5 100644 --- a/src/widgets/about-video/ui/about-video.tsx +++ b/src/widgets/about-video/ui/about-video.tsx @@ -11,7 +11,7 @@ type AboutVideoProps = { lang?: 'en' | 'ru' }; export const AboutVideo = ({ lang = 'en' }: AboutVideoProps) => { // Needed to prevent flakiness in screenshot tests - const isRunningInDev = process.env.NEXT_PUBLIC_DEV === 'true'; + const isRunningInDev = process.env.NODE_ENV === 'development'; return (