Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:boostcampwm-2024/web31-BooLock into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lee0jae330 committed Dec 6, 2024
2 parents f13ccb5 + bc68819 commit 1bf3a73
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const CodeExportButton = () => {
return (
<button
onClick={handleClick}
className="text-bold-rg rounded-full border border-gray-100 px-4 py-2 text-gray-400 transition-colors ease-in-out hover:border-gray-300 hover:bg-gray-50 hover:text-gray-300"
className="text-bold-rg rounded-full border border-gray-100 bg-white px-4 py-2 text-gray-400 transition-colors ease-in-out hover:border-gray-300 hover:bg-gray-50 hover:text-gray-300"
disabled={isLoading}
>
{isLoading ? (
Expand Down
25 changes: 17 additions & 8 deletions apps/client/src/pages/Workspacepage/WorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Helmet } from 'react-helmet-async';
import { Loading } from '@/shared/ui';
import { NotFound } from '@/pages/NotFound/NotFound';
import { useParams } from 'react-router-dom';
import { useLayoutEffect } from 'react';
import { useLayoutEffect, useEffect } from 'react';
import { useCoachMarkStore } from '@/shared/store/useCoachMarkStore';

/**
Expand All @@ -16,22 +16,31 @@ export const WorkspacePage = () => {
const { workspaceId } = useParams();
const { isPending, isError } = useGetWorkspace(workspaceId as string);
usePreventLeaveWorkspacePage();
const { isCoachMarkOpen, openCoachMark, closeCoachMark } = useCoachMarkStore();

if (isError) {
return <NotFound />;
}
const { currentStep, isCoachMarkOpen, openCoachMark } = useCoachMarkStore();
const toolboxDiv = document.querySelector('.blocklyToolboxDiv');

useLayoutEffect(() => {
const isCoachMarkDismissed = localStorage.getItem('isCoachMarkDismissed');

if (!isCoachMarkDismissed) {
openCoachMark();
} else {
closeCoachMark();
}
}, []);

useEffect(() => {
if (!toolboxDiv) return;

if (currentStep <= 1) {
toolboxDiv.classList.add('coachMarkHighlight');
} else {
toolboxDiv.classList.remove('coachMarkHighlight');
}
}, [currentStep, toolboxDiv]);

if (isError) {
return <NotFound />;
}

return (
<>
<Helmet>
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/shared/store/useCoachMarkStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export const useCoachMarkStore = create<TCoachMarkStore>()((set) => ({
isCoachMarkOpen: true,
currentStep: 0,
openCoachMark: () => set({ isCoachMarkOpen: true, currentStep: 0 }),
closeCoachMark: () => set({ isCoachMarkOpen: false }),
closeCoachMark: () => set({ isCoachMarkOpen: false, currentStep: 5 }),
setCurrentStep: (step) => set({ currentStep: step }),
}));
2 changes: 0 additions & 2 deletions apps/client/src/shared/utils/tags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// TODO: 위치 논의 필요 (shared or core)

export const container = ['div', 'span', 'header', 'section', 'nav', 'main', 'article', 'footer'];
export const text = [
'p',
Expand Down
21 changes: 3 additions & 18 deletions apps/client/src/widgets/workspace/CoachMark/CoachMark.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { useEffect } from 'react';
import { useCoachMarkStore } from '@/shared/store/useCoachMarkStore';
import { CircleButton } from '@/shared/ui';
import { coachMarkContent } from '@/shared/utils';
import { useEffect } from 'react';
import * as Blockly from 'blockly/core';
import TabbedToolbox from '@/core/tabbedToolbox';
import { coachMarkContent } from '@/shared/utils';

export const CoachMark = () => {
const { currentStep, setCurrentStep, closeCoachMark } = useCoachMarkStore();
const stepsLength = coachMarkContent.length;
const toolboxDiv = document.querySelector('.blocklyToolboxDiv');
// const blockCanvas = document.querySelector('.blocklyBlockCanvas');
// TODO: 사용자가이드 - 블록 하이라이팅

const nextStep = () => {
if (currentStep < stepsLength - 1) {
Expand All @@ -36,7 +33,6 @@ export const CoachMark = () => {
}

const toolbox = workspace.getToolbox() as TabbedToolbox;

if (!toolbox) return;

switch (currentStep) {
Expand All @@ -49,17 +45,7 @@ export const CoachMark = () => {
case 2:
toolbox.clickTab('html');
}

if (toolboxDiv) {
if (currentStep <= 1) {
toolboxDiv.classList.add('coachMarkHighlight');
// blockCanvas.classList.add('coachMarkHighlight');
} else {
toolboxDiv.classList.remove('coachMarkHighlight');
// blockCanvas.classList.remove('coachMarkHighlight');
}
}
}, [currentStep, toolboxDiv]);
}, [currentStep]);

return (
<div className="fixed inset-0 z-[100] flex items-center justify-center bg-black bg-opacity-70">
Expand All @@ -83,7 +69,6 @@ export const CoachMark = () => {
그만 보기
</CircleButton>

{/* TODO: 이전 버튼 - 기능 구현 후 삭제 */}
<CircleButton
className="text-bold-sm h-8 w-16"
onClick={prevStep}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ export const WorkspacePageHeader = () => {
</div>
<div className="flex gap-11">
<button
className="text-medium-rg hover flex items-center gap-1 text-gray-300"
className="text-medium-rg hover flex items-center gap-1 text-gray-300 hover:text-gray-500"
onClick={openCoachMark}
aria-label="도움말 버튼"
>
도움말 <Question />
{/* TODO: hover시 효과 */}
</button>
<WorkspaceHeaderButtons />
</div>
Expand Down

0 comments on commit 1bf3a73

Please sign in to comment.