Skip to content

Commit

Permalink
update animation view
Browse files Browse the repository at this point in the history
  • Loading branch information
chenmh0901 committed Jun 17, 2024
1 parent 83672da commit 5f58738
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 32 deletions.
30 changes: 3 additions & 27 deletions src/components/AnimationView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@
import WaterLightAnimation from '@/views/WaterLight'
import TimeLineAniamtion from '@/views/TimeLine'
import BubbleAnimation from '@/views/Bubble'
import CheckOnAnimation from '@/views/CheckOn'
import MouseFollowAnimation from '@/views/MouseFollow'
import CardAnimation from '@/views/Card'
import ImageWallAnimation from '@/views/ImageWall'
import ClockAnimation from '@/views/Clock'
import BugWordAnimation from '@/views/BugWord'
import Calendar from '@/views/Calendar'
import { VIEW_COMPONENTS } from './type'
import type { IView } from '@/types/view'
import { ViewType } from '@/types/view'

Check failure on line 3 in src/components/AnimationView/index.tsx

View workflow job for this annotation

GitHub Actions / build

'ViewType' is declared but its value is never read.
import './style.css'

export default function Views({ activeView }: { activeView: IView }) {
const ActiveComponent = VIEW_COMPONENTS[activeView.value]
return (
<div className="views">
{activeView.value === ViewType.Clock && <ClockAnimation />}
{activeView.value === ViewType.Image && <ImageWallAnimation />}
{activeView.value === ViewType.Card && <CardAnimation />}
{activeView.value === ViewType.MouseFollow && <MouseFollowAnimation />}
{activeView.value === ViewType.CheckOn && <CheckOnAnimation />}
{activeView.value === ViewType.Bubble && <BubbleAnimation />}
{activeView.value === ViewType.TimeLine && <TimeLineAniamtion />}
{activeView.value === ViewType.WaterLight && <WaterLightAnimation />}
{activeView.value === ViewType.BugWord && <BugWordAnimation />}
{activeView.value === ViewType.Calendar && (
<Calendar
value={new Date()}
onChange={(date: Date) => {
alert(date.toLocaleDateString())
}}
/>
)}
<ActiveComponent />
</div>
)
}
26 changes: 26 additions & 0 deletions src/components/AnimationView/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type React from 'react'
import WaterLightAnimation from '@/views/WaterLight'
import TimeLineAniamtion from '@/views/TimeLine'
import BubbleAnimation from '@/views/Bubble'
import CheckOnAnimation from '@/views/CheckOn'
import MouseFollowAnimation from '@/views/MouseFollow'
import CardAnimation from '@/views/Card'
import ImageWallAnimation from '@/views/ImageWall'
import ClockAnimation from '@/views/Clock'
import BugWordAnimation from '@/views/BugWord'
import Calendar from '@/views/Calendar'
import { ViewType } from '@/types/view'

// 创建映射对象
export const VIEW_COMPONENTS: Record<ViewType, React.ElementType> = {
[ViewType.Clock]: ClockAnimation,
[ViewType.Image]: ImageWallAnimation,
[ViewType.Card]: CardAnimation,
[ViewType.MouseFollow]: MouseFollowAnimation,
[ViewType.CheckOn]: CheckOnAnimation,
[ViewType.Bubble]: BubbleAnimation,
[ViewType.TimeLine]: TimeLineAniamtion,
[ViewType.WaterLight]: WaterLightAnimation,
[ViewType.BugWord]: BugWordAnimation,
[ViewType.Calendar]: Calendar,
}
5 changes: 0 additions & 5 deletions src/types/view.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export enum ViewType {
List = 'List',
Clock = 'Clock',
Image = 'Image',
Card = 'Card',
Expand All @@ -18,10 +17,6 @@ export interface IView {
}

export const viewList: IView[] = [
{
label: 'List',
value: ViewType.List,
},
{
label: 'Clock',
value: ViewType.Clock,
Expand Down

0 comments on commit 5f58738

Please sign in to comment.