Skip to content

Commit 74d9998

Browse files
committed
Component box, css binding & copy css to clipboard added
1 parent 380435d commit 74d9998

File tree

11 files changed

+189
-11
lines changed

11 files changed

+189
-11
lines changed

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"lint": "vue-cli-service lint"
99
},
1010
"dependencies": {
11-
"vue": "^2.6.6"
11+
"raw-loader": "^1.0.0",
12+
"vue": "^2.6.6",
13+
"vue-clipboard2": "^0.3.0"
1214
},
1315
"devDependencies": {
1416
"@vue/cli-plugin-babel": "^3.4.0",

public/favicon.ico

-1.12 KB
Binary file not shown.

src/App.vue

+40-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
<template>
22
<div id="app">
33
<NavBar></NavBar>
4+
<h3>Click on the animation to copy.</h3>
5+
<div class="wrapper">
6+
<Box :rawCss="borderLeftRight">Hover me</Box>
7+
<Box></Box>
8+
<Box></Box>
9+
<Box></Box>
10+
<Box></Box>
11+
<Box></Box>
12+
<Box></Box>
13+
<Box></Box>
14+
<Box></Box>
15+
<Box></Box>
16+
</div>
417
</div>
518
</template>
619

720
<script>
821
import NavBar from '@/components/NavBar.vue';
22+
import Box from '@/components/Box.vue';
23+
import rawCss from '@/styles/index';
924
1025
export default {
1126
name: 'app',
12-
components: { NavBar },
27+
28+
components: { NavBar, Box },
29+
30+
data() {
31+
return {
32+
rawCss,
33+
};
34+
},
1335
};
1436
</script>
1537

@@ -21,12 +43,28 @@ export default {
2143
}
2244
2345
body {
24-
background: #F3F7F9;
46+
background: #fcfdff;
2547
font-family: europa, sans-serif;
2648
-webkit-font-smoothing: antialiased;
2749
-moz-osx-font-smoothing: grayscale;
2850
color: #474E51;
2951
margin: 0;
3052
padding: 0;
53+
font-size: 1.6rem;
54+
}
55+
56+
.wrapper {
57+
width: 70%;
58+
margin: 0 auto;
59+
display: grid;
60+
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
61+
justify-items: center;
62+
}
63+
64+
h3 {
65+
text-align: center;
66+
font-size: 2rem;
67+
margin-bottom: 4rem;
68+
margin-top: 0;
3169
}
3270
</style>

src/assets/logo.png

-6.69 KB
Binary file not shown.

src/components/Box.vue

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<div class="box" v-clipboard:copy="css">
3+
<div class="slot-wrapper">
4+
<slot></slot>
5+
</div>
6+
</div>
7+
</template>
8+
9+
<script>
10+
export default {
11+
name: 'Box.vue',
12+
13+
data() {
14+
return {
15+
css: this.rawCss,
16+
};
17+
},
18+
19+
props: {
20+
rawCss: {
21+
type: String,
22+
default: '',
23+
},
24+
},
25+
methods: {
26+
onCopy(e) {
27+
alert(`You just copied: ${e.text}`);
28+
},
29+
onError(e) {
30+
alert('Failed to copy texts');
31+
},
32+
},
33+
};
34+
</script>
35+
36+
<style lang="scss" scoped>
37+
38+
</style>

src/components/NavBar.vue

+20-8
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ export default {
1616

1717
<style lang="scss" scoped>
1818
.wrapper {
19-
width: 80%;
19+
width: 75%;
2020
margin: 0 auto;
2121
display: flex;
2222
justify-content: space-between;
2323
align-items: center;
24-
padding: 20px 0;
24+
padding: 4rem 0;
2525
}
2626
2727
h1 {
2828
font-size: 2.6rem;
2929
display: inline-block;
30+
3031
span {
3132
color: #5878F3;
3233
}
@@ -35,20 +36,31 @@ export default {
3536
display: inline-block;
3637
color: #D8ECF6;
3738
font-size: 1.6rem;
38-
border-radius: 40px;
39+
border-radius: 4rem;
3940
background: #5878F3;
40-
width: 160px;
41-
padding: 10px 0;
41+
width: 16rem;
42+
padding: 1rem 0;
4243
text-align: center;
4344
text-decoration: none;
44-
box-shadow: 0 4px 6px rgba(50,50,93,.11), 0 1px 3px rgba(0,0,0,.08);
45+
box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
46+
4547
&:last-of-type {
4648
background: #fff;
4749
color: #5878F3;
50+
51+
&:hover {
52+
background: darken(#fff, 3);
53+
color: #5878F3;
54+
}
4855
}
56+
57+
&:hover {
58+
background: lighten(#5878F3, 3);
59+
color: lighten(#D8ECF6, 3);
60+
}
61+
4962
&:not(:last-child) {
50-
margin-right: 50px;
63+
margin-right: 5rem;
5164
}
5265
}
53-
5466
</style>

src/main.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import Vue from 'vue';
2+
import VueClipboard from 'vue-clipboard2';
23
import App from './App.vue';
34

5+
import './styles/borderLeftRight.css';
6+
47
Vue.config.productionTip = false;
8+
Vue.use(VueClipboard);
59

610
new Vue({
711
render: h => h(App),

src/styles/borderLeftRight.css

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.slot-wrapper {
2+
display: inline-block;
3+
position: relative;
4+
color: #474E51;
5+
cursor: pointer;
6+
}
7+
.slot-wrapper::after {
8+
content: '';
9+
position: absolute;
10+
width: 100%;
11+
transform: scaleX(0);
12+
height: 2px;
13+
bottom: 0;
14+
left: 0;
15+
background-color: #5878F3;
16+
transform-origin: bottom right;
17+
transition: transform 0.25s ease-out;
18+
}
19+
.slot-wrapper:hover::after {
20+
transform: scaleX(1);
21+
transform-origin: bottom left;
22+
}

src/styles/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import borderLeftRight from '!raw-loader!./borderLeftRight.css';
2+
3+
4+
export default {
5+
borderLeftRight,
6+
};

vue.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
configureWebpack: {
3+
rules: [
4+
{
5+
test: /\.txt$/i,
6+
use: 'raw-loader',
7+
},
8+
],
9+
},
10+
};

yarn.lock

+46
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,15 @@ cli-width@^2.0.0:
19591959
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
19601960
integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=
19611961

1962+
clipboard@^2.0.0:
1963+
version "2.0.4"
1964+
resolved "https://registry.yarnpkg.com/clipboard/-/clipboard-2.0.4.tgz#836dafd66cf0fea5d71ce5d5b0bf6e958009112d"
1965+
integrity sha512-Vw26VSLRpJfBofiVaFb/I8PVfdI1OxKcYShe6fm0sP/DtmiWQNCjhM/okTvdCo0G+lMMm1rMYbk4IK4x1X+kgQ==
1966+
dependencies:
1967+
good-listener "^1.2.2"
1968+
select "^1.1.2"
1969+
tiny-emitter "^2.0.0"
1970+
19621971
clipboardy@^1.2.3:
19631972
version "1.2.3"
19641973
resolved "https://registry.yarnpkg.com/clipboardy/-/clipboardy-1.2.3.tgz#0526361bf78724c1f20be248d428e365433c07ef"
@@ -2621,6 +2630,11 @@ delayed-stream@~1.0.0:
26212630
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
26222631
integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk=
26232632

2633+
delegate@^3.1.2:
2634+
version "3.2.0"
2635+
resolved "https://registry.yarnpkg.com/delegate/-/delegate-3.2.0.tgz#b66b71c3158522e8ab5744f720d8ca0c2af59166"
2636+
integrity sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==
2637+
26242638
delegates@^1.0.0:
26252639
version "1.0.0"
26262640
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
@@ -3788,6 +3802,13 @@ globby@^9.0.0:
37883802
pify "^4.0.1"
37893803
slash "^2.0.0"
37903804

3805+
good-listener@^1.2.2:
3806+
version "1.2.2"
3807+
resolved "https://registry.yarnpkg.com/good-listener/-/good-listener-1.2.2.tgz#d53b30cdf9313dffb7dc9a0d477096aa6d145c50"
3808+
integrity sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=
3809+
dependencies:
3810+
delegate "^3.1.2"
3811+
37913812
graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6:
37923813
version "4.1.15"
37933814
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"
@@ -6357,6 +6378,14 @@ raw-body@2.3.3:
63576378
iconv-lite "0.4.23"
63586379
unpipe "1.0.0"
63596380

6381+
raw-loader@^1.0.0:
6382+
version "1.0.0"
6383+
resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-1.0.0.tgz#3f9889e73dadbda9a424bce79809b4133ad46405"
6384+
integrity sha512-Uqy5AqELpytJTRxYT4fhltcKPj0TyaEpzJDcGz7DFJi+pQOOi3GjR/DOdxTkTsF+NzhnldIoG6TORaBlInUuqA==
6385+
dependencies:
6386+
loader-utils "^1.1.0"
6387+
schema-utils "^1.0.0"
6388+
63606389
rc@^1.2.7:
63616390
version "1.2.8"
63626391
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
@@ -6785,6 +6814,11 @@ select-hose@^2.0.0:
67856814
resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca"
67866815
integrity sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo=
67876816

6817+
select@^1.1.2:
6818+
version "1.1.2"
6819+
resolved "https://registry.yarnpkg.com/select/-/select-1.1.2.tgz#0e7350acdec80b1108528786ec1d4418d11b396d"
6820+
integrity sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=
6821+
67886822
selfsigned@^1.9.1:
67896823
version "1.10.4"
67906824
resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-1.10.4.tgz#cdd7eccfca4ed7635d47a08bf2d5d3074092e2cd"
@@ -7464,6 +7498,11 @@ timsort@^0.3.0:
74647498
resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4"
74657499
integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=
74667500

7501+
tiny-emitter@^2.0.0:
7502+
version "2.1.0"
7503+
resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz#1d1a56edfc51c43e863cbb5382a72330e3555423"
7504+
integrity sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==
7505+
74677506
tmp@^0.0.33:
74687507
version "0.0.33"
74697508
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
@@ -7802,6 +7841,13 @@ vm-browserify@0.0.4:
78027841
dependencies:
78037842
indexof "0.0.1"
78047843

7844+
vue-clipboard2@^0.3.0:
7845+
version "0.3.0"
7846+
resolved "https://registry.yarnpkg.com/vue-clipboard2/-/vue-clipboard2-0.3.0.tgz#b04d3f9a2d46f12ca85178445930b38463640b22"
7847+
integrity sha512-6/Y9NJErWb4LNBLMgsJSdKb7KpF6/jqXagvKlYut6VQzQsNj6515FpwH0r5hhmeJMqaPzf1kxAw8L8Qvw/QBJQ==
7848+
dependencies:
7849+
clipboard "^2.0.0"
7850+
78057851
vue-eslint-parser@^2.0.3:
78067852
version "2.0.3"
78077853
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-2.0.3.tgz#c268c96c6d94cfe3d938a5f7593959b0ca3360d1"

0 commit comments

Comments
 (0)