Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/deploy-to-cf-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
timeout-minutes: 5
env:
BRANCH_NAME: ${{ github.head_ref }}
steps:
- name: "Checkout Github Action"
uses: actions/checkout@v4
Expand All @@ -40,6 +42,7 @@ jobs:
run: |
touch .env
echo VITE_FEATURE_TOGGLE_CLIENT_KEY=${{ vars.VITE_FEATURE_TOGGLE_CLIENT_KEY }} >> .env
echo VITE_BRANCH_NAME=${{ env.BRANCH_NAME }} >> .env
- name: Build Project
run: |
npm run build
Expand Down
14 changes: 12 additions & 2 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { useMedia } from "@hooks/useMedia";
import { useStores } from "@stores";
import { MODAL_TYPE } from "@stores/ModalStore";

import { CONFIG } from "@utils/getConfig";

import { ConnectWalletButton } from "../ConnectWalletButton";
import { AccountInfoSheet } from "../Modal";
import { SmartFlex } from "../SmartFlex";
Expand All @@ -31,6 +33,8 @@ const Header: React.FC = observer(() => {
const [isMobileMenuOpen, openMobileMenu, closeMobileMenu] = useFlag();
const [isAccountInfoSheetOpen, openAccountInfo, closeAccountInfo] = useFlag();

const SparkLogo = CONFIG.APP.isMainnet ? Logo : LogoStyled;

useEffect(() => {
if (media.desktop) {
closeMobileMenu();
Expand Down Expand Up @@ -68,7 +72,7 @@ const Header: React.FC = observer(() => {
<>
<SmartFlex center="y">
<a href="/" rel="noreferrer noopener">
<Logo />
<SparkLogo />
</a>
<StyledText>BETA</StyledText>
</SmartFlex>
Expand Down Expand Up @@ -96,7 +100,7 @@ const Header: React.FC = observer(() => {
<>
<SmartFlex center="y">
<a href="/" rel="noreferrer noopener">
<Logo />
<SparkLogo />
</a>
<StyledText>BETA</StyledText>
<Divider />
Expand Down Expand Up @@ -190,3 +194,9 @@ const WalletContainer = styled(SmartFlex)<{ isVisible?: boolean }>`
}
}
`;

const LogoStyled = styled(Logo)`
path {
fill: ${({ theme }) => theme.colors.greenLight};
}
`;
11 changes: 10 additions & 1 deletion src/typings/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@
/// <reference types="react" />
/// <reference types="react-dom" />
/// <reference types="vite/client" />
/// <reference types="vite-plugin-svgr/client" />
/// <reference types="vite-plugin-svgr/client" />

interface ImportMetaEnv {
VITE_FEATURE_TOGGLE_CLIENT_KEY: string | undefined;
VITE_BRANCH_NAME: string | undefined;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
17 changes: 16 additions & 1 deletion src/utils/getConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import assert from "assert";

import { Undefinable } from "tsdef";

import TOKEN_LOGOS from "@constants/tokenLogos";

import { Token } from "@entity";
Expand All @@ -21,8 +23,21 @@ export interface Market {
contractId: string;
}

function getConfigByBranch(branchName: Undefinable<string>) {
if (branchName === "main") {
return configProdJSON;
}

if (branchName?.includes("stage/")) {
return configDevJSON;
}

return configDevJSON;
}

function createConfig() {
const configJSON = import.meta.env.DEV ? configDevJSON : configProdJSON;
const configJSON = getConfigByBranch(import.meta.env.VITE_BRANCH_NAME);

assert(configJSON.version === CURRENT_CONFIG_VER, "Version mismatch");

console.warn("SPARK CONFIG", configJSON);
Expand Down