Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 774202e

Browse files
committed
feat(focus): focusing of button composition api
1 parent 19b54a2 commit 774202e

File tree

7 files changed

+80
-12
lines changed

7 files changed

+80
-12
lines changed

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@babel/preset-env": "^7.6.3",
16+
"@vue/composition-api": "^0.3.2",
1617
"core-js": "^2.6.5",
1718
"css-loader": "^3.2.0",
1819
"esm": "^3.2.25",

Diff for: src/App.vue

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
<template>
22
<div>
3-
{{ greeting }}
4-
<Button>Simple text</Button>
3+
{{ state.greeting }}
4+
<Button>{{ state.buttonText }}</Button>
5+
<Button @click="increment" variant="ghost" color="success" size="lg" > Increment </Button>
6+
<br>
7+
<h1>{{ state.count }}</h1>
58
</div>
69
</template>
710

811
<script>
9-
import Button from './components/Button/index'
12+
import Button from './components/Button'
13+
import { useIncrement } from './use-increment'
1014
1115
export default {
16+
setup () {
17+
const { state, increment } = useIncrement()
18+
19+
return {
20+
state,
21+
increment
22+
}
23+
},
1224
name: 'App',
1325
components: {
1426
Button
15-
},
16-
data () {
17-
return {
18-
greeting: 'Hi!'
19-
}
2027
}
2128
}
2229
</script>

Diff for: src/lib/styles/components/Button.scss

+30-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
font-weight: bold;
88
border: none;
99
transition: all 0.2s ease-in;
10+
outline: none;
1011

1112
&.rounded {
1213
border-radius: 999px;
@@ -30,13 +31,13 @@
3031
background-image: radial-gradient(circle, rgb(255, 255, 255) 10%, transparent 10.01%);
3132
background-repeat: no-repeat;
3233
background-position: 50%;
33-
transform: scale(10,10);
34+
transform: scale(10, 10);
3435
opacity: 0;
3536
transition: transform .5s, opacity 1s;
3637
}
3738

3839
&:active::after {
39-
transform: scale(0,0);
40+
transform: scale(0, 0);
4041
opacity: .2;
4142
transition: 0s;
4243
}
@@ -47,6 +48,10 @@
4748
background: $primary;
4849
color: lighten($primary, 45%);
4950

51+
&:focus {
52+
box-shadow: rgba($primary, 0.6) 0px 0px 0px 3px;
53+
}
54+
5055
&.solid {
5156
background: $primary;
5257
color: lighten($primary, 50%);
@@ -121,6 +126,10 @@
121126
background: $secondary;
122127
color: lighten($secondary, 45%);
123128

129+
&:focus {
130+
box-shadow: rgba($secondary, 0.6) 0px 0px 0px 3px;
131+
}
132+
124133
&.shadow {
125134
box-shadow: 0px 2px 4px rgba($secondary, 0.5);
126135
}
@@ -198,6 +207,10 @@
198207
background: $success;
199208
color: $light;
200209

210+
&:focus {
211+
box-shadow: rgba($success, 0.6) 0px 0px 0px 3px;
212+
}
213+
201214
&.shadow {
202215
box-shadow: 0px 2px 4px rgba($success, 0.5);
203216
}
@@ -275,6 +288,10 @@
275288
background: $warning;
276289
color: lighten($warning, 45%);
277290

291+
&:focus {
292+
box-shadow: rgba($warning, 0.6) 0px 0px 0px 3px;
293+
}
294+
278295
&.shadow {
279296
box-shadow: 0px 2px 4px rgba($warning, 0.5);
280297
}
@@ -352,6 +369,10 @@
352369
background: $danger;
353370
color: lighten($danger, 45%);
354371

372+
&:focus {
373+
box-shadow: rgba($danger, 0.6) 0px 0px 0px 3px;
374+
}
375+
355376
&.shadow {
356377
box-shadow: 0px 2px 4px rgba($danger, 0.5);
357378
}
@@ -429,7 +450,9 @@
429450
background: $dark;
430451
color: lighten($dark, 45%);
431452

432-
&.ripple {}
453+
&:focus {
454+
box-shadow: rgba($dark, 0.6) 0px 0px 0px 3px;
455+
}
433456

434457
&.shadow {
435458
box-shadow: 0px 2px 4px rgba($dark, 0.5);
@@ -509,6 +532,10 @@
509532
background: $light;
510533
color: lighten($light, 45%);
511534

535+
&:focus {
536+
box-shadow: rgba($light, 0.6) 0px 0px 0px 3px;
537+
}
538+
512539
&.shadow {
513540
box-shadow: 0px 2px 4px rgba($light, 0.5);
514541
}

Diff for: src/main.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import Vue from 'vue'
2+
import VueCompositionApi from '@vue/composition-api'
23
import App from './App.vue'
34
import './registerServiceWorker'
45
import Kiwi from './lib/plugin'
56

67
Vue.config.productionTip = false
78

9+
Vue.use(VueCompositionApi)
10+
811
// Install Kiwi plugin
912
Vue.use(Kiwi, {
1013
theme: {

Diff for: src/scss/focus.scss

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.focus {
2+
box-shadow: rgba(24, 170, 228, 0.6) 0px 0px 0px 3px;
3+
}

Diff for: src/use-increment.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { reactive, onMounted } from '@vue/composition-api'
2+
3+
export function useIncrement () {
4+
const state = reactive({
5+
greeting: 'Hi!',
6+
buttonText: 'Simple Text',
7+
count: 0
8+
})
9+
10+
// Methods
11+
const increment = () => state.count++
12+
13+
onMounted(() => {
14+
console.log('Mounted App')
15+
})
16+
17+
return {
18+
state, increment
19+
}
20+
}

Diff for: yarn.lock

+8-1
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,13 @@
19361936
source-map "~0.6.1"
19371937
vue-template-es2015-compiler "^1.9.0"
19381938

1939+
"@vue/composition-api@^0.3.2":
1940+
version "0.3.2"
1941+
resolved "https://registry.yarnpkg.com/@vue/composition-api/-/composition-api-0.3.2.tgz#2d797028e489bf7812f08c7bb33ffd03ef23c617"
1942+
integrity sha512-fD4dn9cJX62QSP2TMFLXCOQOa+Bu2o7kWDjrU/FNLkNqPPcCKBLxCH/Lc+gNCRBKdEUGyI3arjAw7j0Yz1hnvw==
1943+
dependencies:
1944+
tslib "^1.9.3"
1945+
19391946
"@vue/eslint-config-standard@^4.0.0":
19401947
version "4.0.0"
19411948
resolved "https://registry.yarnpkg.com/@vue/eslint-config-standard/-/eslint-config-standard-4.0.0.tgz#6be447ee674e3b0f733c584098fd9a22e6d76fcd"
@@ -13372,7 +13379,7 @@ tsconfig@^7.0.0:
1337213379
strip-bom "^3.0.0"
1337313380
strip-json-comments "^2.0.0"
1337413381

13375-
tslib@^1.9.0:
13382+
tslib@^1.9.0, tslib@^1.9.3:
1337613383
version "1.10.0"
1337713384
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
1337813385
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==

0 commit comments

Comments
 (0)