Built Portfolio Page - 8 (Skills Component)

Steps:

  1. Add Skills Component
  2. Add margin bottom in Projects.tsx
  3. Add css to skill component
  4. Add hook
  5. Add animation

1. Add Skills Component

Add src/components/Skills.tsx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import React from 'react'
import SectionHeading from './Section-heading'
import { skillsData } from '@/libs/data'

export default function Skills() {
return (
<section>
<SectionHeading>My skills</SectionHeading>
<ul>
{
skillsData.map((skill,index)=>(
<li key={index}>{skill}</li>
))
}
</ul>
</section>
)
}

2. Add margin bottom in Projects.tsx

Projects.tsx

1
2
3
...
<section id="projects" className='scroll-mt-28 mb-28'>
...

3. Add css to skills component

Skills.tsx:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
<section className='mb-28 max-w-[42rem] scroll-mt-28 text-center sm:mb-40'>
<SectionHeading>My skills</SectionHeading>
<ul className='flex flex-wrap justify-center gap-2 text-lg text-gray-800'>
{
skillsData.map((skill,index)=>(
<li
className='bg-white border border-black/[0.1] rounded-xl px-5 py-3'
key={index}
>
{skill}
</li>
))
}
</ul>
</section>
...

4. Add hook

Skills.tsx:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
import { useSectionInView } from '@/hooks/useSectionInView';

export default function Skills() {
const { ref } = useSectionInView("Skills");

return (
<section
ref={ref}
id='skills'
className='mb-28 max-w-[42rem] scroll-mt-28 text-center sm:mb-40'
>

...

5. Add Animation

Skills.tsx:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"use client"

import React from 'react'
import SectionHeading from './Section-heading'
import { skillsData } from '@/libs/data'
import { useSectionInView } from '@/hooks/useSectionInView';
import { motion } from 'framer-motion';

const fadeInAnimationVariant = {
initial:{
opticity:0,
y:100,
},
animate:(index:number)=>({
opacity: 1,
y:0,
transition: {
delay: 0.05 * index,
}
}),
}
export default function Skills() {
const { ref } = useSectionInView("Projects");

return (
<section
ref={ref}
id='skills'
className='mb-28 max-w-[42rem] scroll-mt-28 text-center sm:mb-40'
>
<SectionHeading>My skills</SectionHeading>
<ul className='flex flex-wrap justify-center gap-2 text-lg text-gray-800'>
{
skillsData.map((skill,index)=>(
<motion.li
className='bg-white border border-black/[0.1] rounded-xl px-5 py-3'
key={index}
variants={fadeInAnimationVariant}
initial="initial"
whileInView="animate"
viewport={{
once:true,
}}
custom={index}
>
{skill}
</motion.li>
))
}
</ul>
</section>
)
}

效果

请我喝杯咖啡吧~

支付宝
微信