Coder Social home page Coder Social logo

myuw-search's Introduction

<myuw-search>

Getting Started

Add the following import to your page's <head>:

<script type="module" src="https://unpkg.com/@myuw-web-components/myuw-search@^1?module"></script>
<script nomodule scr="https://unpkg.com/@myuw-web-components/myuw-search@^1"></script>

Important: For responsive features to work properly, ensure your application includes the viewport meta tag:

<meta name="viewport" content="width=device-width, initial-scale=1">

Use the component's HTML tag wherever you want:

<myuw-search
    input-label="Search MyUW"
    button-label="Submit search"
    icon="search">
</myuw-search>

Listen for the myuw-search CustomEvent and process the value how you like:

/* 
    1. Listen for myuw-search event
    2. Get the event data from event.detail.value
    3. Do what you want with the search term!
*/
document.body.addEventListener('myuw-search', (event) => {
  var valueFromSearchBar = event.detail.value // "detail" object is part of CustomEvent spec
  /*
    Perform search logic here. For example:
      - Pass the search value as a parameter to your app's search page
  */
}, false );

Configurable properties via attributes

  • inputLabel (input-label): Text to use in the aria-label and placeholder of the search field
  • buttonLabel (button-label): Text to use for the aria-label of the search button
  • icon (icon): Text name of the material icon to use for the submit button ("search" by default)

Custom CSS properties

  • --myuw-search-border: Used to set the border color of the search component (to support themes with light background colors). Defaults to none.
  • --myuw-app-bar-color: Used by to set the color of the search button icon on small screens. Defaults to white.

Development and contribution

To run the demo app locally and test the component, run the following commands:

$ npm install
$ npm start

myuw-search's People

Contributors

davidmsibley avatar ievavold avatar saberg3 avatar thevoiceofzeke avatar

Watchers

 avatar  avatar

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.