1.2.2 • Published 2 years ago

slack-modalizer v1.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

slack-modalizer

Stupid-easy Modal Implementation for Slack

Installation

npm install slack-modalizer --save

Attach to Slack App as middleware

const { App } = require('@slack/bolt');
const { Modalizer } = require('slack-modalizer');

// Instantiate your Slack App however you'd like
const app = new App({
  token: process.env.SLACK_BOT_TOKEN,
  signingSecret: process.env.SLACK_SIGNING_SECRET
});

// Attach to Slack App as middleware 
app.use(async ({ ack, body, context, client, next }) => {
  context.modalizer = new Modalizer({body, client, context, ack});
  await next();
});

Pop up a modal, in any context within your controllers

modalView payload

app.action('main_screen', async ({ context }) => {
  // can be invoked from an action in an existing modal
  // or from a message action 
  await context.modalizer.show({
    renderedView: modalView
  });
  
  /**
  *  Wait a few seconds (define your own sleep fnc)
  *  await sleep(3);
  */
  
  // render an updated modal later on
  await context.modalizer.show({
    renderedView: modalView2
  });
});

// in a view_submission
app.view('store_config', async ({ context }) => {
  await context.modalizer.show({
    renderedView: modalView
  });
});
1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago