Skip to content

Commit

Permalink
Merge pull request #151 from Abhinavcode13/Patch-1
Browse files Browse the repository at this point in the history
Added navbar ui component
  • Loading branch information
thekavikumar committed Jun 15, 2023
2 parents b36167c + 47cf305 commit 8db8061
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Navbar/navbar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { Story, Meta } from '@storybook/react';

import Navbar, { NavbarProps } from './Navbar';

export default {
title: 'Components/Navbar',
component: Navbar,
} as Meta;

const Template: Story<NavbarProps> = (args) => <Navbar {...args} />;

export const Default = Template.bind({});
Default.args = {
title: 'My App',
isLoggedIn: false,
onLogout: () => {
// Handle logout action
console.log('Logged out');
},
};

export const LoggedIn = Template.bind({});
LoggedIn.args = {
title: 'My App',
isLoggedIn: true,
onLogout: () => {
// Handle logout action
console.log('Logged out');
},
};
28 changes: 28 additions & 0 deletions src/Navbar/navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import { AppBar, Toolbar, Typography, Button } from '@material-ui/core';

interface NavbarProps {
title: string;
isLoggedIn: boolean;
onLogout: () => void;
}

const Navbar: React.FC<NavbarProps> = ({ title, isLoggedIn, onLogout }) => {
return (
<AppBar position="static">
<Toolbar>
<Typography variant="h6">{title}</Typography>
{isLoggedIn && (
<Button color="inherit" onClick={onLogout}>
Logout
</Button>
)}
</Toolbar>
</AppBar>
);
};

export default Navbar;

/*npm install @material-ui/core @material-ui/icons
*/

1 comment on commit 8db8061

@vercel
Copy link

@vercel vercel bot commented on 8db8061 Jun 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.