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

feat: Add SidebarItem, sideBarGroup and sideBar components #6065

Merged
merged 27 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c00e184
feat: Add SidebarItem, sideBarGroup and sideBar components
Oct 29, 2023
3f6ceb7
feat: Add styling to sideBarGroup
Oct 29, 2023
f5a5706
Update components/Common/Sidebar/index.tsx
manikantamavireddy Oct 30, 2023
26afc9d
Update types/sidebar.ts
manikantamavireddy Oct 30, 2023
19f72c3
Update components/Common/Sidebar/index.tsx
manikantamavireddy Oct 30, 2023
d0aa4e6
Update components/Common/Sidebar/index.tsx
manikantamavireddy Oct 30, 2023
c08e601
Update components/Common/SidebarItem/index.module.css
manikantamavireddy Oct 30, 2023
ba1c55e
Update components/Common/SidebarItem/index.tsx
manikantamavireddy Oct 30, 2023
933b474
feat: refactored component structure for sidebar
Oct 30, 2023
748117c
Merge remote-tracking branch 'upstream/main' into sidebar-component-f…
Oct 31, 2023
3e1a711
removed console log
Oct 31, 2023
aed8917
Update components/Common/Sidebar/SidebarGroup/index.module.css
manikantamavireddy Nov 2, 2023
f1cc918
Update components/Common/Sidebar/SidebarGroup/index.module.css
manikantamavireddy Nov 2, 2023
836a83f
Update components/Common/Sidebar/SidebarGroup/index.module.css
manikantamavireddy Nov 2, 2023
87095b1
Update components/Common/Sidebar/SidebarGroup/index.tsx
manikantamavireddy Nov 2, 2023
a0b867d
Update components/Common/Sidebar/SidebarGroup/index.tsx
manikantamavireddy Nov 2, 2023
e65e6c0
Merge remote-tracking branch 'upstream/main' into sidebar-component-f…
Nov 2, 2023
12e4183
removed unused import
Nov 2, 2023
37941ae
feat:refactored sidebar component removed internal state
Nov 2, 2023
49a033d
updated styling to match ui with figma design
Nov 3, 2023
85c534c
updated styling
Nov 4, 2023
48aa032
minor code refactoring and updated storybook to make it look like rea…
Nov 9, 2023
173d113
Merge remote-tracking branch 'upstream/main' into sidebar-component-f…
Nov 9, 2023
c7885d2
fixed lint issues
Nov 13, 2023
0997d2e
Merge remote-tracking branch 'upstream/main' into sidebar-component-f…
Nov 13, 2023
10db9d9
updated imports
Nov 13, 2023
73f675c
chore: address review feedback, align with figma
bmuenzenmeyer Nov 15, 2023
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
23 changes: 23 additions & 0 deletions components/Common/Sidebar/SidebarGroup/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.group {
@apply flex
w-full
flex-col
gap-2;
}

.groupName {
@apply px-2
text-xs
font-semibold
text-neutral-800
dark:text-neutral-200;
}

.itemList {
@apply m-0
flex
flex-col
items-start
gap-0.5
p-0;
}
35 changes: 35 additions & 0 deletions components/Common/Sidebar/SidebarGroup/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { ComponentProps, FC } from 'react';

import SidebarItem from '@/components/Common/Sidebar/SidebarItem';

import styles from './index.module.css';

type SidebarGroupProps = {
groupName: string;
items: ComponentProps<typeof SidebarItem>[];
activeItem?: ComponentProps<typeof SidebarItem>;
};

const SidebarGroup: FC<SidebarGroupProps> = ({
groupName,
items,
activeItem,
}) => (
<section className={styles.group}>
<label className={styles.groupName}>{groupName}</label>
<ul className={styles.itemList}>
{items.map(({ title, url }) => (
<SidebarItem
key={title}
title={title}
url={url}
isActive={
activeItem?.title === title && activeItem.url === activeItem.url
}
/>
))}
</ul>
</section>
);

export default SidebarGroup;
25 changes: 25 additions & 0 deletions components/Common/Sidebar/SidebarItem/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.sideBarItem {
@apply flex
w-full
list-none;

a {
@apply w-full
p-2
text-sm
font-regular
text-neutral-800
dark:text-neutral-200;
bmuenzenmeyer marked this conversation as resolved.
Show resolved Hide resolved
}
}

