Skip to content

Commit 38a42f8

Browse files
committed
Add a collapsible mixin and update the API page
1 parent 01781e5 commit 38a42f8

File tree

5 files changed

+79
-3
lines changed

5 files changed

+79
-3
lines changed

src/components/API/api.css

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

88
section {
99
padding: 10px;
10+
flex-grow: 1;
1011
}
1112

1213
section h1 {

src/components/API/api.vue

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
11
<template>
22
<div :class="$style['content']">
33
<section>
4-
<h1>Introduction</h1>
4+
<h1>Introduction: Simple Roll API</h1>
55
<div>
66
The WOD5E system has an API that modules and macros can use to integrate with the same functions the system itself uses. Though not every specific function is exposed, in particular probably the most useful is the diceroller code as the system uses custom dice and has its own formatting.
77

8-
The macro on this page is a great example of that: Though it takes a little bit of constructing and calculations to get what the system needs, you can send a roll to the system's diceroller and get the outcome you need. This can be really powerful for setting up rolls that you use very often, and the roll function itself is extremely powerful too
8+
The macro on this page is a great example of that: Though it takes a little bit of constructing and calculations to get what the system needs, you can send a roll to the system's diceroller and get the outcome you need. This can be really nice for setting up rolls that you use very often, and the roll function itself is extremely powerful too, letting you do things like pre-set a difficulty, trigger other macros after the result is processed, modify things like whether hunger/rage dice effects are processed, and so on!
9+
10+
Below, you'll find documentation about the current variables the roll function can accept.
11+
12+
<pre class="language-javascript"><code class="language-javascript">
13+
* basicDice (Optional, default 0) The number of 'basic' dice to roll, such as vampire, werewolf, and hunter dice
14+
* advancedDice (Optional, default 0) The number of 'advanced' dice to roll, such as hunger, rage and desperation dice
15+
* actor The actor that the roll is coming from
16+
* data Actor or item data to pass along with the roll
17+
* title Title of the roll for the dialog/chat message
18+
* disableBasicDice (Optional, default false) Whether to disable basic dice on this roll
19+
* disableAdvancedDice (Optional, default false) Whether to disable advanced dice on this roll
20+
* willpowerDamage (Optional, default 0) How much to damage willpower after the roll is complete
21+
* increaseHunger (Optional, default false) Whether to increase hunger on failures
22+
* decreaseRage (Optional, default false) Whether to reduce rage on failures
23+
* difficulty (Optional, default 0) The number that the roll must succeed to count as a success
24+
* flavor (Optional, default '') Text that appears in the description of the roll
25+
* callback (Optional) A callable function for determining the chat message flavor given parts and data
26+
* quickRoll (Optional, default false) Whether the roll was called to bypass the roll dialog or not
27+
* rollMode (Optional, default FVTT's current roll mode) Which roll mode the message should default as
28+
* rerollHunger (Optional, default false) Whether to reroll failed hunger dice
29+
* selectors (Optional, default []) Any selectors to use when compiling situational modifiers
30+
* macro (Optional, default '') A macro to run after the roll has been made
31+
* disableMessageOutput (optional, default false) Whether to display the message output of a roll
32+
* advancedCheckDice (optional, default 0) Any dice that, part of an 'advanced' diceset, is rolled separately but at the same time
33+
</code></pre>
934
</div>
1035
</section>
11-
36+
<section>
37+
<div class="collapsible-container">
38+
<div class="collapsible-header" @click="toggleCollapse" ref="rollApiExample">
39+
WOD5E.api.Roll Example
40+
</div>
41+
<div class="collapsible-content" ref="rollApiExample">
1242
<pre><code class="language-javascript">// This macro is an example of how you can access the WOD5E Roll API.
1343

1444
// Define the actor
@@ -40,6 +70,9 @@ WOD5E.api.Roll({
4070
advancedDice
4171
})
4272
</code></pre>
73+
</div>
74+
</div>
75+
</section>
4376
</div>
4477
</template>
4578

src/global.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,23 @@ button:hover {
2828
h1, h2, h3, h4 {
2929
margin-bottom: 0;
3030
}
31+
32+
.collapsible-container {
33+
flex-grow: 0.5;
34+
}
35+
36+
.collapsible-header {
37+
font-weight: bold;
38+
cursor: pointer;
39+
margin-bottom: 5px;
40+
display: flex;
41+
flex-direction: row;
42+
align-items: center;
43+
}
44+
45+
.collapsible-content {
46+
border: 1px solid #ccc;
47+
padding: 10px;
48+
transition: max-height 0.3s ease;
49+
overflow: hidden;
50+
}

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import icon from '@/assets/icon.ico'
88
// Components
99
import TemplateComponent from '@/components/Template/template.vue'
1010

11+
// Mixins
12+
import CollapsibleMixin from '@/mixins/collapsible.js'
13+
1114
// Import stylings and components
1215
import '@/global.css'
1316

@@ -22,5 +25,6 @@ library.add(fas, far, fab)
2225
// Create, configure and mount the app
2326
const app = createApp(TemplateComponent)
2427
app.component('font-awesome-icon', FontAwesomeIcon)
28+
app.mixin(CollapsibleMixin)
2529
app.use(router)
2630
app.mount('#app')

src/mixins/collapsible.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default {
2+
data () {
3+
return {}
4+
},
5+
methods: {
6+
// Toggle the collapsed state
7+
toggleCollapse (event) {
8+
const target = event.target
9+
const container = target.closest('.collapsible-container')
10+
const content = container.querySelector('.collapsible-content')
11+
12+
if (content) {
13+
// Toggle the `display` style to show/hide the element
14+
content.style.display = content.style.display === 'none' ? 'block' : 'none'
15+
}
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)