Skip to content

Commit

Permalink
tryin' to figure out why Chakra UI is inaccessible 🤼‍♀️
Browse files Browse the repository at this point in the history
  • Loading branch information
dysbulic committed Aug 9, 2022
1 parent 2e4808b commit 614fc74
Show file tree
Hide file tree
Showing 16 changed files with 4,599 additions and 4,088 deletions.
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ preferInteractive: true

progressBarStyle: simba

nmHoistingLimits: none

yarnPath: .yarn/releases/yarn-3.2.0.cjs
1 change: 1 addition & 0 deletions packages/scene/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ yarn-error.log*

# vercel
.vercel
.yarn/
4 changes: 2 additions & 2 deletions packages/scene/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@react-three/drei": "^8.20.2",
"@react-three/fiber": "^7.0.26",
"next": "12.1.2",
"react": "18.0.0",
"react-dom": "18.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"three": "^0.139.0"
},
"devDependencies": {
Expand Down
4,793 changes: 2,782 additions & 2,011 deletions packages/scene/yarn.lock

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions packages/ui-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,33 @@
"preview": "vite preview"
},
"dependencies": {
"@chakra-ui/icons": "^2.0.4",
"@chakra-ui/react": "^2.2.4",
"@emotion/react": "^11.10.0",
"@emotion/styled": "^11.10.0",
"@walletconnect/web3-provider": "^1.8.0",
"esbuild": "^0.14.53",
"ethers": "^5.6.9",
"framer-motion": "^6.5.1",
"graphql": "^16.5.0",
"it-all": "^1.0.6",
"multiformats": "^9.7.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"react-router-dom": "^6.3.0"
"react-hook-form": "^7.34.0",
"react-is": "^18.2.0",
"react-markdown": "^8.0.3",
"react-router-dom": "^6.3.0",
"web3modal": "^1.9.8"
},
"devDependencies": {
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@types/react-helmet": "^6",
"@types/react-helmet": "^6.1.5",
"@vitejs/plugin-react": "^2.0.0",
"typescript": "^4.6.4",
"rollup": "^2.77.2",
"typescript": "^4.7.4",
"vite": "^3.0.0"
}
}
5 changes: 1 addition & 4 deletions packages/ui-vite/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// import '../styles/globals.css'
import {Helmet} from 'react-helmet'
import { Helmet } from 'react-helmet'
import { ChakraProvider } from '@chakra-ui/react'
import { Web3ContextProvider } from './lib/hooks'
import {
ApolloClient,
InMemoryCache,
ApolloProvider,
useQuery,
gql
} from '@apollo/client'
import { CONFIG } from './config'
import Home from './pages/home'
Expand All @@ -17,7 +15,6 @@ import {
BrowserRouter as Router,
Routes,
Route,
Link
} from "react-router-dom";

