Skip to content

Commit

Permalink
feat: added Inter fonts (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyhyco authored Jun 13, 2024
1 parent 2fe1b7a commit 1cd548a
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-eggs-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@coinbase/onchainkit": patch
---

- **feat**: introduce Inter font-family and internal text components. By @kyhyco #506
13 changes: 13 additions & 0 deletions src/internal/text/TextBody.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ReactNode } from 'react';

type TextBodyReact = {
children: ReactNode;
};

export function TextBody({ children }: TextBodyReact) {
return (
<span className="text-sans text-base leading-normal text-black">
{children}
</span>
);
}
12 changes: 12 additions & 0 deletions src/internal/text/TextCaption.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ReactNode } from 'react';

type TextCaptionReact = {
children: ReactNode;
};

/* istanbul ignore next */
export function TextCaption({ children }: TextCaptionReact) {
return (
<span className="text-sans text-bold text-xs leading-4">{children}</span>
);
}
13 changes: 13 additions & 0 deletions src/internal/text/TextHeadline.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ReactNode } from 'react';

type TextHeadlineReact = {
children: ReactNode;
};

export function TextHeadline({ children }: TextHeadlineReact) {
return (
<span className="text-sans text-base leading-normal text-bold text-[#0A0B0D]">
{children}
</span>
);
}
14 changes: 14 additions & 0 deletions src/internal/text/TextLabel1.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ReactNode } from 'react';

type TextLabel1React = {
children: ReactNode;
};

/* istanbul ignore next */
export function TextLabel1({ children }: TextLabel1React) {
return (
<span className="text-sans text-bold text-sm leading-5 text-[#0A0B0D]">
{children}
</span>
);
}
14 changes: 14 additions & 0 deletions src/internal/text/TextLabel2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ReactNode } from 'react';

type TextLabel2React = {
children: ReactNode;
};

/* istanbul ignore next */
export function TextLabel2({ children }: TextLabel2React) {
return (
<span className="text-sans text-sm leading-5 text-[#0A0B0D]">
{children}
</span>
);
}
10 changes: 10 additions & 0 deletions src/internal/text/TextLegal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ReactNode } from 'react';

type TextLegalReact = {
children: ReactNode;
};

/* istanbul ignore next */
export function TextLegal({ children }: TextLegalReact) {
return <span className="text-sans text-xs leading-4">{children}</span>;
}
2 changes: 2 additions & 0 deletions src/internal/text/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { TextBody } from './TextBody';
export { TextHeadline } from './TextHeadline';
4 changes: 3 additions & 1 deletion src/styles/index-with-tailwind.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@import url('https://fonts.googleapis.com/css2?family=Inter&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@700&display=swap');
@import url('./tailwind-base.css');
@import url('./index.css');
@import url('./index.css');
5 changes: 2 additions & 3 deletions src/token/components/TokenChip.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TextBody } from '../../internal/text';
import type { TokenChipReact } from '../types';

/**
Expand All @@ -14,9 +15,7 @@ export function TokenChip({ token, onClick }: TokenChipReact) {
onClick={() => onClick?.(token)}
>
<img className="mr-2 h-6 w-6" src={token.image || ''} />
<span className="font-medium text-base text-black leading-4">
{token.symbol}
</span>
<TextBody>{token.symbol}</TextBody>
</button>
);
}
5 changes: 2 additions & 3 deletions src/token/components/TokenRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { memo } from 'react';
import type { TokenRowReact } from '../types';
import { formatAmount } from '../core/formatAmount';
import { TokenImage } from './TokenImage';
import { TextHeadline } from '../../internal/text';

export const TokenRow = memo(function TokenRow({
token,
Expand All @@ -19,9 +20,7 @@ export const TokenRow = memo(function TokenRow({
<span className="flex items-center gap-3">
{!hideImage && <TokenImage token={token} size={48} />}
<span className="flex flex-col items-start">
<span className="font-medium text-[#0A0B0D] leading-normal">
{token.name}
</span>
<TextHeadline>{token.name}</TextHeadline>
{!hideSymbol && (
<span className="font-normal text-[#5B616E] leading-normal">
{token.symbol}
Expand Down
12 changes: 4 additions & 8 deletions src/token/components/TokenSelectButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type ForwardedRef, forwardRef } from 'react';
import type { TokenSelectButtonReact } from '../types';
import { TokenImage } from './TokenImage';
import { TextBody } from '../../internal/text';

function CaretUp() {
return (
Expand Down Expand Up @@ -52,17 +53,12 @@ export const TokenSelectButton = forwardRef(function TokenSelectButton(
{token ? (
<>
<TokenImage token={token} size={16} />
<span
data-testid="ockTokenSelectButton_Symbol"
className="font-medium text-[#0a0b0d] text-base leading-normal"
>
<TextBody data-testid="ockTokenSelectButton_Symbol">
{token.symbol}
</span>
</TextBody>
</>
) : (
<span className="font-medium text-[#0a0b0d] text-base leading-normal">
Select
</span>
<TextBody>Select</TextBody>
)}
{isOpen ? <CaretUp /> : <CaretDown />}
</button>
Expand Down
3 changes: 3 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
export default {
content: ['./src/**/*.{ts,tsx}'],
theme: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
},
extend: {},
},
plugins: [],
Expand Down

0 comments on commit 1cd548a

Please sign in to comment.