diff options
| author | Dhravya <[email protected]> | 2024-05-25 18:41:26 -0500 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-05-25 18:41:26 -0500 |
| commit | 075f45986fd4d198292226e64afb71b3515576b4 (patch) | |
| tree | 5c728356cd0310f1c1c012fd6618c72a836c314b /apps/web/src/lib | |
| parent | added social material (diff) | |
| download | supermemory-075f45986fd4d198292226e64afb71b3515576b4.tar.xz supermemory-075f45986fd4d198292226e64afb71b3515576b4.zip | |
refactored UI, with shared components and UI, better rules and million lint
Diffstat (limited to 'apps/web/src/lib')
| -rw-r--r-- | apps/web/src/lib/icons.tsx | 34 | ||||
| -rw-r--r-- | apps/web/src/lib/searchParams.ts | 12 | ||||
| -rw-r--r-- | apps/web/src/lib/utils.ts | 111 |
3 files changed, 0 insertions, 157 deletions
diff --git a/apps/web/src/lib/icons.tsx b/apps/web/src/lib/icons.tsx deleted file mode 100644 index 51a4714e..00000000 --- a/apps/web/src/lib/icons.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import * as React from "react"; -import type { SVGProps } from "react"; -const Chrome = (props: SVGProps<SVGSVGElement>) => ( - <svg - xmlns="http://www.w3.org/2000/svg" - preserveAspectRatio="xMidYMid" - viewBox="0 0 190.5 190.5" - width="1em" - height="1em" - {...props} - > - <path - fill="#fff" - d="M95.252 142.873c26.304 0 47.627-21.324 47.627-47.628s-21.323-47.628-47.627-47.628-47.627 21.324-47.627 47.628 21.323 47.628 47.627 47.628z" - /> - <path - fill="#229342" - d="m54.005 119.07-41.24-71.43a95.227 95.227 0 0 0-.003 95.25 95.234 95.234 0 0 0 82.496 47.61l41.24-71.43v-.011a47.613 47.613 0 0 1-17.428 17.443 47.62 47.62 0 0 1-47.632.007 47.62 47.62 0 0 1-17.433-17.437z" - /> - <path - fill="#fbc116" - d="m136.495 119.067-41.239 71.43a95.229 95.229 0 0 0 82.489-47.622A95.24 95.24 0 0 0 190.5 95.248a95.237 95.237 0 0 0-12.772-47.623H95.249l-.01.007a47.62 47.62 0 0 1 23.819 6.372 47.618 47.618 0 0 1 17.439 17.431 47.62 47.62 0 0 1-.001 47.633z" - /> - <path - fill="#1a73e8" - d="M95.252 132.961c20.824 0 37.705-16.881 37.705-37.706S116.076 57.55 95.252 57.55 57.547 74.431 57.547 95.255s16.881 37.706 37.705 37.706z" - /> - <path - fill="#e33b2e" - d="M95.252 47.628h82.479A95.237 95.237 0 0 0 142.87 12.76 95.23 95.23 0 0 0 95.245 0a95.222 95.222 0 0 0-47.623 12.767 95.23 95.23 0 0 0-34.856 34.872l41.24 71.43.011.006a47.62 47.62 0 0 1-.015-47.633 47.61 47.61 0 0 1 41.252-23.815z" - /> - </svg> -); -export default Chrome; diff --git a/apps/web/src/lib/searchParams.ts b/apps/web/src/lib/searchParams.ts deleted file mode 100644 index aae3f4c7..00000000 --- a/apps/web/src/lib/searchParams.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { - createSearchParamsCache, - parseAsInteger, - parseAsString, -} from "nuqs/server"; -// Note: import from 'nuqs/server' to avoid the "use client" directive - -export const searchParamsCache = createSearchParamsCache({ - // List your search param keys and associated parsers here: - q: parseAsString.withDefault(""), - maxResults: parseAsInteger.withDefault(10), -}); diff --git a/apps/web/src/lib/utils.ts b/apps/web/src/lib/utils.ts deleted file mode 100644 index 81fa8549..00000000 --- a/apps/web/src/lib/utils.ts +++ /dev/null @@ -1,111 +0,0 @@ -"use client"; -import { type ClassValue, clsx } from "clsx"; -import { twMerge } from "tailwind-merge"; - -export function cn(...inputs: ClassValue[]) { - return twMerge(clsx(inputs)); -} - -// removes http(s?):// and / from the url -export function cleanUrl(url: string) { - if (url.endsWith("/")) { - url = url.slice(0, -1); - } - return url.startsWith("https://") - ? url.slice(8) - : url.startsWith("http://") - ? url.slice(7) - : url; -} - -export function getIdsFromSource(sourceIds: string[]) { - console.log(sourceIds); - return sourceIds.map((id) => { - const parts = id.split("-"); - if (parts.length > 1) { - return parts.slice(0, -1).join("-"); - } else { - return id; - } - }); -} - -export function generateId() { - return Math.random().toString(36).slice(2, 9); -} - -export function svgId(prefix: string, id: string) { - return `${prefix}-${id}`; -} - -export function countLines(textarea: HTMLTextAreaElement): number { - let _buffer: HTMLTextAreaElement | null = null; - - if (_buffer == null) { - _buffer = document.createElement("textarea"); - _buffer.style.border = "none"; - _buffer.style.height = "0"; - _buffer.style.overflow = "hidden"; - _buffer.style.padding = "0"; - _buffer.style.position = "absolute"; - _buffer.style.left = "0"; - _buffer.style.top = "0"; - _buffer.style.zIndex = "-1"; - document.body.appendChild(_buffer); - } - - const cs = window.getComputedStyle(textarea); - const pl = parseInt(cs.paddingLeft as string); - const pr = parseInt(cs.paddingRight as string); - let lh = parseInt(cs.lineHeight as string); - - // [cs.lineHeight] may return 'normal', which means line height = font size. - if (isNaN(lh)) lh = parseInt(cs.fontSize as string); - - // Copy content width. - if (_buffer) { - _buffer.style.width = textarea.clientWidth - pl - pr + "px"; - - // Copy text properties. - _buffer.style.font = cs.font as string; - _buffer.style.letterSpacing = cs.letterSpacing as string; - _buffer.style.whiteSpace = cs.whiteSpace as string; - _buffer.style.wordBreak = cs.wordBreak as string; - _buffer.style.wordSpacing = cs.wordSpacing as string; - _buffer.style.wordWrap = cs.wordWrap as string; - - // Copy value. - _buffer.value = textarea.value; - - const result = Math.floor(_buffer.scrollHeight / lh); - return result > 0 ? result : 1; - } - - return 0; -} - -export function convertRemToPixels(rem: number) { - return rem * parseFloat(getComputedStyle(document.documentElement).fontSize); -} - -export function isArraysEqual(a: any[], b: any[]) { - if (a === b) return true; - if (a == null || b == null) return false; - if (a.length !== b.length) return false; - - let isEqual = true; - - a.forEach((i) => { - if (!isEqual) return; - isEqual = b.includes(i); - }); - - if (!isEqual) return isEqual; - - b.forEach((i) => { - if (!isEqual) return; - isEqual = a.includes(i); - }); - - return isEqual; -} |