mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 06:33:05 -04:00
[nextgen/cardstack] add slot support to components
- migrate existing code to slots - add interactiveComponent.activeColor to overwrite the default "selected" button style - improve handling of cached components
This commit is contained in:
parent
e2c8a368c6
commit
668bb946a7
5 changed files with 173 additions and 88 deletions
|
@ -2,7 +2,7 @@ const { createEmbed, page } = require("#utils/embed");
|
|||
const { acknowledge } = require("#utils/interactions");
|
||||
|
||||
const {createDynamicCardStack} = require("#cardstack/index");
|
||||
const {ResolveCallbackTypes} = require("#cardstack/constants");
|
||||
const {ResolveCallbackTypes, InteractiveComponentTypes} = require("#cardstack/constants");
|
||||
|
||||
module.exports = {
|
||||
label: "text",
|
||||
|
@ -31,8 +31,83 @@ module.exports = {
|
|||
},
|
||||
interactive: {
|
||||
always_active_button: {
|
||||
type: InteractiveComponentTypes.BUTTON,
|
||||
label: "single sub page",
|
||||
slot: 1,
|
||||
visible: true,
|
||||
disableCache: true,
|
||||
resolvePage: ()=>{
|
||||
return {
|
||||
type: ResolveCallbackTypes.SUBSTACK,
|
||||
cards: [
|
||||
createEmbed("success", context, "smiley")
|
||||
].map((p)=>page(p))
|
||||
}
|
||||
}
|
||||
},
|
||||
always_active_button1: {
|
||||
type: InteractiveComponentTypes.BUTTON,
|
||||
label: "single sub page",
|
||||
slot: 1,
|
||||
visible: true,
|
||||
disableCache: true,
|
||||
resolvePage: ()=>{
|
||||
return {
|
||||
type: ResolveCallbackTypes.SUBSTACK,
|
||||
cards: [
|
||||
createEmbed("success", context, "smiley")
|
||||
].map((p)=>page(p))
|
||||
}
|
||||
}
|
||||
},
|
||||
always_active_button2: {
|
||||
type: InteractiveComponentTypes.BUTTON,
|
||||
label: "single sub page",
|
||||
slot: 1,
|
||||
visible: true,
|
||||
disableCache: true,
|
||||
resolvePage: ()=>{
|
||||
return {
|
||||
type: ResolveCallbackTypes.SUBSTACK,
|
||||
cards: [
|
||||
createEmbed("success", context, "smiley")
|
||||
].map((p)=>page(p))
|
||||
}
|
||||
}
|
||||
},
|
||||
always_active_button3: {
|
||||
type: InteractiveComponentTypes.BUTTON,
|
||||
label: "single sub page",
|
||||
slot: 1,
|
||||
visible: true,
|
||||
disableCache: true,
|
||||
resolvePage: ()=>{
|
||||
return {
|
||||
type: ResolveCallbackTypes.SUBSTACK,
|
||||
cards: [
|
||||
createEmbed("success", context, "smiley")
|
||||
].map((p)=>page(p))
|
||||
}
|
||||
}
|
||||
},
|
||||
always_active_button4: {
|
||||
type: InteractiveComponentTypes.BUTTON,
|
||||
label: "single sub page",
|
||||
slot: 1,
|
||||
visible: true,
|
||||
disableCache: true,
|
||||
resolvePage: ()=>{
|
||||
return {
|
||||
type: ResolveCallbackTypes.SUBSTACK,
|
||||
cards: [
|
||||
createEmbed("success", context, "smiley")
|
||||
].map((p)=>page(p))
|
||||
}
|
||||
}
|
||||
},
|
||||
always_active_button5: {
|
||||
type: InteractiveComponentTypes.BUTTON,
|
||||
label: "single sub page",
|
||||
inline: true,
|
||||
visible: true,
|
||||
disableCache: true,
|
||||
resolvePage: ()=>{
|
||||
|
@ -45,10 +120,9 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
conditional_button: {
|
||||
type: InteractiveComponentTypes.BUTTON,
|
||||
// Button Label
|
||||
label: "Conditional",
|
||||
// Next to pagination or new row
|
||||
inline: false,
|
||||
visible: (page) => {
|
||||
return (page.getState("key") === "t_1")
|
||||
},
|
||||
|
@ -63,6 +137,8 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
dynamic_button: {
|
||||
type: InteractiveComponentTypes.BUTTON,
|
||||
slot: 3,
|
||||
// Button Label
|
||||
label: (page) => {
|
||||
console.log(page.getState("key"))
|
||||
|
|
|
@ -112,7 +112,6 @@ module.exports = {
|
|||
episodes_button: {
|
||||
type: InteractiveComponentTypes.BUTTON,
|
||||
label: "Episodes",
|
||||
inline: false,
|
||||
visible: true,
|
||||
condition: (page) => {
|
||||
return (page.getState("episodes_key") !== null)
|
||||
|
@ -168,7 +167,6 @@ module.exports = {
|
|||
characters_button: {
|
||||
type: InteractiveComponentTypes.BUTTON,
|
||||
label: "Characters",
|
||||
inline: false,
|
||||
visible: true,
|
||||
condition: (page) => {
|
||||
return (page.getState("characters_key") !== null)
|
||||
|
@ -210,7 +208,6 @@ module.exports = {
|
|||
related_button: {
|
||||
type: InteractiveComponentTypes.BUTTON,
|
||||
label: "Related",
|
||||
inline: false,
|
||||
visible: true,
|
||||
condition: (page) => {
|
||||
return (page.getState("related_key") !== null)
|
||||
|
|
|
@ -78,7 +78,6 @@ module.exports = {
|
|||
type: InteractiveComponentTypes.BUTTON,
|
||||
label: "Full Coverage",
|
||||
icon: "button_full_coverage",
|
||||
inline: true,
|
||||
visible: (pg) => {
|
||||
return (pg.getState("full_coverage_key") !== null)
|
||||
},
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
const { wolframAlpha, wolframSupplemental} = require("#api");
|
||||
const { paginator } = require('#client');
|
||||
const { PERMISSION_GROUPS } = require('#constants');
|
||||
|
||||
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed');
|
||||
const { createEmbed, page } = require('#utils/embed');
|
||||
const { acknowledge } = require('#utils/interactions');
|
||||
const { citation, smallIconPill } = require('#utils/markdown');
|
||||
const { editOrReply } = require('#utils/message')
|
||||
|
@ -84,7 +83,6 @@ module.exports = {
|
|||
interactive: {
|
||||
state_buttons: {
|
||||
type: InteractiveComponentTypes.BUTTON_GENERATOR,
|
||||
inline: true,
|
||||
// Resolve Components
|
||||
resolveComponents: (pg)=>{
|
||||
if(!pg.getState("supplemental") || pg.getState("supplemental").length === 0) return [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue