Skip to content

Instantly share code, notes, and snippets.

View ryanjyost's full-sized avatar

Ryan Yost ryanjyost

View GitHub Profile
@ryanjyost
ryanjyost / Content.js
Last active March 27, 2019 02:14
last bit
//... same above
const contentStyle = {
paddingTop: styles.showSidebar ? 20 : styles.topBarHeight + 20,
paddingRight: 20,
paddingBottom: styles.showSidebar ? 20 : styles.footerMenuHeight + 20,
paddingLeft: styles.showSidebar ? styles.sidebarWidth + 20 : 20
};
//... same below
@ryanjyost
ryanjyost / App.js
Last active May 8, 2019 12:41
Final
import React, { Component } from "react";
import TopBar from "./components/TopBar";
import FooterMenu from "./components/FooterMenu";
import Content from "./components/Content";
import Sidebar from "./components/Sidebar";
class App extends Component {
constructor(props) {
super(props);
this.state = {
import React from "react";
const Sidebar = ({ menuItems, styles }) => {
const sidebarStyle = {
height: "100vh",
width: styles.sidebarWidth,
position: "fixed",
backgroundColor: "#333",
paddingTop: 40
};
@ryanjyost
ryanjyost / FooterMenu.js
Last active March 26, 2019 03:33
Show text in menu items if the screen is big enough.
//...same above...
{menuItems.map((item, i) => {
return (
<div
key={i}
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
@ryanjyost
ryanjyost / App.js
Last active March 26, 2019 03:29
Showing footer menu item text based on screensize
//...rest of App.js above....
render() {
const { windowWidth } = this.state;
const styles = {
white: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
black: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`,
topBarHeight: 40,
footerMenuHeight: 50,
@ryanjyost
ryanjyost / App.js
Last active March 26, 2019 03:23
Tracking the window size
//...no change to imports
class App extends Component {
constructor(props) {
super(props);
this.state = {
windowWidth: 0,
windowHeight: 0
};
this.updateDimensions = this.updateDimensions.bind(this);
import React from "react";
const Content = ({ styles }) => {
const dummyPost = {
title: `Here's a blog post title`,
summary:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
};
const posts = Array(20).fill(dummyPost);
import React from "react";
const FooterMenu = ({ menuItems, styles }) => {
return (
<div
style={{
display: "flex",
alignItems: "stretch",
width: "100%",
height: styles.footerMenuHeight,
import React from "react";
const TopBar = ({ styles }) => {
const topBarStyle = {
position: "fixed",
top: 0,
display: "flex",
justifyContent: "space-between",
alignItems: "center",
width: "100%",
@ryanjyost
ryanjyost / App.js
Last active May 8, 2019 12:40
App.js #1 in React Responsive Tutorial
import React, { Component } from "react";
import TopBar from "./components/TopBar";
import FooterMenu from "./components/FooterMenu";
import Content from "./components/Content";
class App extends Component {
constructor(props) {
super(props);
this.state = {};
}