File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change 8
8
<div >
9
9
<div class =" card-name" >
10
10
<a @click =" selectEntity(card)"
11
- :class =" {'selected': card.selected, 'targetable': doingAction && targets.indexOf(card.id) !== -1}" >{{card.properties.name}}
11
+ :class =" {'selected': card.selected, 'targetable': doingAction && targets.indexOf(card.id) !== -1}"
12
+ :style =" `font-size: ${adjustFontSize(card.properties.name)}em`" >
13
+ {{card.properties.name}}
12
14
</a >
13
15
</div >
14
16
</div >
20
22
</div >
21
23
</div >
22
24
<!-- card type -->
23
- <div class =" card-type" >
25
+ <div class =" card-type"
26
+ :style =" `font-size: ${adjustFontSize(card.properties.creatureType)}em`" >
24
27
{{card.properties.creatureType}}
25
28
</div >
26
29
<!-- card statistics -->
@@ -103,6 +106,25 @@ export default {
103
106
methods: {
104
107
resolveImage (path ) {
105
108
return require (' ../assets/images/cards/' + path);
109
+ },
110
+
111
+ /**
112
+ * Adjusts the size of the font to be displayed on a CardModel
113
+ * based on the length of the text and whether it is all caps.
114
+ *
115
+ * @param {String} text - the text to decide the font size for
116
+ * @return {Number} - the font size in em units
117
+ */
118
+ adjustFontSize (text ) {
119
+ let baselineEm = 1.1 ;
120
+ const isAllCaps = text === text .toUpperCase ();
121
+ const length = text .length ;
122
+ if (length >= 20 ) {
123
+ baselineEm = isAllCaps ? 0.7 : 0.8 ;
124
+ } else if (length >= 18 ) {
125
+ baselineEm = isAllCaps ? 0.9 : 1.0 ;
126
+ }
127
+ return baselineEm;
106
128
}
107
129
},
108
130
created () {
You can’t perform that action at this time.
0 commit comments