Skip to content

Commit

Permalink
change profile tabs to use Ark+Panda
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Dec 26, 2023
1 parent 6afd866 commit 112cd68
Show file tree
Hide file tree
Showing 8 changed files with 513 additions and 28 deletions.
2 changes: 2 additions & 0 deletions web/panda.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { input } from "src/theme/components/Input/input.recipe";
import { link } from "src/theme/components/Link/link.recipe";
import { menu } from "src/theme/components/Menu/menu.recipe";
import { skeleton } from "src/theme/components/Skeleton/skeleton.recipe";
import { tabs } from "src/theme/components/Tabs/tabs.recipe";
import { titleInput } from "src/theme/components/TitleInput/titleInput.recipe";

// TODO: Dark mode = 40%
Expand Down Expand Up @@ -69,6 +70,7 @@ export default defineConfig({
button: button,
link: link,
menu: menu,
tabs: tabs,
checkbox: checkbox,
skeleton: skeleton,
},
Expand Down
59 changes: 33 additions & 26 deletions web/src/screens/profile/components/Content/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Tab, TabList, TabPanel, TabPanels, Tabs } from "@chakra-ui/react";

import { PublicProfile } from "src/api/openapi/schemas";
import { MixedPostList } from "src/components/feed/mixed/MixedPostList";
import { Unready } from "src/components/site/Unready";
import {
Tabs,
TabsContent,
TabsIndicator,
TabsList,
TabsTrigger,
} from "src/theme/components/Tabs";

import { CollectionList } from "../CollectionList/CollectionList";
import { PostList } from "../PostList/PostList";
Expand All @@ -18,30 +23,32 @@ export function Content(props: PublicProfile) {

return (
<VStack alignItems="start" w="full">
<Tabs width="full" variant="soft-rounded">
<TabList>
<Tab>Posts</Tab>
<Tab>Replies</Tab>
<Tab>Collections</Tab>
</TabList>
<TabPanels>
<TabPanel>
<MixedPostList
posts={content.data.threads}
onDelete={content.handlers.handleDelete}
/>
</TabPanel>
<TabPanel>
<Box>
<PostList posts={content.data.posts} />
</Box>
</TabPanel>
<TabPanel>
<Box>
<CollectionList collections={content.data.collections} />
</Box>
</TabPanel>
</TabPanels>
<Tabs width="full" variant="line" defaultValue="posts">
<TabsList>
<TabsTrigger value="posts">Posts</TabsTrigger>
<TabsTrigger value="replies">Replies</TabsTrigger>
<TabsTrigger value="collections">Collections</TabsTrigger>
<TabsIndicator />
</TabsList>

<TabsContent value="posts">
<MixedPostList
posts={content.data.threads}
onDelete={content.handlers.handleDelete}
/>
</TabsContent>

<TabsContent value="replies">
<Box>
<PostList posts={content.data.posts} />
</Box>
</TabsContent>

<TabsContent value="collections">
<Box>
<CollectionList collections={content.data.collections} />
</Box>
</TabsContent>
</Tabs>
</VStack>
);
Expand Down
32 changes: 32 additions & 0 deletions web/src/theme/components/Tabs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Tabs as ArkTabs } from "@ark-ui/react/tabs";
import { styled } from "styled-system/jsx";
import { tabs } from "styled-system/recipes";

import { createStyleContext } from "src/theme/create-style-context";

const { withProvider, withContext } = createStyleContext(tabs);

const Tabs = withProvider(styled(ArkTabs.Root), "root");
const TabsContent = withContext(styled(ArkTabs.Content), "content");
const TabsIndicator = withContext(styled(ArkTabs.Indicator), "indicator");
const TabsList = withContext(styled(ArkTabs.List), "list");
const TabsTrigger = withContext(styled(ArkTabs.Trigger), "trigger");

const Root = Tabs;
const Content = TabsContent;
const Indicator = TabsIndicator;
const List = TabsList;
const Trigger = TabsTrigger;

export {
Content,
Indicator,
List,
Root,
Tabs,
TabsContent,
TabsIndicator,
TabsList,
TabsTrigger,
Trigger,
};
261 changes: 261 additions & 0 deletions web/src/theme/components/Tabs/tabs.recipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
import { tabsAnatomy } from "@ark-ui/react";
import { defineSlotRecipe } from "@pandacss/dev";

export const tabs = defineSlotRecipe({
className: "tabs",
slots: tabsAnatomy.keys(),
base: {
root: {
display: "flex",
width: "full",
_horizontal: {
flexDirection: "column",
},
_vertical: {
flexDirection: "row",
},
},
list: {
display: "flex",
flexShrink: "0",
_horizontal: {
flexDirection: "row",
},
_vertical: {
flexDirection: "column",
},
overflow: "auto",
position: "relative",
scrollbarWidth: "none",
"&::-webkit-scrollbar": {
display: "none",
},
},
trigger: {
alignItems: "center",
color: "fg.muted",
cursor: "pointer",
display: "inline-flex",
flexShrink: "0",
fontWeight: "semibold",
gap: "2",
justifyContent: "center",
transitionDuration: "normal",
transitionProperty: "color, background, border-color",
transitionTimingFunction: "default",
whiteSpace: "nowrap",
_disabled: {
color: "fg.disabled",
cursor: "not-allowed",
_hover: {
color: "fg.disabled",
},
},
_hover: {
color: "fg.muted",
},
_selected: {
color: "fg.default",
_hover: {
color: "fg.default",
},
},
_vertical: {
justifyContent: "start",
},
},
},
defaultVariants: {
size: "md",
},
variants: {
variant: {
line: {
list: {
_horizontal: {
boxShadow: "0 -1px 0 0 inset var(--colors-border-default)",
gap: "4",
},
_vertical: {
boxShadow: "1px 0 0 0 inset var(--colors-border-default)",
gap: "1",
},
},
indicator: {
background: "colorPalette.default",
_horizontal: {
height: "2px",
bottom: "0",
},
_vertical: {
width: "2px",
left: "0",
},
},
content: {
pt: "4",
},
trigger: {
_horizontal: {
pb: "2.5",
},
},
},
outline: {
list: {
_horizontal: {
mb: "-1px",
},
_vertical: {
mr: "-1px",
},
},
trigger: {
borderColor: "transparent",
borderWidth: "1px",
_horizontal: {
borderTopRadius: "l2",
},
_vertical: {
borderTopLeftRadius: "l2",
borderBottomLeftRadius: "l2",
},
_selected: {
background: "bg.default",
borderColor: "accent.500",
_horizontal: {
borderBottomColor: "transparent",
},
_vertical: {
borderRightColor: "transparent",
},
},
},
content: {
borderWidth: "1px",
borderColor: "accent.500",
background: "bg.default",
width: "full",
},
},
},
size: {
sm: {
trigger: {
"& svg": {
width: "4",
height: "4",
},
},
},
md: {
trigger: {
"& svg": {
width: "5",
height: "5",
},
},
},
lg: {
trigger: {
"& svg": {
width: "5",
height: "5",
},
},
},
},
},
compoundVariants: [
{
size: "sm",
variant: "outline",
css: {
trigger: {
h: "9",
minW: "9",
textStyle: "sm",
px: "3.5",
},
content: {
p: "3.5",
},
},
},
{
size: "md",
variant: "outline",
css: {
trigger: {
h: "10",
minW: "10",
textStyle: "sm",
px: "4",
},
content: {
p: "4",
},
},
},
{
size: "lg",
variant: "outline",
css: {
trigger: {
h: "11",
minW: "11",
textStyle: "md",
px: "4.5",
},
content: {
p: "4.5",
},
},
},
{
size: "sm",
variant: "line",
css: {
trigger: {
fontSize: "sm",
h: "9",
minW: "9",
px: "2.5",
},
content: {
pt: "3",
},
},
},
{
size: "md",
variant: "line",
css: {
trigger: {
fontSize: "md",
h: "10",
minW: "10",
px: "3",
},
content: {
pt: "4",
},
},
},
{
size: "lg",
variant: "line",
css: {
trigger: {
px: "3.5",
h: "11",
minW: "11",
fontSize: "md",
},
content: {
pt: "5",
},
},
},
],
});
3 changes: 2 additions & 1 deletion web/styled-system/recipes/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export * from './link';
export * from './menu';
export * from './checkbox';
export * from './skeleton';
export * from './select';
export * from './select';
export * from './tabs';
Loading

2 comments on commit 112cd68

@vercel
Copy link

@vercel vercel bot commented on 112cd68 Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 112cd68 Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.