From 8aace7dde73f9eada60092e77441857cdcff6540 Mon Sep 17 00:00:00 2001 From: canerakdas Date: Thu, 16 Nov 2023 01:08:24 +0300 Subject: [PATCH] feat: ProgressionSidebar component (#6104) * feat: ProgressionSidebar component * fix: safari content-fit not working as expected * refactor: review updates * refactor: revert pseudo notation * refactor: pseudo class and content added * refactor: self review * refactor: review updates --- .../ProgressionSidebarGroup/index.module.css | 53 +++++++++++++ .../ProgressionSidebarGroup/index.tsx | 26 ++++++ .../ProgressionSidebarIcon/index.tsx | 16 ++++ .../ProgressionSidebarItem/index.module.css | 33 ++++++++ .../ProgressionSidebarItem/index.tsx | 27 +++++++ .../ProgressionSidebar/index.module.css | 13 +++ .../ProgressionSidebar/index.stories.tsx | 79 +++++++++++++++++++ .../Containers/ProgressionSidebar/index.tsx | 19 +++++ 8 files changed, 266 insertions(+) create mode 100644 components/Containers/ProgressionSidebar/ProgressionSidebarGroup/index.module.css create mode 100644 components/Containers/ProgressionSidebar/ProgressionSidebarGroup/index.tsx create mode 100644 components/Containers/ProgressionSidebar/ProgressionSidebarIcon/index.tsx create mode 100644 components/Containers/ProgressionSidebar/ProgressionSidebarItem/index.module.css create mode 100644 components/Containers/ProgressionSidebar/ProgressionSidebarItem/index.tsx create mode 100644 components/Containers/ProgressionSidebar/index.module.css create mode 100644 components/Containers/ProgressionSidebar/index.stories.tsx create mode 100644 components/Containers/ProgressionSidebar/index.tsx diff --git a/components/Containers/ProgressionSidebar/ProgressionSidebarGroup/index.module.css b/components/Containers/ProgressionSidebar/ProgressionSidebarGroup/index.module.css new file mode 100644 index 0000000000000..6ba28a1398b69 --- /dev/null +++ b/components/Containers/ProgressionSidebar/ProgressionSidebarGroup/index.module.css @@ -0,0 +1,53 @@ +.group { + @apply flex + flex-col + gap-4 + text-sm + font-medium + text-neutral-800 + dark:text-neutral-200; + + .items { + @apply relative + -left-1 + flex + flex-col + gap-2; + + &::after { + @apply absolute + left-[calc(0.5rem-0.5px)] + top-0 + z-10 + h-full + w-px + bg-neutral-200 + content-[''] + dark:bg-neutral-800; + } + + a { + &:first-child::before { + @apply absolute + bottom-[calc(50%+0.25rem)] + left-0 + h-20 + w-4 + bg-white + content-[''] + dark:bg-neutral-950; + } + + &:last-child::after { + @apply absolute + left-0 + top-[calc(50%+0.25rem)] + h-20 + w-4 + bg-white + content-[''] + dark:bg-neutral-950; + } + } + } +} diff --git a/components/Containers/ProgressionSidebar/ProgressionSidebarGroup/index.tsx b/components/Containers/ProgressionSidebar/ProgressionSidebarGroup/index.tsx new file mode 100644 index 0000000000000..d9214d5831906 --- /dev/null +++ b/components/Containers/ProgressionSidebar/ProgressionSidebarGroup/index.tsx @@ -0,0 +1,26 @@ +import type { ComponentProps, FC } from 'react'; + +import ProgressionSidebarItem from '@/components/Containers/ProgressionSidebar/ProgressionSidebarItem'; + +import styles from './index.module.css'; + +type ProgressionSidebarGroupProps = { + name: string; + items: ComponentProps[]; +}; + +const ProgressionSidebarGroup: FC = ({ + name, + items, +}) => ( +
+ {name} +
+ {items.map(({ url, title }) => ( + + ))} +
+
+); + +export default ProgressionSidebarGroup; diff --git a/components/Containers/ProgressionSidebar/ProgressionSidebarIcon/index.tsx b/components/Containers/ProgressionSidebar/ProgressionSidebarIcon/index.tsx new file mode 100644 index 0000000000000..4c89095de5504 --- /dev/null +++ b/components/Containers/ProgressionSidebar/ProgressionSidebarIcon/index.tsx @@ -0,0 +1,16 @@ +import type { FC, SVGAttributes } from 'react'; + +const ProgressionSidebarIcon: FC> = props => ( + + + +); + +export default ProgressionSidebarIcon; diff --git a/components/Containers/ProgressionSidebar/ProgressionSidebarItem/index.module.css b/components/Containers/ProgressionSidebar/ProgressionSidebarItem/index.module.css new file mode 100644 index 0000000000000..7658d5fc23bb2 --- /dev/null +++ b/components/Containers/ProgressionSidebar/ProgressionSidebarItem/index.module.css @@ -0,0 +1,33 @@ +a.item { + @apply relative + z-20 + flex + w-full + items-center + gap-1 + overflow-hidden + text-sm + font-regular + text-neutral-800 + hover:text-neutral-900 + dark:text-neutral-200 + dark:hover:text-white; + + svg { + @apply flex-shrink-0 + fill-neutral-200 + stroke-white + stroke-[4] + dark:fill-neutral-800 + dark:stroke-neutral-950; + } + + &.active { + @apply text-neutral-900 + dark:text-white; + + svg { + @apply fill-green-500; + } + } +} diff --git a/components/Containers/ProgressionSidebar/ProgressionSidebarItem/index.tsx b/components/Containers/ProgressionSidebar/ProgressionSidebarItem/index.tsx new file mode 100644 index 0000000000000..5af622e187f5e --- /dev/null +++ b/components/Containers/ProgressionSidebar/ProgressionSidebarItem/index.tsx @@ -0,0 +1,27 @@ +import type { FC } from 'react'; + +import ActiveLink from '@/components/Common/ActiveLink'; +import ProgressionSidebarIcon from '@/components/Containers/ProgressionSidebar/ProgressionSidebarIcon'; + +import styles from './index.module.css'; + +type ProgressionSidebarItemProps = { + url: string; + title: string; +}; + +const ProgressionSidebarItem: FC = ({ + url, + title, +}) => ( + + + {title} + +); + +export default ProgressionSidebarItem; diff --git a/components/Containers/ProgressionSidebar/index.module.css b/components/Containers/ProgressionSidebar/index.module.css new file mode 100644 index 0000000000000..01743d239c83b --- /dev/null +++ b/components/Containers/ProgressionSidebar/index.module.css @@ -0,0 +1,13 @@ +.wrapper { + @apply flex + flex-col + gap-8 + overflow-auto + border-r + border-neutral-200 + bg-white + p-6 + dark:border-neutral-900 + dark:bg-neutral-950 + md:max-w-xs; +} diff --git a/components/Containers/ProgressionSidebar/index.stories.tsx b/components/Containers/ProgressionSidebar/index.stories.tsx new file mode 100644 index 0000000000000..64464e03d5866 --- /dev/null +++ b/components/Containers/ProgressionSidebar/index.stories.tsx @@ -0,0 +1,79 @@ +import type { Meta as MetaObj, StoryObj } from '@storybook/react'; + +import ProgressionSidebar from '@/components/Containers/ProgressionSidebar'; + +type Story = StoryObj; +type Meta = MetaObj; + +export const Default: Story = { + args: { + groups: [ + { + name: 'Getting Started', + items: [ + { + title: 'Introduction to Node.js', + url: '/', + }, + { + title: 'How to install Node.js', + url: '/how-to-install-nodejs', + }, + { + title: 'How much JavaScript do you need to know to use Node.js?', + url: '/how-much-javascript-do-you-need-to-know-to-use-nodejs', + }, + { + title: 'Differences between Node.js and the Browser', + url: '/differences-between-nodejs-and-the-browser', + }, + { + title: 'The V8 JavaScript Engine', + url: '/the-v8-javascript-engine', + }, + { + title: 'An introduction to the NPM package manager', + url: '/an-introduction-to-the-npm-package-manager', + }, + ], + }, + { + name: 'Asynchronous Work', + items: [ + { + title: 'Asynchronous flow control', + url: '/asynchronous-flow-control', + }, + { + title: 'Overview of Blocking vs Non-Blocking', + url: '/overview-of-blocking-vs-non-blocking', + }, + ], + }, + { + name: 'Manipulating Files', + items: [ + { + title: 'Node.js file stats', + url: '/nodejs-file-stats', + }, + { + title: 'Node.js File Paths', + url: '/nodejs-file-paths', + }, + ], + }, + { + name: 'Single item', + items: [ + { + title: 'Item', + url: '/item', + }, + ], + }, + ], + }, +}; + +export default { component: ProgressionSidebar } as Meta; diff --git a/components/Containers/ProgressionSidebar/index.tsx b/components/Containers/ProgressionSidebar/index.tsx new file mode 100644 index 0000000000000..21e05c2b6b87f --- /dev/null +++ b/components/Containers/ProgressionSidebar/index.tsx @@ -0,0 +1,19 @@ +import type { ComponentProps, FC } from 'react'; + +import ProgressionSidebarGroup from '@/components/Containers/ProgressionSidebar/ProgressionSidebarGroup'; + +import styles from './index.module.css'; + +type ProgressionSidebarProps = { + groups: ComponentProps[]; +}; + +const ProgressionSidebar: FC = ({ groups }) => ( + +); + +export default ProgressionSidebar;