File tree Expand file tree Collapse file tree 3 files changed +87
-0
lines changed Expand file tree Collapse file tree 3 files changed +87
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import navigation from './widgets/navigation/widget.vue';
1111import status from './widgets/status/widget.vue' ;
1212import textfield from './widgets/textfield/widget.vue' ;
1313import table from './widgets/table/widget.vue' ;
14+ import button from './widgets/button/widget.vue' ;
1415
1516import _store from './core/store' ;
1617import _bus from './core/eventBus' ;
@@ -28,6 +29,7 @@ export const Navigation = navigation;
2829export const Status = status ;
2930export const Textfield = textfield ;
3031export const Table = table ;
32+ export const Button = button ;
3133
3234export const bus = _bus ;
3335export const store = _store ;
Original file line number Diff line number Diff line change 1+ import Button from './widget' ;
2+
3+ describe ( 'Button widget' , ( ) => {
4+ let result ;
5+ let component ;
6+
7+ describe ( 'computed' , ( ) => {
8+ describe ( '#style' , ( ) => {
9+ it ( 'returns the styles' , ( ) => {
10+ component = Button . setup (
11+ {
12+ backgroundColor : 'red' ,
13+ color : 'white'
14+ } ,
15+ { expose : ( ) => 'mock reqired for composition api' }
16+ ) ;
17+
18+ result = component . style . value ;
19+
20+ expect ( result ) . toEqual ( `
21+ background-color: red;
22+ color: white;
23+ ` ) ;
24+ } ) ;
25+ } ) ;
26+ } ) ;
27+ } ) ;
Original file line number Diff line number Diff line change 1+ <!-- eslint-disable vue/no-v-html -->
2+ <template >
3+ <button
4+ :disabled =" disabled"
5+ :style =" style"
6+ >
7+ <slot >
8+ {{ text }}
9+ </slot >
10+ </button >
11+ </template >
12+
13+ <script setup>
14+ import { computed } from ' vue'
15+
16+ const props = defineProps ({
17+ text: {
18+ type: String ,
19+ default: ' ' ,
20+ },
21+ disabled: {
22+ type: Boolean ,
23+ default: false ,
24+ },
25+ backgroundColor: {
26+ type: String ,
27+ default: ' #2C98F0' ,
28+ },
29+ color: {
30+ type: String ,
31+ default: ' #FFF' ,
32+ },
33+ })
34+
35+ const style = computed (() => `
36+ background-color: ${ props .backgroundColor } ;
37+ color: ${ props .color } ;
38+ ` );
39+ </script >
40+
41+ <style lang="stylus">
42+ button {
43+ text-transform : uppercase ;
44+ overflow : hidden ;
45+ padding-left : 8px ;
46+ padding-right : 8px ;
47+ border-radius : 2px ;
48+ cursor : pointer ;
49+ border-style : none ;
50+ font-family : Roboto , "Helvetica Neue" , sans-serif ;
51+
52+ & :hover {
53+ opacity : 0.5 ;
54+ }
55+ }
56+ </style >
57+
58+
You can’t perform that action at this time.
0 commit comments