Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc generation #86

Merged
merged 12 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ checkout:
post:
- git pull origin ${CIRCLE_BRANCH}
- git clone git@github.com:wholesale-design-system/styleguide.git
- git config --global user.email circleci@circleci
- git config --global user.email t.schlage@gmx.net
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use different PRs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the future

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say, in the future something like "tech-fabric@zalando.de" where all engineers working with it are subscribed ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said you can create such a user if you want :D
I don't know where to store the credentials in a secure way so that also peoples after us get the access.

- git config --global user.name "${CIRCLE_PROJECT_USERNAME}"

dependencies:
Expand Down
45 changes: 45 additions & 0 deletions doc/components/date-picker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Date Picker

## Simple date picker
A date picker consist in general of an input element and a picker dialog which appears when the input
is focused and gives the user the ability to select a date in a natural way. Our date picker is a complete
component which comes with all of these. As with all of our components the changes are propagated via
custom change events which contains details about the selected date as object and pre-formatted string.
Like a common input element you can set the `placeholder` and `value` attribute while the value has to be
a date string which is parsable by `Date.parse()` or which matches the value in the `format` attribute if specified.

<ws-date-picker placeholder="Select a date" change.delegate="log('Date1 changed', $event)"></ws-date-picker>
```html
<ws-date-picker placeholder="Select a date" id="date1"></ws-date-picker>
<script>
document.getElementById('date1').addEventListener('change', event => console.log('Date1 changed', event));
</script>
```

## Formatting dates
If you have a localized website or simply have a global date format you want to use, you can change the
formatting of the date picker component by adding the `format` attribute. The pattern for the format follows
the rules of the [flatpickr](https://chmln.github.io/flatpickr/formatting/). For instance `Y-m-d` will
result in the date `2017-06-04` which will be displayed in the input and passed through the change event.

<ws-date-picker value="2017-06-04" format="Y-m-d" change.delegate="log('Date2 changed', $event.detail.value)"></ws-date-picker>
```html
<ws-date-picker value="2017-06-04" format="Y-m-d" id="date2"></ws-date-picker>
<script>
document.getElementById('date2').addEventListener('change', event => console.log('Date2 changed', event));
</script>
```

## Custom options
Since our date picker is based on the flatpickr you can configure it like the flatpickr by passing an
object through the `options` attribute. All possible options can be found [here](https://chmln.github.io/flatpickr/options/).

<ws-date-picker value="2017-06-15" format="Y-m-d" options.bind="{minDate: '2017-06-01', maxDate: '2017-06-24'}"></ws-date-picker>
```html
<ws-date-picker
value="2017-06-15"
format="Y-m-d"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need format?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it was a requirement by CAT and it makes sense because the backend requires specific date formats.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the displaying of the date should be unified. @wholesale-design-system/ux
Processing the date afterwards to send it to the backend can be done by each application differently.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can align for Wholesale but since we want to give the styleguide to others we can not enforce them to use a specific formatting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed in #87

options='{"minDate": "2017-06-01", "maxDate": "2017-06-24"}'>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we change the format directly to min/max attributes like discussed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but lets to this in a specific PR :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

</ws-date-picker>
```

5 changes: 5 additions & 0 deletions doc/components/dropdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ like `text="Click me" icon="icon-filter"`. As following you can see an example o
</div>
</div>

**Disabled**
As any common html element the dropdown can be disabled by adding the `disabled="1"` flag to it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disabled="1" is confusing. disabled is not really a boolean attribute: https://codepen.io/anon/pen/NgpZYe

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend just using "disabled"

Copy link
Contributor Author

@fragsalat fragsalat Jun 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not working everywhere. The problem is that disabled will result in the property disabled: "" which will be false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a React thing?
if it is about implementation do the check props.disabled!==undefined (or sth like that) this results in the same behaviour as native

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a HTML and wrapper thing. If you call getAttribute('name') and you define disabled as a flag it will return an empty string which will be false. So either you define a list of boolean attributes or create the convention that every attribute which has an empty string will be boolean. Btw as far as I know disabled="1" is valid HTML.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is valid HTML but I just say it gives the wrong impression as disabled="false" is still disabling a button: https://codepen.io/anon/pen/owwdEp

My approach is here https://codepen.io/anon/pen/GEEdXP

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, as you both discussed this I checked if disabled="1" is really valid XHTML specification and it is not. If you use W3C Validator it shows you an error.

For example, setting the disabled attribute to the value "false" is disallowed, because despite the appearance of meaning that the element is enabled, it in fact means that the element is disabled (what matters for implementations is the presence of the attribute, not its value).

or

A number of attributes are boolean attributes. The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.

from here:
http://w3c.github.io/html/single-page.html#sec-boolean-attributes

so basically:

<input type="text" disabled />
<input type="text" disabled="" />
<input type="text" disabled="disabled" />

See: https://codepen.io/fokusferit/pen/gRoWKd (disabled="{0,1, lala, ...}" everything disables the button.

The style of the trigger will change and the dropdown con not be opened any more.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: con => can

<ws-dropdown type="button" text="Click me" items.bind='["Item 1", "Item 2"]' disabled="1"></ws-dropdown>

**Items**:
All dropdown elements requires the items attribute to be specified with an list of dropdown items.
An item can be either a simple string or a object containing the following keys:
Expand Down
52 changes: 52 additions & 0 deletions doc/components/notification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Notification

## Setup
Because the notifications are elements which should be displayed on top of everything and relative to the window
you have to add the tag `<ws-notification></ws-notification>` to the most root container you can add.
So either document body or the application root depending on your setup. This notification element is
just the holder / list of notifications.

## Creating notifications
To create a notification you have to publish a custom event to the window containing the relevant data.
The type of the event has to be `ws-notification-open` and the details has to be an object containing:
- **title**: string, required
- **description**: string, optional
- **type**: info|error|warning|success, default: info
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk maybe mention those are strings?

- **lifetime**: number, milliseconds until disappearing, default: 2147483647

<button class="mod-small" id="notification1" click.delegate="notification({title: 'Do you want to stay logged in?', type: 'info', lifetime: 5000})">Show notification</button>
```html
<button class="mod-small" id="notification1">Show notification</button>
<script type="text/javascript">
document.getElementById('notification1').addEventListener('click', event => {
window.dispatchEvent(new CustomEvent('ws-notification-open', {detail: {title: 'Do you want to stay logged in?', type: 'info', lifetime: 5000}}));
});
</script>
```

## Options
Here you can try out the different combinations of the options you can provide to the notification.
<div class="row collapse">
<div class="column small-6">
<label>Title</label>
<input type="text" placeholder="Title" value="Some title" ref="navTitle" />
</div>
<div class="column small-6">
<label>Description</label>
<input type="text" placeholder="Title" ref="navDescription" />
</div>
<div class="column small-6">
<label>Type</label>
<select ref="navType">
<option value="info">Info</option>
<option value="success">Success</option>
<option value="warning">Warning</option>
<option value="error">Error</option>
</select>
</div>
<div class="column small-6">
<label>Lifetime</label>
<input type="number" placeholder="Title" value="5000" ref="navLifetime" />
</div>
</div></br>
<button class="mod-small" click.delegate="notification({title: navTitle.value, description: navDescription.value, type: navType.value, lifetime: navLifetime.value})">Show notification</button>