Skip to content

Instantly share code, notes, and snippets.

Avatar
📖
Writing. Code & Prose

Yoav Niran yoavniran

📖
Writing. Code & Prose
View GitHub Profile
@yoavniran
yoavniran / App.styles.jxs
Created Sep 14, 2020
react-native uploady demo - styles
View App.styles.jxs
const styles = StyleSheet.create({
uploadedImage: {
width: 400,
height: 400,
resizeMode: 'cover',
},
body: {
backgroundColor: "#ffffff",
},
sectionContainer: {
@yoavniran
yoavniran / app.upload.jsx
Created Sep 14, 2020
react-native uploady demo - upload
View app.upload.jsx
const Upload = () => {
const [uploadUrl, setUploadUrl] = useState(false);
const uploadyContext = useContext(UploadyContext);
useItemFinishListener((item) => {
const response = JSON.parse(item.uploadResponse.data);
console.log(`item ${item.id} finished uploading, response was: `, response);
setUploadUrl(response.url);
});
@yoavniran
yoavniran / App.jsx
Last active Sep 14, 2020
react-native uploady demo - app
View App.jsx
import React, { useState, useCallback, useContext } from "react";
import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, Button, ImageBackground, Image } from "react-native";
import DocumentPicker from "react-native-document-picker/index";
import NativeUploady, {
UploadyContext,
useItemFinishListener,
useItemStartListener,
useItemErrorListener,
@yoavniran
yoavniran / ItemPreviewWithCrop.jsx
Last active Jul 8, 2020
ItemPreviewWithCrop.jsx - react-uploady demo
View ItemPreviewWithCrop.jsx
import ReactCrop from "react-image-crop";
import { withRequestPreSendUpdate, useItemFinalizeListener } from "@rpldy/uploady";
import { PREVIEW_TYPES } from "@rpldy/upload-preview";
import cropImage from "./image-crop-helper";
const ItemPreviewWithCrop = withRequestPreSendUpdate(props => {
const { id, url, isFallback, type, updateRequest, requestData, previewMethods } = props;
const [finished, setFinished] = useState(false);
const [crop, setCrop] = useState(null);
@yoavniran
yoavniran / UploadWithCrop.jsx
Last active Jul 8, 2020
UploadWithCrop.jsx - react-uploady demo
View UploadWithCrop.jsx
import Uploady from "@rpldy/uploady";
import UploadButton from "@rpldy/upload-button";
import UploadPreview from "@rpldy/upload-preview";
export default function UploadWithCrop() {
const previewMethodsRef = useRef();
return (
<Uploady
destination={{ url: "[upload-url]" }}
@yoavniran
yoavniran / UploadWithProgressPreview.jsx
Created May 21, 2020
React-Uploady preview with progress demo - UploadWithProgressPreview.jsx
View UploadWithProgressPreview.jsx
import UploadButton from "@rpldy/upload-button";
import UploadPreview from "@rpldy/upload-preview";
import CustomImagePreview from "./CustomImagePreview";
const UploadWithProgressPreview = () => {
const getPreviewProps = useCallback(item => ({ id: item.id }), []);
return (
<>
<UploadButton>Upload Files</UploadButton>
@yoavniran
yoavniran / CustomImagePreview.jsx
Last active May 22, 2020
React-Uploady preview with progress demo - CustomImagePreview.jsx
View CustomImagePreview.jsx
import styled from "styled-components"
import { useItemProgressListener } from "@rpldy/uploady";
const PreviewImage = styled.img`
margin: 5px;
max-width: 200px;
height: auto;
transition: opacity 0.4s;
${({ completed }) => `opacity: ${completed / 100};`}
@yoavniran
yoavniran / App.jsx
Created May 21, 2020
React-Uploady preview with progress demo - app.jsx
View App.jsx
import Uploady from "@rpldy/uploady";
import UploadWithProgressPreview from "./UploadWithProgressPreview";
const App = > () {
return (
<Uploady
destination={{ url: "[upload-url]" }}
>
<div className="App">
<h1>Hello React Uploady</h1>
@yoavniran
yoavniran / App.jsx
Created May 21, 2020
React-Uploady preview with progress demo
View App.jsx
import Uploady from "@rpldy/uploady";
const App = > () {
return (
<Uploady
destination={{ url: "[upload-url]" }}
>
<div className="App">
<h1>Hello React Uploady</h1>
<UploadWithProgressPreview />
@yoavniran
yoavniran / simple.jsx
Created May 3, 2020
React-Uploady - Simple
View simple.jsx
import React from "react";
import Uploady from "@rpldy/uploady";
import UploadButton from "@rpldy/upload-button";
const MyApp = () => (
<Uploady destination={{url: "https://my-server.com/upload"}}>
<UploadButton/>
</Uploady>
);