Skip to content

Commit 2ca9146

Browse files
committed
Add button
1 parent bccc7a6 commit 2ca9146

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import navigation from './widgets/navigation/widget.vue';
1111
import status from './widgets/status/widget.vue';
1212
import textfield from './widgets/textfield/widget.vue';
1313
import table from './widgets/table/widget.vue';
14+
import button from './widgets/button/widget.vue';
1415

1516
import _store from './core/store';
1617
import _bus from './core/eventBus';
@@ -28,6 +29,7 @@ export const Navigation = navigation;
2829
export const Status = status;
2930
export const Textfield = textfield;
3031
export const Table = table;
32+
export const Button = button;
3133

3234
export const bus = _bus;
3335
export const store = _store;

src/widgets/button/widget.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
});

src/widgets/button/widget.vue

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+

0 commit comments

Comments
 (0)