Skip to content

Commit adafaec

Browse files
committed
feat(documentation): Added new doc for date picker and notification
1 parent 4573649 commit adafaec

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

doc/components/date-picker.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Date Picker
2+
3+
## Simple date picker
4+
A date picker consist in general of an input element and a picker dialog which appears when the input
5+
is focused and gives the user the ability to select a date in a natural way. Our date picker is a complete
6+
component which comes with all of these. As with all of our components the changes are propagated via
7+
custom change events which contains details about the selected date as object and pre-formatted string.
8+
Like a common input element you can set the `placeholder` and `value` attribute while the value has to be
9+
a date string which is parsable by `Date.parse()` or which matches the value in the `format` attribute if specified.
10+
11+
<ws-date-picker placeholder="Select a date" change.delegate="log('Date1 changed', $event)"></ws-date-picker>
12+
```html
13+
<ws-date-picker placeholder="Select a date" id="date1"></ws-date-picker>
14+
<script>
15+
document.getElementById('date1').addEventListener('change', event => console.log('Date1 changed', event));
16+
</script>
17+
```
18+
19+
## Formatting dates
20+
If you have a localized website or simply have a global date format you want to use, you can change the
21+
formatting of the date picker component by adding the `format` attribute. The pattern for the format follows
22+
the rules of the [flatpickr](https://chmln.github.io/flatpickr/formatting/). For instance `Y-m-d` will
23+
result in the date `2017-06-04` which will be displayed in the input and passed through the change event.
24+
25+
<ws-date-picker value="2017-06-04" format="Y-m-d" change.delegate="log('Date2 changed', $event.detail.value)"></ws-date-picker>
26+
```html
27+
<ws-date-picker value="2017-06-04" format="Y-m-d" id="date2"></ws-date-picker>
28+
<script>
29+
document.getElementById('date2').addEventListener('change', event => console.log('Date2 changed', event));
30+
</script>
31+
```
32+
33+
## Custom options
34+
Since our date picker is based on the flatpickr you can configure it like the flatpickr by passing an
35+
object through the `options` attribute. All possible options can be found [here](https://chmln.github.io/flatpickr/options/).
36+
37+
<ws-date-picker value="2017-06-15" format="Y-m-d" options.bind="{minDate: '2017-06-01', maxDate: '2017-06-24'}"></ws-date-picker>
38+
```html
39+
<ws-date-picker
40+
value="2017-06-15"
41+
format="Y-m-d"
42+
options='{"minDate": "2017-06-01", "maxDate": "2017-06-24"}'>
43+
</ws-date-picker>
44+
```
45+

doc/components/dropdown.md

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ like `text="Click me" icon="icon-filter"`. As following you can see an example o
2626
</div>
2727
</div>
2828

29+
**Disabled**
30+
As any common html element the dropdown can be disabled by adding the `disabled="1"` flag to it.
31+
The style of the trigger will change and the dropdown con not be opened any more.
32+
<ws-dropdown type="button" text="Click me" items.bind='["Item 1", "Item 2"]' disabled="1"></ws-dropdown>
33+
2934
**Items**:
3035
All dropdown elements requires the items attribute to be specified with an list of dropdown items.
3136
An item can be either a simple string or a object containing the following keys:

doc/components/notification.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Notification
2+
3+
## Setup
4+
Because the notifications are elements which should be displayed on top of everything and relative to the window
5+
you have to add the tag `<ws-notification></ws-notification>` to the most root container you can add.
6+
So either document body or the application root depending on your setup. This notification element is
7+
just the holder / list of notifications.
8+
9+
## Creating notifications
10+
To create a notification you have to publish a custom event to the window containing the relevant data.
11+
The type of the event has to be `ws-notification-open` and the details has to be an object containing:
12+
- **title**: string, required
13+
- **description**: string, optional
14+
- **type**: info|error|warning|success, default: info
15+
- **lifetime**: number, milliseconds until disappearing, default: 2147483647
16+
17+
<button class="mod-small" id="notification1" click.delegate="notification({title: 'Do you want to stay logged in?', type: 'info', lifetime: 5000})">Show notification</button>
18+
```html
19+
<button class="mod-small" id="notification1">Show notification</button>
20+
<script type="text/javascript">
21+
document.getElementById('notification1').addEventListener('click', event => {
22+
window.dispatchEvent(new CustomEvent('ws-notification-open', {detail: {title: 'Do you want to stay logged in?', type: 'info', lifetime: 5000}}));
23+
});
24+
</script>
25+
```
26+
27+
## Options
28+
Here you can try out the different combinations of the options you can provide to the notification.
29+
<div class="row collapse">
30+
<div class="column small-6">
31+
<label>Title</label>
32+
<input type="text" placeholder="Title" value="Some title" ref="navTitle" />
33+
</div>
34+
<div class="column small-6">
35+
<label>Description</label>
36+
<input type="text" placeholder="Title" ref="navDescription" />
37+
</div>
38+
<div class="column small-6">
39+
<label>Type</label>
40+
<select ref="navType">
41+
<option value="info">Info</option>
42+
<option value="success">Success</option>
43+
<option value="warning">Warning</option>
44+
<option value="error">Error</option>
45+
</select>
46+
</div>
47+
<div class="column small-6">
48+
<label>Lifetime</label>
49+
<input type="number" placeholder="Title" value="5000" ref="navLifetime" />
50+
</div>
51+
</div></br>
52+
<button class="mod-small" click.delegate="notification({title: navTitle.value, description: navDescription.value, type: navType.value, lifetime: navLifetime.value})">Show notification</button>

0 commit comments

Comments
 (0)