From cb98bb21d88c956e02ded1fec0b9b500cbf503f9 Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Sat, 21 Sep 2024 10:26:46 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Delete=20unused=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../landing/src/components/home/color-hash.ts | 55 ----------- apps/web/src/components/badge.tsx | 28 ------ apps/web/src/components/button.tsx | 52 ---------- apps/web/src/components/card.tsx | 22 ----- apps/web/src/components/data-table.tsx | 79 --------------- apps/web/src/components/menu-styles.ts | 13 --- apps/web/src/components/no-ssr.tsx | 10 -- apps/web/src/components/pay-wall.tsx | 99 ------------------- apps/web/src/contexts/current-event.ts | 72 -------------- packages/ui/src/helpers/input-attributes.ts | 85 ---------------- packages/ui/src/types.ts | 0 11 files changed, 515 deletions(-) delete mode 100644 apps/landing/src/components/home/color-hash.ts delete mode 100644 apps/web/src/components/badge.tsx delete mode 100644 apps/web/src/components/button.tsx delete mode 100644 apps/web/src/components/card.tsx delete mode 100644 apps/web/src/components/data-table.tsx delete mode 100644 apps/web/src/components/menu-styles.ts delete mode 100644 apps/web/src/components/no-ssr.tsx delete mode 100644 apps/web/src/components/pay-wall.tsx delete mode 100644 apps/web/src/contexts/current-event.ts delete mode 100644 packages/ui/src/helpers/input-attributes.ts delete mode 100644 packages/ui/src/types.ts diff --git a/apps/landing/src/components/home/color-hash.ts b/apps/landing/src/components/home/color-hash.ts deleted file mode 100644 index 93721495bb0..00000000000 --- a/apps/landing/src/components/home/color-hash.ts +++ /dev/null @@ -1,55 +0,0 @@ -import ColorHash from "color-hash"; - -export const colorHash = new ColorHash({ - hue: [{ min: 185, max: 320 }], - lightness: [0.65], - saturation: 0.8, -}); - -type RGBColor = [number, number, number]; - -const avatarBackgroundColors: RGBColor[] = [ - [255, 135, 160], - [255, 179, 71], - [255, 95, 95], - [240, 128, 128], - [255, 160, 122], - [255, 192, 203], - [230, 230, 250], - [173, 216, 230], - [176, 224, 230], - [106, 90, 205], - [123, 104, 238], - [147, 112, 219], - [138, 43, 226], - [148, 0, 211], - [153, 50, 204], - [139, 0, 139], - [75, 0, 130], - [72, 61, 139], - [219, 39, 119], - [236, 72, 153], -]; - -function isBright(color: RGBColor): boolean { - const [r, g, b] = color; - const L = (0.2126 * r) / 255 + (0.7152 * g) / 255 + (0.0722 * b) / 255; - return L > 0.6 ? true : false; -} - -export const getRandomAvatarColor = (str: string) => { - const strSum = str.split("").reduce((acc, val) => acc + val.charCodeAt(0), 0); - const randomIndex = strSum % avatarBackgroundColors.length; - const color = avatarBackgroundColors[randomIndex] as RGBColor; - const [r, g, b] = color; - return { color: `rgb(${r}, ${g}, ${b})`, requiresDarkText: isBright(color) }; -}; - -export const generateGradient = (s: string): string => { - const s1 = s.substring(0, s.length / 2); - const s2 = s.substring(s.length / 2); - const c1 = colorHash.hex(s1); - const c2 = colorHash.hex(s2); - - return `linear-gradient(45deg, ${c1}, ${c2})`; -}; diff --git a/apps/web/src/components/badge.tsx b/apps/web/src/components/badge.tsx deleted file mode 100644 index 29e455163d9..00000000000 --- a/apps/web/src/components/badge.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import clsx from "clsx"; -import React from "react"; - -const Badge: React.FunctionComponent<{ - children?: React.ReactNode; - color?: "gray" | "amber" | "green" | "red" | "blue"; - className?: string; -}> = ({ children, color = "gray", className }) => { - return ( -
- {children} -
- ); -}; - -export default Badge; diff --git a/apps/web/src/components/button.tsx b/apps/web/src/components/button.tsx deleted file mode 100644 index a0b2362f22e..00000000000 --- a/apps/web/src/components/button.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { Button as NewButton } from "@rallly/ui/button"; -import * as React from "react"; - -export interface ButtonProps - extends Omit< - React.DetailedHTMLProps< - React.ButtonHTMLAttributes, - HTMLButtonElement - >, - "type" | "ref" - > { - children?: React.ReactNode; - className?: string; - disabled?: boolean; - loading?: boolean; - icon?: React.ReactElement; - htmlType?: React.ButtonHTMLAttributes["type"]; - type?: "default" | "primary" | "danger"; - form?: string; - title?: string; - onClick?: React.MouseEventHandler; -} - -export const LegacyButton = React.forwardRef( - function Button( - { - children, - loading, - type = "default", - htmlType = "button", - icon, - disabled, - ...passThroughProps - }, - ref, - ) { - return ( - - {icon ? React.cloneElement(icon, { className: "size-5 mr-1.5" }) : null} - {children} - - ); - }, -); diff --git a/apps/web/src/components/card.tsx b/apps/web/src/components/card.tsx deleted file mode 100644 index 54fa930572b..00000000000 --- a/apps/web/src/components/card.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { cn } from "@rallly/ui"; - -export const Card = ( - props: React.PropsWithChildren<{ - className?: string; - fullWidthOnMobile?: boolean; - }>, -) => { - return ( -
- {props.children} -
- ); -}; diff --git a/apps/web/src/components/data-table.tsx b/apps/web/src/components/data-table.tsx deleted file mode 100644 index 328e1eed931..00000000000 --- a/apps/web/src/components/data-table.tsx +++ /dev/null @@ -1,79 +0,0 @@ -"use client"; - -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@rallly/ui/table"; -import { - ColumnDef, - flexRender, - getCoreRowModel, - useReactTable, -} from "@tanstack/react-table"; - -interface DataTableProps { - columns: ColumnDef[]; - data: TData[]; -} - -export function DataTable({ - columns, - data, -}: DataTableProps) { - const table = useReactTable({ - data, - columns, - getCoreRowModel: getCoreRowModel(), - }); - - return ( -
- - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => { - return ( - - {header.isPlaceholder - ? null - : flexRender( - header.column.columnDef.header, - header.getContext(), - )} - - ); - })} - - ))} - - - {table.getRowModel().rows?.length ? ( - table.getRowModel().rows.map((row) => ( - - {row.getVisibleCells().map((cell) => ( - - {flexRender(cell.column.columnDef.cell, cell.getContext())} - - ))} - - )) - ) : ( - - - No results. - - - )} - -
-
- ); -} diff --git a/apps/web/src/components/menu-styles.ts b/apps/web/src/components/menu-styles.ts deleted file mode 100644 index 3aa8baccee9..00000000000 --- a/apps/web/src/components/menu-styles.ts +++ /dev/null @@ -1,13 +0,0 @@ -import clsx from "clsx"; - -export const styleMenuItem = ({ - active, - selected, -}: { - active: boolean; - selected: boolean; -}) => - clsx("menu-item text-sm", { - "font-medium": selected, - "bg-blue-50": active, - }); diff --git a/apps/web/src/components/no-ssr.tsx b/apps/web/src/components/no-ssr.tsx deleted file mode 100644 index 7939e473836..00000000000 --- a/apps/web/src/components/no-ssr.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import dynamic from "next/dynamic"; -import React from "react"; - -const NoSsr = (props: { children?: React.ReactNode }) => ( - {props.children} -); - -export default dynamic(() => Promise.resolve(NoSsr), { - ssr: false, -}); diff --git a/apps/web/src/components/pay-wall.tsx b/apps/web/src/components/pay-wall.tsx deleted file mode 100644 index 43f13afb72a..00000000000 --- a/apps/web/src/components/pay-wall.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import { Badge } from "@rallly/ui/badge"; -import { Button } from "@rallly/ui/button"; -import { m } from "framer-motion"; -import Link from "next/link"; -import { useParams } from "next/navigation"; -import React from "react"; - -import { Trans } from "@/components/trans"; -import { usePlan } from "@/contexts/plan"; - -const Teaser = () => { - const params = useParams(); - - return ( - -
- -
- -
-
-

- -

-

- -

-
-
- - -
-
-
- ); -}; - -export const PayWall = ({ children }: React.PropsWithChildren) => { - const isPaid = usePlan() === "paid"; - - if (isPaid) { - return <>{children}; - } - return ( -
-
- {children} -
-
- -
-
- ); -}; - -export const PayWallTeaser = ({ children }: React.PropsWithChildren) => { - return
{children}
; -}; diff --git a/apps/web/src/contexts/current-event.ts b/apps/web/src/contexts/current-event.ts deleted file mode 100644 index 720556443fb..00000000000 --- a/apps/web/src/contexts/current-event.ts +++ /dev/null @@ -1,72 +0,0 @@ -import React from "react"; -import { createStateContext } from "react-use"; - -import { trpc } from "@/utils/trpc/client"; - -export const [usePollId, PollIdProvider] = createStateContext(""); - -const useCurrentEventId = () => { - const [pollId] = usePollId(); - return pollId; -}; - -export const useCurrentPollResponses = () => { - const pollId = useCurrentEventId(); - return trpc.polls.participants.list.useQuery({ pollId }); -}; - -export const useCurrentEvent = () => { - const pollId = useCurrentEventId(); - return trpc.polls.get.useQuery({ urlId: pollId }); -}; - -export type OptionScore = { - yes: string[]; - ifNeedBe: string[]; - no: string[]; -}; - -export const useCreatePollLink = () => { - const pollId = useCurrentEventId(); - const basePath = `/poll/${pollId}`; - return React.useCallback( - (path?: string) => (path ? `${basePath}/${path}` : basePath), - [basePath], - ); -}; - -export const useScore = (optionId: string) => { - const { data: participants = [] } = useCurrentPollResponses(); - return participants.reduce( - (acc, participant) => { - for (const vote of participant.votes) { - if (vote.optionId === optionId) { - acc[vote.type]++; - } - } - return acc; - }, - { - yes: 0, - ifNeedBe: 0, - no: 0, - }, - ); -}; - -// export const useDateFormatter = () => { -// const { dayjs } = useDayjs(); -// const { preferredTimeZone } = useUserPreferences(); -// const { data: event } = useCurrentEvent(); - -// return React.useCallback( -// (date: string | number | Date, format: string) => { -// let d = dayjs(date).utc(); -// if (event?.timeZone) { -// d = d.tz(event.timeZone, true).tz(preferredTimeZone); -// } -// return d.format(format); -// }, -// [dayjs, event?.timeZone, preferredTimeZone], -// ); -// }; diff --git a/packages/ui/src/helpers/input-attributes.ts b/packages/ui/src/helpers/input-attributes.ts deleted file mode 100644 index 8a3aa2c81ec..00000000000 --- a/packages/ui/src/helpers/input-attributes.ts +++ /dev/null @@ -1,85 +0,0 @@ -// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes - -type InputAttributes = - | "accept" - | "alt" - | "autocapitalize" - | "autocomplete" - | "capture" - | "checked" - | "defaultChecked" - | "defaultValue" - | "disabled" - | "form" - | "formaction" - | "formenctype" - | "formmethod" - | "formnovalidate" - | "formtarget" - | "height" - | "list" - | "max" - | "maxlength" - | "min" - | "minlength" - | "multiple" - | "name" - | "pattern" - | "placeholder" - | "popovertarget" - | "popovertargetaction" - | "readonly" - | "required" - | "size" - | "src" - | "step" - | "type" - | "value" - | "width"; - -// Includes all text-like inputs, e.g. text, email, password, number, date, etc. -type InputTextualAttributes = - | "autoCapitalize" - | "autoComplete" - | "defaultValue" - | "disabled" - | "form" - | "list" - | "maxLength" - | "minLength" - | "min" - | "multiple" - | "max" - | "name" - | "pattern" - | "placeholder" - | "readOnly" - | "required" - | "size" - | "step" - | "type" - | "value"; - -type InputRadioAttributes = - | "checked" - | "defaultChecked" - | "defaultValue" - | "disabled" - | "form" - | "name" - | "required" - | "value"; - -type NotInputRadioAttributes = Exclude; -type NotInputTextualAttributes = Exclude< - InputAttributes, - InputTextualAttributes ->; - -export type { - InputAttributes, - InputRadioAttributes, - InputTextualAttributes, - NotInputRadioAttributes, - NotInputTextualAttributes, -}; diff --git a/packages/ui/src/types.ts b/packages/ui/src/types.ts deleted file mode 100644 index e69de29bb2d..00000000000