debian-mirror-gitlab/doc/development/fe_guide/components.md

63 lines
1.6 KiB
Markdown
Raw Normal View History

2018-03-27 19:54:05 +05:30
# Components
## Contents
2019-03-02 22:35:43 +05:30
- [Dropdowns](#dropdowns)
- [Modals](#modals)
2018-03-27 19:54:05 +05:30
## Dropdowns
2019-02-15 15:39:39 +05:30
See also the [corresponding UX guide](https://design.gitlab.com/#/components/dropdowns).
2018-03-27 19:54:05 +05:30
### How to style a bootstrap dropdown
2019-03-02 22:35:43 +05:30
2018-03-27 19:54:05 +05:30
1. Use the HTML structure provided by the [docs][bootstrap-dropdowns]
1. Add a specific class to the top level `.dropdown` element
```Haml
.dropdown.my-dropdown
%button{ type: 'button', data: { toggle: 'dropdown' }, 'aria-haspopup': true, 'aria-expanded': false }
%span.dropdown-toggle-text
Toggle Dropdown
= icon('chevron-down')
%ul.dropdown-menu
%li
%a
item!
```
Or use the helpers
```Haml
.dropdown.my-dropdown
= dropdown_toggle('Toogle!', { toggle: 'dropdown' })
= dropdown_content
%li
%a
item!
```
[bootstrap-dropdowns]: https://getbootstrap.com/docs/3.3/javascript/#dropdowns
## Modals
2019-02-15 15:39:39 +05:30
See also the [corresponding UX guide](https://design.gitlab.com/#/components/modals).
2018-03-27 19:54:05 +05:30
2018-12-05 23:21:45 +05:30
We have a reusable Vue component for modals: [vue_shared/components/gl_modal.vue](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/assets/javascripts/vue_shared/components/gl_modal.vue)
2018-03-27 19:54:05 +05:30
Here is an example of how to use it:
```html
<gl-modal
id="dogs-out-modal"
:header-title-text="s__('ModalExample|Let the dogs out?')"
footer-primary-button-variant="danger"
:footer-primary-button-text="s__('ModalExample|Let them out')"
@submit="letOut(theDogs)"
>
{{ s__('ModalExample|Youre about to let the dogs out.') }}
</gl-modal>
```
![example modal](img/gl-modal.png)