Skip to content

Instantly share code, notes, and snippets.

View ankedsgn's full-sized avatar

Anke ankedsgn

  • Flink
View GitHub Profile
@ankedsgn
ankedsgn / copy-url.html.twig
Created June 21, 2021 17:46
Create a copyable link of an article in drupal
<div class="article__copy-link__container">
<div class="button--group-message article__copy-link js-copy-wrap">
<a class="button button--secondary button--icon button--icon-left button--has-message button--copy-link js-copy-link" href="#">
{{ 'Copy the link'|t }}
<svg class="icon icon--link">
<use xlink:href="#icon-link"/>
</svg>
</a>
<div class="button__message js-copy-message">
{{ 'Link copied to clipboard'|t }}
@ankedsgn
ankedsgn / scrolling-switch.js
Created August 3, 2021 12:10
Add class when page is scrolled farther dan Xpx down (drupal jquery)
(function ($, Drupal) {
$(window).on('scroll', function () {;
scrollingSwitch();
// console.log('scrolling scrolling scrolling');
});
function scrollingSwitch() {
@ankedsgn
ankedsgn / menu--main.html.twig
Last active August 16, 2021 10:27
Menu tpl that shows menu level (Drupal 8)
{% import _self as menus %}
{#
We call a macro which calls itself to render the full tree.
@see http://twig.sensiolabs.org/doc/tags/macro.html
#}
{{ menus.menu_links(items, attributes, 0) }}
{% macro menu_links(items, attributes, menu_level) %}
{% import _self as menus %}
@ankedsgn
ankedsgn / Animations.scss
Created August 18, 2021 07:39
Animations
// Bouncing link
a:hover {
animation: bounce .7s ease-in-out;
}
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
40% {transform: translateY(-5px);}
$(function() {
$(document).on('click', 'a[href^="#"]', function(e) {
// target element id
var id = $(this).attr('href');
// target element
var $id = $(id);
if ($id.length === 0) {
return;
}
@ankedsgn
ankedsgn / progress-bar.js
Last active September 7, 2022 09:53
Progress bar of how far you have scrolled
(function ($, Drupal, drupalSettings) {
Drupal.behaviors.progressBar = {
attach: function (context) {
//add a listener for scroll
$(window).scroll(() => {
if (document.querySelector('.js-progress-bar').length) {
const ProgressText = document.querySelector('.progress-bar__text');
@ankedsgn
ankedsgn / teaser--specific-node.html.twig
Created January 13, 2025 14:28
Add class to extended drupal template (twig)
{% extends '@events/extends/teaser.html.twig' %}
{% block teaserclass %}teaser--inline{% endblock %}
{# rest of code #}