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

Add SolanaCreator page #63

Merged
merged 25 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6619c41
Add SolanaCreator page and related components; update dependencies an…
kuba80-02 Oct 7, 2024
a2faf69
Refactor CreateToken component: optimize validation logic and improve…
kuba80-02 Oct 8, 2024
8034ea3
Change react ver
kuba80-02 Oct 8, 2024
18c6d47
Update
kuba80-02 Oct 8, 2024
34056ae
Update dependencies: upgrade React, React DOM, and React Hook Form to…
kuba80-02 Oct 8, 2024
b2a31b4
Refactor input components: streamline label capitalization and improv…
kuba80-02 Oct 8, 2024
8ac8b65
Refactor input validation: enhance error handling and improve user fe…
kuba80-02 Oct 8, 2024
a5b0816
Refactor ImagePicker: destructure field in render prop for improved r…
kuba80-02 Oct 8, 2024
7b01088
fix validation
kuba80-02 Oct 9, 2024
be5c5cb
fix: Fixed validations & refactor
kuba80-02 Oct 9, 2024
4e2666d
chore: Replace divs to mui Boxes
kuba80-02 Oct 9, 2024
03efd5d
chore: Edit hover color
kuba80-02 Oct 9, 2024
b0cc725
refactor: Enhance input components and styles for better usability an…
kuba80-02 Oct 10, 2024
0898342
fix: Update error messages for better clarity and remove unused code
kuba80-02 Oct 10, 2024
8c36994
fix: Improve error handling and animations in NumericInput component
kuba80-02 Oct 10, 2024
eec42ba
fix: Remove unnecessary console log from getErrorMessages function
kuba80-02 Oct 10, 2024
cba34df
fix: jumping meta info about token
kuba80-02 Oct 11, 2024
c0132a4
fix: jumping containers, and validation bug
kuba80-02 Oct 11, 2024
64b56e8
fix: jumping containers
kuba80-02 Oct 11, 2024
3341f39
fix: jumping
kuba80-02 Oct 11, 2024
3e17f57
chore: Added custom scroll and changed divs to boxed
kuba80-02 Oct 11, 2024
7bdcd79
chore: Move onSubmit from solana uitls to CreateToken component
kuba80-02 Oct 11, 2024
17877be
chore: Hide token metadata
kuba80-02 Oct 11, 2024
3ea1f21
chore: Temp remove token meta data
kuba80-02 Oct 11, 2024
81eae90
fix: lint error
kuba80-02 Oct 11, 2024
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
21 changes: 14 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
"notistack": "^3.0.1",
"patch-package": "^6.4.7",
"rc-scrollbars": "^1.1.3",
"react": "^16.13.1",
"react": "^16.14.0",
"react-app-rewire-hot-loader": "^2.0.1",
"react-copy-to-clipboard": "^5.0.3",
"react-dom": "^16.13.1",
"react-dom": "^16.14.0",
"react-helmet": "^6.1.0",
"react-hook-form": "^6.3.2",
"react-hook-form": "^7.53.0",
"react-hot-loader": "^4.12.21",
"react-number-format": "^4.7.3",
"react-redux": "^7.2.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const Header: React.FC<IHeader> = ({

const isXsDown = useMediaQuery(theme.breakpoints.down('xs'))

const routes = ['swap', 'pool', 'stats', 'farms']
const routes = ['swap', 'pool', 'stats', 'farms', 'token']

const otherRoutesToHighlight: Record<string, RegExp[]> = {
pool: [/^newPosition\/*/, /^position\/*/],
Expand Down
3 changes: 3 additions & 0 deletions src/pages/PagesRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SwapPage } from './SwapPage/SwapPage'
import Footer from '@components/Footer/Footer'
import FarmsPage from './FarmsPage/FarmsPage'
import StatsPage from './StatsPage/StatsPage'
import SolanaCreator from './SolanaCreator/SolanaCreator'
// import BondsPage from './BondsPage/BondsPage'

