Skip to content

Commit d1dd005

Browse files
committed
docs: optimize button styles
1 parent fd10578 commit d1dd005

File tree

3 files changed

+72
-27
lines changed

3 files changed

+72
-27
lines changed

docs/.vuepress/theme/Layout.vue

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<previewer class="previewer"></previewer>
1111
<div class="intro-container">
1212
<p>An infinite scroll plugin for Vue.js</p>
13-
<button class="button button-intro">Get Started</button>
14-
<button class="button button-intro">View GitHub</button>
13+
<button class="button button-large button-basic">Get Started</button>
14+
<button class="button button-large">View GitHub</button>
1515
<ul class="feat-list">
1616
<li>
1717
<h3>Out of the box</h3>
@@ -32,6 +32,7 @@
3232
</template>
3333

3434
<script>
35+
import 'focus-visible';
3536
import Previewer from './Previewer';
3637
3738
export default {
@@ -42,6 +43,8 @@ export default {
4243
</script>
4344

4445
<style lang="less">
46+
@import './less/button.less';
47+
4548
body {
4649
margin: 0;
4750
font: 16px/1.42857 PingFang SC, Lantinghei SC, Microsoft Yahei, Hiragino Sans GB, Microsoft Sans Serif, WenQuanYi Micro Hei, sans-serif;
@@ -99,7 +102,6 @@ main.container {
99102
+ h1 {
100103
top: 280px;
101104
left: 38%;
102-
margin-top: 20px;
103105
margin-left: 179px;
104106
font-size: 32px;
105107
}
@@ -128,30 +130,8 @@ main.container {
128130
color: @c-basic-light;
129131
}
130132
131-
.button-intro {
132-
padding: 16px 48px;
133-
color: #fff;
134-
font-size: 20px;
135-
background: lighten(@c-basic, 20%);
136-
border: 1px solid lighten(@c-basic, 20%);
137-
border-radius: 2px;
138-
cursor: pointer;
139-
outline: none;
140-
141-
&:hover,
142-
&:focus {
143-
opacity: 0.9;
144-
}
145-
146-
&:active {
147-
opacity: 1;
148-
}
149-
150-
+ .button-intro {
151-
margin-left: 20px;
152-
color: @c-basic;
153-
background: transparent;
154-
}
133+
.button + .button {
134+
margin-left: 20px;
155135
}
156136
157137
.feat-list {

docs/.vuepress/theme/less/button.less

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
@import './variables.less';
2+
3+
.button-shadow-generator(@color, @offsetx: 0) {
4+
box-shadow: 0 (12px + @offsetx) 30px -10px @color,
5+
0 (8px + @offsetx) 20px -20px fadein(@color, 5%);
6+
}
7+
8+
.button {
9+
padding: 12px 24px;
10+
color: @c-basic;
11+
font-size: 16px;
12+
background: #fff;
13+
border: 0;
14+
border-radius: 2px;
15+
cursor: pointer;
16+
transition: opacity 0.2s, transform 0.2s;
17+
18+
&,
19+
&:active {
20+
.button-shadow-generator(rgba(0, 0, 0, 0.1));
21+
}
22+
23+
// action status
24+
&:hover {
25+
opacity: 0.95;
26+
transform: translateY(-1px);
27+
.button-shadow-generator(rgba(0, 0, 0, 0.1), 1px);
28+
}
29+
30+
&:focus:not(.focus-visible) {
31+
outline: none;
32+
}
33+
34+
&:active {
35+
opacity: 1;
36+
transform: none;
37+
}
38+
39+
// size control
40+
&.button-large {
41+
padding: 16px 48px;
42+
font-size: 20px;
43+
}
44+
45+
&.button-small {
46+
padding: 8px 16px;
47+
font-size: 14px;
48+
}
49+
50+
// color control
51+
&.button-basic {
52+
color: #fff;
53+
background: linear-gradient(30deg, lighten(@c-basic, 10%), lighten(@c-basic, 25%));
54+
55+
&,
56+
&:active {
57+
.button-shadow-generator(rgba(28, 90, 160, 0.5));
58+
}
59+
60+
&:hover {
61+
.button-shadow-generator(rgba(28, 90, 160, 0.5), 1px);
62+
}
63+
}
64+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"eslint-loader": "^2.1.0",
5858
"eslint-plugin-import": "^2.14.0",
5959
"eslint-plugin-vue": "^4.7.1",
60+
"focus-visible": "^4.1.5",
6061
"html-webpack-plugin": "^3.2.0",
6162
"husky": "^0.14.3",
6263
"karma": "^3.0.0",

0 commit comments

Comments
 (0)