.active {
@apply rounded
bg-green-600;

a,
a:hover {
@apply text-white
dark:text-white;
bmuenzenmeyer marked this conversation as resolved.
Show resolved Hide resolved
}
}
28 changes: 28 additions & 0 deletions components/Common/Sidebar/SidebarItem/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import classNames from 'classnames';
import type { FC } from 'react';

import Link from '@/components/Link';

import styles from './index.module.css';

type SidebarItemProps = {
title: string;
url: string;
isActive?: boolean;
};

const SidebarItem: FC<SidebarItemProps> = ({
url,
title,
isActive = false,
}) => (
<li
className={classNames(styles.sideBarItem, {
[styles.active]: isActive,
})}
>
<Link href={url}>{title}</Link>
</li>
);

export default SidebarItem;
15 changes: 15 additions & 0 deletions components/Common/Sidebar/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.sideBar {
@apply flex
flex-col
items-start
gap-8
overflow-auto
border-r
border-r-neutral-200
bg-white
px-4
py-6
dark:border-r-neutral-900
dark:bg-neutral-950
md:max-w-xs;
}
160 changes: 160 additions & 0 deletions components/Common/Sidebar/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import type { Meta as MetaObj, StoryObj } from '@storybook/react';

import Sidebar from '@/components/Common/Sidebar';

type Story = StoryObj<typeof Sidebar>;
type Meta = MetaObj<typeof Sidebar>;

export const Default: Story = {
args: {
groups: [
{
groupName: 'About Node.js',
items: [
{
url: '/item1',
title: 'About Node.js',
},
{
url: '/item2',
title: 'Project Governance',
},
{
url: '/item3',
title: 'Releases',
},
{
url: '/item4',
title: 'Branding',
},
{
url: '/item5',
title: 'Privacy Policy',
},
{
url: '/item6',
title: 'Security Reporting',
},
],
},
{
groupName: 'Get Involved',
items: [
{
url: '/item7',
title: 'Get Involved',
},
{
url: '/item8',
title: 'Collab Summit',
},
{
url: '/item9',
title: 'Contribute',
},
{
url: '/item10',
title: 'Code of Conduct',
},
],
},
{
groupName: 'Download',
items: [
{
url: '/item11',
title: 'Download',
},
{
url: '/item12',
title: 'Package Manager',
},
{
url: '/item13',
title: 'Previous Releases',
},
],
},
],
},
};

export const ActiveItem: Story = {
args: {
groups: [
{
groupName: 'About Node.js',
items: [
{
url: '/item1',
title: 'About Node.js',
},
{
url: '/item2',
title: 'Project Governance',
},
{
url: '/item3',
title: 'Releases',
},
{
url: '/item4',
title: 'Branding',
},
{
url: '/item5',
title: 'Privacy Policy',
},
{
url: '/item6',
title: 'Security Reporting',
},
],
},
{
groupName: 'Get Involved',
items: [
{
url: '/item7',
title: 'Get Involved',
},
{
url: '/item8',
title: 'Collab Summit',
},
{
url: '/item9',
title: 'Contribute',
},
{
url: '/item10',
title: 'Code of Conduct',
},
],
},
{
groupName: 'Download',
items: [
{
url: '/item11',
title: 'Download',
},
{
url: '/item12',
title: 'Package Manager',
},
{
url: '/item13',
title: 'Previous Releases',
},
],
},
],
activeItem: {
url: '/item1',
title: 'About Node.js',
},
},
canerakdas marked this conversation as resolved.
Show resolved Hide resolved
};

export default { component: Sidebar } as Meta;
26 changes: 26 additions & 0 deletions components/Common/Sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { ComponentProps, FC } from 'react';

import SidebarGroup from '@/components/Common/Sidebar/SidebarGroup';
import type SidebarItem from '@/components/Common/Sidebar/SidebarItem';

import styles from './index.module.css';

type SidebarProps = {
groups: ComponentProps<typeof SidebarGroup>[];
activeItem?: ComponentProps<typeof SidebarItem>;
};

const SideBar: FC<SidebarProps> = ({ groups, activeItem }) => (
<aside className={styles.sideBar}>
{groups.map(({ groupName, items }) => (
<SidebarGroup
key={groupName}
groupName={groupName}
items={items}
activeItem={activeItem}
/>
))}
</aside>
);

export default SideBar;
Loading