Skip to content

Commit

Permalink
feat: add tabscard
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecadavid committed Sep 30, 2024
1 parent ecec579 commit 5b62c97
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
14 changes: 14 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 16 additions & 5 deletions packages/ui-kit/src/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@ import React from 'react'
import { Tabs as TabsBase } from '@radix-ui/themes'
import { Card as CardBase } from '../Card'
import '@radix-ui/themes/styles.css'
import './styles.css'
import { TabsCSS } from './TabsCSS'

type TabsBase = typeof TabsBase

interface Tabs extends Omit<TabsBase, 'List'> {
interface Tabs extends Omit<TabsBase, 'List' | 'Root'> {
Root: typeof Root
Card: typeof Card
List: typeof List
}

const List = ({ children, ...props }: React.ComponentProps<typeof TabsBase.List>) => (
<TabsBase.List {...props}>{children}</TabsBase.List>
)
const Root = ({ children, ...props }: React.ComponentProps<typeof TabsBase.Root>) => {
return (
<>
<TabsBase.Root {...props}>{children}</TabsBase.Root>
<TabsCSS />
</>
)
}

const List = ({ children, ...props }: React.ComponentProps<typeof TabsBase.List>) => {
return <TabsBase.List {...props}>{children}</TabsBase.List>
}

const Card = ({ children, ...props }: React.ComponentProps<typeof TabsBase.Trigger>) => (
<TabsBase.Trigger {...props}>
Expand All @@ -25,6 +35,7 @@ const Card = ({ children, ...props }: React.ComponentProps<typeof TabsBase.Trigg

const Tabs: Tabs = {
...TabsBase,
Root,
Card,
List
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
.rt-BaseTabList:has(.propel-Card) {
'use client'

import React, { useEffect } from 'react'
import styleInject from 'style-inject'

export const TabsCSS = () => {
useEffect(() => {
if (typeof window !== 'undefined') {
styleInject(`.rt-BaseTabList:has(.propel-Card) {
all: unset;
width: 100%;
}
Expand All @@ -17,4 +25,10 @@
.rt-BaseTabList:has(.propel-Card) .rt-TabsTrigger > .rt-TabsTriggerInnerHidden {
display: none;
}
`)
}
}, [])

return <></>
}
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5703,6 +5703,7 @@ __metadata:
"@types/ora": ^3.2.0
"@types/react": latest
"@types/react-dom": latest
"@types/style-inject": ^0.3.5
"@types/testing-library__jest-dom": ^5.14.7
axios: ^1.6.2
chart.js: ^4.1.2
Expand Down Expand Up @@ -10288,6 +10289,13 @@ __metadata:
languageName: node
linkType: hard

"@types/style-inject@npm:^0.3.5":
version: 0.3.5
resolution: "@types/style-inject@npm:0.3.5::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2F%40types%2Fstyle-inject%2F-%2Fstyle-inject-0.3.5.tgz"
checksum: 615b3e58f8f91a53b4fcf7fab813f72c00181b205b8ac048e259010b5f55e70a41755b9491e0d0971fddea6bd7bef3aba0f16e9d1dfceb454d247a0555345cab
languageName: node
linkType: hard

"@types/testing-library__jest-dom@npm:^5.14.7, @types/testing-library__jest-dom@npm:^5.9.1":
version: 5.14.9
resolution: "@types/testing-library__jest-dom@npm:5.14.9::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2F%40types%2Ftesting-library__jest-dom%2F-%2Ftesting-library__jest-dom-5.14.9.tgz"
Expand Down

0 comments on commit 5b62c97

Please sign in to comment.