0.5.12 • Published 2 months ago

@rededor/nice-chat-component-lib v0.5.12

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
2 months ago

👨‍💻 Nice Chat Web Component

Este componente encapsula uma API de acesso ao Nice Chat. Para utiliza-lo é necessário um token de acesso a um dashboard do Nice Chat.

🌐 Utilizando esse componente

Para utiliza-lo, você precisará instala-lo via npm/yarn. IMPORTANTE É necessário o arquivo npmrc com as credenciais de leitura para pacotes da Rede D'or.

🚧 Atente-se com as props obrigatórias e as disponíveis, atualmente:

  /**
   * Evento chamado ao ser modificado o estado de visibilidade do widget.
   */
  @Event() widgetChange: EventEmitter<boolean>;
  /**
   * Evento disparado assim que o chat for carregado na tela.
   */
  @Event() chatLoaded: EventEmitter<void>;
  /** Required
   * Token de acesso ao dashboard do nice chat.
   */
  @Prop() token: string;
  /** Required
   * Modifica interface para versão mobile.
   */
  @Prop() isMobile: boolean = false;
  /** Required
   *  Define se o componente deve ser chamado durante a montagem da inteface.
   *  @true [default] as APIs que abrem o chat são chamadas apenas quando o usuário clicar no botão.
   *  @false o componente é chamando assim que o elemento é montado na tela.
   */
  @Prop() isLazy: boolean = true;
  /** Not Required
   * Esconde o formulário em que é pedido o nome do usuário e
   * mostra diretamente a conversa.
   *
   */
  @Prop() hidePreSurvey: boolean = false;
  /** Not Required
   * Nome para identificação do usuário.
   */
  @Prop() userName?: string;
  /** Not Required
   *  Redirecionar o usuário para uma fila/skill específica, ao iniciar a conversa.
   *  Propriedade escutada, portanto mudanças nela acarreta afeitos colaterais na página.
   *
   *  @param TicketThreadProp - aceita ‘string’ do tipo TicketThreadEnum
   */
  @Prop() ticketThreadChosen?: TicketThreadProp

🌐 Webcomponent no HTML

  • Escrever script que chama o webcomponent:
<script type="module">
  import { defineCustomElements } from 'https://cdn.jsdelivr.net/npm/@rededor/nice-chat-component-lib@x.x.x/dist/loader/index.js';
  defineCustomElements();
</script>
  • Utilizar Tag <nice-chat> no <body>, e encapsular o botão que abre o Chat:
<!-- adicione a token e implemente os atributos. -->
<nice-chat token="" is-mobile="true">...</nice-chat>
  • Adicionar lógica que exibe view do Chat para mobile ou desktop (abaixo da tag <nice-chat>)
<script>
  let isDesktop = window.matchMedia("(min-width: 768px)");

  function _setNiceDisplay() {
    const handleNiceView = ({ isMobile = false }) => (
      const niceChat = document.querySelector('nice-chat')
      niceChat.setAttribute('is-mobile', String(isMobile))
    )

    return handleNiceView({ isMobile: !isDesktop.matches })
  }

  _setNiceDisplay()
</script>

⚛️ Webcomponent no React

  • Começe com npm ou yarn, a instalação da lib @rededor/nice-chat-component-lib-react
npm install @rededor/nice-chat-component-lib-react
// ou
yarn add @rededor/nice-chat-component-lib-react
  • Você pode usar o WebComponent como se estivesse a usar outro componente do projeto:
// exemplo de como importar o ChatNice - React
import { NiceChat } from '@rededor/nice-chat-component-lib-react';
  • Na sequência, use o componente se atentando as props obrigatórias.
// exemplo de como utilizar o webcomponent - React
<ChatNice isLazy={false} token={CHATNICE} isMobile={!isDesktop} style={{ display: 'none' }} />

⚠️ Pode ser que você encontre alguns problemas por falta de uma dependência, que no caso seria: @rededor/nice-chat-component, caso ainda haja problemas mesmo essa outra lib instalada, veja se o seu projeto transpila esses componentes fora da pasta "/src", tente configurar o babel para isso.

Devs Stencil - Naming Components

When creating new component tags, we recommend not using stencil in the component name (ex: <stencil-datepicker>). This is because the generated component has little to nothing to do with Stencil; it's just a web component!

Instead, use a prefix that fits your company or any name for a group of related components. For example, all of the Ionic generated web components use the prefix ion.

Devs Stencil - Stencil Component Starter

This is a starter project for building a standalone Web Component using Stencil.

Stencil is also great for building entire apps. For that, use the stencil-app-starter instead.

Stencil

Stencil is a compiler for building fast web apps using Web Components.

Stencil combines the best concepts of the most popular frontend frameworks into a compile-time rather than run-time tool. Stencil takes TypeScript, JSX, a tiny virtual DOM layer, efficient one-way data binding, an asynchronous rendering pipeline (similar to React Fiber), and lazy-loading out of the box, and generates 100% standards-based Web Components that run in any browser supporting the Custom Elements v1 spec.

Stencil components are just Web Components, so they work in any major framework or with no framework at all.

0.5.12

2 months ago

0.5.11-alpha.3

3 months ago

0.5.11-alpha.4

3 months ago

0.5.11-alpha.5

3 months ago

0.5.11-alpha.6

2 months ago

0.5.11-alpha.7

2 months ago

0.5.12-alpha.0

3 months ago

0.5.11-alpha.2

4 months ago

0.5.11-alpha.0

4 months ago

0.5.11-alpha.1

4 months ago

0.5.10-alpha.3

5 months ago

0.5.10-alpha.0

5 months ago

0.5.10-alpha.1

5 months ago

0.5.10-alpha.2

5 months ago

0.5.8

6 months ago

0.5.9

6 months ago

0.5.9-alpha.0

6 months ago

0.5.7

11 months ago

0.5.7-alpha.9

11 months ago

0.5.7-alpha.5

11 months ago

0.5.7-alpha.6

11 months ago

0.5.7-alpha.7

11 months ago

0.5.7-alpha.8

11 months ago

0.5.7-alpha.1

11 months ago

0.5.7-alpha.2

11 months ago

0.5.7-alpha.3

11 months ago

0.5.7-alpha.4

11 months ago

0.5.6-alpha.0

1 year ago

0.5.5-alpha.0

1 year ago

0.5.4-alpha.0

1 year ago

0.5.3-alpha.0

1 year ago

0.5.8-alpha.0

1 year ago

0.5.3

1 year ago

0.5.6

1 year ago

0.5.5

1 year ago

0.5.2

1 year ago

0.5.7-alpha.0

1 year ago

0.5.0

2 years ago

0.5.1

1 year ago

0.4.4-alpha.0

2 years ago

0.4.3-alpha.0

2 years ago

0.4.1-alpha.0

2 years ago

0.4.0-alpha.0

2 years ago

0.3.0-alpha.0

2 years ago

0.2.2-alpha.0

2 years ago

0.2.1-alpha

2 years ago

0.2.0-alpha

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago