Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better dialog support for template literal #43

Merged
merged 17 commits into from
Aug 7, 2019

Conversation

yhatt
Copy link
Owner

@yhatt yhatt commented Aug 7, 2019

Resolves #42. Now jsxslack template literal can use dialog components.

import { jsxslack } from '@speee-js/jsx-slack'

console.log(jsxslack`
  <Dialog callbackId="example" title="Example">
    <Select name="rating" label="Rating" required>
      <Option value="5">${':star:'.repeat(5)}</Option>
      <Option value="4">${':star:'.repeat(4)}</Option>
      <Option value="3">${':star:'.repeat(3)}</Option>
      <Option value="2">${':star:'.repeat(2)}</Option>
      <Option value="1">${':star:'.repeat(1)}</Option>
    </Select>
  </Option>
`)

The kind of <Select> and similar components will be resolved by the container component <Blocks> and <Dialog>. We've refactored template literal logic to apply multi-pass parsing for resolving component based on structure.

On the other hand, jsxslack.fragment cannot yet resolve which kind of component will be used because the root container is not defined in fragments. So we will parse Dialog prefix to specify using component.

const Component = ({ value }) => jsxslack.fragment`
  <Dialog.UsersSelect name="first-user" label="First user" initialUser=${value} />
  <Dialog.UsersSelect name="second-user" label="Second user" initialUser=${value} />
`

ToDo

  • Update documents
    • Remove usage with interpolation
    • Add information about using dialog components in jsxslack.fragment
  • Update demo (Now works dialog components by this implementation)
    • Add dialog example

@yhatt yhatt changed the title Native dialog support for template literal Better dialog support for template literal Aug 7, 2019
@yhatt yhatt merged commit 9eb2834 into master Aug 7, 2019
@yhatt yhatt deleted the dialog-for-template-literal branch August 7, 2019 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Native dialog support for template literal
1 participant