Skip to content

Instantly share code, notes, and snippets.

View dfvalero's full-sized avatar
🌵

David Fernandez dfvalero

🌵
View GitHub Profile
@dfvalero
dfvalero / multiSort.ts
Last active November 11, 2025 13:44
Multi Sort
type SortDirection = 'asc' | 'desc';
type SortField<T> = {
field: keyof T;
dir: SortDirection;
};
const comparators = {
string: (a: string, b: string) => a.localeCompare(b),
boolean: (a: boolean, b: boolean) => Number(a) - Number(b),
@dfvalero
dfvalero / operations.js
Last active February 10, 2020 11:01
Redux + normalize DEMO
import { normalize } from 'normalizr';
import { API } from '@/client/apis/whatever';
import * as types from './types';
import * as schema from '@/client/store/schema';
export const fetchUserProfile = username => {
return async dispatch => {
dispatch({type: types.FETCH_USER_PROFILE_START});
try {
@dfvalero
dfvalero / slideshow.html
Last active September 29, 2016 09:11
Example Component
<div class="slideshow" data-component="slideshow">
<div class="slideshow__content" data-content>
<div class="slideshow__wrapper" data-slideshow>
{% for element in elements %}
<div class="slideshow__slide" data-slide data-title="{{ element.title }}">
<img src="{{ element.src }}" alt="{{ element.title }}">
</div>
{% endfor %}
</div>
<div class="slideshow__pagination" data-pagination></div>