Handle svg files using svgr

This commit is contained in:
delivan 2022-12-19 17:30:00 +09:00
parent 4ccffda192
commit f4170a761c
11 changed files with 37 additions and 100 deletions

View File

@ -1,4 +1,3 @@
import { ChainItemType } from "../../types";
import { import {
Dispatch, Dispatch,
FunctionComponent, FunctionComponent,
@ -6,19 +5,19 @@ import {
useEffect, useEffect,
useState, useState,
} from "react"; } from "react";
import { ChainItemType } from "../../types";
import { ChainImage } from "./chain-image"; import styled from "styled-components";
import AllChainsIcon from "../../public/images/svg/all-chains-icon.svg";
import color from "../../styles/color";
import { Flex1 } from "../../styles/flex-1"; import { Flex1 } from "../../styles/flex-1";
import { Checkbox } from "../checkbox";
import { import {
ChainInfoContainer, ChainInfoContainer,
ChainItemContainer, ChainItemContainer,
ChainName, ChainName,
WalletAddress, WalletAddress,
} from "./chain-item"; } from "./chain-item";
import color from "../../styles/color";
import styled from "styled-components";
import { Checkbox } from "../checkbox";
import AllChainsIcon from "../../public/images/svg/all-chains-icon.svg";
interface Props { interface Props {
chainList: ChainItemType[]; chainList: ChainItemType[];
@ -55,7 +54,7 @@ export const AllChainsItem: FunctionComponent<Props> = (props) => {
checked={checked} checked={checked}
onClick={checkHandler} onClick={checkHandler}
> >
<ChainImage src={AllChainsIcon} fill={true} alt={`all chain images`} /> <AllChainsIcon />
<ChainInfoContainer> <ChainInfoContainer>
<ChainName>{`.all chains(${chainList.length})`}</ChainName> <ChainName>{`.all chains(${chainList.length})`}</ChainName>
<WalletAddress> <WalletAddress>

View File

@ -3,7 +3,6 @@ import ArrowRightIcon from "../../public/images/svg/arrow-right.svg";
import color from "../../styles/color"; import color from "../../styles/color";
import { Flex1 } from "../../styles/flex-1"; import { Flex1 } from "../../styles/flex-1";
import styled from "styled-components"; import styled from "styled-components";
import Image from "next/image";
import { import {
MINIMUM_VERSION, MINIMUM_VERSION,
SELECTED_WALLET_KEY, SELECTED_WALLET_KEY,
@ -67,14 +66,9 @@ export const WalletItem: FunctionComponent<Props> = (props: Props) => {
return ( return (
<WalleButton disabled={!wallet.isReady} onClick={onClickWalletItem}> <WalleButton disabled={!wallet.isReady} onClick={onClickWalletItem}>
<WalletIcon> <WalletIconContainer>
<Image <wallet.IconComponent width="60" height="60" />
src={wallet.image} </WalletIconContainer>
fill={true}
sizes="3.75rem"
alt="wallet Icon"
/>
</WalletIcon>
<WalletContentContainer> <WalletContentContainer>
<WalletName>{wallet.name}</WalletName> <WalletName>{wallet.name}</WalletName>
{wallet.isReady ? ( {wallet.isReady ? (
@ -88,7 +82,7 @@ export const WalletItem: FunctionComponent<Props> = (props: Props) => {
<Flex1 /> <Flex1 />
<Image src={ArrowRightIcon} alt="arrow right icon" /> <ArrowRightIcon />
</WalleButton> </WalleButton>
); );
}; };
@ -116,7 +110,7 @@ const WalleButton = styled.button`
} }
`; `;
const WalletIcon = styled.div` const WalletIconContainer = styled.div`
position: relative; position: relative;
width: 3.75rem; width: 3.75rem;

View File

@ -50,12 +50,7 @@ export const ErrorModal: FunctionComponent<Props> = (props) => {
<ModalContainer> <ModalContainer>
<ErrorTitleContainer> <ErrorTitleContainer>
<ErrorImageContainer> <ErrorImageContainer>
<Image <ErrorIcon />
src={ErrorIcon}
fill={true}
sizes="2.5rem"
alt="error icon"
/>
</ErrorImageContainer> </ErrorImageContainer>
Error Error
</ErrorTitleContainer> </ErrorTitleContainer>
@ -65,12 +60,7 @@ export const ErrorModal: FunctionComponent<Props> = (props) => {
{errorMessage?.path ? ( {errorMessage?.path ? (
<ErrorBackButton onClick={onClose}> <ErrorBackButton onClick={onClose}>
<ErrorBackIconContainer> <ErrorBackIconContainer>
<Image <ArrowLeftIcon />
src={ArrowLeftIcon}
fill={true}
sizes="1.5rem"
alt="back button icon"
/>
</ErrorBackIconContainer> </ErrorBackIconContainer>
GO BACK TO HOME GO BACK TO HOME
</ErrorBackButton> </ErrorBackButton>

View File

@ -1,14 +1,13 @@
import { Bech32Address } from "@keplr-wallet/cosmos";
import Image from "next/image";
import { useRouter } from "next/router";
import { FunctionComponent } from "react"; import { FunctionComponent } from "react";
import color from "../../styles/color";
import ReactModal from "react-modal"; import ReactModal from "react-modal";
import styled from "styled-components"; import styled from "styled-components";
import TwitterIcon from "../../public/images/svg/twitter-modal-icon.svg"; import { MINIMUM_OSMO_FEE } from "../../constants/wallet";
import Image from "next/image"; import color from "../../styles/color";
import { PrimaryButton } from "../primary-button"; import { PrimaryButton } from "../primary-button";
import { SecondaryButton } from "../secondary-button"; import { SecondaryButton } from "../secondary-button";
import { MINIMUM_OSMO_FEE } from "../../constants/wallet";
import { useRouter } from "next/router";
import { Bech32Address } from "@keplr-wallet/cosmos";
interface Props { interface Props {
twitterUserName: string | undefined; twitterUserName: string | undefined;

View File

@ -1,25 +1,18 @@
// NextJs // NextJs
import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
// Image Assets // Image Assets
import LogoIcon from "../../public/images/svg/logo.svg"; import LogoIcon from "../../public/images/svg/logo.svg";
// Styles // Styles
import styled from "styled-components";
import { FunctionComponent } from "react"; import { FunctionComponent } from "react";
import styled from "styled-components";
export const Logo: FunctionComponent = () => { export const Logo: FunctionComponent = () => {
return ( return (
<Link href="/"> <Link href="/">
<LogoContainer> <LogoContainer>
<Image <LogoIcon />
src={LogoIcon}
fill={true}
sizes="10rem"
alt="Home Logo"
priority
/>
</LogoContainer> </LogoContainer>
</Link> </Link>
); );

View File

@ -1,7 +1,5 @@
import { Dispatch, FunctionComponent, SetStateAction } from "react"; import { Dispatch, FunctionComponent, SetStateAction } from "react";
import Image from "next/image";
import styled from "styled-components"; import styled from "styled-components";
import color from "../../styles/color"; import color from "../../styles/color";
@ -18,7 +16,7 @@ export const SearchInput: FunctionComponent<Props> = (props) => {
return ( return (
<SearchContainer> <SearchContainer>
<SearchIconContainer> <SearchIconContainer>
<Image src={SearchIcon} fill={true} sizes="1.3rem" alt="search icon" /> <SearchIcon />
</SearchIconContainer> </SearchIconContainer>
<SearchText <SearchText

View File

@ -1,7 +1,6 @@
import { StaticImageData } from "next/image"; import { SVGProps } from "react";
import KeplrIcon from "../public/images/svg/keplr-icon.svg";
import CosmostationIcon from "../public/images/svg/cosmostation-icon.svg"; import CosmostationIcon from "../public/images/svg/cosmostation-icon.svg";
import KeplrIcon from "../public/images/svg/keplr-icon.svg";
export const WALLET_INSTALL_URL = export const WALLET_INSTALL_URL =
"https://chrome.google.com/webstore/detail/keplr/dmkamcknogkgcdfhhbddcghachkejeap"; "https://chrome.google.com/webstore/detail/keplr/dmkamcknogkgcdfhhbddcghachkejeap";
@ -13,20 +12,20 @@ export const MINIMUM_OSMO_FEE = process.env.MINIMUM_OSMO_FEE ?? "0.5 OSMO";
export type WalletName = "Keplr" | "Cosmostation"; export type WalletName = "Keplr" | "Cosmostation";
export interface WalletType { export interface WalletType {
name: WalletName; name: WalletName;
image: StaticImageData;
isReady: boolean; isReady: boolean;
IconComponent: (props: SVGProps<SVGSVGElement>) => JSX.Element;
} }
export const WalletList: WalletType[] = [ export const WalletList: WalletType[] = [
{ {
name: "Keplr", name: "Keplr",
image: KeplrIcon,
isReady: true, isReady: true,
IconComponent: KeplrIcon,
}, },
{ {
name: "Cosmostation", name: "Cosmostation",
image: CosmostationIcon,
isReady: false, isReady: false,
IconComponent: CosmostationIcon,
}, },
]; ];

View File

@ -115,7 +115,7 @@ export default function CompletePage() {
<DescriptionContainer> <DescriptionContainer>
<AlertIcon> <AlertIcon>
<Image src={AlertCircleOutlineIcon} fill={true} alt="alert icon" /> <AlertCircleOutlineIcon />
</AlertIcon> </AlertIcon>
<DescriptionText> <DescriptionText>
If you want to make that name address with same twitter account, If you want to make that name address with same twitter account,
@ -125,7 +125,7 @@ export default function CompletePage() {
{/*<ShareButtonContainer onClick={onClickShareButton}>*/} {/*<ShareButtonContainer onClick={onClickShareButton}>*/}
{/* <ShareButtonText>SHARE MY NAME</ShareButtonText>*/} {/* <ShareButtonText>SHARE MY NAME</ShareButtonText>*/}
{/* <Image src={TwitterIcon} alt="twitter icon" />*/} {/* <TwitterIcon /> */}
{/*</ShareButtonContainer>*/} {/*</ShareButtonContainer>*/}
</MainContainer> </MainContainer>
</Container> </Container>

View File

@ -1,8 +1,5 @@
import * as amplitude from "@amplitude/analytics-browser"; import * as amplitude from "@amplitude/analytics-browser";
// NextJs
import Image from "next/image";
// Styles // Styles
import styled from "styled-components"; import styled from "styled-components";
import color from "../styles/color"; import color from "../styles/color";
@ -52,28 +49,10 @@ export default function Home() {
<MainContainer> <MainContainer>
<MainTitleContainer> <MainTitleContainer>
<MainTitleImageBackground> <MainTitleImageBackground>
<Image <StarIcon className="starIcon first" />
src={StarIcon} <StarIcon className="starIcon last" />
width={50}
height={50}
alt="Star Icon"
className="starIcon first"
/>
<Image
src={StarIcon}
width={50}
height={50}
alt="Star Icon"
className="starIcon last"
/>
<MainTitleImageContainer> <MainTitleImageContainer>
<Image <MainTitle />
src={MainTitle}
fill={true}
sizes="60rem"
alt="Main Title"
priority
/>
</MainTitleImageContainer> </MainTitleImageContainer>
</MainTitleImageBackground> </MainTitleImageBackground>
@ -97,32 +76,18 @@ export default function Home() {
</CTAContainer> </CTAContainer>
<SubContainer> <SubContainer>
<CheckContainer> <CheckContainer>
<CheckIconContainer> <CheckIcon />
<Image
src={CheckIcon}
fill={true}
sizes="1.6rem"
alt="Check Icon"
/>
</CheckIconContainer>
Osmo is required for this transaction Osmo is required for this transaction
</CheckContainer> </CheckContainer>
<CheckContainer> <CheckContainer>
<CheckIconContainer> <CheckIcon />
<Image
src={CheckIcon}
fill={true}
sizes="1.6rem"
alt="Check Icon"
/>
</CheckIconContainer>
More wallet support coming soon More wallet support coming soon
</CheckContainer> </CheckContainer>
</SubContainer> </SubContainer>
</MainTitleContainer> </MainTitleContainer>
<MainLogoContainer> <MainLogoContainer>
<Image src={MainLogo} fill={true} sizes="25rem" alt="Main Logo" /> <MainLogo />
</MainLogoContainer> </MainLogoContainer>
</MainContainer> </MainContainer>
@ -158,7 +123,7 @@ const MainContainer = styled.div`
margin-top: 15rem; margin-top: 15rem;
margin-left: 10rem; margin-left: 10rem;
img.starIcon { .starIcon {
position: absolute; position: absolute;
&.first { &.first {

View File

@ -1,4 +1,4 @@
<svg width="81" height="80" viewBox="0 0 81 80" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="current" height="current" viewBox="0 0 81 80" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="0.25" width="80" height="80" rx="20" fill="#1B1B21"/> <rect x="0.25" width="80" height="80" rx="20" fill="#1B1B21"/>
<g clip-path="url(#clip0_249_4007)"> <g clip-path="url(#clip0_249_4007)">
<path d="M30.5465 56.0417L19.3466 37.1577C18.779 36.2007 18.779 35.0167 19.3466 34.0597L30.5465 15.1855C31.1141 14.2285 32.1682 13.6365 33.3034 13.6365H55.7032C56.8384 13.6365 57.8925 14.2285 58.4601 15.1855L69.6598 34.0696L64.1562 37.1676L53.8583 19.8325H35.1278L25.7624 35.6186L36.04 52.9538L30.5363 56.0516L30.5465 56.0417Z" fill="#9C6CFF"/> <path d="M30.5465 56.0417L19.3466 37.1577C18.779 36.2007 18.779 35.0167 19.3466 34.0597L30.5465 15.1855C31.1141 14.2285 32.1682 13.6365 33.3034 13.6365H55.7032C56.8384 13.6365 57.8925 14.2285 58.4601 15.1855L69.6598 34.0696L64.1562 37.1676L53.8583 19.8325H35.1278L25.7624 35.6186L36.04 52.9538L30.5363 56.0516L30.5465 56.0417Z" fill="#9C6CFF"/>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -1,4 +1,4 @@
<svg width="60" height="61" viewBox="0 0 60 61" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <svg width="current" height="current" viewBox="0 0 60 61" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<path d="M46.3636 0.5H13.6364C6.10521 0.5 0 6.60521 0 14.1364V46.8636C0 54.3948 6.10521 60.5 13.6364 60.5H46.3636C53.8948 60.5 60 54.3948 60 46.8636V14.1364C60 6.60521 53.8948 0.5 46.3636 0.5Z" fill="url(#pattern0)"/> <path d="M46.3636 0.5H13.6364C6.10521 0.5 0 6.60521 0 14.1364V46.8636C0 54.3948 6.10521 60.5 13.6364 60.5H46.3636C53.8948 60.5 60 54.3948 60 46.8636V14.1364C60 6.60521 53.8948 0.5 46.3636 0.5Z" fill="url(#pattern0)"/>
<path d="M24.3786 46.1818V32.2906L37.6296 46.1818H45.0001V45.8213L29.7604 30.0064L43.8246 14.9984V14.8181H36.4066L24.3786 28.0798V14.8181H18.4092V46.1818H24.3786Z" fill="white"/> <path d="M24.3786 46.1818V32.2906L37.6296 46.1818H45.0001V45.8213L29.7604 30.0064L43.8246 14.9984V14.8181H36.4066L24.3786 28.0798V14.8181H18.4092V46.1818H24.3786Z" fill="white"/>
<defs> <defs>

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 148 KiB