Skip to content

Instantly share code, notes, and snippets.

View JonathanDn's full-sized avatar
💭
Building Reusable Vue Components

Yonatan Doron JonathanDn

💭
Building Reusable Vue Components
View GitHub Profile
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'maxLength'
})
export class MaxLengthPipe implements PipeTransform {
transform(value: string, limit: number){
if (value.length > limit) return value.substring(0, limit) + '...';
else return value;
}
@JonathanDn
JonathanDn / component.vue
Last active June 20, 2023 15:54
Vue.js 2/3 - Vue.Observable - Simple Store Implementation, returning a reactive object.
// component importing and mutating state from store.js (all getters, mutations, actions)
// reference = https://austincooper.dev/2019/08/09/vue-observable-state-store/
<template>
<div>
<div>Radius: {{ radius }}</div>
<div>Color: {{ color }}</div>
<button @:click="setRadius(0)">Reset radius</button>
<button @:click="fetchColorFromApi">Fetch color</button>
</div>
</template>
@JonathanDn
JonathanDn / medium_clap.html
Last active June 9, 2023 07:34
(moved to a repo https://github.com/JonathanDn/mediumclap ) Medium Clap Reproduction - My take on it by looking, researching and trial & error. Demo available --> https://jsfiddle.net/urft14zr/425/
<div class="canvas">
<div id="totalCounter" class="total-counter"></div>
<div id="clap" class="clap-container">
<i class="clap-icon fa fa-hand-paper-o"></i>
</div>
<div id="clicker" class="click-counter">
<span class="counter"></span>
</div>
@JonathanDn
JonathanDn / timeline.component.ts
Created February 19, 2017 17:00
Angular 2 - D3 Horizontal Scrollable Timeline, with mock date data / real log data - circles re-rendering when zoom activated & when side-scrolling - change colors according to input v1.0.0
import {Component, OnInit, Input, ChangeDetectionStrategy} from '@angular/core';
import * as d3 from 'd3';
import {Observable} from "rxjs";
import {UIConsts} from "../../../../shared/app.consts";
@Component({
selector: 'timeline',
styleUrls: ['timeline.scss'],
template: `
<div class="timeline-svg-container">
@JonathanDn
JonathanDn / gravity.css
Created October 16, 2019 08:04
HTML Canvas Gravity
body {
margin: 0;
overflow: hidden;
}
@JonathanDn
JonathanDn / getinitials.pipe.ts
Created November 3, 2016 13:58
Angular 2 pipe to turn string into initials
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'getInitials'
})
export class GetInitialsPipe implements PipeTransform {
transform(value: string) {
return value.replace(/[a-z]/g, '').replace(' ', '');
}
body {
background: cyan;
}
@keyframes donut-spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
@JonathanDn
JonathanDn / media-query.css
Created November 15, 2019 13:43 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@JonathanDn
JonathanDn / util-elastic-collision.js
Created October 19, 2019 09:40 — forked from christopher4lis/util-elastic-collision.js
A set of utility functions used to reproduce the effect of elastic collision within HTML5 canvas. Used in the Chris Courses tutorial video on collision detection: https://www.youtube.com/watch?v=789weryntzM
/**
* Rotates coordinate system for velocities
*
* Takes velocities and alters them as if the coordinate system they're on was rotated
*
* @param Object | velocity | The velocity of an individual particle
* @param Float | angle | The angle of collision between two objects in radians
* @return Object | The altered x and y velocities after the coordinate system has been rotated
*/
@JonathanDn
JonathanDn / interactive-circles.css
Created October 16, 2019 08:06
HTML Canvas Interactvie Circles
body {
margin: 0;
overflow: hidden;
}