Skip to content

Instantly share code, notes, and snippets.

View andrzejewsky's full-sized avatar

Patryk Andrzejewski andrzejewsky

  • Wrocław
View GitHub Profile
@andrzejewsky
andrzejewsky / withLoadingData.jsx
Last active January 5, 2019 16:46
Loading data
import React, { Component } from "react";
import Loading from "./../components/Loading";
import fetchData from "./../data";
/*
variables - function that returns parameters (based on the component props) for the fetchData()
*/
const withLoadingData = variables => WrappedComponent => {
class WithLoadingData extends Component {
state = {
import React from "react";
const ListContext = React.createContext();
export default ListContext;
import React, { Component } from "react";
import ListContext from "./context";
import "./List.css";
class List extends Component {
state = {
selectedItem: null
};
handleSelectItem = selectedItem => {
import React from "react";
import ListContext from "./context";
import "./Item.css";
const Item = ({ id, icon, className, info, children }) => (
<ListContext.Consumer>
{value => (
<button
className={["item", className].join(" ")}
key={id}
import List from "./List";
import Item from "./Item";
List.Item = Item;
export default List;
@andrzejewsky
andrzejewsky / calcDuration.js
Created January 10, 2019 21:26
calcDuration
const calcDuration = duration => {
const totalMinutes = duration / 60;
const minutes = ~~totalMinutes;
const seconds = ~~((totalMinutes - minutes) * 100);
return `${minutes}m ${seconds}s`;
};
export default calcDuration;
@andrzejewsky
andrzejewsky / ImageResource.jsx
Created January 10, 2019 21:27
ImageResource
import React, { Component } from "react";
class ImageResource extends Component {
constructor(props) {
super(props);
const image = new Image();
image.onload = this.handleLoadImage;
this.state = { image, src: props.lowQuality };
@andrzejewsky
andrzejewsky / Slider.htm
Created March 2, 2019 13:11
Netflix slider html
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
</div>
@andrzejewsky
andrzejewsky / Netflix-slider.css
Created March 2, 2019 13:12
Netflix slider css
.container {
display: flex;
padding: 0 55px;
}
.item {
background: green;
flex: 0 0 19.7%;
text-align: center;
margin: 0 2px;
@andrzejewsky
andrzejewsky / translationleft.scss
Created March 2, 2019 13:19
Netflix slider left translation
.container:hover .item {
transform: translateX(-25%);
}