Skip to content

Commit

Permalink
chore: port design system to inline tailwind (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
pluvrt authored May 4, 2024
1 parent d16a6bb commit 29ac41f
Show file tree
Hide file tree
Showing 166 changed files with 1,808 additions and 3,214 deletions.
35 changes: 35 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"eslint.codeActionsOnSave.mode": "problems",
"eslint.workingDirectories": [
{ "pattern": "./packages/*/" },
{ "pattern": "./apps/*/" }
],
"[graphql]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
},
"[typescript]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
},
"[typescriptreact]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
},
"eslint.validate": [
"graphql",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"[graphql][typescript][typescriptreact]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
},
"typescript.tsdk": "node_modules/typescript/lib"
}
41 changes: 19 additions & 22 deletions apps/storybook/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import withPlugins from "next-compose-plugins";
import remarkGfm from "remark-gfm";

const withBundleAnalyzer = bundleAnalyzerPlugin({
enabled: process.env.BUNDLE_ANALYZE === "true",
enabled: process.env.BUNDLE_ANALYZE === "true",
});

const withMdx = mdxPlugin({
extension: /\.mdx?$/,
options: {
providerImportSource: "@mdx-js/react",
remarkPlugins: [frontmatter, remarkGfm],
rehypePlugins: [],
},
extension: /\.mdx?$/,
options: {
providerImportSource: "@mdx-js/react",
remarkPlugins: [frontmatter, remarkGfm],
rehypePlugins: [],
},
});

/** @type {import("next").NextConfig} */
Expand All @@ -23,22 +23,19 @@ const config = {
externalDir: true,
},
i18n: {
locales: ["en-US"],
defaultLocale: "en-US",
},
locales: ["en-US"],
defaultLocale: "en-US",
},
images: {
deviceSizes: [320, 420, 768, 1024, 1200],
domains: [],
loader: "default",
},
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
deviceSizes: [320, 420, 768, 1024, 1200],
domains: [],
loader: "default",
},
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
reactStrictMode: true,
env: {
WS_ENDPOINT: process.env.WS_ENDPOINT,
},
env: {
WS_ENDPOINT: process.env.WS_ENDPOINT,
},
};

