Skip to content

Commit 0bd5869

Browse files
Remove duplicate and dead code (#161)
1 parent 35b9707 commit 0bd5869

24 files changed

+35
-367
lines changed

app/lib/color-scheme.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useMemo } from "react";
22
import { useNavigation, useRouteLoaderData } from "@remix-run/react";
3-
import { useIsomorphicLayoutEffect } from "~/lib/misc";
43
import type { loader as rootLoader } from "~/root";
4+
import { useLayoutEffect } from "~/ui/primitives/utils";
55

66
export type ColorScheme = "dark" | "light" | "system";
77

@@ -40,7 +40,7 @@ function ColorSchemeScriptImpl() {
4040
);
4141

4242
// Set
43-
useIsomorphicLayoutEffect(() => {
43+
useLayoutEffect(() => {
4444
switch (colorScheme) {
4545
case "light":
4646
document.documentElement.classList.remove("dark");
@@ -60,7 +60,7 @@ function ColorSchemeScriptImpl() {
6060

6161
// always sync the color scheme if "system" is used
6262
// this accounts for the docs pages adding some classnames to documentElement in root
63-
useIsomorphicLayoutEffect(() => {
63+
useLayoutEffect(() => {
6464
if (colorScheme === "system") {
6565
let media = window.matchMedia("(prefers-color-scheme: dark)");
6666
syncColorScheme(media);

app/lib/conf.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,6 @@ export function isTalkArray(arr: any): arr is Array<Talk> {
169169
return Array.isArray(arr) && arr.every(isTalk);
170170
}
171171

172-
export function isScheduleItemRawArray(
173-
arr: any,
174-
): arr is Array<ScheduleItemRaw> {
175-
return Array.isArray(arr) && arr.every(isScheduleItemRaw);
176-
}
177-
178172
export function isScheduleItemArray(arr: any): arr is Array<ScheduleItem> {
179173
return Array.isArray(arr) && arr.every(isScheduleItem);
180174
}
181-
182-
export function sluggify(string: string) {
183-
return string
184-
.toLowerCase()
185-
.replace(/[ .':]/g, " ")
186-
.split(" ")
187-
.filter(Boolean)
188-
.join("-");
189-
}

app/lib/conf2022.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import {
2222
isTalk,
2323
isTalkArray,
2424
isTalkScheduleItemRaw,
25-
sluggify,
2625
} from "./conf";
2726

2827
import speakersYamlFileContents from "../../data/conf/2022/speakers.yaml?raw";
2928
import sponsorsYamlFileContents from "../../data/conf/2022/sponsors.yaml?raw";
3029
import talksYamlFileContents from "../../data/conf/2022/talks.yaml?raw";
3130
import scheduleYamlFileContents from "../../data/conf/2022/schedule.yaml?raw";
31+
import { slugify } from "~/ui/primitives/utils";
3232

3333
let cache = new LRUCache<
3434
string,
@@ -54,7 +54,7 @@ export async function getSpeakers() {
5454
let speakerRawWithDefaults = {
5555
bioHTML,
5656
type: "speaker",
57-
slug: sluggify(speakerRaw.name),
57+
slug: slugify(speakerRaw.name),
5858
...speakerRaw,
5959
};
6060
invariant(

app/lib/conf2023.server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { DateTime } from "luxon";
33
import yaml from "yaml";
44
import invariant from "tiny-invariant";
55
import {
6-
sluggify,
76
validateSessionizeSessionData,
87
validateSessionizeSpeakerData,
98
} from "./conf2023";
@@ -18,6 +17,7 @@ import type {
1817
} from "./conf2023";
1918
import type { Sponsor } from "./conf";
2019
import { isSponsor, isSponsorArray } from "./conf";
20+
import { slugify } from "~/ui/primitives/utils";
2121

2222
const CONF_TIME_ZONE = "America/Denver";
2323
const NO_CACHE =
@@ -341,7 +341,7 @@ function modelSpeaker(speaker: SessionizeSpeakerData): Speaker {
341341
nameFirst,
342342
nameLast,
343343
nameFull,
344-
slug: sluggify(nameFull),
344+
slug: slugify(nameFull),
345345
imgUrl,
346346
twitterHandle,
347347
isTopSpeaker: !!speaker.isTopSpeaker,
@@ -365,7 +365,7 @@ function modelSpeakerSession(session: SessionizeSessionData): SpeakerSession {
365365
return {
366366
id: speaker.id,
367367
name: speaker.name,
368-
slug: sluggify(speaker.name),
368+
slug: slugify(speaker.name),
369369
};
370370
})
371371
: [];

app/lib/conf2023.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
import type { DateTime } from "luxon";
2-
import { sluggify } from "~/lib/conf";
3-
4-
export { sluggify };
5-
6-
export function getSpeakerSlug(speaker: Speaker) {
7-
return sluggify(speaker.nameFull);
8-
}
92

103
export function validateSessionizeSpeakerData(
114
data: unknown,

app/lib/misc.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

app/lib/resources.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getRepoContent } from "./gh-docs/repo-content";
55
import { processMarkdown } from "./md.server";
66
import type { Octokit } from "octokit";
77
import resourcesYamlFileContents from "../../data/resources.yaml?raw";
8-
import { slugify } from "./misc";
8+
import { slugify } from "~/ui/primitives/utils";
99

1010
// TODO: parse this with zod
1111
let _resources: ResourceYamlData[] = yaml.parse(resourcesYamlFileContents);

app/root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import { removeTrailingSlashes, isProductionHost } from "~/lib/http.server";
2323
import { ColorSchemeScript, useColorScheme } from "~/lib/color-scheme";
2424
import { parseColorScheme } from "~/lib/color-scheme.server";
2525
import iconsHref from "~/icons.svg";
26-
import { canUseDOM } from "~/lib/misc";
2726
import cx from "clsx";
27+
import { canUseDOM } from "./ui/primitives/utils";
2828

2929
export async function loader({ request }: LoaderFunctionArgs) {
3030
removeTrailingSlashes(request);

app/routes/_extras.resources._index/ui.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { Category, Resource } from "~/lib/resources.server";
22
import { InitCodeblock, ResourceTag, useCreateTagUrl } from "~/ui/resources";
33
import { Link, useSearchParams } from "@remix-run/react";
4-
import { slugify } from "~/lib/misc";
54
import cx from "clsx";
65
import iconsHref from "~/icons.svg";
6+
import { slugify } from "~/ui/primitives/utils";
77

88
export let categories = ["all", "templates", "libraries"];
99

app/routes/_extras.showcase.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { Fragment, forwardRef, useEffect, useRef } from "react";
55
import type { ShowcaseExample } from "~/lib/showcase.server";
66
import { showcaseExamples } from "~/lib/showcase.server";
77
import { clsx } from "clsx";
8-
import { useHydrated } from "~/lib/misc";
98
import { CACHE_CONTROL } from "~/lib/http.server";
9+
import { useHydrated } from "~/ui/primitives/utils";
1010

1111
export const loader = async ({ request }: LoaderFunctionArgs) => {
1212
let requestUrl = new URL(request.url);

0 commit comments

Comments
 (0)