# Adding a New Section

1. Let's say we want to add a new section. First, we need to update the navigation menu by adding a new \<li>\</li> element:

{% hint style="warning" %}
Always remember to add the classes **nav\_\_tab, nav\_\_tab--\[section number]** as well as the data attribute ( **data-tab=\[section number] )** with its respective section number.
{% endhint %}

<figure><img src="https://2257434529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4sABE3FsF3LHpa0gPTzA%2Fuploads%2FTbpTBfFsjLQ6KinLMRWb%2Fcode.png?alt=media&#x26;token=9a997a5d-d91d-4bf2-bafb-68efa8d4a378" alt=""><figcaption></figcaption></figure>

***

2. Then we can add the section content at the bottom of the code, after the section:

{% hint style="warning" %}
Remember to add the classes **section\_\_tab** and **section\_\_tab--\[section number]** with its respective section number since it is necessary for the section to be displayed.
{% endhint %}

<figure><img src="https://2257434529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4sABE3FsF3LHpa0gPTzA%2Fuploads%2FgOUBtnt8SmPrMJYdVGPy%2Fcode2.png?alt=media&#x26;token=6c046a42-2cd4-496d-9881-a3bf4ee16e01" alt=""><figcaption></figcaption></figure>

***

3. To make the index and title appear you can use the following structure:

<figure><img src="https://2257434529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4sABE3FsF3LHpa0gPTzA%2Fuploads%2FPJUwOKttF14R169O7nf9%2Fcode3.png?alt=media&#x26;token=35e7e609-ec47-42e3-8067-0232bf040a98" alt=""><figcaption></figcaption></figure>

***

4. **Highlight Effect to a Title**

To highlight a word in the title (or any other word in the template), follow these steps:

1. Wrap the word you want to highlight in a `<span>` tag.
2. Add the class `marked` to the `<span>` tag.

For example, in your HTML, it would look like this:

<pre class="language-html"><code class="lang-html"><strong>&#x3C;h2 class="title-section w-100">
</strong><strong>    New 
</strong><strong>    &#x3C;span class="marked">Section&#x3C;/span>
</strong><strong>&#x3C;/h2>
</strong></code></pre>

***

5. How to Apply Animations to Elements:

* In the HTML, simply add the `data-animation` attribute to the element you want to animate, and assign the animation name.&#x20;

For example:

```html
<h3 class="title-section w-100" data-animation="slide-right">
    New 
    <span class="marked">Section</span>
</h3>
```

* The available animations in your template are defined in the CSS using `@keyframes` to create transformation and opacity transitions, as shown below:

```css
/*==== Text and heading animations ====*/
.slide-up {
    animation: slide-up 1s ease forwards;
}

.slide-right {
    animation: slide-right 1s ease forwards;
}

.slide-left {
    animation: slide-left 1s ease forwards;
}

/* Keyframes */
@keyframes slide-up {
    from {
        transform: translateY(20%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slide-right {
    from {
        transform: translateX(5%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slide-left {
    from {
        transform: translateX(-5%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
```

Each animation has a set duration and transition type (e.g., `ease`, `forwards`) to control the timing and end state of the animation.

Ensure that the HTML elements you want to animate have the appropriate `data-animation` attribute.

* The animations are controlled by the `app.js` file located in the `js` folder. This script ensures that the correct animation is applied when the `data-animation` attribute is detected in the HTML.

***

6. How to Apply Animations Using the Intersection Observer:

Certain elements in the template are animated when they come into view, thanks to the Intersection Observer. These animations are triggered by adding either the `animated-up` or `animated-scale` class to an element.

**HTML Structure**

To animate an element, simply add the `animated-up` or `animated-scale` class to it. For example:

```html
<article class="service animated-scale">
    <!--Content -->
</article>
```

**CSS Animations**

The `animated-up` and `animated-scale` classes are defined in the CSS to create the animations. When the element enters the viewport, these classes are animated with transitions for opacity and transform:

```css
/* Observer animations */
.animated-up {
    opacity: 0;
    transform: translateY(80px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.animated-up.animated-up-item {
    opacity: 1;
    transform: translateY(0);
}

.animated-scale {
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.animated-scale.animated-scale-item {
    opacity: 1;
    transform: scale(1);
}
```

**JavaScript (Intersection Observer)**

The Intersection Observer in your `app.js` file handles the detection when an element with the `animated` or `animated-scale` class comes into view. When the element is visible, the observer adds the `animated-item` or `animated-scale-item` classes to trigger the animation:

```javascript
// Observer
document.addEventListener("DOMContentLoaded", () => {
    const animatedItem = document.querySelectorAll(".animated");
    const animatedScale = document.querySelectorAll('.animated-scale')

    const observer = new IntersectionObserver(
        (entries) => {
            entries.forEach((entry, index) => {
                if (entry.isIntersecting) {
                    setTimeout(() => {
                        entry.target.classList.add("animated-item");
                        entry.target.classList.add("animated-scale-item");
                    }, index * 100);
                } else {
                    entry.target.classList.remove("animated-item");
                    entry.target.classList.remove("animated-scale-item");
                }
            });
        },{
            threshold: 0.1,
        }
    );

    animatedScale.forEach(item => observer.observe(item));
    animatedItem.forEach(item => observer.observe(item));
});

```

This script ensures that elements with the `animated` or `animated-scale` class are animated when they are scrolled into view. The `setTimeout` with the `index * 100` adds a slight delay to each element to make the animations appear sequentially.
