Pheli – React for Slack Apps

栏目: IT技术 · 发布时间: 5年前

内容简介:Build interactive Slack apps without webhooks or JSON headache. If you know React, you know how to make a Slack app.See:

Pheli – React for Slack Apps

:zap: Phelia

React for Slack Apps

Build interactive Slack apps without webhooks or JSON headache. If you know React, you know how to make a Slack app.

Quick start

  1. Create your message with React:

    import randomImage from "../utils";
    
    export function RandomImage({ useState }: PheliaMessageProps) {
      const [imageUrl, setImageUrl] = useState("imageUrl", randomImage());
    
      return (
        <Message text="Choose a dog">
          <ImageBlock
            title="an adorable :dog:"
            alt="a very adorable doggy dog"
            imageUrl={imageUrl}
            emoji
          />
          <Divider />
          <Actions>
            <Button
             
              action="randomImage"
              onClick={() => setImageUrl(randomImage())}
            >
              New doggy
            </Button>
          </Actions>
        </Message>
      );
    }
  2. Register your component

    const client = new Phelia(process.env.SLACK_TOKEN);
    
    app.post(
      "/interactions",
      client.messageHandler(process.env.SLACK_SIGNING_SECRET, [RandomImage])
    );
    
    client.postMessage(RandomImage, "@max");
  3. Interact with your message:

    Pheli – React for Slack Apps

See: docs for more info or join our community Slack .

How this works

Phelia transforms React components into Slack messages by use of a custom React reconciler . Components (with their internal state and props) are serialized into a custom storage . When a user interacts with a posted message Phelia retrieves the component, re-hydrates it's state and props, and performs any actions which may result in a new state.

Components

Each component is a mapping of a specific object type for a slack block. There are 3 categories of components, each with special rules for how that component can be used with other components.

  1. Surface Components (Message, Home, Modal) - Root components that contains Block Components
  2. Block Components (Actions, Context, Divider, Image, Input, Section) - Direct descendants of a Surface Component. Contains Block Components
  3. Block Element Components (Text, CheckBoxes, TextField, etc) - Direct descendants of a Block Components.

Feature Support

To request a feature submit a new issue .

Component Example
Actions :white_check_mark: Counter
Button :white_check_mark: Counter
Channel Select Menus :white_check_mark: Channel Select Menu
Checkboxes :white_check_mark: Modal Example
Confirmation dialog :white_check_mark: Random Image
Context :white_check_mark:
Conversation Select Menus :white_check_mark: Conversation Select Menu
Date Picker :white_check_mark: Birthday Picker
Divider :white_check_mark: Random Image
External Select Menus :white_check_mark: External Select Menu
Home Tab :white_check_mark: Home App Example
Image Block :white_check_mark: Random Image
Image :white_check_mark: Random Image
Input :white_check_mark: Modal Example
Messages :white_check_mark: Server
Modals :white_check_mark: Modal Example
Multi channels select Menu :white_check_mark: Multi Channels Select Menu
Multi conversations select Menu :white_check_mark: Multi Conversations Select Menu
Multi external select Menu :white_check_mark: Multi External Select Menu
Multi static select Menu :white_check_mark: Multi Static Select Menu
Multi users select Menu :white_check_mark: Multi Users Select Menu
Option group :white_check_mark: Static Select Menu
Option :white_check_mark:
Overflow Menu :white_check_mark: Overflow Menu
Plain-text input :white_check_mark: Modal Example
Radio button group :white_check_mark: Radio Buttons
Section :white_check_mark: Counter
Static Select Menus :white_check_mark: Static Select Menu
Text :white_check_mark: Counter
Text :white_check_mark: Random Image
User Select Menus :white_check_mark: User Select Menu

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

游戏编程权威指南

游戏编程权威指南

Mike McShaffry 麦克沙福瑞、David “Rez” Graham 格雷海姆 / 师蓉、李静、李青翠 / 人民邮电 / 2016-3 / 99.00元

全书分为4个部分共24章。首部分是游戏编程基础,主要介绍了游戏编程的定义、游戏架构等基础知识。 第二部分是让游戏跑起来,主要介绍了初始化和关闭代码、主循环、游戏主题和用户界面等。 第三部分是核心游戏技术,主要介绍了一些*为复杂的代码 示例,如3D编程、游戏音频、物理和AI编程等。 第四部分是综合应用,主要介绍了网络编程、多道程序设计和用C#创建工具等,并利用前面所讲的 知识开发出......一起来看看 《游戏编程权威指南》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具