GithubHelp home page GithubHelp logo

thealphamerc / unsplash-image-picker Goto Github PK

View Code? Open in Web Editor NEW
18.0 3.0 6.0 1.1 MB

React library to search and select photos from Unsplash

Home Page: https://thealphamerc.github.io/unsplash-image-picker/

HTML 16.63% TypeScript 64.46% CSS 4.67% JavaScript 9.03% SCSS 5.21%
image-picker-library react unsplash-api unsplash-photos photos picker

unsplash-image-picker's Introduction

unsplash-image-picker

Provide component to search and choose image from unsplash images

npm JavaScript Style Guide Hits

Live Demo

Live Demo Code Sandbox

Install

npm install --save unsplash-image-picker

Usage

Package provide 2 component to search and choose image from unsplash images.

  • UnsplashImagePicker - search and choose image from unsplash images
  • UnsplashImagePickerModal - Display modal to search and choose image from unsplash images

How to use UnsplashImagePickerModal

import React, { Component } from 'react'
import UnsplashImagePickerModal from 'unsplash-image-picker'
import 'unsplash-image-picker/dist/index.css'

const App = () => {
  const [active, setActive] = React.useState(false)
  const unsplashAccessKey = 'UNSPLASH_ACCESS_KEY'
  const [photos, SetPhotos] = React.useState([])
  return (
    <div>
      <button
        onClick={() => {
          setActive(true)
        }}
      >
        Show Picker
      </button>
      <UnsplashImagePickerModal
        unsplashAccessKey={unsplashAccessKey}
        active={active}
        setActive={setActive}
        initialPhotoSearchQuery=''
        onPhotoSelect={(photo) => {
          let list = photos ?? []
          list.push(photo)
          SetPhotos(list)
          setActive(false)
        }}
      />
    </div>
  )
}

How to use UnSplashImagePicker

import React from 'react'
import 'unsplash-image-picker/dist/index.css'
import { UnSplashImagePicker } from 'unsplash-image-picker'

const App = () => {
  const [photos, setPhotos] = React.useState([])
  const unsplashAccessKey = 'UNSPLASH_ACCESS_KEY'
  return (
    <div className='App '>
      <UnSplashImagePicker
        unsplashAccessKey={unsplashAccessKey}
        initialPhotoSearchQuery=''
        onPhotoSelect={(photo) => {
          let list = photos ?? []
          list.push(photo)
          SetPhotos(list)
        }}
      />
    </div>
  )
}

export default App

To get UNSPLASH ACCESS KEY, you can register at unsplash.com

License

MIT © thealphamerc

unsplash-image-picker's People

Contributors

thealphamerc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

unsplash-image-picker's Issues

Allow different orientations

Hey, thanks for developing this!

I'd love to be able to adjust the orientation requested. Right now, it seems like it's hard coded here:

It would be great to have the option of passing to the component what gets sent through unsplash.search.getPhotos().

I'm not very well setup to develop in typescript so sorry for just asking instead of suggesting a pull request, but if this can be done it would be greatly appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.