This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Select component and document it
- Loading branch information
1 parent
8d41e12
commit eeefc39
Showing
7 changed files
with
118 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
frontend.bundle.min.js | ||
src/styles/atomic.css | ||
src/components/Select/index.css | ||
src/constants/styles.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var jsonfile = require('jsonfile') | ||
var variables = require('../src/constants/styles.js') | ||
var file = './src/constants/styles.json' | ||
|
||
jsonfile.writeFile(file, variables, {spaces: 2}, function (err) { | ||
err && console.error(err) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Select from 'react-select' | ||
import './index.css' | ||
|
||
export default Select |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
@import '../../constants/styles.json'; | ||
|
||
// Variables | ||
// ------------------------------ | ||
|
||
// control options | ||
$select-input-bg: #fff !default; | ||
$select-input-bg-disabled: map-get($colors, light); | ||
$select-input-border-color: map-get($colors, neutral); | ||
$select-input-border-radius: map-get($rhythmem, eq); | ||
$select-input-border-focus: map-get($colors, pri); | ||
$select-input-border-width: .125em !default; // 2px | ||
$select-input-height: map-get($rhythmem, e1h); | ||
$select-input-internal-height: ($select-input-height - ($select-input-border-width * 2)); | ||
$select-input-placeholder: map-get($colors, neutral); | ||
$select-text-color: map-get($colors, dark); | ||
$select-link-hover-color: map-get($colors, pri); | ||
|
||
$select-padding-vertical: map-get($rhythmem, eq); | ||
$select-padding-horizontal: map-get($rhythmem, eh); | ||
|
||
// menu options | ||
$select-menu-zindex: 1000 !default; | ||
$select-menu-max-height: 200px !default; | ||
|
||
$select-option-color: lighten($select-text-color, 20%) !default; | ||
$select-option-bg: $select-input-bg !default; | ||
$select-option-focused-color: map-get($colors, light); | ||
$select-option-focused-bg: map-get($colors, pri); | ||
$select-option-disabled-color: map-get($colors, muted); | ||
|
||
$select-noresults-color: map-get($colors, muted); | ||
|
||
// clear "x" button | ||
$select-clear-size: 1.5em; | ||
$select-clear-color: map-get($colors, muted); | ||
$select-clear-hover-color: map-get($colors, danger); | ||
$select-clear-width: ($select-input-internal-height / 1.25); | ||
|
||
// arrow indicator | ||
$select-arrow-color: map-get($colors, neutral); | ||
$select-arrow-color-hover: map-get($colors, muted); | ||
$select-arrow-width: .3125em !default; // 5px | ||
|
||
// loading indicator | ||
$select-loading-size: 1em; | ||
$select-loading-color: $select-text-color !default; | ||
$select-loading-color-bg: $select-input-border-color !default; | ||
|
||
// multi-select item | ||
$select-item-border-radius: map-get($rhythmem, eq); | ||
$select-item-gutter: .3125em; // 5px | ||
$select-item-padding-vertical: .125em; // 2px | ||
$select-item-padding-horizontal: .3125em; // 5px | ||
$select-item-font-size: .9em !default; | ||
$select-item-color: map-get($colors, pri) !default; | ||
$select-item-bg: map-get($colors, pri); | ||
$select-item-border-color: darken($select-item-bg, 10%) !default; | ||
$select-item-hover-color: darken($select-item-color, 5%) !default; | ||
$select-item-hover-bg: darken($select-item-bg, 5%) !default; | ||
$select-item-disabled-color: map-get($colors, dark) !default; | ||
$select-item-disabled-bg: map-get($colors, light) !default; | ||
$select-item-disabled-border-color: darken($select-item-disabled-bg, 10%) !default; | ||
|
||
@import 'react-select/scss/default.scss'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Based on [React Select](https://github.com/JedWatson/react-select), this just | ||
adds custom styling. | ||
See [React Select Docs](https://github.com/JedWatson/react-select) for available | ||
option. | ||
|
||
To adjust the size, you can change the font-size using className, | ||
e.g. `className='Fz(ms2)'`. | ||
|
||
var options = [ | ||
{ value: 'one', label: 'One' }, | ||
{ value: 'two', label: 'Two' }, | ||
{ value: 'three', label: 'Three' }, | ||
{ value: 'four', label: 'Four' }, | ||
{ value: 'five', label: 'Five' }, | ||
{ value: 'six', label: 'Six' } | ||
]; | ||
|
||
function handleChange(val) { | ||
setState({value: val}) | ||
} | ||
|
||
<Select | ||
name='form-field-name' | ||
value={state.value} | ||
placeholder='Select a value' | ||
options={options} | ||
onChange={handleChange} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters