Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
ce22a183
Commit
ce22a183
authored
5 years ago
by
Bekerle, Patrizio
Committed by
Reiter, Christoph
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add attribute for disabling the spinner, the disabled property and documenation
parent
a4a64997
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/common/vpu-button.js
+39
-7
39 additions, 7 deletions
packages/common/vpu-button.js
with
39 additions
and
7 deletions
packages/common/vpu-button.js
+
39
−
7
View file @
ce22a183
import
{
html
,
LitElement
,
css
}
from
'
lit-element
'
;
import
*
as
commonUtils
from
'
./utils.js
'
;
import
bulmaCSSPath
from
'
bulma/css/bulma.min.css
'
;
import
VPULitElement
from
'
./vpu-lit-element.js
'
;
class
Button
extends
LitElement
{
/**
* vpu-button implements a button with Bulma styles and automatic spinner and
* disabling if button is clicked
*
* Use the attribute "no-spinner-on-click" to disable the spinner, then you can
* start it with start() and stop it with stop()
*
* Use the attribute "type" to set Bulma styles like "is-info"
* See https://bulma.io/documentation/elements/button/#colors for a list of all styles
*/
class
Button
extends
VPULitElement
{
constructor
()
{
super
();
this
.
value
=
""
;
// see: https://bulma.io/documentation/elements/button/#colors
this
.
type
=
"
primary
"
;
this
.
type
=
"
is-
primary
"
;
this
.
spinner
=
false
;
this
.
s
pinnerOnClick
=
tru
e
;
this
.
noS
pinnerOnClick
=
fals
e
;
this
.
disabled
=
false
;
this
.
button
=
null
;
}
connectedCallback
()
{
super
.
connectedCallback
();
const
that
=
this
;
this
.
updateComplete
.
then
(()
=>
{
this
.
button
=
this
.
_
(
"
button
"
);
});
}
static
get
properties
()
{
...
...
@@ -19,7 +39,7 @@ class Button extends LitElement {
value
:
{
type
:
String
},
type
:
{
type
:
String
},
spinner
:
{
type
:
Boolean
},
s
pinnerOnClick
:
{
type
:
Boolean
,
attribute
:
'
spinner-on-click
'
},
noS
pinnerOnClick
:
{
type
:
Boolean
,
attribute
:
'
no-
spinner-on-click
'
},
disabled
:
{
type
:
Boolean
},
};
}
...
...
@@ -29,13 +49,25 @@ class Button extends LitElement {
}
clickHandler
()
{
if
(
this
.
s
pinnerOnClick
)
{
this
.
s
pinner
=
true
;
if
(
!
this
.
noS
pinnerOnClick
)
{
this
.
s
tart
()
;
}
}
start
()
{
this
.
spinner
=
true
;
this
.
disabled
=
true
;
this
.
setAttribute
(
"
disabled
"
,
"
disabled
"
);
}
stop
()
{
this
.
spinner
=
false
;
this
.
disabled
=
false
;
this
.
removeAttribute
(
"
disabled
"
);
}
isDisabled
()
{
return
this
.
button
.
hasAttribute
(
"
disabled
"
);
}
render
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment