Commit 81c693ad authored by hewenhao's avatar hewenhao

feat: responsive font-size

parent 833f0465
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
> >
<div class="avatar" v-if="shouldShowPhoto"> <div class="avatar" v-if="shouldShowPhoto">
<img :src="item.avatar" v-if="item.avatar" /> <img :src="item.avatar" v-if="item.avatar" />
<span v-else>{{ item.index }}</span> <span v-else :style="getAvatarNameStyle(item)">{{ item.index }}</span>
</div> </div>
<div class="name" :class="{ 'no-avatar': !shouldShowPhoto }">{{item.name || item.index}}</div> <div class="name" :class="{ 'no-avatar': !shouldShowPhoto }">{{item.name || item.index}}</div>
</div> </div>
...@@ -100,6 +100,26 @@ export default { ...@@ -100,6 +100,26 @@ export default {
} }
}, },
methods: { methods: {
getAvatarNameStyle (item) {
const len = this.composedList.length
const str = String(item.index)
if (len > 0 && len < 3) {
if (str.length > 3) {
return 'font-size: 120px;'
}
return 'font-size: 160px;'
} else if (len > 2 && len < 5) {
if (str.length > 3) {
return 'font-size: 90px;'
}
return 'font-size: 110px;'
} else if (len > 4) {
if (str.length > 3) {
return 'font-size: 75px;'
}
return 'font-size: 90px;'
}
},
applise () { applise () {
const myConfetti = ( const myConfetti = (
this._confetti = confetti.create(this.$refs.canvas, { this._confetti = confetti.create(this.$refs.canvas, {
...@@ -244,13 +264,15 @@ export default { ...@@ -244,13 +264,15 @@ export default {
justify-content: center; justify-content: center;
span { span {
background-image: linear-gradient(#2de2ff,#8b67fb); background-image: linear-gradient(136deg, rgba(28, 254, 250, 1), rgba(0, 148, 255, 1), rgba(111, 59, 255, 1));
background-clip: text; background-clip: text;
-webkit-background-clip: text; -webkit-background-clip: text;
color: transparent; color: transparent;
font-size: 60px; font-size: 60px;
position: relative; position: relative;
z-index: 3; z-index: 3;
font-family: fantasy;
white-space: nowrap;
} }
img { img {
width: 100%; width: 100%;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment