Skip to content

React Menu Bar Sample #1

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

Merged
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
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# getting-started-with-the-react-menu-bar-component
# Getting Started with the React Menu Bar Component

A quick-start project that helps you create and configure the Syncfusion React Menu Bar component. This project also contains codes to configure a few of the control’s basic features like data binding, adding icons, multilevel nesting, and changing its orientation.

Refer to the following documentation for the Syncfusion React Menu Bar:
https://ej2.syncfusion.com/react/documentation/menu/getting-started/

Check out this online example of the Syncfusion React Menu Bar:
https://ej2.syncfusion.com/react/demos/#/bootstrap5/menu/default

## Project prerequisites

Make sure that you have the latest versions of NodeJS and Visual Studio Code in your machine before starting to work on this project.

### How to run this application?

To run this application, you need to clone the `getting-started-with-the-react-menu-bar-component` repository and then open it in Visual Studio Code. Now, simply install all the necessary react packages into your current project using the `npm install` command and run your project using the `npm start` command.
44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "myreactapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"@syncfusion/ej2-react-navigations": "^20.2.43",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.11.47",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"typescript": "^4.7.4",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
27 changes: 27 additions & 0 deletions src/App.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
208 changes: 208 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
import React from 'react';
import { MenuComponent, MenuItemModel } from '@syncfusion/ej2-react-navigations';
import './App.css';

function App() {
//Hierarchical Data
const menuItems: MenuItemModel[] = [
{
text: "File",
iconCss: "em-icons e-file",
items: [
{text: "Open"},
{ text: 'Save' },
{ separator: true },
{ text: 'Exit' }
]
},
{
text: 'Edit',
items: [
{ text: 'Cut' },
{ text: 'Copy' },
{ text: 'Paste' }
]
},
{
text: 'View',
items: [
{
text: 'Toolbars',
items: [
{ text: 'Menu Bar' },
{ text: 'Bookmarks Toolbar' },
{ text: 'Customize' },
]
},
{
text: 'Zoom',
items: [
{ text: 'Zoom In' },
{ text: 'Zoom Out' },
{ text: 'Reset' },
]
},
{ text: 'Full Screen' }
]
},
{
text: 'Tools',
items: [
{ text: 'Spelling & Grammar' },
{ text: 'Customize' },
{ text: 'Options' }
]
},
{
text: 'Help'
}
]

//Complex Data
const complexData: object[] = [
{
continent: "Asia",
countries: [
{
country: "India",
languages: [
{language: "English"},
{language: "Tamil"},
{language: "Hindi"}
]
},
{
country: 'China',
languages: [
{ language: 'Chinese' },
{ language: 'Cantonese' }
]
},
{
country: 'Japan',
languages: [
{ language: 'Japanese' }
]
},
]
},
{
continent: 'Africa',
countries: [
{
country: 'Nigeria',
languages: [
{ language: 'English' },
{ language: 'Hausa' }
]
},
{
country: 'Egypt',
languages: [
{ language: 'Arabic' }
]
},
{
country: 'South Africa',
languages: [
{ language: 'Tswana' },
{ language: 'Swati' }
]
}
]
},
{
continent: 'North America',
countries: [
{
country: 'Canada',
languages: [
{ language: 'French' }
]
},
{
country: 'Mexico',
languages: [
{ language: 'Spanish' }
]
},
{
country: 'USA',
languages: [
{ language: 'English' }
]
}
]
},
{
continent: 'South America',
countries: [
{
country: 'Brazil',
languages: [
{ language: 'Portuguese' }
]
},
{
country: 'Colombia',
languages: [
{ language: 'Spanish' }
]
},
{
country: 'Argentina',
languages: [
{ language: 'Spanish' }
]
}
]
},
{
continent: 'Oceania',
countries: [
{
country: 'Australia'
},
{
country: 'New Zealand'
},
{
country: 'Samoa'
},
]
}
]

//Self referential data
const selfData: object[] = [
{id:"parent1", text: "Events"},
{ id: 'parent2', text: 'Movies' },
{ id: 'parent3', text: 'Directory' },
{ id: 'parent4', pId: null, text: 'Queries' },
{ id: 'parent5', pId: null, text: 'Services' },
{ id: 'parent6', pId: 'parent1', text: 'Conferences' },
{ id: 'parent7', pId: 'parent1', text: 'Music' },
{ id: 'parent8', pId: 'parent1', text: 'Workshops' },
{ id: 'parent9', pId: 'parent2', text: 'Now Showing' },
{ id: 'parent10', pId: 'parent2', text: 'Coming Soon' },
{ id: 'parent10', pId: 'parent3', text: 'Media Gallery' },
{ id: 'parent11', pId: 'parent3', text: 'Newsletters' },
{ id: 'parent12', pId: 'parent4', text: 'Our Policy' },
{ id: 'parent13', pId: 'parent4', text: 'Site Map' },
{ id: 'parent14', pId: 'parent7', text: 'Pop' },
{ id: 'parent15', pId: 'parent7', text: 'Folk' },
{ id: 'parent16', pId: 'parent7', text: 'Classical' }
]
return (
<div className="App">
<MenuComponent items={selfData} orientation="Vertical"
fields={{
itemId: "id",
parentId: "pId",
text: "text"
}}></MenuComponent>
</div>
);
}

export default App;
Loading