Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Editorial - insert contact module

Solved by Pedro M View solution

Started by Stanislav 2 years ago · 4 replies · 79 views
2 years ago

There is such code, I want to integrate it into the theme Editorial beautifully and correctly.
I will be grateful for any advice. Demo - lower right corner +

HTML
<div class="contact-button">
    <div class="icon phone">
        <a href="tel:+77777777777"><i class="fa fa-phone"></i></a>
    </div>
    <div class="icon whatsapp">
        <a href="https://wa.me/77777777777" target="_blank"><i class="fab fa-whatsapp"></i></a>
    </div>
    <div class="main-button">
        <i class="fa fa-plus"></i>
    </div>
</div>

<script>
document.querySelector('.main-button').addEventListener('click', function() {
    document.querySelectorAll('.contact-button .icon').forEach(function(icon) {
        icon.style.display = icon.style.display === 'block' ? 'none' : 'block';
    });
});
</script>

<style>
.contact-button {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 1000;
}

.contact-button .icon {
    display: none;
    position: absolute;
    bottom: 58px;
    right: 0;
    width: 44px;
    height: 44px;
    background-color: #fff;
    border-radius: 50%;
    text-align: center;
    line-height: 44px;
    color: #007bff;
    font-size: 30px;
    transition: all 0.3s;
}

.contact-button .icon.phone {
    bottom: 120px;
}

.contact-button .main-button {
    width: 44px;
    height: 44px;
    background-color: #fe3000;
    border-radius: 50%;
    text-align: center;
    line-height: 44px;
    color: #fff;
    font-size: 21px;
    cursor: pointer;
}

.contact-button .main-button:hover + .icon,
.contact-button .main-button:hover + .icon + .icon {
    display: block;
}
</style>
2 years ago

Hi.
You can propose your code in a pull request in the Editorial theme repository, explaining what you want to achieve with it.

However, if you try to add some code to the Editorial theme, it is better to keep it separate, i.e. the styles in a styles file (preferably specific to these buttons, and in scss format), inside the assets/scss/components folder. The javascript code, integrated inside main.js and a partial template, which contains the logic of the buttons, loading through the theme blueprint, the buttons to be displayed and their links (see social.htm.twig and blueprints.yaml).

last edited 10/01/24 by Pedro M
2 years ago

Eh, I'm still learning. Alas, I don't know how to do it. GitHub is still complicated for me

2 years ago Solution

I'll put it on the list of new features for the theme for now. Right now I'm working on some personal projects that take up a lot of my time.

👍 1
2 years ago

@pmoreno:
Я пока внесу его в список новых функций темы. Сейчас я работаю над некоторыми личными проектами, которые отнимают у меня много времени.

You are just Batman and my idol 🤩

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 193 2 months ago
Themes & Styling · by Ian, 2 months ago
3 90 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 449 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 43 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 123 3 months ago