export const PagesRouter: React.FC = () => {
Expand Down Expand Up @@ -72,6 +73,8 @@ export const PagesRouter: React.FC = () => {
/>
<Route path={'/pool'} component={ListPage} />
<Route path={'/farms'} component={FarmsPage} />
<Route path={'/token'} component={SolanaCreator} />

{/* <Route
path={'/farm/:id'}
render={({ match }) => <SingleFarmPage id={match.params.id} />}
Expand Down
15 changes: 15 additions & 0 deletions src/pages/SolanaCreator/SolanaCreator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'
import useStyles from './styles'
import { Grid } from '@material-ui/core'
import { CreateToken } from './components/CreateToken/CreateToken'

export const SolanaCreator: React.FC = () => {
const classes = useStyles()
return (
<Grid container className={classes.container}>
<CreateToken />
</Grid>
)
}

export default SolanaCreator
63 changes: 63 additions & 0 deletions src/pages/SolanaCreator/components/CreateToken/CreateToken.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React from 'react'
import { useForm } from 'react-hook-form'
import { Box, Typography } from '@material-ui/core'
import useStyles from './styles'
// import { TokenMetadataInputs } from '../CreatorComponents/TokenMetadataInputs'
import { validateDecimals, validateSupply } from '../../utils/solanaCreatorUtils'
import { TokenInfoInputs } from '../CreatorComponents/TokenInfoInputs'

interface FormData {
name: string
symbol: string
decimals: string
supply: string
description: string
website: string
twitter: string
telegram: string
discord: string
image: string
}

export const CreateToken: React.FC = () => {
const classes = useStyles()

const formMethods = useForm<FormData>({
mode: 'onChange',
reValidateMode: 'onChange'
})
const onSubmit = (data: FormData) => {
try {
const decimalsError = validateDecimals(data.decimals)
if (decimalsError) {
throw new Error(decimalsError)
}

const supplyError = validateSupply(data.supply, data.decimals)
if (supplyError) {
throw new Error(supplyError)
}

console.log(data)
} catch (error) {
console.error('Error submitting form:', error)
}
}

return (
<Box className={classes.pageWrapper}>
<Box className={classes.creatorMainContainer}>
<Box className={classes.column}>
<Typography variant='h1' className={classes.headerTitle}>
Create token
</Typography>
<form onSubmit={formMethods.handleSubmit(onSubmit)}>
<Box className={classes.row}>
<TokenInfoInputs formMethods={formMethods} />
</Box>
</form>
</Box>
</Box>
</Box>
)
}
122 changes: 122 additions & 0 deletions src/pages/SolanaCreator/components/CreateToken/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { makeStyles } from '@material-ui/core/styles'
import { typography, colors } from '@static/theme'

const useStyles = makeStyles(theme => ({
pageWrapper: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
gap: '24px',
width: '100%',
padding: '10px'
},
input: {
padding: '11px 12px',
width: '100%',
minHeight: '32px',
boxSizing: 'border-box',
...typography.body2,
outline: 'none',
marginRight: -8,
fontFamily: 'Mukta',
outlineStyle: 'none',
fontSize: 16,
backgroundColor: colors.invariant.newDark,
color: colors.invariant.lightGrey,
borderRadius: 8,
cursor: 'pointer',
'&::placeholder': {
color: colors.invariant.textGrey
},
'&:focus': {
color: colors.white.main
}
},
column: {
display: 'flex',
flexDirection: 'column',
gap: '10px'
},
columnInput: {
display: 'flex',
flexDirection: 'column',
gap: '10px',
width: '100%'
},

row: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
gap: '10px',
[theme.breakpoints.up('sm')]: {
flexDirection: 'row'
}
},
container: {
display: 'flex',
flexDirection: 'column',
padding: '24px',
gap: '24px',
height: 'fit-content',
background: colors.invariant.component,
borderRadius: '24px'
},
inputsWrapper: {
display: 'flex',
flexDirection: 'column',
gap: '16px'
},
inputContainer: {
height: '110px',
display: 'flex',
flexDirection: 'column'
},
button: {
color: colors.invariant.dark,
...typography.body1,
textTransform: 'none',
borderRadius: 14,
height: 40,
minWidth: 130,
paddingInline: 0,
background:
'linear-gradient(180deg, rgba(239, 132, 245, 0.8) 0%, rgba(156, 62, 189, 0.8) 100%)',
'&:hover': {
background: 'linear-gradient(180deg, #EF84F5 0%, #9C3EBD 100%)',
boxShadow: '0px 0px 16px rgba(239, 132, 245, 0.35)'
},
'&:disabled': {
background: colors.invariant.light,
color: colors.invariant.componentBcg
}
},
headerTitle: {
fontFamily: 'Mukta',
fontStyle: 'normal',
fontWeight: 700,
fontSize: '20px',
lineHeight: '24px',
display: 'flex',
alignSelf: 'flex-start',
letterSpacing: '-0.03em',
color: colors.invariant.text
},
buttonText: {
WebkitPaddingBefore: '2px'
},
creatorMainContainer: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
gap: '24px',
paddingTop: '24px',
width: '100%',
[theme.breakpoints.up('md')]: {
flexDirection: 'row',
width: '70%'
}
}
}))
export default useStyles
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react'
import { Controller } from 'react-hook-form'
import { TextInput } from '../TextInput/TextInput'
import { NumericInput } from '../NumericInput/NumericInput'
import getErrorMessages, { FormData } from '../../utils/solanaCreatorUtils'

interface ControlledInputProps {
name: keyof FormData
label: string
control: any
rules?: object
errors: any
}

interface ControlledTextInputProps extends ControlledInputProps {
multiline?: boolean
minRows?: number
maxRows?: number
}

interface ControlledNumericInputProps extends ControlledInputProps {
decimalsLimit: number
}

export const ControlledTextInput: React.FC<ControlledTextInputProps> = ({
name,
label,
control,
rules,
errors,
multiline,
minRows
}) => (
<Controller
name={name}
control={control}
rules={rules}
defaultValue=''
render={({ field: { onChange, value } }) => (
<TextInput
label={label}
value={value}
handleChange={(e: React.ChangeEvent<HTMLInputElement>) => onChange(e.target.value)}
error={!!errors[name]}
errorMessage={errors[name]?.message || ''}
multiline={multiline}
minRows={minRows}
maxRows={minRows}
/>
)}
/>
)
export const ControlledNumericInput: React.FC<ControlledNumericInputProps> = ({
name,
label,
control,
errors,
rules,
decimalsLimit
}) => {
const error = errors[name]

const { shortErrorMessage, fullErrorMessage } = getErrorMessages(error)

return (
<Controller
name={name}
control={control}
rules={rules}
render={({ field: { onChange, value } }) => (
<NumericInput
label={label}
value={value}
onChange={onChange}
error={!!error}
errorMessage={shortErrorMessage}
fullErrorMessage={fullErrorMessage}
decimalsLimit={decimalsLimit}
/>
)}
/>
)
}
Loading
Loading