Skip to content

Commit

Permalink
Merge pull request #116 from ApeSwapFinance/feat/sid
Browse files Browse the repository at this point in the history
Display SID domain name
  • Loading branch information
obiedobo authored Nov 14, 2022
2 parents d8227c6 + 82769f1 commit a18d523
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 29 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: 3 additions & 1 deletion src/__tests__/widgets/menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ it("renders correctly", () => {
<BrowserRouter>
<Navbar
mailChimpUrl=""
uDName="babadrape64.wallet"
sidName="bbdrape.bnb"
account="0xbdda50183d817c3289f895a4472eb475967dc980"
login={noop}
logout={noop}
Expand Down Expand Up @@ -175,7 +177,7 @@ it("renders correctly", () => {
<span
class="css-1yc05tr"
>
0xbd...c980
babadrape64.wallet
</span>
</button>
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
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 a18d523

Please sign in to comment.