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(components/navigation): add Navigation #11

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ yarn-error.log*
next-env.d.ts

*storybook.log

#lock
yarn.lock
package-lock.json
5 changes: 5 additions & 0 deletions src/components/Navigation/Navigation.props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { HTMLAttributes } from 'react';

export interface Props extends HTMLAttributes<HTMLDivElement> {
activePath?: string;
}
24 changes: 24 additions & 0 deletions src/components/Navigation/Navigation.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {Meta, StoryObj} from '@storybook/react';
import {Props} from './Navigation.props';
import Navigation from './';

const actionsData = {};

const meta: Meta<Props> = {
component: Navigation,
args: {...actionsData},
};

export default meta;

type Story = StoryObj<Props>;

export const Deafult: Story = {
args: {},
};

export const SchemeSelected: Story = {
args: {
activePath: '/scheme'
},
};
54 changes: 54 additions & 0 deletions src/components/Navigation/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type {FC} from 'react';
import {Props} from './Navigation.props';
import Link from 'next/link';
import {usePathname} from 'next/navigation';

interface NavigationTab {
title: string;
path: string;
}

const navigationTabs: NavigationTab[] = [
{title: 'Схема', path: '/scheme'},
{title: 'Рассылки', path: '/posts'},
{title: 'Настройки', path: '/settings'},
];
Robocotik marked this conversation as resolved.
Show resolved Hide resolved

const getTabTileClassNames = ({isActive}: {isActive: boolean}): string => {
return `
align-baseline
py-2
font-normal
text-2xl
hover:text-white hover:underline
underline-offset-8 transition-all duration-200 decoration-2 decoration-color-white-underline
text-nowrap
${isActive ? ' underline text-white' : 'text-color-white-unselected'}
`;
};

const Navigation: FC<Props> = ({activePath, className, ...props}) => {
const activeNextPathName = usePathname();
activePath = activePath === undefined ? activeNextPathName : activePath;
return (
<div className={`${className} w-full max-w-10`} {...props}>
<ul className='flex gap-4 '>
{navigationTabs.map((item, index) => {
return (
<li key={index}>
<Link
href={item.path}
className={`${getTabTileClassNames({
isActive: item.path === activePath,
})}`}>
{item.title}{' '}
</Link>
</li>
);
})}
</ul>
</div>
);
};

export default Navigation;
64 changes: 33 additions & 31 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
import type { Config } from "tailwindcss";
import defaultTheme from 'tailwindcss/defaultTheme'
import type {Config} from 'tailwindcss';
import defaultTheme from 'tailwindcss/defaultTheme';

const config: Config = {
content: [
"./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
"./src/app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
fontFamily: {
sans: ['Roboto', ...defaultTheme.fontFamily.sans],
},
colors: {
'support-separator': '#33FFFFFF',
'support-overlay' : '#52000000',
'label-primary': '#FFFFFF',
'label-secondary': '#99FFFFFF',
'label-tertiary': '#66FFFFFF',
'label-disable': '#26FFFFFF',
'color-red': '#FF453A',
'color-green': '#32D74B',
'color-blue': '#0A84FF',
'color-grey': '#8E8E93',
'color-gray-light': '#48484A',
'color-white': '#FFFFFF',
'back-primary': '#161618',
'back-secondary': '#252528',
'back-elevated': '#3C3C3F',
}
content: [
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {
fontFamily: {
sans: ['Roboto', ...defaultTheme.fontFamily.sans],
},
colors: {
'support-separator': '#33FFFFFF',
'support-overlay': '#52000000',
'label-primary': '#FFFFFF',
'label-secondary': '#99FFFFFF',
'label-tertiary': '#66FFFFFF',
'label-disable': '#26FFFFFF',
'color-red': '#FF453A',
'color-green': '#32D74B',
'color-blue': '#0A84FF',
'color-grey': '#8E8E93',
'color-gray-light': '#48484A',
'color-white': '#FFFFFF',
'color-white-unselected': 'rgba(255, 255, 255, 0.6)',
'color-white-underline': 'rgba(255, 255, 255, 0.8)',
'back-primary': '#161618',
'back-secondary': '#252528',
'back-elevated': '#3C3C3F',
},
},
},
Robocotik marked this conversation as resolved.
Show resolved Hide resolved
},
plugins: [],
plugins: [],
};
export default config;
Loading