Giter VIP home page Giter VIP logo

switch-element's Introduction

switch-element

A switch form element (utilising the Laravel Collective custom component feature to componentise and Bootstrap for themeing).

Requirements

Installation

  1. Add to AppServiceProvider@boot() the component definition:
\Form::component('switch', 'templates._switch-partial', ['name', 'value', 'label', 'text' => ['Yes', 'No'], 'color' => 'success', 'attributes' => []]);
  1. Include the _switch-partial.blade.php blade file to /resources/views/templates/

Usage

{{ Form::switch(name, value, label, text, theme, attributes) }}

[string] name

Names the input element and the value to check upon form submission.

[string] value

This is the value which will be sent on form submission. Important: The truthiness of the value determines the state of the switch.

[string] label

The text which will sit next to (generally to the left of) the switch component. Use the class .control-label to style (eg, display:block forces the label to be on a different line than the switch. This value is not escaped by Laravel so HTML is permissable here.

[array] text

Must be an array of two values - the "on" text and "off" text. ie, ['Yes', 'No']

[string] theme

Determines the colours used on the switch. This value must be one of the available Bootstrap theme keywords. (some show better than others!).

Theme Hex
Primary #007BFF #007BFF
Secondary #FFC107 #FFC107
Success #17A2B8 #17A2B8
Danger #DC3545 #DC3545
Warning #343A40 #343A40
Info #17A2B8 #17A2B8
Light #FFFFFF #FFFFFF
Dark #000000 #000000
(the hex values will differ if you've customised your Bootstrap)

[array] attributes

Any remaining HTML element attributes - these will be added to the form element in the switch. To access/change any other elements which make up the switch use the classes defined below.

Component Elements

Element Class
Surrounding DIV .switch-component
LABEL .control-label
INPUT .switch-input
Handle .switch-hanle
On/off label .switch-label

Example

{{ Form::switch('online_store', $store->online, 'Online Store?', ['Yes', 'No'], 'success', ['class' => 'online_class']) }}

switch-element's People

Contributors

cartoonclouds avatar

Watchers

 avatar  avatar

switch-element's Issues

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.