Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: dead theme config #196

Merged
merged 5 commits into from
Jul 24, 2024
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
STORYBOOK_COVALENT_API_KEY
STORYBOOK_GOLDRUSH_API_KEY
4 changes: 2 additions & 2 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const preview: Preview = {
decorators: [
(storyFn) => (
<GoldRushProvider
apikey={import.meta.env.STORYBOOK_COVALENT_API_KEY}
newTheme={{
apikey={import.meta.env.STORYBOOK_GOLDRUSH_API_KEY}
theme={{
borderRadius: 10,
}}
>
Expand Down
103 changes: 62 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">
<a href="https://www.covalenthq.com/products/goldrush/" target="_blank">
<img alt="GoldRush Kit Logo" src="https://raw.githubusercontent.com/covalenthq/goldrush-kit/main/src/static/grk-kit-banner.png" style="max-width: 100%;"/>
<a href="https://goldrush.dev/products/goldrush/" target="_blank" rel="noopener noreferrer">
<img alt="GoldRush Kit Logo" src="./src/static/grk-kit-banner.png" style="max-width: 100%;"/>
</a>
</div>

Expand All @@ -16,14 +16,19 @@
<img src="https://img.shields.io/github/license/covalenthq/goldrush-kit" alt="MIT">
</p>

<h1 align="center">Beautifully designed React components for your dApp frontend.</h1>
<h1 align="center">
Beautifully designed React components for your dApp frontend.
</h1>

<div align="center">
200+ Chains. Open-source. Customizable.
200+ Chains. Open-source. Customizable.
</div>

<p align="center">
<br />
<a href="https://www.covalenthq.com/docs/unified-api/goldrush/kit/gold-rush-provider/" rel="dofollow"><strong>Explore the docs »</strong></a>
<a href="https://goldrush.dev/docs/unified-api/goldrush/kit/gold-rush-provider/" rel="dofollow">
<strong>Explore the docs »</strong>
</a>
<br />
</p>

Expand All @@ -50,7 +55,8 @@ import { GoldRushProvider } from "@covalenthq/goldrush-kit";
```

2. Wrap `GoldRushProvider` around the application.
3. Configure the provider and add it to the `apikey` props with your Covalent API key. You can register for a free key on [Covalent's website](https://www.covalenthq.com/platform/auth/register/).
3. Configure the provider and add it to the `apikey` props with your GoldRush API key. You can register for a free key on [GoldRush's website](https://goldrush.dev/platform/auth/register/).
> **Note:** You should always keep your API key private, never put it directly into your code, especially front end code. Instead, use an environment variable to inject the key into your code.

```tsx
<GoldRushProvider apikey="<YOUR_API_KEY>">{children}</GoldRushProvider>
Expand All @@ -62,46 +68,62 @@ import { GoldRushProvider } from "@covalenthq/goldrush-kit";
import "@covalenthq/goldrush-kit/styles.css";
```

5. Add desired components. If you're using `next.js` versions `^13.0` and are using `app` router, make sure you have `use client;` at the top of the file to disable Next's server component modules. Visit GoldRush's [component documentation](https://www.covalenthq.com/docs/unified-api/goldrush/kit/gold-rush-provider/) for more information.
5. Add desired components.
> **Note:** If you're using `next.js` versions `^13.0` and are using `app` router, make sure you have `use client;` at the top of the file to disable Next's server component modules. Visit GoldRush's [component documentation](https://goldrush.dev/docs/unified-api/goldrush/kit/gold-rush-provider/) for more information.

```tsx
import {
GoldRushProvider,
NFTWalletTokenListView,
TokenBalancesListView,
TokenTransfersListView,
AddressActivityListView,
NFTWalletCollectionList,
TokenBalancesList,
TokenTransfersList,
AddressActivityList,
} from "@covalenthq/goldrush-kit";
```

## Ready-to-go React Component example

Here's a full example to get you started. If you're using `next.js` versions `^13.0` and are using `app` router, make sure you have `use client;` at the top of the file to disable Next's server component modules.

**Note:** You should always keep your API key private, never put it directly into your code, especially front end code. Instead, use an environment variable to inject the key into your code.
Here's a full example to get you started.

Be sure to secure your key to prevent unauthorized use in the Covalent platform by restricting usage to specific URLs.
Be sure to secure your key to prevent unauthorized use in the GoldRush platform by restricting usage to specific URLs.

```tsx
"use client";

import "@covalenthq/goldrush-kit/styles.css";
import {
GoldRushProvider,
NFTWalletTokenListView,
TokenBalancesListView,
TokenTransfersListView,
AddressActivityListView,
NFTWalletCollectionList,
TokenBalancesList,
TokenTransfersList,
AddressActivityList,
} from "@covalenthq/goldrush-kit";

export default function GoldRushExample() {
const GoldRushExample = () => {
return (
<main className="">
<GoldRushProvider
apikey={process.env.NEXT_PUBLIC_API_KEY}
mode="dark"
color="emerald"
theme={{
borderRadius: 6,
colors: {
dark: {
primary: "#FF4C8B",
background: "#000426",
foreground: "#FFFFFF",
secondary: "#868E96",
},
light: {
primary: "#00D8D5",
background: "#FFFFFF",
foreground: "#1C2024",
secondary: "#868E96",
},
},
mode: "dark",
}}
>
<TokenBalancesListView
<TokenBalancesList
chain_names={[
"eth-mainnet",
"matic-mainnet",
Expand All @@ -112,35 +134,34 @@ export default function GoldRushExample() {
hide_small_balances
address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
/>
<TokenTransfersListView

<TokenTransfersList
chain_name="eth-mainnet"
address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
contract_address="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
/>
<AddressActivityListView address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de" />
<NFTWalletTokenListView

<AddressActivityList address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de" />

<NFTWalletCollectionList
address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
chain_names={[
"eth-mainnet",
"matic-mainnet",
"bsc-mainnet",
"avalanche-mainnet",
"optimism-mainnet",
]}
chain_name="eth-mainnet"
/>
</GoldRushProvider>
</main>
);
}
};

export default GoldRushExample;
```

## GoldRush Templates

| Template | Description | Link |
| ------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
| Wallet & Portfolio UI | Display your tokens and NFTs across multiple chains. | https://github.com/covalenthq/goldrush-wallet-portfolio-ui |
| NFT Collection Gallery & Analytics UI | Display NFTs by collection and see their details. | https://github.com/covalenthq/goldrush-nft-gallery-ui |
| Transaction Receipt View | A beautifully designed view for blockchain transactions. | https://github.com/covalenthq/goldrush-tx-receipt-ui |
| Template | Description | Link |
| ------------------------------------- | -------------------------------------------------------- | ---------------------------------------------------------- |
| Wallet & Portfolio UI | Display your tokens and NFTs across multiple chains. | https://github.com/covalenthq/goldrush-wallet-portfolio-ui |
| NFT Collection Gallery & Analytics UI | Display NFTs by collection and see their details. | https://github.com/covalenthq/goldrush-nft-gallery-ui |
| Transaction Receipt View | A beautifully designed view for blockchain transactions. | https://github.com/covalenthq/goldrush-tx-receipt-ui |

## HIGHLIGHT: GoldRush Transaction Receipt View

Expand All @@ -167,7 +188,7 @@ Storybook provides developers with a way to quickly prototype and develop compon
Create and add a `.env` file to the root directory of your project and the following to the file.

```
STORYBOOK_COVALENT_API_KEY = "<YOUR_API_KEY>"
STORYBOOK_GOLDUSH_API_KEY = "<YOUR_API_KEY>"
```

### Start
Expand Down Expand Up @@ -199,4 +220,4 @@ Give a ⭐️ if this project helped you!

## License

This project is <a href="https://github.com/covalenthq/goldrush-kit/blob/main/LICENSE">Apache 2.0</a> licensed.
This project is <a href="./LICENSE">Apache 2.0</a> licensed.
Binary file removed src/static/goldrush-kit-logo.png
Binary file not shown.
Binary file modified src/static/grk-kit-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 3 additions & 17 deletions src/utils/store/GoldRush.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const GoldRushContext = createContext<GoldRushContextType>(
export const GoldRushProvider: React.FC<GoldRushProviderProps> = ({
children,
apikey,
newTheme,
theme: initialTheme,
}) => {
const covalentClient = useMemo<CovalentClient>(
() => new CovalentClient(apikey, {}, "GoldRush"),
Expand All @@ -48,7 +48,6 @@ export const GoldRushProvider: React.FC<GoldRushProviderProps> = ({
},
},
mode: "light",
style: "classic",
}),
[]
);
Expand All @@ -58,7 +57,7 @@ export const GoldRushProvider: React.FC<GoldRushProviderProps> = ({
const [theme, setTheme] = useState<GoldRushThemeType>(
defaultsDeep(
JSON.parse(localStorage.getItem("goldrush_theme") || "null") ?? {},
defaultsDeep(newTheme, defaultTheme)
defaultsDeep(initialTheme, defaultTheme)
)
);

Expand All @@ -78,7 +77,7 @@ export const GoldRushProvider: React.FC<GoldRushProviderProps> = ({

useEffect(() => {
localStorage.setItem("goldrush_theme", JSON.stringify(theme));
const { borderRadius, colors, mode, style } = theme;
const { borderRadius, colors, mode } = theme;

const body = document.body;
const root = document.documentElement;
Expand All @@ -96,19 +95,6 @@ export const GoldRushProvider: React.FC<GoldRushProviderProps> = ({
}
}

switch (style) {
case "neo": {
body.classList.add("neo");
root.classList.add("neo");
break;
}
case "classic": {
body.classList.remove("neo");
root.classList.remove("neo");
break;
}
}

root.style.setProperty("--grk-border-radius", `${borderRadius}px`);

Object.entries(colors).forEach(([_mode, _types]) => {
Expand Down
6 changes: 5 additions & 1 deletion src/utils/types/store.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export type GoldRushThemeMode = "dark" | "light";

export interface GoldRushThemeType {
mode: GoldRushThemeMode;
style: "classic" | "neo";
borderRadius: number;
colors: Partial<{
dark: Partial<GoldRushThemeColorType>;
Expand All @@ -53,5 +52,10 @@ export interface GoldRushThemeType {
export interface GoldRushProviderProps {
children: React.ReactNode;
apikey: string;
/**
* @deprecated Please use `theme` going forward!
* This prop will be removed after Aug 30, 2024.
*/
newTheme?: Partial<GoldRushThemeType>;
theme?: Partial<GoldRushThemeType>;
}
Loading