Skip to content

Commit ca5ca39

Browse files
committed
initial commit
0 parents  commit ca5ca39

16 files changed

+21341
-0
lines changed

.babelrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
"react",
4+
"env",
5+
],
6+
"plugins": [
7+
"transform-export-extensions",
8+
"transform-class-properties",
9+
"transform-object-rest-spread",
10+
],
11+
}

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
public
4+
*.log

.vscode/settings.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"workbench.colorCustomizations": {
3+
"activityBar.background": "#3399ff",
4+
"activityBar.foreground": "#15202b",
5+
"activityBar.inactiveForeground": "#15202b99",
6+
"activityBarBadge.background": "#bf0060",
7+
"activityBarBadge.foreground": "#e7e7e7",
8+
"titleBar.activeBackground": "#007fff",
9+
"titleBar.inactiveBackground": "#007fff99",
10+
"titleBar.activeForeground": "#e7e7e7",
11+
"titleBar.inactiveForeground": "#e7e7e799",
12+
"statusBar.background": "#007fff",
13+
"statusBarItem.hoverBackground": "#3399ff",
14+
"statusBar.foreground": "#e7e7e7"
15+
},
16+
"peacock.color": "#007fff"
17+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Netlify
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# netlify-cms-widget-nested-select>
2+
3+
[Check out a demo!](https://netlify-cms-widget-nested-select.netlify.com/demo)
4+
5+
This widget will conditionally show a second select with its own options based on what's chosen in the first select. This can be used, for example, to set up subcategories inside of categories.
6+
7+
## Install
8+
9+
As an npm package:
10+
11+
```shell
12+
npm install --save netlify-cms-widget-nested-select
13+
```
14+
15+
```js
16+
import NestedSelect from 'netlify-cms-widget-nested-select'
17+
18+
CMS.registerWidget('nested-select', NestedSelectControl, NestedSelectPreview)
19+
```
20+
21+
Via `script` tag:
22+
23+
```html
24+
<script src="https://unpkg.com/netlify-cms-widget-nested-select@^1.0.0"></script>
25+
26+
<script>
27+
CMS.registerWidget('nested-select', NestedSelectControl, NestedSelectPreview)
28+
</script>
29+
```
30+
31+
## How to use
32+
33+
Add to your Netlify CMS configuration:
34+
35+
```yaml
36+
fields:
37+
- {
38+
name: <fieldname>,
39+
label: <fieldlabel>,
40+
widget: nested-select,
41+
options: [
42+
"Regular option",
43+
"Another regular option",
44+
{
45+
label: "Option with suboptions",
46+
options: [
47+
"Suboption 1",
48+
"Suboption 2",
49+
"Suboption 3"
50+
]
51+
}
52+
]
53+
}
54+
```
55+
56+
## Support
57+
58+
For help with this widget, open an [issue](https://github.com/kbravh/netlify-cms-widget-nested-select) or ask the Netlify CMS community in [Gitter](https://gitter.im/netlify/netlifycms).

dev/bootstrap.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.CMS_MANUAL_INIT = true

dev/index.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import './bootstrap.js'
2+
import CMS, { init } from 'netlify-cms'
3+
import 'netlify-cms/dist/cms.css'
4+
import { NestedSelectControl, NestedSelectPreview } from '../src'
5+
6+
const config = {
7+
backend: {
8+
name: 'test-repo',
9+
login: false,
10+
},
11+
media_folder: 'assets',
12+
collections: [{
13+
name: 'test',
14+
label: 'Test',
15+
files: [{
16+
file: 'test.yml',
17+
name: 'test',
18+
label: 'Test',
19+
fields: [{
20+
name: 'nested-select',
21+
label: 'Nested Select',
22+
widget: 'nested-select',
23+
options: [
24+
"Regular option",
25+
"Another regular option",
26+
{
27+
label: "Option with suboptions",
28+
options: [
29+
"Suboption 1",
30+
"Suboption 2",
31+
"Suboption 3"
32+
]
33+
}
34+
]
35+
}, ],
36+
}],
37+
}],
38+
}
39+
40+
CMS.registerWidget('nested-select', NestedSelectControl, NestedSelectPreview)
41+
42+
init({
43+
config
44+
})

netlify.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build]
2+
publish = "public/"
3+
command = "yarn demo"
4+
5+
[[redirects]]
6+
from = "/demo"
7+
to = "/#/collections/test/entries/test"

0 commit comments

Comments
 (0)