Skip to content

Commit 1167f27

Browse files
hdorotech4him1
authored andcommitted
New design for the widgets section in the docs (#866)
* Initial commit for the new widgets section * Placing all the widgets and refining the CSS and Hugo logic * Initial commit for the new widgets section * Placing all the widgets and refining the CSS and Hugo logic * Rebased and updated the info according to @verythorough contribution * Fixing the yaml codes for the relation and select widget sections * Merging with widgets.md and app.j * Fixing some silly mistakes (sorry!) * Following @verythorough contributions :) * Adding the markdown widget and fixing the widgets container background * Adding the URL functionality and myself as a contributor :) * Adding myself as a contributor :)
1 parent 4515edd commit 1167f27

25 files changed

+567
-312
lines changed

.all-contributorsrc

+9
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,15 @@
448448
"contributions": [
449449
"doc"
450450
]
451+
},
452+
{
453+
"login": "hcavalieri",
454+
"name": "Henrique Cavalieri",
455+
"avatar_url": "https://avatars0.githubusercontent.com/u/27744332?v=4",
456+
"profile": "https://kaordica.com.br",
457+
"contributions": [
458+
"doc"
459+
]
451460
}
452461
]
453462
}

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Netlify CMS
2-
[![All Contributors](https://img.shields.io/badge/all_contributors-55-orange.svg)](#contributors)
2+
[![All Contributors](https://img.shields.io/badge/all_contributors-56-orange.svg)](#contributors)
33
[![](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/netlify/netlifycms)
44

55
A CMS for static site generators. Give non-technical users a simple way to edit
@@ -56,7 +56,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
5656
| [<img src="https://avatars3.githubusercontent.com/u/4349324?v=4" width="100px;"/><br /><sub><b>Benjamin Kniffler</b></sub>](https://github.com/bkniffler)<br /> | [<img src="https://avatars1.githubusercontent.com/u/845983?v=4" width="100px;"/><br /><sub><b>Mike Wickett</b></sub>](http://www.wickett.ca)<br /> | [<img src="https://avatars1.githubusercontent.com/u/2751799?v=4" width="100px;"/><br /><sub><b>Rory Claasen</b></sub>](http://roryclaasen.me)<br /> | [<img src="https://avatars3.githubusercontent.com/u/724844?v=4" width="100px;"/><br /><sub><b>Frederic Brodbeck</b></sub>](http://www.freder.io/)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1245746?v=4" width="100px;"/><br /><sub><b>Stuart Dum</b></sub>](https://github.com/simplystuart)<br /> | [<img src="https://avatars0.githubusercontent.com/u/8184251?v=4" width="100px;"/><br /><sub><b>Ryan Watters</b></sub>](https://github.com/rdwatters)<br /> | [<img src="https://avatars3.githubusercontent.com/u/4315?v=4" width="100px;"/><br /><sub><b>Helder S Ribeiro</b></sub>](https://twitter.com/hsribei)<br /> |
5757
| [<img src="https://avatars1.githubusercontent.com/u/979966?v=4" width="100px;"/><br /><sub><b>Artem Govorov</b></sub>](http://dm.gl)<br /> | [<img src="https://avatars3.githubusercontent.com/u/2683300?v=4" width="100px;"/><br /><sub><b>Cédric Delpoux</b></sub>](http://xuopled.netlify.com/)<br /> | [<img src="https://avatars3.githubusercontent.com/u/83225?v=4" width="100px;"/><br /><sub><b>imorente</b></sub>](https://github.com/imorente)<br /> | [<img src="https://avatars3.githubusercontent.com/u/5230460?v=4" width="100px;"/><br /><sub><b>David Francoeur</b></sub>](http://davidfrancoeur.com)<br /> | [<img src="https://avatars3.githubusercontent.com/u/1954977?v=4" width="100px;"/><br /><sub><b>Rusta</b></sub>](https://github.com/Rusta)<br /> | [<img src="https://avatars1.githubusercontent.com/u/1299786?v=4" width="100px;"/><br /><sub><b>Henrik Lau Eriksson</b></sub>](http://henrik.laueriksson.com)<br /> | [<img src="https://avatars0.githubusercontent.com/u/1294877?v=4" width="100px;"/><br /><sub><b>Kraig Walker</b></sub>](https://www.kraigwalker.com)<br /> |
5858
| [<img src="https://avatars1.githubusercontent.com/u/2994311?v=4" width="100px;"/><br /><sub><b>Rich Cook</b></sub>](http://www.TalesofMurder.com)<br /> | [<img src="https://avatars3.githubusercontent.com/u/1309950?v=4" width="100px;"/><br /><sub><b>Damien Van Der Windt</b></sub>](https://github.com/damienvdw)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1571899?v=4" width="100px;"/><br /><sub><b>Matt Jared</b></sub>](http://mattjared.github.io/)<br /> | [<img src="https://avatars1.githubusercontent.com/u/1100280?v=4" width="100px;"/><br /><sub><b>bruce-one</b></sub>](https://github.com/bruce-one)<br /> | [<img src="https://avatars3.githubusercontent.com/u/103008?v=4" width="100px;"/><br /><sub><b>Frank Taillandier</b></sub>](https://frank.taillandier.me)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=DirtyF "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/2936813?v=4" width="100px;"/><br /><sub><b>Aquib Master</b></sub>](http://aquibm.com/)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=aquibm "Code") | [<img src="https://avatars0.githubusercontent.com/u/3147296?v=4" width="100px;"/><br /><sub><b>Eric Jinks</b></sub>](http://ericjinks.com)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=Jinksi "Code") |
59-
| [<img src="https://avatars3.githubusercontent.com/u/784848?v=4" width="100px;"/><br /><sub><b>Tony Alves</b></sub>](https://github.com/talves)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=talves "Code") | [<img src="https://avatars3.githubusercontent.com/u/782?v=4" width="100px;"/><br /><sub><b>Ernie Bello</b></sub>](http://ern.me)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3Aebello "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/6202476?v=4" width="100px;"/><br /><sub><b>Alexander Kushi-Willis</b></sub>](https://ackushiw.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=ackushiw "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/54089?v=4" width="100px;"/><br /><sub><b>Igor Kuznetsov</b></sub>](http://www.igk.ru)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3Aigk1972 "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=igk1972 "Code") [🔌](#plugin-igk1972 "Plugin/utility libraries") | [<img src="https://avatars2.githubusercontent.com/u/1312538?v=4" width="100px;"/><br /><sub><b>Tim Erickson</b></sub>](http://neutyp.com)<br />[🎨](#design-neutyp "Design") | [<img src="https://avatars0.githubusercontent.com/u/871552?v=4" width="100px;"/><br /><sub><b>David Jones</b></sub>](http://davidejones.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=davidejones "Documentation") |
59+
| [<img src="https://avatars3.githubusercontent.com/u/784848?v=4" width="100px;"/><br /><sub><b>Tony Alves</b></sub>](https://github.com/talves)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=talves "Code") | [<img src="https://avatars3.githubusercontent.com/u/782?v=4" width="100px;"/><br /><sub><b>Ernie Bello</b></sub>](http://ern.me)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3Aebello "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/6202476?v=4" width="100px;"/><br /><sub><b>Alexander Kushi-Willis</b></sub>](https://ackushiw.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=ackushiw "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/54089?v=4" width="100px;"/><br /><sub><b>Igor Kuznetsov</b></sub>](http://www.igk.ru)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3Aigk1972 "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=igk1972 "Code") [🔌](#plugin-igk1972 "Plugin/utility libraries") | [<img src="https://avatars2.githubusercontent.com/u/1312538?v=4" width="100px;"/><br /><sub><b>Tim Erickson</b></sub>](http://neutyp.com)<br />[🎨](#design-neutyp "Design") | [<img src="https://avatars0.githubusercontent.com/u/871552?v=4" width="100px;"/><br /><sub><b>David Jones</b></sub>](http://davidejones.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=davidejones "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/27744332?v=4" width="100px;"/><br /><sub><b>Henrique Cavalieri</b></sub>](https://kaordica.com.br)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=hcavalieri "Documentation") |
6060
<!-- ALL-CONTRIBUTORS-LIST:END -->
6161

62-
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
62+
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

website/site/content/docs/widgets.md

+2-308
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To see working examples of all of the built-in widgets, try making a 'Kitchen Si
1717
The following options are available on all fields:
1818

1919
- `required`: specify as `false` to make a field optional; defaults to `true`
20-
- `pattern`: add field validation by specifying a list with a regex pattern and an error message; more extensive validation can be achieved with [custom widgets](https://www.netlifycms.org/docs/custom-widgets/#advanced-field-validation)
20+
- `pattern`: add field validation by specifying a list with a [regex pattern](https://regexr.com/) and an error message; more extensive validation can be achieved with [custom widgets](https://www.netlifycms.org/docs/custom-widgets/#advanced-field-validation)
2121
- **Example:**
2222

2323
```yaml
@@ -27,310 +27,4 @@ The following options are available on all fields:
2727
pattern: ['.{10,}', "Must have at least 20 characters"]
2828
```
2929
30-
31-
## Boolean
32-
33-
The boolean widget translates a toggle switch input to a true/false value.
34-
35-
- **Name:** `boolean`
36-
- **UI:** toggle switch
37-
- **Data type:** boolean
38-
- **Options:**
39-
- `default`: accepts `true` or `false`; defaults to `false`
40-
- **Example:**
41-
42-
```yaml
43-
- {label: "Draft", name: "draft", widget: "boolean", default: true}
44-
```
45-
46-
47-
## Date
48-
49-
The date widget translates a date picker input to a date string. For saving date and time together, use the [DateTime](#datetime) widget.
50-
51-
- **Name:** `date`
52-
- **UI:** date picker
53-
- **Data type:** Moment.js-formatted date string
54-
- **Options:**
55-
- `default`: accepts a date string, or an empty string to accept blank input; otherwise defaults to current date
56-
- `format`: accepts Moment.js [tokens](https://momentjs.com/docs/#/parsing/string-format/); defaults to ISO8601 format `YYYY-MM-DD`
57-
- **Example:**
58-
59-
```yaml
60-
- label: "Birthdate"
61-
name: "birthdate"
62-
widget: "date"
63-
default: ""
64-
format: "MMM Do YY"
65-
```
66-
67-
68-
## DateTime
69-
70-
The datetime widget translates a datetime picker to a datetime string. For saving the date only, use the [Date](#date) widget.
71-
72-
- **Name:** `datetime`
73-
- **UI:** datetime picker
74-
- **Data type:** Moment.js-formatted datetime string
75-
- **Options:**
76-
- `default`: accepts a datetime string, or an empty string to accept blank input; otherwise defaults to current datetime
77-
- `format`: accepts Moment.js [tokens](https://momentjs.com/docs/#/parsing/string-format/); defaults to ISO8601 format `YYYY-MM-DDTHH:mm:ssZ`
78-
- **Example:**
79-
80-
```yaml
81-
- label: "Start time"
82-
name: "start"
83-
widget: "datetime"
84-
default: ""
85-
format: "LLL"
86-
```
87-
88-
89-
## File
90-
91-
The file widget allows editors to upload a file or select an existing one from the media library. The path to the file will be saved to the field as a string.
92-
93-
- **Name:** `file`
94-
- **UI:** file picker button opens media gallery
95-
- **Data type:** file path string, based on `media_folder`/`public_folder` configuration
96-
- **Options:**
97-
- `default`: accepts a file path string; defaults to null
98-
- **Example:**
99-
100-
```yaml
101-
- label: "Manual PDF"
102-
name: "manual_pdf"
103-
widget: "file"
104-
default: "/uploads/general-manual.pdf"
105-
```
106-
107-
108-
## Hidden
109-
110-
Hidden widgets do not display in the UI. In folder collections that allow users to create new items, you will often want to set a default for hidden fields, so they will be set without requiring an input.
111-
112-
- **Name:** `hidden`
113-
- **UI:** none
114-
- **Data type:** any valid data type
115-
- **Options:**
116-
- `default`: accepts any valid data type; recommended for collections that allow adding new items
117-
- **Example:**
118-
119-
```yaml
120-
- {label: "Layout", name: "layout", widget: "hidden", default: "blog"}
121-
```
122-
123-
124-
## Image
125-
126-
The image widget allows editors to upload an image or select an existing one from the media library. The path to the image file will be saved to the field as a string.
127-
128-
- **Name:** `image`
129-
- **UI:** file picker button opens media gallery allowing image files (jpg, jpeg, webp, gif, png, bmp, tiff, svg) only; displays selected image thumbnail
130-
- **Data type:** file path string, based on `media_folder`/`public_folder` configuration
131-
- **Options:**
132-
- `default`: accepts a file path string; defaults to null
133-
- **Example:**
134-
135-
```yaml
136-
- label: "Featured Image"
137-
name: "thumbnail"
138-
widget: "image"
139-
default: "/uploads/chocolate-dogecoin.jpg"
140-
```
141-
142-
143-
## List
144-
145-
The list widget allows you to create a repeatable item in the UI which saves as a list of widget values. map a user-provided string with a comma delimiter into a list. You can choose any widget as a child of a list widget—even other lists.
146-
147-
- **Name:** `list`
148-
- **UI:** if `fields` is specified, field containing a repeatable child widget, with controls for adding, deleting, and re-ordering the repeated widgets; if unspecified, a text input for entering comma-separated values
149-
- **Data type:** list of widget values
150-
- **Options:**
151-
- `default`: if `fields` is specified, declare defaults on the child widgets; if not, you may specify a list of strings to populate the text field
152-
- `field`: a single widget field to be repeated
153-
- `fields`: a nested list of multiple widget fields to be included in each repeatable iteration
154-
- **Example** (`field`/`fields` not specified):
155-
156-
```yaml
157-
- label: "Tags"
158-
name: "tags"
159-
widget: "list"
160-
default: ["news"]
161-
```
162-
163-
- **Example** (with `field`):
164-
165-
```yaml
166-
- label: "Gallery"
167-
name: "galleryImages"
168-
widget: "list"
169-
field:
170-
- {label: Image, name: image, widget: image}
171-
```
172-
173-
- **Example** (with `fields`):
174-
175-
```yaml
176-
- label: "Testimonials"
177-
name: "testimonials"
178-
widget: "list"
179-
fields:
180-
- {label: Quote, name: quote, widget: string, default: "Everything is awesome!"}
181-
- label: Author
182-
name: author
183-
widget: object
184-
fields:
185-
- {label: Name, name: name, widget: string, default: "Emmet"}
186-
- {label: Avatar, name: avatar, widget: image, default: "/img/emmet.jpg"}
187-
```
188-
189-
190-
## Number
191-
192-
The number widget uses an HTML number input, saving the value as a string, integer, or floating point number.
193-
194-
- **Name:** `number`
195-
- **UI:** HTML [number input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number)
196-
- **Data type:** string by default; configured by `valueType` option
197-
- **Options:**
198-
- `default`: accepts string or number value; defaults to empty string
199-
- `valueType`: accepts `int` or `float`; any other value results in saving as a string
200-
- `min`: accepts a number for minimum value accepted; unset by default
201-
- `max`: accepts a number for maximum value accepted; unset by default
202-
- **Example:**
203-
204-
```yaml
205-
- label: "Puppy Count"
206-
name: "puppies"
207-
widget: "number"
208-
default: 2
209-
valueType: "int"
210-
min: 1
211-
max: 101
212-
```
213-
214-
215-
## Object
216-
217-
The object widget allows you to group multiple widgets together, nested under a single field. You can choose any widget as a child of an object widget—even other objects.
218-
219-
- **Name:** `object`
220-
- **UI:** a field containing one or more child widgets
221-
- **Data type:** list of child widget values
222-
- **Options:**
223-
- `default`: you can set defaults within each sub-field's configuration
224-
- `fields`: (**required**) a nested list of widget fields to include in your widget
225-
- **Example:**
226-
227-
```yaml
228-
- label: "Profile"
229-
name: "profile"
230-
widget: "object"
231-
fields:
232-
- {label: "Public", name: "public", widget: "boolean", default: true}
233-
- {label: "Name", name: "name", widget: "string"}
234-
- label: "Birthdate"
235-
name: "birthdate"
236-
widget: "date"
237-
default: ""
238-
format: "MM/DD/YYYY"
239-
- label: "Address"
240-
name: "address"
241-
widget: "object"
242-
fields:
243-
- {label: "Street Address", name: "street", widget: "string"}
244-
- {label: "City", name: "city", widget: "string"}
245-
- {label: "Postal Code", name: "post-code", widget: "string"}
246-
```
247-
248-
249-
## Relation
250-
251-
The relation widget allows you to reference items from another collection. It provides a search input with a list of entries from the collection you're referencing, and the list automatically updates with matched entries based on what you've typed.
252-
253-
- **Name:** `relation`
254-
- **UI:** text input with search result dropdown
255-
- **Data type:** data type of the value pulled from the related collection item
256-
- **Options:**
257-
- `default`: accepts any widget data type; defaults to an empty string
258-
- `collection`: (**required**) name of the collection being referenced (string)
259-
- `searchFields`: (**required**) list of one or more names of fields in the referenced collection to search for the typed value
260-
- `valueField`: (**required**) name of the field from the referenced collection whose value will be stored for the relation
261-
- **Example** (assuming a separate "authors" collection with "name" and "twitterHandle" fields):
262-
263-
```yaml
264-
- label: Post Author
265-
name: author
266-
widget: relation
267-
collection: authors
268-
searchFields: [name, twitterHandle]
269-
valueField: name
270-
```
271-
The generated UI input will search the authors collection by name and twitterHandle as the user types. On selection, the author name will be saved for the field.
272-
273-
274-
## Select
275-
276-
The select widget allows you to pick a single string value from a dropdown menu.
277-
278-
- **Name:** `select`
279-
- **UI:** HTML select input
280-
- **Data type:** string
281-
- **Options:**
282-
- `default`: accepts a string; defaults to an empty string
283-
- `options`: (**required**) a list of options for the dropdown menu; can be listed in two ways:
284-
- string values: the label displayed in the dropdown is the value saved in the file
285-
- object with `label` and `value` fields: the label displays in the dropdown; the value is saved in the file
286-
- **Example** (options as strings):
287-
288-
```yaml
289-
- label: "Align Content"
290-
name: "align"
291-
widget: "select"
292-
options: ["left", "center", "right"]
293-
```
294-
- **Example** (options as objects):
295-
296-
```yaml
297-
- label: "City"
298-
name: "airport-code"
299-
widget: "select"
300-
options:
301-
- { label: "Chicago", value: "ORD" }
302-
- { label: "Paris", value: "CDG" }
303-
- { label: "Tokyo", value: "HND" }
304-
```
305-
306-
307-
## String
308-
309-
The string widget translates a basic text input to a string value. For larger textarea inputs, use the [text](#text) widget.
310-
311-
- **Name:** `string`
312-
- **UI:** text input
313-
- **Data type:** string
314-
- **Options:**
315-
- `default`: accepts a string; defaults to an empty string
316-
- **Example:**
317-
318-
```yaml
319-
- {label: "Title", name: "title", widget: "string"}
320-
```
321-
322-
323-
## Text
324-
325-
The text widget takes a multiline text field and saves it as a string. For shorter text inputs, use the [string](#string) widget.
326-
327-
- **Name:** `text`
328-
- **UI:** HTML textarea
329-
- **Data type:** string
330-
- **Options:**
331-
- `default`: accepts a string; defaults to an empty string
332-
- **Example:**
333-
334-
```yaml
335-
- {label: "Description", name: "description", widget: "text"}
336-
```
30+
## Default widgets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
label: "Boolean"
3+
target: "boolean"
4+
type: "widget"
5+
---
6+
7+
### Boolean
8+
9+
The boolean widget translates a toggle switch input to a true/false value.
10+
11+
- **Name:** `boolean`
12+
- **UI:** toggle switch
13+
- **Data type:** boolean
14+
- **Options:**
15+
- `default`: accepts `true` or `false`; defaults to `false`
16+
- **Example:**
17+
18+
```yaml
19+
- {label: "Draft", name: "draft", widget: "boolean", default: true}
20+
```

0 commit comments

Comments
 (0)