Skip to content

Instantly share code, notes, and snippets.

View yoSteve's full-sized avatar

Steve Yorke yoSteve

  • Grand Lake, NS
  • 02:16 (UTC -03:00)
View GitHub Profile
@yoSteve
yoSteve / rxjs-react-hooks.ts
Created September 7, 2023 19:35
React Hooks for interacting with RxJS Observables and managing subscriptions.
import { useEffect, useState } from 'react';
import { Observable } from 'rxjs';
/**
* A React hook that manages the subscription of a source Observable, and calls event handlers
* when source emits 'next' and 'error' events.
*
* @param source$ an Observable of type T
* @param nextHandler a function to be called when source$ emits next value
* @param errorHandler a function to be called if source$ emits error
@yoSteve
yoSteve / ng-let.directive.ts
Last active March 24, 2021 12:03
*ngLet Structural Directive
export class NgLetContext<T = any> {
$implicit: T = null!;
ngLet: T = null!;
}
@Directive({
selector: '[ngLet]',
})
export class NgLetDirective<T> implements OnInit {
private _context = new NgLetContext<T>();
@yoSteve
yoSteve / _aspect-ratio-mixin.scss
Last active September 10, 2020 13:27
A Sassy Mixin for maintaining a responsive aspect ratio. Include this on a wrapper element.
// For an aspect ratio of 16:9 use like this:
// .wrapper-element {
// @include aspect-ratio(16, 9);
// }
@mixin aspect-ratio($width, $height) {
position: relative;
overflow: hidden;
height: 0;
padding-top: calc(#{$height} / #{$width} * 100%);
@yoSteve
yoSteve / _easing-functions.scss
Last active July 19, 2019 22:22 — forked from robpataki/_easing-functions.scss
Easing function variables for SCSS
// Easing function variables - SEE EXAMPLES: http://easings.net/en#
// SINE
$ease-in-sine: cubic-bezier(0.47, 0, 0.745, 0.715);
$ease-out-sine: cubic-bezier(0.39, 0.575, 0.565, 1);
$ease-in-out-sine: cubic-bezier(0.445, 0.05, 0.55, 0.95);
// QUAD
$ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
$ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
@yoSteve
yoSteve / _flex-mixin.scss
Last active July 15, 2020 15:56
A Sassy Mixin for applying CSS Flexbox. Centres the content by default.
@mixin flex($direction: row, $justify: center, $align: center) {
display: flex;
flex-direction: $direction;
justify-content: $justify;
align-items: $align;
}
@yoSteve
yoSteve / _shadow-mixin.scss
Last active July 19, 2019 21:38
Shadow: A Sassy Mixin for Material-style shadows
@mixin shadow($height: 'lowest', $color: #000, $darkness: 1, $inset: false) {
@if $height == 'lowest' {
box-shadow: 0 1px 3px rgba($color, 0.12 * $darkness),
0 1px 2px rgba($color, 0.24 * $darkness);
@if $inset {
box-shadow: inset 0 1px 3px rgba($color, 0.12 * $darkness),
inset 0 1px 2px rgba($color, 0.24 * $darkness);
}
}
@yoSteve
yoSteve / safe.pipe.ts
Last active June 26, 2019 16:27
Angular Safe Pipe: Sanitize trusted inline url/html/style values. Safety first!
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
@Pipe({
name: 'safe'
})
export class SafePipe implements PipeTransform {
transform(value: string, type?: 'style' | 'html' | 'url'): any {
if (value) {
@yoSteve
yoSteve / devlog.operator.ts
Last active July 16, 2020 00:19
DevLog: A Most Excellent Custom RxJS Operator
import { tap } from 'rxjs/operators';
import { environment as ENV } from '../../environments/environment'; // NOTE: adjust path to environment files
const normalStyle = [
'display: block',
'color: mediumVioletRed',
'font-weight: normal',
'background: linear-gradient(135deg, #98fb98 66%, #22c1c3 100%)',
'padding: 3px 9px',
@yoSteve
yoSteve / README.md
Last active May 24, 2023 19:53
VS Code User Settings for Pop!_OS UI Theme

VS Code Pop!_UI Color Theme

Have you seen Pop!_OS by System76? It's gorgeous.

Electrifying teals and scintillating tangerines pop against dark chocolate-grey windows and menus. Adding these customizations to 'User Settings' will allows you to enjoy the Pop!_OS UI color theme, and still be able to swap in your favourite syntax highlighting theme for improved readability and visual lexing.

Installation

  1. Open VS Code 'User Settings' File > Preferences > Settings.
  2. Copy the contents of vscode-color-settings.json into "workbench.colorCustomizations".