Skip to content

Commit

Permalink
Adding Menu bar (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhuignoto authored Mar 6, 2022
1 parent a5f89fe commit b425a4f
Show file tree
Hide file tree
Showing 26 changed files with 1,184 additions and 534 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,36 @@
"@typescript-eslint/parser": "^5.13.0",
"autoprefixer": "^10.4.2",
"cssnano": "^5.1.0",
"esbuild": "^0.14.23",
"esbuild": "^0.14.25",
"eslint": "^8.10.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.0.0",
"eslint-plugin-react": "^7.29.2",
"eslint-plugin-react": "^7.29.3",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-typescript-sort-keys": "^2.1.0",
"husky": "^7.0.4",
"lint-staged": "^12.3.4",
"lint-staged": "^12.3.5",
"postcss": "^8.4.7",
"postcss-bem-linter": "^3.3.0",
"postcss-preset-env": "^7.4.1",
"postcss-preset-env": "^7.4.2",
"postcss-scss": "^4.0.3",
"prettier": "^2.5.1",
"pretty-quick": "^3.1.3",
"react": "^18.0.0-rc.0",
"react-dom": "^18.0.0-rc.0",
"sass": "^1.49.9",
"snyk": "^1.860.0",
"snyk": "^1.863.0",
"stylelint": "14.5.3",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-sass-guidelines": "^9.0.1",
"stylelint-order": "^5.0.0",
"stylelint-scss": "^4.1.0",
"ts-toolbelt": "^9.6.0",
"turbo": "^1.1.4",
"turbo": "^1.1.5",
"typescript": "^4.6.2"
},
"scripts": {
Expand Down
61 changes: 61 additions & 0 deletions packages/documentation/components/menu-bar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react';
import DemoPageRenderer from '../../common/demo-page-renderer';
import Widgets from './widgets';

function menu() {
return (
<DemoPageRenderer
tabTitles={['Examples', 'Properties', 'Stackblitz']}
stackBlitzCodes={['react-ts-gxoodzp']}
title="Menu Bar"
description={`A menu bar is a graphical control element which contains drop-down menus.
The menu bar's purpose is to supply a common housing for window- or
application-specific menus which provide access to such functions as opening files, interacting with an application, or displaying help documentation or manuals`}
sourceId="menu/menu.tsx"
editId="menu"
callbacks={[
{
default: '',
description: 'Callback function for when a menu item is selected',
name: 'onSelect',
optional: 'Yes',
type: 'function',
},
]}
properties={[
{
default: 'false',
description:
'Set to true to render the menu bar in a right-to-left direction',
name: 'RTL',
optional: 'Yes',
type: 'boolean',
},
{
description:
'Set to true to disable the unique id generation for menu items',
name: 'noUniqueId',
optional: 'Yes',
type: 'boolean',
},
{
default: '[]',
description: 'The menu items to render',
name: 'items',
optional: 'No',
type: 'Array<MenuItem>',
},
{
default: 'True',
description: 'Set to true to make the menu bar focusable',
name: 'focusable',
optional: 'Yes',
type: 'boolean',
},
]}
demoWidget={<Widgets />}
></DemoPageRenderer>
);
}

export default menu;
103 changes: 103 additions & 0 deletions packages/documentation/components/menu-bar/widgets.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { faHackerNews } from '@fortawesome/free-brands-svg-icons';
import { faFile, faSearch, faWrench } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React from 'react';
import { BlockQuote, MenuBar, Section } from '../../../lib/components';
import { DemoWidget } from '../../common/demo-widget';

const icons = [
<FontAwesomeIcon icon={faFile} key="1" />,
<FontAwesomeIcon icon={faSearch} key="2" />,
<FontAwesomeIcon icon={faWrench} key="3" />,
<FontAwesomeIcon icon={faHackerNews} key="9" />,
];

const items = [
{
items: [
{
name: 'Open',
},
{
name: 'Save As',
},
{
name: 'Save',
},
{
name: 'Close',
},
],
name: 'File',
},
{
items: [
{
name: 'Cut',
},
{
name: 'Copy',
},
{
name: 'Paste',
},
{
name: 'Select All',
},
],
name: 'Edit',
},
{
items: [
{
name: 'About',
},
{
name: 'Version',
},
],
name: 'Help',
},
];

function Widgets() {
return (
<div className="rc-demo-widgets">
<Section title="Default Render" size="md">
<DemoWidget width={400} style={{ marginLeft: '2rem' }}>
<MenuBar items={items} />
</DemoWidget>
</Section>
<Section title="RTL" size="md">
<BlockQuote>
Use the <code>RTL</code> prop for right to left alignment
</BlockQuote>
<DemoWidget width={400} style={{ marginLeft: '2rem' }}>
<MenuBar items={items} RTL />
</DemoWidget>
</Section>
<Section title="Icons" size="md">
<BlockQuote>
The <code>icons</code> prop can be used to add a custom icon for each
top level menu bar item
</BlockQuote>
<DemoWidget width={400} style={{ marginLeft: '2rem' }}>
<MenuBar items={items} icons={icons} />
</DemoWidget>
</Section>
<Section title="Custom Sizes" size="md">
<BlockQuote>
With the <code>size</code> prop customize the size of the menu bar.
</BlockQuote>
<DemoWidget width={400} style={{ marginLeft: '2rem' }}>
<MenuBar items={items} size="md" />
</DemoWidget>
<DemoWidget width={400} style={{ marginLeft: '2rem' }}>
<MenuBar items={items} size="lg" />
</DemoWidget>
</Section>
</div>
);
}

export default Widgets;
10 changes: 10 additions & 0 deletions packages/documentation/components/menu-button/widgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ function widgets() {
/>
</DemoWidget>
</Section>
<Section title="Custom sizes" size="md">
<DemoWidget>
<MenuButton
size="md"
items={['save', 'save as new', 'discard']}
width={150}
RTL
/>
</DemoWidget>
</Section>
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/documentation/home/sidebar-home-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default [
{ name: 'Drawer' },
{ name: 'Tooltip' },
{ name: 'Menu' },
{ name: 'Menu Bar' },
],
title: 'Overlay',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/documentation/home/sidebar-home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const SideBar: FunctionComponent<{
onSelect: (group: SidebarGroupModel, item: SidebarItemModel) => void;
theme: Theme;
}> = React.memo(
({ theme, onSelect }) => {
({ onSelect }) => {
return (
<div style={{ height: '100vh', width: '100%' }}>
<Sidebar
Expand All @@ -39,7 +39,6 @@ const SideBar: FunctionComponent<{
sectionsCollapsible={false}
groups={data}
focusable={false}
backGroundColor={theme.darkMode ? '#000' : '#fff'}
icons={[
<FontAwesomeIcon size="2x" icon={faRocket} key="home" />,
<FontAwesomeIcon size="2x" icon={faBorderAll} key="layout" />,
Expand Down
6 changes: 3 additions & 3 deletions packages/documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@
"@vitejs/plugin-react-refresh": "^1.3.6",
"autoprefixer": "^10.4.2",
"cssnano": "^5.1.0",
"esbuild": "^0.14.23",
"esbuild": "^0.14.25",
"postcss": "^8.4.7",
"postcss-bem-linter": "^3.3.0",
"postcss-prefixer": "^2.1.3",
"postcss-preset-env": "^7.4.1",
"postcss-preset-env": "^7.4.2",
"prettier": "^2.5.1",
"react-element-to-jsx-string": "^14.3.4",
"react-responsive": "^9.0.0-beta.6",
Expand All @@ -72,7 +72,7 @@
"recoil": "^0.6.1",
"rimraf": "^3.0.2",
"sass": "^1.49.9",
"snyk": "^1.860.0",
"snyk": "^1.863.0",
"stylelint": "14.5.3",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-sass-guidelines": "^9.0.1",
Expand Down
5 changes: 5 additions & 0 deletions packages/documentation/route-configs/route-configs-2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ export const routes = [
key: 'form-field',
path: '/form-field',
},
{
component: lazy(() => import('../components/menu-bar')),
key: 'menu-bar',
path: '/menu-bar',
},
];

export { routes as routes2 };
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ exports[`Accordion > should render snapshot 1`] = `
class="_accordion_nzff8_1 _no-border_nzff8_1"
>
<div
aria-controls="accordion-body-8PNI-82IEKg_0XO5rzwfz"
aria-controls="accordion-body-8kblQgE_4OTrCvy7VHf1Z"
aria-expanded="false"
class="_header_pm41k_1 undefined"
id="accordion-_FWS9JW7C3L_SLks9uxxF"
id="accordion-V0nzJ4Iv0fI8SDHPm52a4"
role="button"
style="outline: none; position: relative;"
tabindex="0"
Expand Down Expand Up @@ -39,9 +39,9 @@ exports[`Accordion > should render snapshot 1`] = `
/>
</div>
<div
aria-labelledby="accordion-_FWS9JW7C3L_SLks9uxxF"
aria-labelledby="accordion-V0nzJ4Iv0fI8SDHPm52a4"
class="_body_nzff8_29 _animate_nzff8_34 _close_nzff8_41"
id="accordion-body-8PNI-82IEKg_0XO5rzwfz"
id="accordion-body-8kblQgE_4OTrCvy7VHf1Z"
style="--title-color: #000; --transition: cubic-bezier(0.19, 1, 0.22, 1); --max-height: 0px;"
>
<p>
Expand Down
1 change: 1 addition & 0 deletions packages/lib/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export { Input } from './input/input';
export { Kbd } from './kbd/kbd';
export { Link } from './link/link';
export { List } from './list/list';
export { MenuBar } from './menu-bar/menu-bar';
export { Menu } from './menu/menu';
export { Notification } from './notification/notification';
export { PageHeader } from './page-header/page-header';
Expand Down
Loading

1 comment on commit b425a4f

@vercel
Copy link

@vercel vercel bot commented on b425a4f Mar 6, 2022

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.