File tree Expand file tree Collapse file tree 5 files changed +50
-15
lines changed Expand file tree Collapse file tree 5 files changed +50
-15
lines changed Original file line number Diff line number Diff line change @@ -25,15 +25,19 @@ <h2 id="basic-pill">Basic Pill</h2>
2525 < fieldset >
2626 < legend > Options</ legend >
2727 < label >
28- < input type ="checkbox " v-model ="isDismissable " />
29- Dismissable
28+ < input type ="checkbox " v-model ="isPersistent " />
29+ Persist
3030 </ label >
3131 </ fieldset >
3232 </ form >
3333 </ header >
3434
3535 < div >
36- < hx-pill :dismissable ="isDismissable " v-text ="content "> </ hx-pill >
36+ < hx-pill
37+ :persist ="isPersistent "
38+ v-text ="content "
39+ @dismiss ="onEvent ">
40+ </ hx-pill >
3741 </ div >
3842
3943 < footer >
Original file line number Diff line number Diff line change @@ -5,13 +5,19 @@ if (document.getElementById('vue-pillDemo')) {
55 el : '#vue-pillDemo' ,
66 data : {
77 content : 'status: unicorns!' ,
8- isDismissable : false ,
8+ isPersistent : false ,
9+ } ,
10+ methods : {
11+ onEvent : function ( evt ) {
12+ evt . preventDefault ( ) ;
13+ alert ( `Event: "${ evt . type } "` ) ;
14+ } ,
915 } ,
1016 computed : {
1117 snippet : function ( ) {
1218 return Util . snippet ( `
1319 <hx-pill
14- ${ this . isDismissable ? 'dismissable ' : '' }
20+ ${ this . isPersistent ? 'persist ' : '' }
1521 >
1622 ${ this . content }
1723 </hx-pill>
Original file line number Diff line number Diff line change 1414 < section >
1515 < h2 > Outside Tables</ h2 >
1616 < p >
17- < hx-pill > Persistent</ hx-pill >
18- < hx-pill dismissable > Dismissible</ hx-pill >
17+ < hx-pill persist > Persistent</ hx-pill >
18+ < hx-pill > Dismissible</ hx-pill >
1919 </ p >
2020 </ section >
2121
@@ -25,12 +25,12 @@ <h2>Inside Tables</h2>
2525 < tbody >
2626 < tr >
2727 < td >
28- < hx-pill > Persistent</ hx-pill >
28+ < hx-pill persist > Persistent</ hx-pill >
2929 </ td >
3030 </ tr >
3131 < tr >
3232 < td >
33- < hx-pill dismissable > Dismissable</ hx-pill >
33+ < hx-pill > Dismissable</ hx-pill >
3434 </ td >
3535 </ tr >
3636 </ tbody >
@@ -43,12 +43,12 @@ <h2>Inside Tables (Condensed)</h2>
4343 < tbody >
4444 < tr >
4545 < td >
46- < hx-pill > Persistent</ hx-pill >
46+ < hx-pill persist > Persistent</ hx-pill >
4747 </ td >
4848 </ tr >
4949 < tr >
5050 < td >
51- < hx-pill dismissable > Dismissable</ hx-pill >
51+ < hx-pill > Dismissable</ hx-pill >
5252 </ td >
5353 </ tr >
5454 </ tbody >
Original file line number Diff line number Diff line change @@ -32,12 +32,35 @@ export class HXPillElement extends HXElement {
3232
3333 $onConnect ( ) {
3434 this . _btnDismiss . addEventListener ( 'click' , this . _onDismiss ) ;
35+ this . $upgradeProperty ( 'persist' ) ;
3536 }
3637
3738 $onDisconnect ( ) {
3839 this . _btnDismiss . removeEventListener ( 'click' , this . _onDismiss ) ;
3940 }
4041
42+ static get $observedAttributes ( ) {
43+ return [ 'persist' ] ;
44+ }
45+
46+ /**
47+ * Property reflecting the `persist` HTML attribute, indicating whether the
48+ * pill may be dismissed. If true, the dismiss button will not be shown.
49+ *
50+ * @default false
51+ * @type {Boolean }
52+ */
53+ get persist ( ) {
54+ return this . hasAttribute ( 'persist' ) ;
55+ }
56+ set persist ( value ) {
57+ if ( value ) {
58+ this . setAttribute ( 'persist' , '' ) ; // boolean
59+ } else {
60+ this . removeAttribute ( 'persist' ) ;
61+ }
62+ }
63+
4164 /**
4265 * Dismiss the pill (removes element from the DOM)
4366 */
Original file line number Diff line number Diff line change 1717 #Button .reset ();
1818 align-items : center ;
1919 color : @gray-600 ;
20- display : none ;
20+ display : inline-flex ;
2121 height : 1.5em ;
2222 justify-content : center ;
2323 margin : 0 -0.5rem 0 0 ;
3333 }
3434}
3535
36- :host ([dismissable]) {
37- #hxDismiss {
38- display : inline-flex ;
36+ :host ([persist]) {
37+ #hxPill {
38+ #hxDismiss {
39+ display : none ;
40+ }
3941 }
4042}
You can’t perform that action at this time.
0 commit comments