export default withPlugins([
withBundleAnalyzer,
withMdx,
], config);
export default withPlugins([withBundleAnalyzer, withMdx], config);
10 changes: 2 additions & 8 deletions apps/web/src/components/DocsBreadcrumbs/DocsBreadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ export const DocsBreadcrumbs = memo<DocsBreadcrumbsProps>((props) => {
const getName = useCallback((slugs: string[]): string | null => {
const [head, ...tail] = slugs;

const path = [head, ...tail.map((part) => `[${part}]`)].join(
"[children]",
);
const path = [head, ...tail.map((part) => `[${part}]`)].join("[children]");

return get(routes, `${path}[name]`) ?? null;
}, []);
Expand All @@ -43,11 +41,7 @@ export const DocsBreadcrumbs = memo<DocsBreadcrumbsProps>((props) => {
const parts = slugs.slice(0, i + 1);

return (
<Breadcrumbs.Item
key={slug}
href={`/docs/${parts.join("/")}`}
selected={i === slugs.length - 1}
>
<Breadcrumbs.Item key={slug} href={`/docs/${parts.join("/")}`} selected={i === slugs.length - 1}>
{getName(parts)}
</Breadcrumbs.Item>
);
Expand Down
20 changes: 8 additions & 12 deletions apps/web/src/components/DocsCard/DocsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Root = tw(Paper)`
items-stretch
gap-3
p-4
rounded-xl
rounded-lg
`;

const Title = tw.h2`
Expand All @@ -29,17 +29,13 @@ export interface DocsCardProps {
title: string;
}

export const DocsCard: FC<DocsCardProps> = ({
className,
description,
href,
style,
title,
}) => {
export const DocsCard: FC<DocsCardProps> = ({ className, description, href, style, title }) => {
return (
<Root as={NextLink} className={className} href={href} style={style}>
<Title>📄️ {title}</Title>
{!!description && <Description>{description}</Description>}
</Root>
<NextLink className={className} href={href} style={style}>
<Root>
<Title>📄️ {title}</Title>
{!!description && <Description>{description}</Description>}
</Root>
</NextLink>
);
};
8 changes: 1 addition & 7 deletions apps/web/src/components/DocsSeo/DocsSeo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,5 @@ export interface DocsSeoProps {
}

export const DocsSeo: FC<DocsSeoProps> = ({ description, title }) => {
return (
<Seo
description={description}
postfix={!!title}
title={title ?? "pluv.io"}
/>
);
return <Seo description={description} postfix={!!title} title={title ?? "pluv.io"} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@ export interface DocsTreeViewNavigationProps {
style?: CSSProperties;
}

export const DocsTreeViewNavigation = memo<DocsTreeViewNavigationProps>(
(props) => {
const { className, onClickLink, style } = props;
export const DocsTreeViewNavigation = memo<DocsTreeViewNavigationProps>((props) => {
const { className, onClickLink, style } = props;

return (
<TreeView className={className} style={style}>
<DocsTreeViewNavigationRoutes
baseRoute="/docs"
level={1}
onClickLink={onClickLink}
routes={routes}
selected={true}
/>
</TreeView>
);
},
);
return (
<TreeView className={className} style={style}>
<DocsTreeViewNavigationRoutes
baseRoute="/docs"
level={1}
onClickLink={onClickLink}
routes={routes}
selected={true}
/>
</TreeView>
);
});

DocsTreeViewNavigation.displayName = "DocsTreeViewNavigation";
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ export interface DocsTreeViewNavigationRoutesProps {
selected?: boolean;
}

export const DocsTreeViewNavigationRoutes: FC<
DocsTreeViewNavigationRoutesProps
> = ({ baseRoute = "", level, onClickLink, routes, selected }) => {
export const DocsTreeViewNavigationRoutes: FC<DocsTreeViewNavigationRoutesProps> = ({
baseRoute = "",
level,
onClickLink,
routes,
selected,
}) => {
const router = useRouter();

const sorted = useMemo(() => {
Expand All @@ -37,10 +41,7 @@ export const DocsTreeViewNavigationRoutes: FC<
.split("/");
}, [baseRoute, router.asPath]);

const routeSlug = useMemo(
() => router.asPath.split("/")[level + 1],
[level, router.asPath],
);
const routeSlug = useMemo(() => router.asPath.split("/")[level + 1], [level, router.asPath]);

const finalSlug = slugs.at(-1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,13 @@ export interface HomeBoxesDemoSectionProps {
style?: CSSProperties;
}

export const HomeBoxesDemoSection: FC<HomeBoxesDemoSectionProps> = ({
className,
style,
}) => {
export const HomeBoxesDemoSection: FC<HomeBoxesDemoSectionProps> = ({ className, style }) => {
return (
<Root className={className} style={style}>
<Title as="h2">Simple-to-use APIs</Title>
<Info as="h3">
Configure your server and client to unlock intuitive APIs that
allow you to focus on your end-user experience.
Configure your server and client to unlock intuitive APIs that allow you to focus on your end-user
experience.
</Info>
<CodeDemoContainer>
<StyledCodeDemo />
Expand Down
35 changes: 5 additions & 30 deletions apps/web/src/components/HomeChessDemo/HomeChessDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
import {
ChessBoard,
ChessBoardRef,
ChessMoveHistory,
LoadingChessBoard,
} from "@pluv-internal/react-chess";
import { ChessBoard, ChessBoardRef, ChessMoveHistory, LoadingChessBoard } from "@pluv-internal/react-chess";
import { yjs } from "@pluv/crdt-yjs";
import ms from "ms";
import {
CSSProperties,
FC,
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import { CSSProperties, FC, useCallback, useEffect, useMemo, useRef, useState } from "react";
import tw, { styled } from "twin.macro";
import { useStorage } from "../../pluv-io/cloudflare";

Expand Down Expand Up @@ -128,20 +115,11 @@ export const HomeChessDemo: FC<HomeChessDemoProps> = ({ className, style }) => {
const [winner, setWinner] = useState<string | null>();
const chessRef = useRef<ChessBoardRef>();

const moveHistory = useMemo(
() => demo?.chessHistory?.slice() ?? null,
[demo],
);
const moveHistory = useMemo(() => demo?.chessHistory?.slice() ?? null, [demo]);

const onGameOver = useCallback((winner: "b" | "w" | null) => {
setGameOver(true);
setWinner(
winner === "b"
? "Black wins!"
: winner === "w"
? "White wins!"
: "Draw",
);
setWinner(winner === "b" ? "Black wins!" : winner === "w" ? "White wins!" : "Draw");
}, []);

useEffect(() => {
Expand Down Expand Up @@ -169,10 +147,7 @@ export const HomeChessDemo: FC<HomeChessDemoProps> = ({ className, style }) => {
id="home-chess"
onGameOver={onGameOver}
onMove={({ game }) => {
sharedType?.set(
"chessHistory",
yjs.array(game.history()),
);
sharedType?.set("chessHistory", yjs.array(game.history()));
}}
/>
) : (
Expand Down
4 changes: 1 addition & 3 deletions apps/web/src/components/HomeChessDemo/useOtherSquares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { useOthers } from "pluv-io";
import { useMemo } from "react";

export const useOtherSquares = (): Record<string, number> => {
const otherSquares = useOthers((others) =>
others.map((other) => other.presence.demoChessSquare),
);
const otherSquares = useOthers((others) => others.map((other) => other.presence.demoChessSquare));

return useMemo(() => {
return otherSquares.reduce<Record<string, number>>(
Expand Down
Loading

0 comments on commit 29ac41f

Please sign in to comment.