Skip to content

Instantly share code, notes, and snippets.

View ladifire's full-sized avatar

Cong Nguyen ladifire

  • Cong
  • Vietnam
View GitHub Profile
@ladifire
ladifire / PressableText.tsx
Created April 21, 2024 02:55
PressableText.tsx - Rewritten by Cong Nguyen
// Rewritten by Cong Nguyen
// original code from Facebook Frontend website: https://gist.github.com/ladifire/21fb3e774cf62ac50d0700fd50d1ccb2
import React, { useCallback, useContext, useRef, useState } from "react";
import { PressableGroupContext } from "@facebook-frontend/context";
import { joinClasses, useMergeRefs } from "@facebook-frontend/utils";
import stylex from "@stylexjs/stylex";
import { Pressability } from "./Pressability";
import { useWebPressableTouchStartHandler } from "./useWebPressableTouchStartHandler";
@ladifire
ladifire / PressableText_ORIGINAL.js
Created April 21, 2024 02:52
Original code for PressableText from Facebook frontend
__d("PressableText.react", ["Pressability", "PressableGroupContext", "RecoverableViolationWithComponentStack.react", "gkx", "joinClasses", "justknobx", "react", "stylex", "useCometErrorProject", "useMergeRefs", "useWebPressableTouchStartHandler"], (function(a, b, c, d, e, f, g) {
"use strict";
var h, i, j = i || (i = d("react"));
b = i;
var k = b.useCallback
, l = b.useContext
, m = b.useRef
, n = b.useState
, o = ["menuitem", "tab", "none"]
, p = {
@ladifire
ladifire / detect-recursion-functions.js
Created July 16, 2022 02:06
Scan recursion functions on repo
const { resolve } = require('path')
const { readdir } = require('fs').promises
const babel = require('@babel/core')
const fs = require('fs')
const t = require('@babel/types')
async function* getFiles(dir) {
const dirents = await readdir(dir, { withFileTypes: true })
for (const dirent of dirents) {
const res = resolve(dir, dirent.name)
@ladifire
ladifire / ExampleComponent.tsx
Created January 3, 2022 03:58
Demonstrate how to use Error boundary component in Reactjs
import React from 'react';
import { withErrorBoundary } from 'components/common/MartyErrorBoundary';
export const ExampleComponent = () => {
return (
<div>
Component
</div>
);
@ladifire
ladifire / MessageList.tsx
Created September 25, 2021 03:26
A Messages list component like Facebook Messenger
/**
* Copyright (c) Ladifire, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import * as React from 'react';
import fbt from 'fbt';
import {forEach} from "lodash";
@ladifire
ladifire / figma1.js
Created August 25, 2021 15:09
Learning Figma technology
window.executeFullscreenEmscriptenCode = () => {
var Module = typeof Module !== "undefined" ? Module : {};
Module = self["Module"] || {};
Module["noExitRuntime"] = true;
Error["stackTraceLimit"] = 100;
Module["onAbort"] = function(what) {
ABORT = true;
EXITSTATUS = 1;
var text = "abort(" + (what && !/^\d+$/.test(what + "") ? JSON.stringify(what) : "") + ")";
console.error(text);
@ladifire
ladifire / UIChannelItem.tsx
Created August 24, 2021 15:17
UIChannelItem.tsx by Ladifire & Cong Nguyen
/**
* Copyright (c) Ladifire, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import * as React from 'react';
import {Pressable} from '@ladifire-ui-react/tetra-button';
@ladifire
ladifire / raw.js
Created August 24, 2021 15:16
WorkGalahadUIChannelItem Component raw from Facbook code
__d("WorkGalahadUIChannelItem.react", ["CometPressableOverlay.react", "Locale", "URI",
"WIGInteractiveElementContext.react", "WIGPressable.react", "WIGTextPairing.react",
"WorkGalahadChannelFocusableTable.react", "gkx", "react", "stylex", "useCometPreloader", "useHoverAndFocusState"], (function(a, b, c, d, e, f, g) {
"use strict";
var h = d("react");
b = d("react");
var i = b.useCallback,
j = b.useMemo,
k = b.useState,
l = c("gkx")("1919265"),
@ladifire
ladifire / CometUFIThreadedComponentDecorator.tsx
Last active August 8, 2021 08:01
CometUFIThreadedComponentDecorator
/**
* Copyright (c) Ladifire, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import * as React from 'react';
import stylex from '@ladifire-opensource/stylex';
@ladifire
ladifire / uses_cases_DEPRECATED.tsx
Created January 26, 2021 16:25
Stylex_uses_cases.tsx
// These are some stylex real examples of uses in our projects
const k = stylex.create({
base: {
backgroundColor: "var(--divider)",
display: "none",
height: "100%",
opacity: 0,
position: "absolute",
right: 0,