Skip to content

Instantly share code, notes, and snippets.

View sajadabedi's full-sized avatar
🧃
Less is more

Sajjad sajadabedi

🧃
Less is more
View GitHub Profile
@sajadabedi
sajadabedi / _App.js
Created August 15, 2021 09:33
Locomotive Scroll + NextJS
export default function MyApp({ Component, pageProps }) {
useEffect(() => {
let scroll;
import('locomotive-scroll').then((locomotiveModule) => {
scroll = new locomotiveModule.default({
el: document.querySelector('[data-scroll-container]'),
smooth: true,
smoothMobile: false,
resetNativeScroll: true,
});
import { useEffect } from 'react';
export function useOutsideClick(containerRef, triggerRef, cb) {
function isOutsideClick(evt) {
if (
(containerRef.current !== null &&
containerRef.current.contains(evt.target)) ||
(triggerRef !== null && triggerRef.current.contains(evt.target))
) {
return cb({
@sajadabedi
sajadabedi / TypeFace.swift
Created March 17, 2017 14:13
Handling UIFont in swift
//custom-dynamic-type.swift
protocol CustomDynamicTypeable {
func preferredFont(forTextStyle style: UIFontTextStyle) -> UIFont?
func font(forSize pointSize: CGFloat) -> UIFont?
}
// judson-enum.swift
enum JudsonFont: String, CustomDynamicTypeable {
case regular = "Judson-Regular"
case bold = "Judson-Bold"
@sajadabedi
sajadabedi / CustomFont.swift
Last active September 6, 2022 19:39 — forked from jimmyhillis/UIFont+CustomFont.swift
Custom font Swift
import UIKit
extension UIFont {
class func systemFontOfSize(size: CGFloat) -> UIFont {
return UIFont(name: "CustomFont-Regular", size: size)!
}
func lightSystemFontOfSize(size: CGFloat) -> UIFont {
return UIFont(name: "CustomFont-Light", size: size)!
}
func boldSystemFontOfSize(size: CGFloat) -> UIFont {