Skip to content

Commit 0c03030

Browse files
committed
chore: move component library from tailwind to sass
1 parent b805816 commit 0c03030

File tree

117 files changed

+3558
-2527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+3558
-2527
lines changed

apps/api-reference/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"pull:env": "[ $CI ] || VERCEL_ORG_ID=team_BKQrg3JJFLxZyTqpuYtIY0rj VERCEL_PROJECT_ID=prj_gbljYVzp0m5EpCuOF6nZpM4WMFM6 vercel env pull",
1414
"start:dev": "next dev --port 3002",
1515
"start:prod": "next start --port 3002",
16-
"test:format": "jest --selectProjects format",
17-
"test:lint": "jest --selectProjects lint",
16+
"test:format": "prettier --check .",
17+
"test:lint": "eslint .",
1818
"test:types": "tsc"
1919
},
2020
"dependencies": {

apps/insights/eslint.config.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
import { fileURLToPath } from "node:url";
2-
3-
import { nextjs, tailwind, storybook } from "@cprussin/eslint-config";
4-
5-
const tailwindConfig = fileURLToPath(
6-
import.meta.resolve(`./tailwind.config.ts`),
7-
);
8-
9-
export default [...nextjs, ...tailwind(tailwindConfig), ...storybook];
1+
export { nextjs as default } from "@cprussin/eslint-config";

apps/insights/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"start:dev": "next dev --port 3003",
1515
"start:prod": "next start --port 3003",
1616
"test:format": "prettier --check .",
17-
"test:lint": "jest --selectProjects lint",
17+
"test:lint": "eslint .",
1818
"test:types": "tsc"
1919
},
2020
"dependencies": {
@@ -55,7 +55,7 @@
5555
"jest": "catalog:",
5656
"postcss": "catalog:",
5757
"prettier": "catalog:",
58-
"tailwindcss": "catalog:",
58+
"sass": "catalog:",
5959
"typescript": "catalog:",
6060
"vercel": "catalog:"
6161
}

apps/insights/postcss.config.js

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

apps/insights/prettier.config.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
import { fileURLToPath } from "node:url";
2-
3-
import { base, tailwind, mergeConfigs } from "@cprussin/prettier-config";
4-
5-
const tailwindConfig = fileURLToPath(
6-
import.meta.resolve(`./tailwind.config.ts`),
7-
);
8-
9-
export default mergeConfigs([base, tailwind(tailwindConfig)]);
1+
export { base as default } from "@cprussin/prettier-config";

apps/insights/src/app/layout.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
import "../tailwind.css";
2-
31
export { Root as default } from "../components/Root";
42
export { metadata, viewport } from "../metadata";
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
@use "@pythnetwork/component-library/theme.scss";
2+
3+
.copyButton {
4+
margin: -#{theme.spacing(0.5)} -0.5em;
5+
display: inline-block;
6+
white-space: nowrap;
7+
border-radius: theme.border-radius("md");
8+
padding: theme.spacing(0.5) 0.5em;
9+
border: none;
10+
background: none;
11+
cursor: pointer;
12+
transition: background-color 100ms linear;
13+
outline: none;
14+
15+
.iconContainer {
16+
position: relative;
17+
top: 0.125em;
18+
margin-left: theme.spacing(1);
19+
display: inline-block;
20+
21+
.copyIconContainer {
22+
opacity: 0.5;
23+
transition: opacity 100ms linear;
24+
25+
.copyIcon {
26+
width: 1em;
27+
height: 1em;
28+
}
29+
30+
.copyIconLabel {
31+
@include theme.sr-only;
32+
}
33+
}
34+
35+
.checkIcon {
36+
position: absolute;
37+
inset: 0;
38+
color: theme.color("states", "success", "normal");
39+
opacity: 0;
40+
transition: opacity 100ms linear;
41+
}
42+
}
43+
44+
&[data-hovered] {
45+
background-color: theme.color("button", "outline", "background", "hover");
46+
}
47+
48+
&[data-pressed] {
49+
background-color: theme.color("button", "outline", "background", "active");
50+
}
51+
52+
&[data-focus-visible] {
53+
outline: 1px auto currentcolor;
54+
outline-offset: theme.spacing(1);
55+
}
56+
57+
&[data-is-copied] .iconContainer {
58+
.copyIconContainer {
59+
opacity: 0;
60+
}
61+
62+
.checkIcon {
63+
opacity: 1;
64+
}
65+
}
66+
}

apps/insights/src/components/CopyButton/index.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
"use client";
22

3-
import { Copy, Check } from "@phosphor-icons/react/dist/ssr";
3+
import { Check } from "@phosphor-icons/react/dist/ssr/Check";
4+
import { Copy } from "@phosphor-icons/react/dist/ssr/Copy";
45
import { useLogger } from "@pythnetwork/app-logger";
56
import { UnstyledButton } from "@pythnetwork/component-library/UnstyledButton";
67
import clsx from "clsx";
78
import { type ComponentProps, useCallback, useEffect, useState } from "react";
89

