@@ -83,7 +83,7 @@ export const VideoRow = function ({title, videos, ...props}) {
8383 }
8484 } ) ; // lazy loads elements with default selector as '.lozad'
8585 observer . observe ( ) ;
86- } )
86+ } , [ videos ] )
8787
8888 return (
8989 < div className = "margin-top--log margin-bottom--log" >
@@ -94,7 +94,7 @@ export const VideoRow = function ({title, videos, ...props}) {
9494 < div className = "row" >
9595 {
9696 videos . map ( ( video , index ) => (
97- < div className = { clsx ( 'col col--6' ) } key = { index } >
97+ < div className = { clsx ( 'col col--6' ) } key = { video . title } >
9898 < div >
9999 < video
100100 type = "video/mp4"
@@ -142,12 +142,17 @@ export const VideoRow = function ({title, videos, ...props}) {
142142 )
143143}
144144
145+ const tags = [ '全部' , '魔法' , 'DynamicTable' , '机器人' , '物联网' , '开源硬件' ]
146+
145147function Projects ( ) {
146148 const context = useDocusaurusContext ( ) ;
149+ const [ currentTag , setCurrentTag ] = useState ( '全部' )
147150 const { siteConfig = { } } = context ;
151+
148152 useLayoutEffect ( ( ) => {
149153 window . $ ( ".stack" ) . lettering ( ) ;
150154 } , [ ] )
155+
151156 return (
152157 < Layout title = "Projects" >
153158 { /*
@@ -159,17 +164,21 @@ function Projects() {
159164 </ div >
160165 < div className = { clsx ( styles . navContainer ) } >
161166 < div className = { clsx ( styles . filter ) } >
162- < button className = { clsx ( styles . tag1 ) } > 全部</ button >
163- < button className = { clsx ( styles . tags ) } > 魔法</ button >
164- < button className = { clsx ( styles . tags ) } > DynamicTable</ button >
165- < button className = { clsx ( styles . tags ) } > 机器人</ button >
166- < button className = { clsx ( styles . tags ) } > 物联网</ button >
167- < button className = { clsx ( styles . tags ) } > 开源硬件</ button >
167+ {
168+ tags . map ( tag => (
169+ < button
170+ className = { clsx ( styles . tag , currentTag === tag && styles . tagActive ) }
171+ onClick = { ( ) => setCurrentTag ( tag ) }
172+ >
173+ { tag }
174+ </ button > )
175+ )
176+ }
168177 </ div >
169178 </ div >
170179 < main className = { clsx ( styles . newContainer ) } >
171- < VideoRow title = "" videos = { videos [ '横版视频' ] } />
172- < VideoRow title = "" videos = { videos [ '竖版视频' ] } />
180+ < VideoRow title = "" videos = { videos [ '横版视频' ] . filter ( video => currentTag === '全部' || video . tags . includes ( currentTag ) ) } />
181+ < VideoRow title = "" videos = { videos [ '竖版视频' ] . filter ( video => currentTag === '全部' || video . tags . includes ( currentTag ) ) } />
173182 </ main >
174183 </ div >
175184 </ Layout >
0 commit comments