Skip to content

Instantly share code, notes, and snippets.

@ryanjyost
Last active March 27, 2019 02:11
Show Gist options
  • Select an option

  • Save ryanjyost/c10cdbbe3db266f8626c0c6fc3dc8c7b to your computer and use it in GitHub Desktop.

Select an option

Save ryanjyost/c10cdbbe3db266f8626c0c6fc3dc8c7b to your computer and use it in GitHub Desktop.
import React from "react";
const Sidebar = ({ menuItems, styles }) => {
const sidebarStyle = {
height: "100vh",
width: styles.sidebarWidth,
position: "fixed",
backgroundColor: "#333",
paddingTop: 40
};
const menuItemStyle = {
display: "flex",
justifyContent: styles.sidebarCollapsed ? "center" : "flex-start",
alignItems: "center",
padding: `4px ${styles.sidebarCollapsed ? 0 : 10}px`,
color: styles.white(0.9)
};
const iconStyle = {
fontSize: 26,
marginRight: styles.sidebarCollapsed ? 0 : 10
};
const logoStyle = {
textAlign: "center",
color: styles.white(),
fontSize: 34,
marginBottom: 60,
fontWeight: "bold"
};
return (
<div style={sidebarStyle}>
<div style={logoStyle}>{styles.sidebarCollapsed ? "A" : "App"}</div>
{menuItems.map((item, i) => (
<div key={i} style={menuItemStyle}>
<span style={iconStyle}>{item.icon}</span>
{!styles.sidebarCollapsed && item.text}
</div>
))}
</div>
);
};
export default Sidebar;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment