Skip to content

Commit

Permalink
Tags implementation (#19)
Browse files Browse the repository at this point in the history
* Initial

* Badge(r)

---------

Co-authored-by: V13Axel <[email protected]>
  • Loading branch information
Haxxer and V13Axel authored Aug 8, 2023
1 parent fad84ae commit 043f087
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 24 deletions.
44 changes: 22 additions & 22 deletions public/json/se_monsters.json
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@
"cr": "1/4",
"size": "Medium",
"type": "Humanoid",
"tags": "Aarakocra",
"tags": "",
"section": "",
"alignment": "neutral good",
"environment": "mountain, planar",
Expand Down Expand Up @@ -1568,7 +1568,7 @@
"cr": "1/4",
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "arctic, desert, dungeon, forest, grassland, mountain, swamp, underground, urban",
Expand Down Expand Up @@ -2078,7 +2078,7 @@
"cr": 12,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "ruins, urban",
Expand All @@ -2095,7 +2095,7 @@
"cr": 8,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "non-good",
"environment": "arctic, cave, coast, desert, dungeon, forest, grassland, mountain, ruins, swamp, underground, urban",
Expand Down Expand Up @@ -2231,7 +2231,7 @@
"cr": "1/8",
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "non-lawful",
"environment": "arctic, coast, desert, forest, grassland, mountain, ruins, urban",
Expand All @@ -2248,7 +2248,7 @@
"cr": 2,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "non-lawful",
"environment": "arctic, coast, desert, forest, grassland, mountain, ruins, urban",
Expand Down Expand Up @@ -2435,7 +2435,7 @@
"cr": 2,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any chaotic",
"environment": "arctic, cave, desert, forest, grassland, mountain, swamp, urban",
Expand Down Expand Up @@ -2962,7 +2962,7 @@
"cr": 0,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "urban",
Expand Down Expand Up @@ -3081,7 +3081,7 @@
"cr": 2,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "non-good",
"environment": "dungeon, urban",
Expand All @@ -3098,7 +3098,7 @@
"cr": "1/8",
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "non-good",
"environment": "dungeon, urban",
Expand Down Expand Up @@ -3574,7 +3574,7 @@
"cr": 2,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "arctic, cave, coast, desert, forest, grassland, mountain, swamp, underground",
Expand Down Expand Up @@ -4815,7 +4815,7 @@
"cr": 5,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "urban",
Expand Down Expand Up @@ -5172,7 +5172,7 @@
"cr": "1/8",
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "urban",
Expand Down Expand Up @@ -5699,7 +5699,7 @@
"cr": 3,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "urban",
Expand Down Expand Up @@ -5971,7 +5971,7 @@
"cr": 6,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "urban",
Expand Down Expand Up @@ -6498,7 +6498,7 @@
"cr": "1/8",
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "urban",
Expand Down Expand Up @@ -6991,7 +6991,7 @@
"cr": 2,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "urban",
Expand Down Expand Up @@ -7535,7 +7535,7 @@
"cr": "1/2",
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "arctic, coast, desert, forest, grassland, mountain, swamp",
Expand Down Expand Up @@ -7875,7 +7875,7 @@
"cr": 1,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "arctic, cave, coast, desert, forest, grassland, mountain, ruins, swamp, urban",
Expand Down Expand Up @@ -8130,7 +8130,7 @@
"cr": "1/2",
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "non-good",
"environment": "arctic, cave, coast, forest, grassland, urban",
Expand Down Expand Up @@ -8181,7 +8181,7 @@
"cr": "1/8",
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "arctic, cave, desert, forest, grassland, mountain, swamp",
Expand Down Expand Up @@ -8419,7 +8419,7 @@
"cr": 3,
"size": "Medium",
"type": "Humanoid",
"tags": "any",
"tags": "any race",
"section": "NPCs",
"alignment": "any",
"environment": "urban",
Expand Down
30 changes: 30 additions & 0 deletions src/components/Badge.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script setup>
const props = defineProps({
color: {
type: String,
default: "emerald"
},
})
</script>

<template>
<!-- Colors: emerald, gray, red, green, yellow, blue, indigo, purple, pink -->
<span
:class="{
'inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-medium ring-1 ring-inset': true,
'bg-emerald-50 text-emerald-700 ring-emerald-600/10 dark:bg-emerald-400/10 dark:text-gray-400 dark:ring-gray-400/20': color === 'emerald',
'bg-gray-50 text-gray-700 ring-gray-600/10 dark:bg-gray-400/10 dark:text-gray-400 dark:ring-gray-400/20': color === 'gray',
'bg-red-50 text-red-700 ring-red-600/10 dark:bg-red-400/10 dark:text-gray-400 dark:ring-gray-400/20': color === 'red',
'bg-green-50 text-green-700 ring-green-600/10 dark:bg-green-500/10 dark:text-gray-400 dark:ring-gray-500/20': color === 'green',
'bg-yellow-50 text-yellow-800 ring-yellow-600/10 dark:bg-yellow-400/10 dark:text-gray-500 dark:ring-gray-400/20': color === 'yellow',
'bg-blue-50 text-blue-700 ring-blue-600/10 dark:bg-blue-400/10 dark:text-gray-400 dark:ring-gray-400/20': color === 'blue',
'bg-indigo-50 text-indigo-700 ring-indigo-600/10 dark:bg-indigo-400/10 dark:text-gray-400 dark:ring-gray-400/20': color === 'indigo',
'bg-purple-50 text-purple-700 ring-purple-600/10 dark:bg-purple-400/10 dark:text-gray-400 dark:ring-gray-400/20': color === 'purple',
'bg-pink-50 text-pink-700 ring-pink-600/10 dark:bg-pink-400/10 dark:text-gray-400 dark:ring-gray-400/20': color === 'pink',
}"
>
<slot></slot>
</span>
</template>
6 changes: 6 additions & 0 deletions src/components/MonsterTableRow.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup>
import {useEncounter} from "../stores/encounter";
import Monster from "../js/monster";
import Badge from "./Badge.vue";
const props = defineProps({
monster: {
Expand Down Expand Up @@ -29,6 +30,11 @@ const encounter = useEncounter();
class="w-full max-w-0 py-2 px-3 text-sm font-medium text-gray-900 dark:text-gray-100 w-64 max-w-64 truncate"
>
<span class="truncate" v-text="monster.name"></span>
<span v-show="monster.tags.length" class="inline-flex space-x-1 ml-2">
<Badge v-for="tag in monster.tags">
{{ tag.toLowerCase() }}
</Badge>
</span>
<dl class="font-normal">
<dt class="sr-only">Sources</dt>
<dd class="mt-1 truncate text-gray-500 dark:text-gray-400">
Expand Down
4 changes: 2 additions & 2 deletions src/js/monster.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export default class Monster {
);

this.tags = attributes.tags
? attributes.tags.split(/\s*,\s*/).sort()
: null;
? attributes.tags.split(/\s*,\s*/)
: [];

this.special = !!attributes.special;
this.legendary = !!attributes.legendary;
Expand Down

0 comments on commit 043f087

Please sign in to comment.