Skip to content

Commit

Permalink
Merge pull request #621 from systemli/Extract-Fields-from-TickerForm
Browse files Browse the repository at this point in the history
♻️ Extract Fields from TickerForm
  • Loading branch information
0x46616c6b authored Apr 28, 2024
2 parents 32f9908 + 8ed4d64 commit b39fccf
Show file tree
Hide file tree
Showing 15 changed files with 540 additions and 300 deletions.
299 changes: 0 additions & 299 deletions src/components/ticker/TickerForm.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/ticker/TickerModalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Tab, Tabs } from '@mui/material'
import React, { FC, useState } from 'react'
import { Ticker } from '../../api/Ticker'
import TabPanel from '../common/TabPanel'
import TickerForm from './TickerForm'
import TickerForm from './form/TickerForm'
import TickerSocialConnections from './TickerSocialConnections'
import Modal from '../common/Modal'

Expand Down
21 changes: 21 additions & 0 deletions src/components/ticker/form/Active.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Checkbox, FormControlLabel } from '@mui/material'
import { FC } from 'react'
import { Controller, useFormContext } from 'react-hook-form'

interface Props {
defaultChecked?: boolean
}

const Active: FC<Props> = ({ defaultChecked }) => {
const { control } = useFormContext()

return (
<Controller
name="active"
control={control}
render={({ field }) => <FormControlLabel control={<Checkbox {...field} defaultChecked={defaultChecked} />} label="Active" />}
/>
)
}

export default Active
32 changes: 32 additions & 0 deletions src/components/ticker/form/Author.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { faUser } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { InputAdornment, TextField } from '@mui/material'
import { FC } from 'react'
import { Controller, useFormContext } from 'react-hook-form'

const Author: FC = () => {
const { control } = useFormContext()

return (
<Controller
name="information.author"
control={control}
render={({ field }) => (
<TextField
{...field}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<FontAwesomeIcon icon={faUser} />
</InputAdornment>
),
}}
label="Author"
margin="dense"
/>
)}
/>
)
}

export default Author
32 changes: 32 additions & 0 deletions src/components/ticker/form/Bluesky.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { faBluesky } from '@fortawesome/free-brands-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { InputAdornment, TextField } from '@mui/material'
import { FC } from 'react'
import { Controller, useFormContext } from 'react-hook-form'

const Bluesky: FC = () => {
const { control } = useFormContext()

return (
<Controller
name="information.bluesky"
control={control}
render={({ field }) => (
<TextField
{...field}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<FontAwesomeIcon icon={faBluesky} />
</InputAdornment>
),
}}
label="Bluesky"
margin="dense"
/>
)}
/>
)
}

export default Bluesky
Loading

0 comments on commit b39fccf

Please sign in to comment.