Skip to content

Commit 53da320

Browse files
authored
Add setup for individual READMEs and add README content for components (#170)
1 parent 39ba439 commit 53da320

File tree

9 files changed

+130
-5
lines changed

9 files changed

+130
-5
lines changed

.changeset/lovely-cars-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@web3-ui/components': patch
3+
---
4+
5+
Add README for the components package

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.DS_STORE
22
packages/**/LICENSE
3-
packages/**/README.md
43

54
node_modules
65
.rpt2_cache

packages/components/README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# @web3-ui/components
2+
3+
A set of React components made for web3-specific use cases. Fully compatible with and built on top of ChakraUI.
4+
5+
```bash
6+
yarn add @web3-ui/components
7+
```
8+
9+
## Getting started
10+
11+
At the root of your React app, wrap your app in the `<Provider>` component:
12+
13+
```tsx
14+
// _app.tsx (or the root of your app)
15+
import { Provider } from '@web3-ui/components';
16+
17+
// Passing in a theme is optional
18+
function MyApp({ Component, pageProps }) {
19+
return (
20+
<Provider theme={yourChakraTheme}>
21+
<Component {...pageProps} />
22+
</Provider>
23+
);
24+
}
25+
```
26+
27+
---
28+
29+
## Components
30+
31+
This is the list of components the package currently provides:
32+
33+
- [Address](#address)
34+
- [AddressInput](#addressinput)
35+
- [NFT](#nft)
36+
- [NFTGallery](#nftgallery)
37+
- [Provider](#provider)
38+
- [TokenGate](#tokengate)
39+
40+
---
41+
42+
### Address
43+
44+
The Address component takes in an Ethereum address or ENS name and displays it in a human-readable format.
45+
46+
```tsx
47+
<Address value='dhaiwat.eth' shortened copiable>
48+
```
49+
50+
`shortened` and `copiable` are optional props.
51+
52+
---
53+
54+
### AddressInput
55+
56+
The AddressInput component is an input for Ethereum addresses. It supports ENS names too.
57+
58+
```tsx
59+
<AddressInput value={value} onChange={setValue} provider={provider} />
60+
```
61+
62+
You need to pass in a `provider` prop if you want to use ENS names.
63+
64+
---
65+
66+
### NFT
67+
68+
The NFT component takes in the contract address and the token ID of an NFT and displays it as a card.
69+
70+
```tsx
71+
<NFT contractAddress="0xxxxx0x0x0x0x0x" tokenId={30} size="md" />
72+
```
73+
74+
The `size` prop is optional.
75+
76+
---
77+
78+
### NFTGallery
79+
80+
The NFTGallery component renders a grid of all the NFTs owned by an account. It accepts ENS names too.
81+
82+
```tsx
83+
<NFTGallery address="vitalik.eth" web3Provider={provider} gridWidth={4} />
84+
```
85+
86+
You need to pass in a `web3Provider` if you want to support ENS names. We know this is not ideal and are fixing it.
87+
88+
`gridWidth` is an optional prop.
89+
90+
---
91+
92+
### Provider
93+
94+
The Provider component is the `web3-ui` equivalent of ChakraUI's `ChakraProvider` component. You need to wrap this component around your entire App. See [Getting Started](#getting-started) for an example.
95+
96+
---
97+
98+
### TokenGate
99+
100+
The TokenGate component lets you conditionally render some content depending on whether the user owns some quantity of tokens or not.
101+
102+
```tsx
103+
<TokenGate
104+
requiredQuantity={10}
105+
walletBalance={walletBalance}
106+
deniedMessage={<p>This will be rendered if walletBalance is less than 10.</p>}
107+
>
108+
<h1>You're eligible!</h1>
109+
<p>This will be rendered if walletBalance is greater than or equal to 10.</p>
110+
</TokenGate>
111+
```

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"build": "preconstruct build",
2222
"format": "prettier --write \"src/**/*.{ts,tsx,json,js,jsx}\"",
2323
"format:check": "prettier --list-different \"src/**/*.{ts,tsx,json,js,jsx}\"",
24-
"prepublishOnly": "yarn build && cp ../../LICENSE ./LICENSE && cp ../../README.md ./README.md"
24+
"prepublishOnly": "yarn build && cp ../../LICENSE ./LICENSE"
2525
},
2626
"main": "dist/web3-ui-components.cjs.js",
2727
"module": "dist/web3-ui-components.esm.js",

packages/components/src/components/TokenGate/TokenGate.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ export interface TokenGateProps {
1717
*/
1818
deniedMessage?: ReactNode;
1919
}
20+
21+
/**
22+
* A 'token gate' that renders some content depending on whether the user has the required quantity of a token or not.
23+
*/
2024
export const TokenGate: React.FC<TokenGateProps> = ({
2125
walletBalance,
2226
requiredQuantity = 1,
2327
children,
24-
deniedMessage,
28+
deniedMessage
2529
}) => {
2630
// return children within simple container
2731
return (

packages/core/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @web3-ui/core
2+
3+
To be populated.

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"build": "preconstruct build",
2222
"format": "prettier --write \"src/**/*.{ts,tsx,json,js,jsx}\"",
2323
"format:check": "prettier --list-different \"src/**/*.{ts,tsx,json,js,jsx}\"",
24-
"prepublishOnly": "yarn build && cp ../../LICENSE ./LICENSE && cp ../../README.md ./README.md"
24+
"prepublishOnly": "yarn build && cp ../../LICENSE ./LICENSE"
2525
},
2626
"main": "dist/web3-ui-core.cjs.js",
2727
"module": "dist/web3-ui-core.esm.js",

packages/hooks/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @web3-ui/hooks
2+
3+
To be populated.

packages/hooks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"test": "jest --maxWorkers=2",
2525
"test:watch": "yarn test --watch",
2626
"test:coverage": "jest --coverage --colors --maxWorkers=2",
27-
"prepublishOnly": "yarn build && cp ../../LICENSE ./LICENSE && cp ../../README.md ./README.md"
27+
"prepublishOnly": "yarn build && cp ../../LICENSE ./LICENSE"
2828
},
2929
"main": "dist/web3-ui-hooks.cjs.js",
3030
"module": "dist/web3-ui-hooks.esm.js",

0 commit comments

Comments
 (0)