Skip to content

Commit

Permalink
chore: Merged with latest main-v-2
Browse files Browse the repository at this point in the history
  • Loading branch information
ape-fede committed Dec 6, 2022
2 parents 473241a + a18d523 commit 1577b0e
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ape.swap/uikit",
"version": "1.3.35",
"version": "1.3.40",
"description": "Set of UI components for apeswap projects",
"main": "dist/index.cjs.js",
"resolutions": {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/widgets/menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ it("renders correctly", () => {
</a>
<a
class="sc-hiSbEG gqZtKj"
href="https://discord.gg/apeswap"
href="https://apeswap.click/discord"
rel="noopener noreferrer"
target="_blank"
>
Expand Down Expand Up @@ -953,7 +953,7 @@ it("renders correctly", () => {
</a>
<a
class="sc-bBXrwG kqTzrD"
href="https://discord.gg/apeswap"
href="https://apeswap.click/discord"
rel="noopener noreferrer"
target="_blank"
>
Expand Down
6 changes: 4 additions & 2 deletions src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ const Footer: React.FC<FooterProps> = ({
onClick={() => trackClick(track, event, position, chainId, "twitter", "https://twitter.com/ape_swap")}
/>
</StyledLink>
<StyledLink href="https://discord.gg/apeswap" target="_blank" rel="noopener noreferrer">
<StyledLink href="https://apeswap.click/discord" target="_blank" rel="noopener noreferrer">
<DiscordIcon
color="white3"
fill={iconFillColor}
onClick={() => trackClick(track, event, position, chainId, "discord", "https://discord.gg/apeswap")}
onClick={() =>
trackClick(track, event, position, chainId, "discord", "https://apeswap.click/discord")
}
/>
</StyledLink>
<StyledLink href="https://t.me/ape_swap" target="_blank" rel="noopener noreferrer">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const supportLinks = [
},
{
label: "Discord",
href: "https://discord.gg/apeswap",
href: "https://apeswap.click/discord",
},
{
label: "Tokenomics",
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/Navbar/MobileNavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ const MobileNavMenu: React.FC<MobileNavMenuProps> = ({
onClick={() => trackClick(track, event, position, chainId, "telegram", "https://t.me/ape_swap")}
/>
</StyledLink>
<StyledLink href="https://discord.gg/apeswap" target="_blank" rel="noopener noreferrer">
<StyledLink href="https://apeswap.click/discord" target="_blank" rel="noopener noreferrer">
<DiscordIcon
color="white3"
fill={iconFillColor}
onClick={() => trackClick(track, event, position, chainId, "discord", "https://discord.gg/apeswap")}
onClick={() => trackClick(track, event, position, chainId, "discord", "https://apeswap.click/discord")}
/>
</StyledLink>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const MobileOnlyOverlay = styled(Overlay)`
`;

const Navbar: React.FC<NavProps> = ({
sidName,
uDName,
account,
login,
Expand Down Expand Up @@ -259,8 +260,8 @@ const Navbar: React.FC<NavProps> = ({
<NetworkButton chainId={chainId} switchNetwork={switchNetwork} t={t} />
</Flex>
)}
<UserBlock uDName={uDName} account={account} login={login} logout={logout} t={t} />
{(uDName || account) && profile && <Avatar profile={profile} />}
<UserBlock sidName={sidName} uDName={uDName} account={account} login={login} logout={logout} t={t} />
{(uDName || sidName || account) && profile && <Avatar profile={profile} />}
{isMobile && (
<MenuButton aria-label="Toggle menu" handleClick={() => setIsPushed(!isPushed)}>
{isPushed ? (
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/Navbar/SubNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ const SubNavbar: React.FC<SubNavbarProps> = ({
onClick={() => trackClick(track, event, position, chainId, "telegram", "https://t.me/ape_swap")}
/>
</StyledLink>
<StyledLink href="https://discord.gg/apeswap" target="_blank" rel="noopener noreferrer">
<StyledLink href="https://apeswap.click/discord" target="_blank" rel="noopener noreferrer">
<DiscordIcon
color="white3"
fill={iconFillColor}
onClick={() => trackClick(track, event, position, chainId, "discord", "https://discord.gg/apeswap")}
onClick={() => trackClick(track, event, position, chainId, "discord", "https://apeswap.click/discord")}
/>
</StyledLink>
</Flex>
Expand Down
28 changes: 15 additions & 13 deletions src/widgets/Navbar/UserBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ import { dynamicStyles } from "./styles";
import { Text } from "../../components/Text";

interface Props {
account?: string | undefined;
uDName?: string | undefined;
account?: string;
uDName?: string;
sidName?: string;
login: Login;
logout: () => void;
t: (key: string) => string;
}

const UserBlock: React.FC<Props> = ({ uDName, account, login, logout, t }) => {
const { onPresentConnectModal, onPresentAccountModal } = useWalletModal(login, logout, t, account, uDName);
const UserBlock: React.FC<Props> = ({ sidName, uDName, account, login, logout, t }) => {
const { onPresentConnectModal, onPresentAccountModal } = useWalletModal(login, logout, t, account, uDName, sidName);
const accountEllipsis = account ? `${account.substring(0, 4)}...${account.substring(account.length - 4)}` : null;
const { isXs } = useMatchBreakpoints();

const buttonStyle = dynamicStyles.userBlockBtn({ account, uDName });
const buttonStyle = dynamicStyles.userBlockBtn({ account, uDName, sidName });

const loadButton = () => {
if (uDName || account) {
if (uDName || sidName || account) {
if (isXs) {
return (
<Button
Expand All @@ -33,9 +34,9 @@ const UserBlock: React.FC<Props> = ({ uDName, account, login, logout, t }) => {
onClick={() => {
onPresentAccountModal();
}}
account={uDName || account}
account={uDName || sidName || account}
>
<Text weight="normal">{uDName || accountEllipsis}</Text>
<Text weight="normal">{uDName || sidName || accountEllipsis}</Text>
</Button>
);
}
Expand All @@ -48,9 +49,9 @@ const UserBlock: React.FC<Props> = ({ uDName, account, login, logout, t }) => {
onClick={() => {
onPresentAccountModal();
}}
account={uDName || account}
account={uDName || sidName || account}
>
<Text weight="normal">{uDName || accountEllipsis}</Text>
<Text weight="normal">{uDName || sidName || accountEllipsis}</Text>
</Button>
);
}
Expand All @@ -62,7 +63,7 @@ const UserBlock: React.FC<Props> = ({ uDName, account, login, logout, t }) => {
onClick={() => {
onPresentConnectModal();
}}
account={uDName || account}
account={uDName || sidName || account}
>
{t("Connect")}
</Button>
Expand All @@ -73,8 +74,9 @@ const UserBlock: React.FC<Props> = ({ uDName, account, login, logout, t }) => {
};

UserBlock.defaultProps = {
account: "",
uDName: "",
account: undefined,
uDName: undefined,
sidName: undefined,
};

export default UserBlock;
9 changes: 6 additions & 3 deletions src/widgets/Navbar/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const langs: Language[] = [...Array(20)].map((_, i) => ({ code: `en${i}`, langua
const translate: (key: string) => string = (key) => key;
const track: TrackHandler =
// eslint-disable-next-line no-empty-pattern
({}: TrackProps) =>
() => ({});
({}: TrackProps) =>
() => ({});
const mcLink = "";

export const Connected: React.FC = (args: any) => {
Expand Down Expand Up @@ -116,6 +116,7 @@ export const NotConnected: React.FC = () => {
<BrowserRouter>
<Navbar
mailChimpUrl={mcLink}
sidName={undefined}
uDName={undefined}
account={undefined}
login={noop}
Expand Down Expand Up @@ -209,7 +210,8 @@ export const WithNoProfile: React.FC = () => {
<BrowserRouter>
<Navbar
mailChimpUrl={mcLink}
uDName="babadrape64.wallet"
sidName="bbdrape.bnb"
uDName={undefined}
account="0xbdda50183d817c3289f895a4472eb475967dc980"
login={noop}
logout={noop}
Expand Down Expand Up @@ -272,6 +274,7 @@ export const WithProfile: React.FC = () => {
<BrowserRouter>
<Navbar
mailChimpUrl={mcLink}
sidName="bbdrape.bnb"
uDName="babadrape64.wallet"
account="0xbdda50183d817c3289f895a4472eb475967dc980"
login={noop}
Expand Down
9 changes: 5 additions & 4 deletions src/widgets/Navbar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,18 @@ const styles: Record<string, ThemeUIStyleObject> = {
interface Props {
account?: string;
uDName?: string;
sidName?: string;
}

export const dynamicStyles: Record<string, (props: any) => ThemeUIStyleObject> = {
userBlockBtn: ({ account, uDName }: Props) => ({
userBlockBtn: ({ account, uDName, sidName }: Props) => ({
height: "35px",
marginLeft: "10px",
lineHeight: "10px",
background: uDName || account ? "white3" : "yellow",
color: uDName || account ? "text" : "primaryBright",
background: uDName || sidName || account ? "white3" : "yellow",
color: uDName || sidName || account ? "text" : "primaryBright",
"&&": {
padding: `0px ${uDName || account ? "45px" : "15px"} 0px 15px`,
padding: `0px ${uDName || sidName || account ? "45px" : "15px"} 0px 15px`,
},
}),
};
Expand Down
1 change: 1 addition & 0 deletions src/widgets/Navbar/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@ export interface NavProps extends PanelProps {
profile?: Profile;
track?: TrackHandler;
uDName?: string;
sidName?: string;
liveResult?: LiveResultProps["apiResult"] | undefined;
}
6 changes: 4 additions & 2 deletions src/widgets/WalletModal/AccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ interface Props {
logout: () => void;
t: (key: string) => string;
uDName?: string;
sidName?: string;
}

const AccountModal: React.FC<Props> = ({ uDName, account, logout, t }) => {
const AccountModal: React.FC<Props> = ({ sidName, uDName = undefined, account, logout, t }) => {
const { handleClose } = useContext(ModalContext);
const { isXs, isSm, isMd } = useMatchBreakpoints();
const reducedAddress = account ? `${account.substring(0, 15)}...${account.substring(account.length - 4)}` : null;
Expand All @@ -30,7 +31,7 @@ const AccountModal: React.FC<Props> = ({ uDName, account, logout, t }) => {
sx={{ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}
mb="8px"
>
{isXs || isSm || isMd ? uDName || reducedAddress : uDName || account}
{isXs || isSm || isMd ? uDName || sidName || reducedAddress : uDName || sidName || account}
</Text>
<Flex sx={{ alignItems: "center" }} mt="8px" mb="32px">
<Link
Expand Down Expand Up @@ -64,6 +65,7 @@ const AccountModal: React.FC<Props> = ({ uDName, account, logout, t }) => {
AccountModal.defaultProps = {
account: undefined,
uDName: undefined,
sidName: undefined,
};

export default AccountModal;
3 changes: 2 additions & 1 deletion src/widgets/WalletModal/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export const Wallet = (args: any) => {
() => null,
translate,
"0xbdda50183d817c3289f895a4472eb475967dc980",
"babadrape64.wallet"
"",
"bbdrape.bnb"
);
return (
<StorybookLayout {...args}>
Expand Down
7 changes: 5 additions & 2 deletions src/widgets/WalletModal/useWalletModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ const useWalletModal = (
logout: () => void,
t: (key: string) => string,
account?: string,
uDName?: string
uDName?: string,
sidName?: string
): ReturnType => {
const [onPresentConnectModal] = useModal(<ConnectModal login={login} t={t} />);
const [onPresentAccountModal] = useModal(<AccountModal uDName={uDName} account={account} logout={logout} t={t} />);
const [onPresentAccountModal] = useModal(
<AccountModal sidName={sidName} uDName={uDName} account={account} logout={logout} t={t} />
);
return { onPresentConnectModal, onPresentAccountModal };
};

Expand Down

0 comments on commit 1577b0e

Please sign in to comment.