const client = new ApolloClient({
Expand Down
11 changes: 7 additions & 4 deletions packages/ui-vite/src/components/Expandable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Maybe } from '../lib/types'
import { ReactNode, useCallback, useRef, useState } from 'react'
import { Box, chakra, Flex, FormLabel, Link, Text } from '@chakra-ui/react'
import {
Box, chakra, Flex, FormLabel, Link, Text,
} from '@chakra-ui/react'

export const Anchor = ({ name }: { name: string }) => {
const anchor = name.toLowerCase().replace(/\s+/g, '-')
Expand All @@ -25,9 +26,11 @@ const Label = ({ name }: { name: string }) => (
</Flex>
)

export const Expandable = ({ name, button = null, children }) => {
export const Expandable = (
{ name, button = null, children }:
{ name: string, button: ReactNode, children: ReactNode }) => {
const [hide, setHide] = useState<Record<string, boolean>>({})
const toggle = useCallback((prop) => {
const toggle = useCallback((prop: string) => {
setHide(h => ({ ...h, [prop]: !h[prop] }))
}, [])
const box = useRef<HTMLDivElement>(null)
Expand Down
15 changes: 11 additions & 4 deletions packages/ui-vite/src/components/ModelModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ModalContent, ModalHeader, ModalOverlay, Select, chakra,
Input, ModalFooter, Button,
} from '@chakra-ui/react'
import { ChangeEvent } from 'react'
import { FormEvent, useState } from 'react'

export type ModelModalProps = {
Expand Down Expand Up @@ -53,7 +54,11 @@ export const ModelModal: React.FC<ModelModalProps> = ({
<Select
ml={5} w="calc(100% - 2rem)"
value={type}
onChange={({ target: { value } }) => setType(value)}
onChange={
({ target: { value } }: ChangeEvent<HTMLSelectElement>) => {
setType(value)
}
}
>
<chakra.optgroup style={{ padding: 0 }}>
<chakra.option value="model/gltf-binary">Binary glTF</chakra.option>
Expand All @@ -73,9 +78,11 @@ export const ModelModal: React.FC<ModelModalProps> = ({
<Input
ml={5} mt={3} w="calc(100% - 2rem)" placeholder="Mime Type"
required={true} value={specifiedType}
onChange={({ target: { value } }) => (
setSpecifiedType(value)
)}
onChange={
({ target: { value } }: ChangeEvent<HTMLInputElement>) => {
setSpecifiedType(value)
}
}
/>
)}
</FormControl>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-vite/src/components/NFTForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export const NFTForm: React.FC<{
setValue('color', `#${bg}`)
}
}
}, [metadata, setImage, setValue])
}, [metadata, setValue])

useEffect(() => {
if(!homepage || isEmpty(homepage) || homepage.endsWith('𝘜𝘯𝘬𝘯𝘰𝘸𝘯')) {
Expand Down
30 changes: 12 additions & 18 deletions packages/ui-vite/src/lib/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import {
Web3Provider, JsonRpcProvider, StaticJsonRpcProvider,
ExternalProvider, Web3Provider, JsonRpcProvider,
StaticJsonRpcProvider,
} from '@ethersproject/providers'
import { Contract } from '@ethersproject/contracts'
import type { Maybe } from './types'
import React, {
createContext,
useCallback,
useContext,
useEffect,
useMemo,
useState,
import type { Maybe } from '@/lib/types'
import {
createContext, useCallback, useContext, useEffect,
useMemo, useState,
} from 'react'
import Web3Modal from 'web3modal'
import providerOptions from './walletConnect'
import { NETWORKS } from './networks'
import CONFIG from '../config'
import { NETWORKS } from '@/lib/networks'
import CONFIG from '@/config'
import { ReactNode } from 'react';

export type Web3ContextType = {
userProvider?: Web3Provider
Expand Down Expand Up @@ -59,8 +57,7 @@ export const useWeb3 = (): Web3ContextType => (
)

export const Web3ContextProvider = (
({ children }) => {
const [wallet, setWallet] = useState<Web3Modal>()
({ children }: { children: ReactNode }) => {
const [userProvider, setUserProvider] = (
useState<Web3Provider>()
)
Expand Down Expand Up @@ -143,7 +140,6 @@ export const Web3ContextProvider = (
const disconnect = useCallback(() => {
web3Modal?.clearCachedProvider()
// clearWalletConnect()
setWallet(undefined)
setAddress(undefined)
setChain(undefined)
setUserProvider(undefined)
Expand All @@ -154,17 +150,15 @@ export const Web3ContextProvider = (
}, [web3Modal])

const update = useCallback(
async (vider) => {
setWallet(vider)

async (vider: ExternalProvider) => {
const web3Provider = new Web3Provider(vider)
setUserProvider(web3Provider)

setAddress(await (
web3Provider.getSigner().getAddress()
))

setChain(vider.chainId)
setChain((vider as { chainId: string }).chainId)
},
[],
)
Expand Down
16 changes: 8 additions & 8 deletions packages/ui-vite/src/pages/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
import { useWeb3 } from '@/lib/hooks'
import { useCallback, useEffect, useState } from 'react'
import { NETWORKS } from '@/lib/networks'
import Head from 'next/head'
import { OptionsForm, Header } from '@/components'
import { useRouter } from 'next/router'
import { Helmet } from 'react-helmet'
import { Header, OptionsForm } from '@/components'
import { Event } from 'ethers'
import { useForm } from 'react-hook-form'
import { CONFIG } from '@/config'
Expand Down Expand Up @@ -68,8 +67,9 @@ const Content: React.FC = () => {
load()
}, [roContract])

const reserve = useCallback(async (data) => {
setWorking(true)
const reserve = useCallback(
async (data: { maintainer?: string }) => {
setWorking(true)

try {
if(!rwContract) {
Expand Down Expand Up @@ -103,16 +103,16 @@ const Content: React.FC = () => {
}
}
))

let { maintainer } = data
if(maintainer === '') {
maintainer = address
}
if(maintainer.includes('.')) {
if(maintainer?.includes('.')) {
if(!ensProvider) {
throw new Error('ENS provider not defined.')
}
maintainer = await ensProvider.resolveName(maintainer)
maintainer = await ensProvider.resolveName(maintainer) ?? undefined
}
const tx = await rwContract['create(address,uint8[],uint8[])'](
maintainer, grants, disables
Expand Down
8 changes: 7 additions & 1 deletion packages/ui-vite/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
"jsx": "react-jsx",
"baseUrl": "src/",
"paths": {
"@/lib/*": ["./lib/*"],
"@/config": ["./config"],
"@/components": ["./components/index"],
},
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
8 changes: 4 additions & 4 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"vercel": "vercel"
},
"dependencies": {
"@chakra-ui/icons": "^1.1.7",
"@chakra-ui/react": "^1.8.6",
"@chakra-ui/icons": "^2.0.4",
"@chakra-ui/react": "^2.2.4",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@ethersproject/contracts": "^5.5.0",
Expand All @@ -39,8 +39,8 @@
"next": "12.1.0",
"nft.storage": "^6.0.2",
"pluralize": "^8.0.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.28.1",
"react-markdown": "^8.0.1",
"tslib": "^2.3.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"@apollo/client": "^3.6.9",
"@chakra-ui/icons": "^2.0.2",
"@chakra-ui/react": "^2.2.1",
"@chakra-ui/react": "^2.2.4",
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
Expand All @@ -23,8 +23,8 @@
"ethers": "^5.6.9",
"framer-motion": "^6.4.2",
"ipfs-http-client": "^57.0.3",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"react-hook-form": "^7.33.1",
"react-markdown": "^8.0.3",
Expand Down
Loading

0 comments on commit 614fc74

Please sign in to comment.