Skip to content

Commit

Permalink
feat(ui): add Menu component
Browse files Browse the repository at this point in the history
  • Loading branch information
stuf committed Oct 4, 2019
1 parent 925c00f commit 0a8e046
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/ui/Menu.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface MenuItem {
label: string;
accelerator?: any;
}

export interface Props {
items: MenuItem[];
}
34 changes: 34 additions & 0 deletions src/components/ui/Menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as React from 'karet';
import * as U from 'karet.util';
import * as T from './Menu';

import styles from './Menu.module.scss';

/**
* @param {T.Props} props
*/
function Menu({ items }) {
return (
<section className={styles.root}>
<ul className={styles.itemList}>
{U.thru(
items,
U.mapElems((it, i) => (
<li
{...{
key: `menuitem-${i}`,
className: styles.item,
}}
>
{U.view('label', it)}
</li>
)),
)}
</ul>
</section>
);
}

export default Menu;

//
19 changes: 19 additions & 0 deletions src/components/ui/Menu.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.root {
border: solid 2px #f00;
height: 100%;
}

.itemList {
margin: 0;
padding: 0;
list-style: none;
display: flex;
height: 100%;
align-items: center;
}

.item {
border: dashed 1px #f00;
margin-right: 0.5rem;
padding: 0.25rem 0.5rem;
}

0 comments on commit 0a8e046

Please sign in to comment.