10+
import styles from "./index.module.scss";
11+
912
type CopyButtonProps = ComponentProps<typeof UnstyledButton> & {
1013
text: string;
1114
};
@@ -51,11 +54,7 @@ export const CopyButton = ({
5154
return (
5255
<UnstyledButton
5356
onPress={copy}
54-
isDisabled={isCopied}
55-
className={clsx(
56-
"group/copy-button mx-[-0.5em] -mt-0.5 inline-block whitespace-nowrap rounded-md px-[0.5em] py-0.5 outline-none outline-0 outline-steel-600 transition data-[hovered]:bg-black/5 data-[focus-visible]:outline-2 dark:outline-steel-300 dark:data-[hovered]:bg-white/10",
57-
className,
58-
)}
57+
className={clsx(styles.copyButton, className)}
5958
{...(isCopied && { "data-is-copied": true })}
6059
{...props}
6160
>
@@ -64,12 +63,12 @@ export const CopyButton = ({
6463
<span>
6564
{typeof children === "function" ? children(...args) : children}
6665
</span>
67-
<span className="relative top-[0.125em] ml-1 inline-block">
68-
<span className="opacity-50 transition-opacity duration-100 group-data-[is-copied]/copy-button:opacity-0">
69-
<Copy className="size-[1em]" />
70-
<div className="sr-only">Copy to clipboard</div>
66+
<span className={styles.iconContainer}>
67+
<span className={styles.copyIconContainer}>
68+
<Copy className={styles.copyIcon} />
69+
<div className={styles.copyIconLabel}>Copy to clipboard</div>
7170
</span>
72-
<Check className="absolute inset-0 text-green-600 opacity-0 transition-opacity duration-100 group-data-[is-copied]/copy-button:opacity-100" />
71+
<Check className={styles.checkIcon} />
7372
</span>
7473
</>
7574
)}

apps/insights/src/components/Error/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { useLogger } from "@pythnetwork/app-logger";
22
import { Button } from "@pythnetwork/component-library/Button";
33
import { useEffect } from "react";
44

5-
import { MaxWidth } from "../MaxWidth";
6-
75
type Props = {
86
error: Error & { digest?: string };
97
reset?: () => void;
@@ -17,13 +15,13 @@ export const Error = ({ error, reset }: Props) => {
1715
}, [error, logger]);
1816

1917
return (
20-
<MaxWidth>
18+
<div>
2119
<h1>Uh oh!</h1>
2220
<h2>Something went wrong</h2>
2321
<p>
2422
Error Details: <strong>{error.digest ?? error.message}</strong>
2523
</p>
2624
{reset && <Button onPress={reset}>Reset</Button>}
27-
</MaxWidth>
25+
</div>
2826
);
2927
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@use "@pythnetwork/component-library/theme.scss";
2+
3+
.h1 {
4+
font-size: theme.font-size("2xl");
5+
font-weight: theme.font-weight("medium");
6+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import clsx from "clsx";
22
import type { ComponentProps } from "react";
33

4+
import styles from "./index.module.scss";
5+
46
export const H1 = ({ className, children, ...props }: ComponentProps<"h1">) => (
5-
<h1 className={clsx(className, "text-2xl font-medium")} {...props}>
7+
<h1 className={clsx(styles.h1, className)} {...props}>
68
{children}
79
</h1>
810
);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@use "@pythnetwork/component-library/theme.scss";
2+
3+
.loading {
4+
@include theme.max-width;
5+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Skeleton } from "@pythnetwork/component-library/Skeleton";
22

3+
import styles from "./index.module.scss";
34
import { H1 } from "../H1";
4-
import { MaxWidth } from "../MaxWidth";
55

66
export const Loading = () => (
7-
<MaxWidth>
7+
<div className={styles.loading}>
88
<H1>
9-
<Skeleton className="w-60" />
9+
<Skeleton width={60} />
1010
</H1>
11-
</MaxWidth>
11+
</div>
1212
);

apps/insights/src/components/MaxWidth/index.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { ButtonLink } from "@pythnetwork/component-library/Button";
22

3-
import { MaxWidth } from "../MaxWidth";
4-
53
export const NotFound = () => (
6-
<MaxWidth>
4+
<div>
75
<h1>Not Found</h1>
86
<p>{"The page you're looking for isn't here"}</p>
97
<ButtonLink href="/">Go Home</ButtonLink>
10-
</MaxWidth>
8+
</div>
119
);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@use "@pythnetwork/component-library/theme.scss";
2+
3+
.overview {
4+
@include theme.max-width;
5+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import styles from "./index.module.scss";
12
import { H1 } from "../H1";
2-
import { MaxWidth } from "../MaxWidth";
33

44
export const Overview = () => (
5-
<MaxWidth>
5+
<div className={styles.overview}>
66
<H1>Overview</H1>
7-
</MaxWidth>
7+
</div>
88
);

0 commit comments

Comments
 (0)