BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
69be3ce8
Commit
69be3ce8
authored
Oct 13, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add loading button
Encompasses designs from -
https://gitlab.com/gitlab-org/gitlab-ce/issues/23206#note_43355199
-
https://gitlab.com/gitlab-org/gitlab-ce/issues/29985#note_30417407
parent
b3f74903
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
184 additions
and
5 deletions
+184
-5
loading_button.vue
...sets/javascripts/vue_shared/components/loading_button.vue
+71
-0
framework.scss
app/assets/stylesheets/framework.scss
+1
-0
buttons.scss
app/assets/stylesheets/framework/buttons.scss
+5
-0
vue_transitions.scss
app/assets/stylesheets/framework/vue_transitions.scss
+9
-0
repo.scss
app/assets/stylesheets/pages/repo.scss
+0
-5
add-shared-vue-loading-button.yml
changelogs/unreleased/add-shared-vue-loading-button.yml
+5
-0
loading_button_spec.js
.../javascripts/vue_shared/components/loading_button_spec.js
+93
-0
No files found.
app/assets/javascripts/vue_shared/components/loading_button.vue
0 → 100644
View file @
69be3ce8
<
script
>
/* This is a re-usable vue component for rendering a button
that will probably be sending off ajax requests and need
to show the loading status by setting the `loading` option.
This can also be used for initial page load when you don't
know the action of the button yet by setting
`loading: true, label: undefined`.
Sample configuration:
<loading-button
:loading="true"
:label="Hello"
@click="..."
/>
*/
import
loadingIcon
from
'./loading_icon.vue'
;
export
default
{
props
:
{
loading
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
label
:
{
type
:
String
,
required
:
false
,
},
},
components
:
{
loadingIcon
,
},
methods
:
{
onClick
(
e
)
{
this
.
$emit
(
'click'
,
e
);
},
},
};
</
script
>
<
template
>
<button
class=
"btn btn-align-content"
@
click=
"onClick"
type=
"button"
:disabled=
"loading"
>
<transition
name=
"fade"
>
<loading-icon
v-if=
"loading"
:inline=
"true"
class=
"js-loading-button-icon"
:class=
"
{
'append-right-5': label
}"
/>
</transition>
<transition
name=
"fade"
>
<span
v-if=
"label"
class=
"js-loading-button-label"
>
{{
label
}}
</span>
</transition>
</button>
</
template
>
app/assets/stylesheets/framework.scss
View file @
69be3ce8
...
...
@@ -5,6 +5,7 @@
@import
"framework/layout"
;
@import
"framework/animations"
;
@import
"framework/vue_transitions"
;
@import
"framework/avatar"
;
@import
"framework/asciidoctor"
;
@import
"framework/banner"
;
...
...
app/assets/stylesheets/framework/buttons.scss
View file @
69be3ce8
...
...
@@ -292,6 +292,11 @@
}
}
.btn-align-content
{
display
:
flex
;
align-items
:
center
;
}
.btn-group
{
&
.btn-grouped
{
@include
btn-with-margin
;
...
...
app/assets/stylesheets/framework/vue_transitions.scss
0 → 100644
View file @
69be3ce8
.fade-enter-active
,
.fade-leave-active
{
transition
:
opacity
$sidebar-transition-duration
$general-hover-transition-curve
;
}
.fade-enter
,
.fade-leave-to
{
opacity
:
0
;
}
app/assets/stylesheets/pages/repo.scss
View file @
69be3ce8
.fade-enter-active
,
.fade-leave-active
{
transition
:
opacity
$sidebar-transition-duration
;
}
.monaco-loader
{
position
:
absolute
;
top
:
0
;
...
...
changelogs/unreleased/add-shared-vue-loading-button.yml
0 → 100644
View file @
69be3ce8
---
title
:
Add loading button for new UX paradigm
merge_request
:
14883
author
:
type
:
added
spec/javascripts/vue_shared/components/loading_button_spec.js
0 → 100644
View file @
69be3ce8
import
Vue
from
'vue'
;
import
loadingButton
from
'~/vue_shared/components/loading_button.vue'
;
import
mountComponent
from
'../../helpers/vue_mount_component_helper'
;
const
LABEL
=
'Hello'
;
describe
(
'LoadingButton'
,
function
()
{
let
vm
;
let
LoadingButton
;
beforeEach
(()
=>
{
LoadingButton
=
Vue
.
extend
(
loadingButton
);
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'loading spinner'
,
()
=>
{
it
(
'shown when loading'
,
()
=>
{
vm
=
mountComponent
(
LoadingButton
,
{
loading
:
true
,
});
expect
(
vm
.
$el
.
querySelector
(
'.js-loading-button-icon'
)).
toBeDefined
();
});
});
describe
(
'disabled state'
,
()
=>
{
it
(
'disabled when loading'
,
()
=>
{
vm
=
mountComponent
(
LoadingButton
,
{
loading
:
true
,
});
expect
(
vm
.
$el
.
disabled
).
toEqual
(
true
);
});
it
(
'not disabled when normal'
,
()
=>
{
vm
=
mountComponent
(
LoadingButton
,
{
loading
:
false
,
});
expect
(
vm
.
$el
.
disabled
).
toEqual
(
false
);
});
});
describe
(
'label'
,
()
=>
{
it
(
'shown when normal'
,
()
=>
{
vm
=
mountComponent
(
LoadingButton
,
{
loading
:
false
,
label
:
LABEL
,
});
const
label
=
vm
.
$el
.
querySelector
(
'.js-loading-button-label'
);
expect
(
label
.
textContent
.
trim
()).
toEqual
(
LABEL
);
});
it
(
'shown when loading'
,
()
=>
{
vm
=
mountComponent
(
LoadingButton
,
{
loading
:
true
,
label
:
LABEL
,
});
const
label
=
vm
.
$el
.
querySelector
(
'.js-loading-button-label'
);
expect
(
label
.
textContent
.
trim
()).
toEqual
(
LABEL
);
});
});
describe
(
'click callback prop'
,
()
=>
{
it
(
'calls given callback when normal'
,
()
=>
{
vm
=
mountComponent
(
LoadingButton
,
{
loading
:
false
,
});
spyOn
(
vm
,
'$emit'
);
vm
.
$el
.
click
();
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'click'
,
jasmine
.
any
(
Object
));
});
it
(
'does not call given callback when disabled because of loading'
,
()
=>
{
vm
=
mountComponent
(
LoadingButton
,
{
loading
:
true
,
indeterminate
:
true
,
});
spyOn
(
vm
,
'$emit'
);
vm
.
$el
.
click
();
expect
(
vm
.
$emit
).
not
.
toHaveBeenCalled
();
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment