Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(platform): Add SVGs to projectTabs #673

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions apps/platform/src/components/shared/navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useEffect, useState } from 'react'
import { usePathname } from 'next/navigation'
import Link from 'next/link'
import { DropdownSVG } from '@public/svg/shared'
import { SecretSVG, VariableSVG, EnvironmentSVG } from '@public/svg/dashboard'
import type { User } from '@keyshade/schema'
import SearchModel from './searchModel'
import {
Expand Down Expand Up @@ -53,8 +54,29 @@ function Navbar(): React.JSX.Element {

const pathname = usePathname()

const settingsTabs = ['Workspace', 'Profile', 'Billing']
const projectTabs = ['Secret', 'Variable', 'Environment']
const settingsTabs = [
{ id: 'workspace', label: 'Workspace' },
{ id: 'profile', label: 'Profile' },
{ id: 'billing', label: 'Billing' }
]

const projectTabs = [
{
id: 'secret',
label: 'Secret',
icon: <SecretSVG />
},
{
id: 'variable',
label: 'Variable',
icon: <VariableSVG />
},
{
id: 'environment',
label: 'Environment',
icon: <EnvironmentSVG />
}
]

useEffect(() => {
const down = (e: KeyboardEvent): void => {
Expand Down
27 changes: 19 additions & 8 deletions apps/platform/src/components/ui/line-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ interface TabProps {
// setSelected: React.Dispatch<React.SetStateAction<string>>
searchParams: ReadonlyURLSearchParams
customID: string
icon?: React.ReactNode
}

function Tab({
text,
selected,
// setSelected,
searchParams,
customID
customID,
icon
}: TabProps): React.JSX.Element {
const router = useRouter()
const pathname = usePathname()
Expand Down Expand Up @@ -46,27 +48,35 @@ function Tab({
}}
type="button"
>
<span className="relative z-10">{text}</span>
<span className="relative z-10 flex items-center gap-2">
{icon && <span className={'h-4 w-4'}>{icon}</span>}
{text}
</span>
{selected ? (
<motion.div
className="absolute left-0 top-0 flex size-full items-end justify-center"
layoutId={`${customID}linetab`}
transition={{ type: 'spring', duration: 0.4, bounce: 0, delay: 0.1 }}
>
<span className="z-0 h-[3px] w-[60%] rounded-t-full bg-white" />
<span className="z-0 h-[3px] w-full rounded-t-full bg-white" />
</motion.div>
) : null}
</button>
)
}

interface TabConfig {
id: string
label: string
icon?: React.ReactNode
}

interface LineTabsProps {
customID: string
tabs: string[]
tabs: TabConfig[]
}

function LineTab({ customID, tabs }: LineTabsProps): React.JSX.Element {
// const [selected, setSelected] = useState(tabs[0])
const searchParams = useSearchParams()
const search = searchParams.get('tab')

Expand All @@ -77,10 +87,11 @@ function LineTab({ customID, tabs }: LineTabsProps): React.JSX.Element {
{tabs.map((tab) => (
<Tab
customID={customID}
key={tab}
icon={tab.icon}
key={tab.id}
searchParams={searchParams}
selected={search?.toLocaleLowerCase() === tab.toLocaleLowerCase()}
text={tab}
selected={search?.toLocaleLowerCase() === tab.id.toLocaleLowerCase()}
text={tab.label}
/>
))}
</div>
Expand Down
Loading