Skip to content

Commit

Permalink
feat: create config.ts to uniformly manage config
Browse files Browse the repository at this point in the history
  • Loading branch information
jinho-choi123 committed Nov 3, 2023
1 parent fafdbd4 commit 5938f32
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/components/Background/Background.animation.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const AnimationDuration = import.meta.env.VITE_ANIMATION_DURATION;
import { ANIMATION_DURATION } from "@/config";

export const backgroundFadeIn = {
to: {
opacity: 1,
},
config: {
duration: AnimationDuration,
duration: ANIMATION_DURATION,
},
};

Expand All @@ -14,6 +14,6 @@ export const backgroundFadeOut = {
opacity: 0,
},
config: {
duration: AnimationDuration,
duration: ANIMATION_DURATION,
},
};
5 changes: 2 additions & 3 deletions src/components/Board/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import { Info } from "@/components/Info";
import { Background } from "@/components/Background";
import { Qr } from "@/components/Qr";
import { Logo } from "@/components/Logo";
import { TRANSITION_INTERVAL } from "@/config";
import style from "./Board.module.scss";

const TransitionInterval = import.meta.env.VITE_TRANSITION_INTERVAL;

export const Board = () => {
const zaboList = useAppSelector((state: ZaboListState) => state.zaboList);
const leftOverZaboLength = useAppSelector(
Expand All @@ -30,7 +29,7 @@ export const Board = () => {
} else {
dispatch(fetchZaboThunk());
}
}, TransitionInterval);
}, TRANSITION_INTERVAL);

return (
<main className={style.board}>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Info/Info.animation.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const AnimationDuration = import.meta.env.VITE_ANIMATION_DURATION;
import { ANIMATION_DURATION } from "@/config";

export const infoFadeIn = {
to: {
opacity: 1,
},
config: {
duration: AnimationDuration,
duration: ANIMATION_DURATION,
},
};

Expand All @@ -14,6 +14,6 @@ export const infoFadeOut = {
opacity: 0,
},
config: {
duration: AnimationDuration,
duration: ANIMATION_DURATION,
},
};
6 changes: 3 additions & 3 deletions src/components/Qr/Qr.animation.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const AnimationDuration = import.meta.env.VITE_ANIMATION_DURATION;
import { ANIMATION_DURATION } from "@/config";

export const qrFadeIn = {
to: {
opacity: 1,
},
config: {
duration: AnimationDuration,
duration: ANIMATION_DURATION,
},
};

Expand All @@ -14,6 +14,6 @@ export const qrFadeOut = {
opacity: 0,
},
config: {
duration: AnimationDuration,
duration: ANIMATION_DURATION,
},
};
8 changes: 4 additions & 4 deletions src/components/Zabo/Zabo.animation.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const AnimationDuration = import.meta.env.VITE_ANIMATION_DURATION;
import { ANIMATION_DURATION } from "@/config";

export const zaboMoveToBefore = {
to: {
x: 3145,
opacity: 0.5,
},
config: {
duration: AnimationDuration,
duration: ANIMATION_DURATION,
},
};

Expand All @@ -16,7 +16,7 @@ export const zaboMoveToCurrent = {
opacity: 1,
},
config: {
duration: AnimationDuration,
duration: ANIMATION_DURATION,
},
};

Expand All @@ -26,6 +26,6 @@ export const zaboFadeOut = {
x: 1731,
},
config: {
duration: AnimationDuration,
duration: ANIMATION_DURATION,
},
};
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const API_SERVER_URL = import.meta.env.VITE_API_SERVER_URL;
export const ANIMATION_DURATION = import.meta.env.VITE_ANIMATION_DURATION;
export const TRANSITION_INTERVAL = import.meta.env.VITE_TRANSITION_INTERVAL;
3 changes: 2 additions & 1 deletion src/redux/zabos/fetchZaboThunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import axios from "axios";
import dayjs from "dayjs";
import type { AppDispatch } from "@/redux/store";
import { ZaboState, type ZaboJson } from "@/types";
import { API_SERVER_URL } from "@/config";
import { pushZabos } from "./zaboSlice";

const ZABO_SHARE_URL = "".concat(import.meta.env.VITE_API_SERVER_URL, "s/");
const ZABO_SHARE_URL = `${API_SERVER_URL}/s/`;

export const fetchZaboThunk = () => async (dispatch: AppDispatch) => {
// attach timestamp to image url to prevent browser cache
Expand Down
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import tsconfigPaths from "vite-tsconfig-paths";

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const TmpEnv = loadEnv(mode, process.cwd());
const tmpEnv = loadEnv(mode, process.cwd());

return {
plugins: [react(), tsconfigPaths()],
server: {
proxy: {
"/api": TmpEnv.VITE_API_SERVER_URL,
"/api": tmpEnv.VITE_API_SERVER_URL,
},
},
};
Expand Down

0 comments on commit 5938f32

Please sign in to comment.