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(menu): add menu-button with menu-items #124

Merged
merged 3 commits into from
Oct 7, 2019
Merged

feat(menu): add menu-button with menu-items #124

merged 3 commits into from
Oct 7, 2019

Conversation

KatvonRivia
Copy link
Member

No description provided.

@KatvonRivia KatvonRivia requested a review from pwambach October 2, 2019 14:58
Copy link
Contributor

@pwambach pwambach left a comment

Choose a reason for hiding this comment

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

Nice! Just some minor improvements...

interface MenuItems {
id: number;
name: string;
link: string | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be link?: string so that it can be a string or undefined. In this case it has to be a string or null, which should't work with {id: 3, name: 'Change language'}

import React, {FunctionComponent, useState} from 'react';
import styles from './menu.styl';

interface MenuItems {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's only one MenuItem

{id: 4, name: 'Share Content'},
{id: 5, name: 'Export Data'},
{id: 6, name: 'More Information'}
];
Copy link
Contributor

Choose a reason for hiding this comment

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

We should tell typescript which type this variable is: You can do this with as MenuItem[] before the ;


const [isOpen, setIsOpen] = useState(false);

const onButtonClickHandler = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Easier: () => setIsOpen(!isOpen)

{menuItems.map(menuItem => (
<li className={styles.menuListItem} key={menuItem.id}>
{menuItem.link ? (
<a href="{link}">{menuItem.name}</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

{link} without the double quotes

import styles from './menu.styl';

interface MenuItems {
id: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's always better to use a string for the id because it's easier to understand when you read it.

@@ -0,0 +1,27 @@
.menuContainer
position: relative
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it would be better to position the container as absolute and the children as relative? Not sure though, I have to see it in the dev tools :)

@pwambach pwambach merged commit 753e948 into develop Oct 7, 2019
@pwambach pwambach deleted the feat/menu branch October 7, 2019 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants