Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dropdown-sample

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dropdown-sample

A simple dropdown component library

  • 1.0.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

dropdown-sample

dropdown component library

NPM JavaScript Style Guide

Install the dropdown component

npm i --save dropdown-sample

Install dependencies (antd & styled components 💅)

npm i --save antd 
npm i --save styled-components 

Usage

import React, { Component } from 'react'

import Dropdown from 'dropdown-sample'

class Example extends Component {
  render () {
    return (
      <Dropdown 
        options={[
          { key: 'one', value: 'A simple option' },
          { key: 'two', value: 'A second option' },
          { key: 'three', value: 'Third and final!' },
          { key: 'four', value: 'mangos' },
        ]}
        placeholder="Select an Option"
        size="small"
        onChange={() => {}}
        onFocus={() => {}}
        onBlur={() => {}}
      />
    )
  }
}

usage with icon emojis.

<Dropdown 
  options={[
    {key: 'one', value: 'strawberry', icon: '🍓'},
    {key: 'two', value: 'watermelon', icon: '🍉' },
    {key: 'three', value: 'mango', icon: '🥭' },
    {key: 'four', value: 'avocado', icon: '🥑' },
    {key: 'five', value: 'pear', icon: '🍐' },
  ]}
  placeholder="Select an option (w/ a cute fruit icon!)"
  size="medium"
  onChange={() => console.log('On change FIRED 🚀')}
  onFocus={() => console.log('On focus FIRED 🚀')}
  onBlur={() => console.log('On blur FIRED 🚀')}
/>

usage with icon emojis + descriptions.

<Dropdown 
  options={[
    {key: 'one', value: 'I have a description', icon: '🍓', description: 'I am an option with a cool fancy description on the bottom!'},
    {key: 'two', value: 'Option 2', icon: '🍓', description: 'If you pick me, yay!'},
    {key: 'three', value: 'Watermelon', icon: '🍓', description: 'Should we make watermelons smoothies?'},
  ]}
  placeholder="Select an option (w/ a description!)"
  size="large"
  onChange={() => console.log('On change FIRED 🚀')}
  onFocus={() => console.log('On focus FIRED 🚀')}
  onBlur={() => console.log('On blur FIRED 🚀')}
/>

Building the project + example

Clone the repository

git clone <path_to_repo>

Install the dependancies

cd  <path_to_repo>
yarn install

Start up the component library

yarn start

Open a new terminal tab and navigate to example directory

cd <path_to_repo>/example 

Install the dependancies for the example react app

yarn install

Start the development server. A browser window should open with some examples of the dropdown :)

yarn start

Props

Propusage
Optionsoptions take a key (string), value (string), icon (emoji/string), and a description (string).
placeholderthe placeholder before an option is selected (string)
sizecan be 'small', 'medium' or 'large' (string)
onChangean function thats fired when an option is selected
onFocusan function thats fired on component focus
onBluran function thats fired on component blur

License

MIT © ejdweck

FAQs

Package last updated on 14 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc