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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 40 additions & 2 deletions
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

Lines changed: 38 additions & 0 deletions
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

Lines changed: 20 additions & 8 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 22 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
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+
};

0 commit comments

Comments
 (0)