Skip to content

Commit c736eeb

Browse files
committed
chore(demo): polish leaderboard demo
1 parent 2bf509c commit c736eeb

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

demo/leaderboard/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<head>
55
<title>LeanCloud Leaderboard Demo</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
67
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
78
<link rel="stylesheet" href="//unpkg.com/@leancloud/styles@^1/styles/font.css">
89
<link rel="stylesheet" href="./leaderboard.css">

demo/leaderboard/leaderboard.css

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ a:visited {
1717

1818
#app {
1919
height: 100%;
20+
display: flex;
21+
flex-direction: column;
2022
}
2123

2224
[v-cloak] {
@@ -62,18 +64,20 @@ a:visited {
6264

6365
.statistic-list {
6466
height: 100%;
67+
flex: 1;
6568
margin: 0;
6669
padding: 0;
6770
list-style: none;
6871
display: flex;
6972
flex-direction: column;
7073
font-size: 1.4em;
74+
overflow: auto;
7175
}
7276

7377
.statistic {
7478
background: linear-gradient(320deg, #581b98, #9c1de7);
7579
height: 100%;
76-
max-height: 7.84%;
80+
max-height: 8.333%;
7781
min-height: 44px;
7882
flex: 1;
7983
display: flex;
@@ -110,19 +114,20 @@ a:visited {
110114
width: 100%;
111115
flex: 1;
112116
}
117+
.statistic .score {
118+
max-width: 44px;
119+
overflow: hidden;
120+
}
113121

114122
.operations {
115-
position: fixed;
116-
bottom: 0;
117-
padding: 6px;
118-
width: 100%;
123+
padding: 6px 0;
119124
text-align: center;
120125
color: #ddd;
121126
}
122127

123128
.operations .separator {
124129
display: inline-block;
125-
margin: 0 0.5em;
130+
margin: 0 0.4em;
126131
}
127132

128133
#overlay {
@@ -143,6 +148,7 @@ a:visited {
143148
background: transparent;
144149
border: 1px solid #ffffff99;
145150
border-width: 0 0 2px 0;
151+
border-radius: 0;
146152
color: white;
147153
font-size: 20px;
148154
text-align: center;

demo/leaderboard/leaderboard.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var app = new Vue({
5050
data: {
5151
statistics: [],
5252
score: null,
53-
hightScore: 0,
53+
highScore: 0,
5454
newHighScore: false,
5555
username: '',
5656
password: '',
@@ -79,7 +79,7 @@ var app = new Vue({
7979
this.fetchResults();
8080
if (!id) {
8181
this.score = null;
82-
this.hightScore = 0;
82+
this.highScore = 0;
8383
this.newHighScore = false;
8484
}
8585
},
@@ -93,9 +93,9 @@ var app = new Vue({
9393
this.newHighScore = false;
9494
setTimeout(() => {
9595
this.score = Math.ceil(Math.pow(Math.random(), 2) * 1000);
96-
if (this.score > this.hightScore) {
96+
if (this.score > this.highScore) {
9797
this.newHighScore = true;
98-
this.hightScore = this.score;
98+
this.highScore = this.score;
9999
this.updateScore(this.score);
100100
}
101101
this.rolling = false;
@@ -126,15 +126,22 @@ var app = new Vue({
126126
: []
127127
),
128128
])
129-
.then(([tops, [beforeUser, user]]) => {
130-
console.log(tops, [beforeUser, user]);
129+
.then(([topStatistics, [beforeUserStatistic, userStatistic]]) => {
130+
console.log(topStatistics, [beforeUserStatistic, userStatistic]);
131131
let statistics;
132-
if (user && user.position >= MAX_RESULTS_COUNT) {
133-
statistics = [...tops.slice(0, -2), beforeUser, user];
132+
if (userStatistic && userStatistic.position >= MAX_RESULTS_COUNT) {
133+
statistics = [
134+
...topStatistics.slice(0, -2),
135+
beforeUserStatistic,
136+
userStatistic,
137+
];
134138
} else {
135-
statistics = tops;
139+
statistics = topStatistics;
136140
}
137141
this.statistics = JSON.parse(JSON.stringify(statistics));
142+
if (userStatistic) {
143+
this.highScore = userStatistic.value;
144+
}
138145
})
139146
.catch(console.error);
140147
},

script/deploy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ echo "Deploy docs to github pages.";
33
npm run docs;
44
mkdir gh_pages;
55
cp -r docs gh_pages/;
6-
cp -r dist/av* gh_pages/;
6+
mkdir gh_pages/dist;
7+
cp -r dist/av* gh_pages/dist/;
78
cp -r demo gh_pages/;
89
cd gh_pages && git init;
910
git config user.name "leancloud-bot";

0 commit comments

Comments
 (0)