Skip to content

Instantly share code, notes, and snippets.

@vilindberg
vilindberg / typed-scss-modules+8.0.1.patch
Created December 12, 2024 10:52
Patch for typed-scss-modules
diff --git a/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js b/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js
index 6c728e5..23fc66a 100644
--- a/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js
+++ b/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js
@@ -30,7 +30,7 @@ const NAME_FORMATS_WITH_TRANSFORMER = Object.keys(transformersMap);
exports.NAME_FORMATS = [...NAME_FORMATS_WITH_TRANSFORMER, "all"];
exports.nameFormatDefault = "camel";
const fileToClassNames = (file, { additionalData, includePaths = [], nameFormat: rawNameFormat, implementation, aliases, aliasPrefixes, importer, } = {}) => __awaiter(void 0, void 0, void 0, function* () {
- const { renderSync } = (0, implementations_1.getImplementation)(implementation);
+ const { compile } = (0, implementations_1.getImplementation)(implementation);
@vilindberg
vilindberg / gist:2c81dc7e2091ede23f883ec32ab56247
Created December 12, 2024 10:49
typed-scss-modules+8.0.1.patch
diff --git a/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js b/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js
index 6c728e5..23fc66a 100644
--- a/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js
+++ b/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js
@@ -30,7 +30,7 @@ const NAME_FORMATS_WITH_TRANSFORMER = Object.keys(transformersMap);
exports.NAME_FORMATS = [...NAME_FORMATS_WITH_TRANSFORMER, "all"];
exports.nameFormatDefault = "camel";
const fileToClassNames = (file, { additionalData, includePaths = [], nameFormat: rawNameFormat, implementation, aliases, aliasPrefixes, importer, } = {}) => __awaiter(void 0, void 0, void 0, function* () {
- const { renderSync } = (0, implementations_1.getImplementation)(implementation);
+ const { compile } = (0, implementations_1.getImplementation)(implementation);
import React, { forwardRef, useEffect, useRef, useState } from 'react'
import { Animated, View } from 'react-native'
import styled from 'styled-components/native'
import { almostBlack, offWhite } from '../../colors'
import { baseText } from '../../styles'
import { measure } from '../../utils/view.util'
import { Touchable } from '../touchable'
type ItemProps = {
text: string
import { useMemo, useState } from 'react'
type Pagination = {
currentPage: number
setPage: (page: number) => void
}
export function usePagination<T>(items: T[] = [], pageSize = 10): [T[], Pagination] {
const [currentPage, setPage] = useState(0)
const fs = require('fs')
const path = require('path')
function logFiles(dir, excludes) {
for (const fileName of fs.readdirSync(dir)) {
const filePath = path.resolve(dir, fileName)
const stats = fs.statSync(filePath)
if (excludes.some(exclude => filePath.includes(exclude))) {
continue
import { useRef, useCallback, useEffect } from "react";
export const useClickOutside = (callback, active) => {
const ref = useRef(null);
const handler = useCallback(
e => {
if (ref.current && !ref.current.contains(e.target)) {
callback();
}
@vilindberg
vilindberg / observable.js
Last active December 12, 2018 22:18
playing with my own observable
class Observable {
constructor({ initFn, element, eventName }) {
if (initFn) {
this._initFn = initFn
}
else if (element && eventName) {
this._event = {
listener: event => {
this.next(event)
class Tester {
constructor(app) {
this.app = app
}
test(cases) {
cases.forEach(tc => {
if (app(tc.input) !== tc.output) {
throw new Error()
}
const stringToCamel = (str: string) => {
str = str.replace(/[-_\s]+(.)?/g, (_, ch) => (ch ? ch.toUpperCase() : ''))
return str.substr(0, 1).toLowerCase() + str.substr(1)
}
const objectToCamel = (obj: Object) =>
Object.keys(obj).reduce((tutti, prop) => {
tutti[stringToCamel(prop)] = obj[prop]
return tutti
}, {})
@vilindberg
vilindberg / compose.ts
Created September 10, 2018 20:46
Compose React hocs
import { ComponentClass } from 'react'
export const compose = <P>(
...hocs: any[]
): ((comp: ((props: P) => JSX.Element) | ComponentClass<P>) => ComponentClass<P>) =>
hocs.reduceRight((a, b) => (arg: any) => b(a(arg)))