-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat: Tutorial 및 Block Tab Menu #33
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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,67 @@ | ||
import { useState } from "react"; | ||
|
||
import Button from "./Button"; | ||
|
||
import { | ||
ModalBackground, | ||
ModalContainer, | ||
ModalContent, | ||
} from "../../style/ModalStyle"; | ||
import { Header, ButtonContainer } from "../../style/CommonStyle"; | ||
import { ImageContainer, ContentContainer } from "../../style/TutorialStyle"; | ||
|
||
const TutorialModal = ({ title, tutorials, onClose }) => { | ||
const [currentIndex, setCurrentIndex] = useState(0); | ||
|
||
const handleNextButton = () => { | ||
if (currentIndex < tutorials.length - 1) { | ||
setCurrentIndex(currentIndex + 1); | ||
} else { | ||
onClose(); | ||
} | ||
}; | ||
|
||
const handlePreviousButton = () => { | ||
if (currentIndex > 0) { | ||
setCurrentIndex(currentIndex - 1); | ||
} | ||
}; | ||
|
||
const currentTutorial = tutorials[currentIndex]; | ||
|
||
return ( | ||
<ModalBackground> | ||
<ModalContainer> | ||
<Header> | ||
<h2>{title}</h2> | ||
</Header> | ||
<ModalContent> | ||
<ImageContainer> | ||
<img | ||
src={currentTutorial.image} | ||
alt={`Tutorial step ${currentIndex + 1}`} | ||
/> | ||
</ImageContainer> | ||
<ContentContainer> | ||
{currentTutorial.content.split(".").join(".\n")} | ||
</ContentContainer> | ||
<ButtonContainer> | ||
<Button | ||
type="text" | ||
text="prev" | ||
handleClick={handlePreviousButton} | ||
disabled={currentIndex === 0} | ||
/> | ||
<Button | ||
type="text" | ||
text={currentIndex === tutorials.length - 1 ? "start" : "next"} | ||
handleClick={handleNextButton} | ||
/> | ||
</ButtonContainer> | ||
</ModalContent> | ||
</ModalContainer> | ||
</ModalBackground> | ||
); | ||
}; | ||
|
||
export default TutorialModal; |
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
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,20 @@ | ||
import styled from "styled-components"; | ||
|
||
const ImageContainer = styled.div` | ||
display: flex; | ||
gap: 4rem; | ||
width: 50rem; | ||
height: 20rem; | ||
|
||
img { | ||
width: 50rem; | ||
} | ||
`; | ||
|
||
const ContentContainer = styled.pre` | ||
display: flex; | ||
line-height: 2rem; | ||
font-weight: bold; | ||
`; | ||
|
||
export { ImageContainer, ContentContainer }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드의 가독성과 함수 재사용성을 고려했을 때 useEffect 외부로 분리해주는 것도 좋을 것 같아요! 물론, 아직은 다른 곳에서 renderBlocks가 사용되고있지는 않지만, 별도로 분리한다면 코드의 가독성이 향상될 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니다. 기연님 의견 반영하여 전체적인 로직을 리팩토링할 때, useEffect를 외부로 분리하는 작업을 이슈로 생성하여 추후에 한 번에 진행하겠습니다! #36