Skip to content

Commit 5acee0b

Browse files
committed
0.7.0 themes & umd build furqanZafar#31 furqanZafar#33
1 parent 9d9c099 commit 5acee0b

13 files changed

+228
-162
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# React Selectize
22

3+
## v0.7.0 / 7th February 2016
4+
* umd build
5+
* added `theme` prop, 3 built-in themes (default, bootstrap3 & material)
6+
* **Breaking Change**: moved index.css from `src/` directory to `themes` & `dist` directory
7+
* fixed issues with `search` & `open` props
8+
* **Breaking Change**: removed `autosize` prop
9+
310
## v0.6.2 / 2nd February 2016
411
* hide the reset button if the select is empty
512
* minor css improvements

README.md

+49-30
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ styles & features inspired by [React Select](http://jedwatson.github.io/react-se
1313

1414
[![](http://i.imgsafe.co/rQmogzn.gif)](http://furqanZafar.github.io/react-selectize/)
1515

16-
- [Changelog](CHANGELOG.md) (last updated on 2nd February 2016)
16+
- [Changelog](CHANGELOG.md) (last updated on 7th February 2016)
1717
- [API Reference](API.md)
1818

1919
# Motivation
@@ -23,6 +23,7 @@ styles & features inspired by [React Select](http://jedwatson.github.io/react-se
2323

2424
## Features
2525
* [Drop in replacement for React.DOM.Select](http://furqanzafar.github.io/react-selectize/#/?category=simple&example=drop-in-replacement-for-react.dom.select)
26+
* [Customizable themes](http://furqanzafar.github.io/react-selectize/#/?category=simple&example=themes)
2627
* Stateless, therefore extremely flexible & extensible
2728
* Clean and compact API fully documented on GitHub
2829
* [Multiselect support](http://furqanzafar.github.io/react-selectize/#/?category=multi&example=multi-select)
@@ -40,37 +41,37 @@ styles & features inspired by [React Select](http://jedwatson.github.io/react-se
4041
* [Mark options as unselectable](http://furqanzafar.github.io/react-selectize/#/?category=simple&example=selectability)
4142
* [Disable selected values](http://furqanzafar.github.io/react-selectize/#/?category=multi&example=disable-selected)
4243
* [Absolute positioned overlay, "Tether"ed to the search field](http://furqanzafar.github.io/react-selectize/#/?category=multi&example=tether)
43-
* Customizable styles, comes with Stylus files
4444

4545
## Install
46+
47+
* **npm:**
4648
`npm install react-selectize`
4749

48-
## Usage (livescript)
49-
```
50-
{create-factory}:React = require \react
51-
{SimpleSelect, MultiSelect, ReactSelectize} = require \react-selectize
52-
SimpleSelect = create-factory SimpleSelect
53-
MultiSelect = create-factory MultiSelect
54-
.
55-
.
56-
.
57-
SimpleSelect do
58-
placeholder: 'Select a fruit'
59-
options: <[apple mango orange banana]> |> map ~> label: it, value: it
60-
on-value-change: (value) ~>
61-
alert value
62-
.
63-
.
64-
.
65-
MultiSelect do
66-
placeholder: 'Select fruits'
67-
options: <[apple mango orange banana]> |> map ~> label: it, value: it
68-
on-values-change: (values) ~>
69-
alert values
50+
to include the default styles add the following import statement to your stylus file:
51+
`@import 'node_modules/react-selectize/themes/index.css'`
52+
53+
* **1998 script tag:**
54+
```html
55+
<html>
56+
<head>
57+
<script src="http://www.preludels.com/prelude-browser-min.js" type="text/javascript" ></script>
58+
<script src="https://npmcdn.com/[email protected]/dist/index.min.js" type="text/javascript" ></script>
59+
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-with-addons.min.js" type="text/javascript" ></script>
60+
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.min.js" type="text/javascript" ></script>
61+
62+
<!-- optional dependency (only required with using the tether prop) -->
63+
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.1.1/js/tether.min.js" type="text/javascript" ></script>
64+
65+
<script src="https://npmcdn.com/[email protected]/dist/index.min.js" type="text/javascript" ></script>
66+
67+
<!-- built in themes (default, bootstrap3, material) -->
68+
<link rel="stylesheet" href="https://npmcdn.com/[email protected]/dist/index.min.css"/>
69+
</head>
70+
</html>
7071
```
7172

7273
## Usage (jsx)
73-
```
74+
```javascript
7475
React = require("react");
7576
ReactSelectize = require("react-selectize");
7677
SimpleSelect = ReactSelectize.SimpleSelect;
@@ -104,11 +105,29 @@ MultiSelect = ReactSelectize.MultiSelect;
104105
/>
105106
```
106107

107-
## Usage (stylus)
108-
to include the default styles add the following import statement to your stylus file:
109-
110-
`@import 'node_modules/react-selectize/src/index.css'`
111-
108+
## Usage (livescript)
109+
```LiveScript
110+
{create-factory}:React = require \react
111+
{SimpleSelect, MultiSelect, ReactSelectize} = require \react-selectize
112+
SimpleSelect = create-factory SimpleSelect
113+
MultiSelect = create-factory MultiSelect
114+
.
115+
.
116+
.
117+
SimpleSelect do
118+
placeholder: 'Select a fruit'
119+
options: <[apple mango orange banana]> |> map ~> label: it, value: it
120+
on-value-change: (value) ~>
121+
alert value
122+
.
123+
.
124+
.
125+
MultiSelect do
126+
placeholder: 'Select fruits'
127+
options: <[apple mango orange banana]> |> map ~> label: it, value: it
128+
on-values-change: (values) ~>
129+
alert values
130+
```
112131

113132
## Gotchas
114133
* the default structure of an option object is `{label: String, value :: a}` where `a` implies that `value` property can be of any equatable type

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-selectize",
3-
"version": "0.6.2",
3+
"version": "0.7.0",
44
"description": "A Stateless & Flexible Select component for React inspired by Selectize",
55
"main": "src/index.js",
66
"scripts": {

public/components/App.ls

+7
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ This can be useful when you are using the select control inside a parent element
127127
jsx: fs.read-file-sync \public/examples/simple/SimpleSelect.jsx, \utf8
128128
ls: fs.read-file-sync \public/examples/simple/SimpleSelect.ls, \utf8
129129

130+
* title: "Themes"
131+
description: ""
132+
languages:
133+
jsx: fs.read-file-sync \public/examples/simple/Themes.jsx, \utf8
134+
ls: fs.read-file-sync \public/examples/simple/Themes.ls, \utf8
135+
136+
130137
* title: "On value change"
131138
description: ""
132139
languages:

public/examples/simple/Themes.jsx

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SimpleSelect = require("react-selectize").SimpleSelect
2+
3+
Form = React.createClass({
4+
5+
// render :: a -> ReactElement
6+
render: function(){
7+
var self = this,
8+
options = ["apple", "mango", "grapes", "melon", "strawberry"].map(function(fruit){
9+
return {label: fruit, value: fruit}
10+
});
11+
return <SimpleSelect
12+
options = {options}
13+
placeholder = "Select a fruit"
14+
theme = "material" // can be one of "default" | "bootstrap3" | "material" | ...
15+
transitionEnter = {true}
16+
/>
17+
}
18+
19+
});
20+
21+
render(<Form/>, mountNode)

public/examples/simple/Themes.ls

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# {SimpleSelect} = require \react-selectize
2+
3+
Form = React.create-class do
4+
5+
# render :: a -> ReactElement
6+
render: ->
7+
React.create-element SimpleSelect,
8+
options: <[apple mango grapes melon strawberry]> |> map ~> label: it, value: it
9+
placeholder: "Select a fruit"
10+
theme: \material # can be one of \default | \bootstrap3 | \material | ...
11+
transition-enter: true
12+
13+
render (React.create-element Form, null), mount-node

public/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<div class="sub-title">Features</div>
5151
<ul>
5252
<li><a href="#/?category=simple&amp;example=drop-in-replacement-for-react.dom.select">Drop in replacement for React.DOM.Select</a></li>
53+
<li><a href="#/?category=simple&amp;example=themes">Customizable themes</a></li>
5354
<li>Stateless, therefore extremely flexible &amp; extensible</li>
5455
<li>Clean and compact API fully documented on GitHub</li>
5556
<li><a href="#/?category=multi&amp;example=multi-select">Multiselect support</a></li>
@@ -67,7 +68,7 @@
6768
<li><a href="#/?category=simple&amp;example=selectability">Mark options as unselectable</a></li>
6869
<li><a href="#/?category=multi&amp;example=disable-selected">Disable selected options instead of removing them</a></li>
6970
<li><a href="#/?category=multi&amp;example=tether">Absolute positioned overlay, "Tether"ed to the search field</a></li>
70-
<li>Customizable stlyes, comes with Stylus files</li>
71+
7172
</ul>
7273
</div>
7374
<div class="install">

src/DropdownMenu.ls

+5-5
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ module.exports = create-class do
9191
transition-leave: @props.transition-leave
9292
transition-enter-timeout: @props.transition-enter-timeout
9393
transition-leave-timeout: @props.transition-leave-timeout
94-
class-name: "dropdown-menu-container #{dynamic-class-name}"
95-
ref: \dropdownMenuContainer
94+
class-name: "dropdown-menu-wrapper #{dynamic-class-name}"
95+
ref: \dropdownMenuWrapper
9696
@render-dropdown computed-state
9797

9898
else
@@ -143,8 +143,8 @@ module.exports = create-class do
143143

144144
# on-height-change :: Number -> ()
145145
on-height-change: (height) !~>
146-
if @refs.dropdown-menu-container
147-
find-DOM-node @refs.dropdown-menu-container .style.height = "#{height}px"
146+
if @refs.dropdown-menu-wrapper
147+
find-DOM-node @refs.dropdown-menu-wrapper .style.height = "#{height}px"
148148

149149
# NO RESULT FOUND
150150
if @props.options.length == 0
@@ -183,7 +183,7 @@ module.exports = create-class do
183183

184184
# component-did-update :: () -> ()
185185
component-did-update: !->
186-
dropdown-menu = find-DOM-node @refs.dropdown-menu-container ? @refs.dropdown-menu
186+
dropdown-menu = find-DOM-node @refs.dropdown-menu-wrapper ? @refs.dropdown-menu
187187
..?style.bottom = switch
188188
| @props.dropdown-direction == -1 => @props.bottom-anchor!.offset-height + dropdown-menu.style.margin-bottom
189189
| _ => ""

src/ReactSelectize.ls

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ module.exports = create-class do
9898
class-name: class-name-from-object do
9999
\react-selectize : 1
100100
"#{@props.theme}" : 1
101+
\control-wrapper : 1
101102
"#{@props.class-name}" : 1
102103
disabled: @props.disabled
103104
open: @props.open

themes/base.styl

+60-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
// component skeleton, extended & decorated by themes
22
.react-selectize
3+
color black
4+
5+
.react-selectize.control-wrapper
36
user-select none
47
position relative
58

9+
&:not(.tethered)
10+
width 300px
11+
612
&.disabled
713
pointer-events none
814

@@ -11,7 +17,14 @@
1117
display flex
1218
align-items flex-start
1319
position relative
20+
21+
// this controls the height of the select
22+
padding 2px
1423

24+
// this controls the height of the select
25+
> div
26+
min-height 30px
27+
1528
.react-selectize-placeholder
1629
display flex
1730
align-items center
@@ -53,35 +66,73 @@
5366
.react-selectize-reset-container
5467
width 16px
5568

69+
.react-selectize-reset-container:hover .react-selectize-reset path
70+
stroke #c0392b
71+
5672
.react-selectize-arrow path
5773
fill #999
5874

5975
.react-selectize-reset path
76+
transition stroke 0.5s 0s ease
6077
stroke #999
6178
stroke-linecap square
6279
stroke-linejoin mitter
6380

64-
// dropdown-menu-container is present for tethered & animated dropdowns only
65-
.react-selectize.dropdown-menu-container
81+
// by default the dropdown-menu is present inside the control-wrapper
82+
.dropdown-menu
83+
84+
&.tethered
85+
min-width 298px
86+
87+
&:not(.tethered)
88+
width calc(100% - 2px)
89+
90+
// wraps the dropdown-menu div, exists only when props.transition-enter or props.transition-leave or both are true
91+
// present inside document.body if props.tether is true, otherwise its present inside the control-wrapper div (above)
92+
.react-selectize.dropdown-menu-wrapper
6693
position absolute
6794

95+
&.tethered
96+
min-width 298px
97+
98+
&:not(.tethered)
99+
width calc(100% - 2px)
100+
101+
// dropdown-menu present in document.body when props.tether is true
68102
.react-selectize.dropdown-menu
69103
overflow auto
70104
position absolute
71105
max-height 200px
72106
z-index 10
73107

74-
&.tethered
75-
min-width 300px
76-
77-
&:not(.tethered)
78-
width 100%
79-
80108
.groups.as-columns
81109
display flex
82110
> div
83111
flex 1
84112

85113
.option-wrapper
86114
cursor pointer
87-
outline none
115+
outline none
116+
117+
// MULTI SELECT
118+
.multi-select.react-selectize.control-wrapper
119+
120+
.simple-value
121+
display inline-block
122+
margin 2px
123+
vertical-align middle
124+
125+
span
126+
display inline-block
127+
padding 2px 5px 4px
128+
vertical-align center
129+
130+
// SIMPLE SELECT
131+
.simple-select.react-selectize.control-wrapper
132+
133+
.simple-value
134+
margin 2px
135+
136+
span
137+
display inline-block
138+
vertical-align center

0 commit comments

Comments
 (0)