-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from junction-asia-2023/feat/active
Feat/active
- Loading branch information
Showing
16 changed files
with
383 additions
and
49 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { FunctionComponent } from 'react'; | ||
|
||
import { previewSubText, previewTitleText } from '../constants'; | ||
|
||
type PreviewSectionProps = { | ||
handlePreviewClick: () => void; | ||
}; | ||
|
||
const PreviewSection: FunctionComponent<PreviewSectionProps> = ({ | ||
handlePreviewClick, | ||
}) => { | ||
return ( | ||
<div className="setting-preview-container"> | ||
<div className="setting-preview-title-text">{previewTitleText}</div> | ||
<div className="setting-preview-sub-text">{previewSubText}</div> | ||
<button className="setting-preview-btn" onClick={handlePreviewClick}> | ||
Preview | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PreviewSection; |
54 changes: 54 additions & 0 deletions
54
src/features/setting/components/SubmitForm/DailySticker.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { FunctionComponent } from 'react'; | ||
import { Controller } from 'react-hook-form'; | ||
import { Control } from 'react-hook-form'; | ||
|
||
import { Inputs } from '../../types'; | ||
import { stickerList, wordStickerText } from '../../constants'; | ||
|
||
import '../../style/index.scss'; | ||
|
||
type DailyStickerProps = { | ||
control: Control<Inputs, any>; | ||
}; | ||
|
||
const DailySticker: FunctionComponent<DailyStickerProps> = ({ control }) => { | ||
return ( | ||
<div className="setting-sticker-container"> | ||
<span className="setting-sticker-title">{wordStickerText}</span> | ||
<Controller | ||
name="mude" | ||
control={control} | ||
rules={{ required: true }} | ||
render={({ field }) => ( | ||
<div className="setting-sticker-box" {...field}> | ||
{stickerList.map((sticker) => ( | ||
<label | ||
htmlFor={sticker} | ||
key={sticker} | ||
className="setting-sticker-width" | ||
> | ||
<input | ||
type="radio" | ||
id={sticker} | ||
name={field.name} | ||
value={sticker} | ||
checked={field.value === sticker} | ||
onChange={(e) => { | ||
field.onChange(e.target.value); | ||
}} | ||
/> | ||
<img | ||
src={`/png/${sticker}.png`} | ||
className="logo react" | ||
alt="React logo" | ||
/> | ||
</label> | ||
))} | ||
</div> | ||
)} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DailySticker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { FunctionComponent } from 'react'; | ||
import { UseFormRegister } from 'react-hook-form'; | ||
|
||
import { Inputs } from '../../types'; | ||
import { wordTitleText } from '../../constants'; | ||
import '../../style/index.scss'; | ||
|
||
type DailyWordProps = { | ||
register: UseFormRegister<Inputs>; | ||
}; | ||
|
||
const DailyWord: FunctionComponent<DailyWordProps> = ({ register }) => { | ||
return ( | ||
<div className="setting-word-container"> | ||
<span className="setting-word-title">{wordTitleText}</span> | ||
<input className="setting-word-input" {...register('comment')} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DailyWord; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useAtom } from 'jotai'; | ||
import { FunctionComponent, useEffect, useRef } from 'react'; | ||
import { | ||
UseFormHandleSubmit, | ||
SubmitHandler, | ||
UseFormRegister, | ||
Control, | ||
} from 'react-hook-form'; | ||
|
||
import { activeSaveAtom } from '../../../shared/layout/atom'; | ||
import { Inputs } from '../../types'; | ||
|
||
import DailySticker from './DailySticker'; | ||
import DailyWord from './DailyWord'; | ||
|
||
type SubmitFormProps = { | ||
handleSubmit: UseFormHandleSubmit<Inputs, undefined>; | ||
onSubmit: SubmitHandler<Inputs>; | ||
register: UseFormRegister<Inputs>; | ||
control: Control<Inputs, any>; | ||
}; | ||
|
||
const SubmitForm: FunctionComponent<SubmitFormProps> = ({ | ||
handleSubmit, | ||
onSubmit, | ||
register, | ||
control, | ||
}) => { | ||
const [activeSave, setActiveSave] = useAtom(activeSaveAtom); | ||
|
||
const inputRef = useRef<HTMLInputElement>(null); | ||
|
||
useEffect(() => { | ||
if (!activeSave) return; | ||
setActiveSave(false); | ||
inputRef.current?.click(); | ||
}, [activeSave]); | ||
|
||
return ( | ||
<form onSubmit={handleSubmit(onSubmit)}> | ||
<DailyWord register={register} /> | ||
<DailySticker control={control} /> | ||
<input ref={inputRef} type="submit" style={{ visibility: 'hidden' }} /> | ||
</form> | ||
); | ||
}; | ||
|
||
export default SubmitForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
export const colorset = ['red', 'yellow', 'green']; | ||
export const stickerList = ['mood_BAD', 'mood_GOOD']; | ||
|
||
export const previewTitleText = 'What is the Active Setting?'; | ||
export const previewSubText = | ||
'Congratulations on winning! Press the button to get a giftCongratulations on winning! Press the button to get a giftCongratulations on winning!'; | ||
|
||
export const wordTitleText = 'Word of the day'; | ||
export const wordStickerText = 'Word of the Sticker'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.