New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bruit/component

Package Overview
Dependencies
Maintainers
1
Versions
162
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bruit/component

send your feedbacks with bruit.io

  • 0.2.14
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
456
increased by67.03%
Maintainers
1
Weekly downloads
 
Created
Source

Bruit.io

BRuit is a User Issues Tool

NPM Version License License Built With Stencil

available on all frameworks that support WebComponents like

javascript Angular React Vue

Bruit is a webComponent for user review ...


Getting started

start on bruit.io

Table of Contents

Install
Usage
Configuration
    BrtConfig
    BrtField
    BrtLabels
    BrtColors
    BrtLogLevels
    BrtData
    BrtError
Add data in feedback
Handle errors
Framework integrations
Contributing
Having troubles ?

Install

npm install @bruit/component --save

or

<script src="https://unpkg.com/@bruit/component/dist/bruit.js"></script>

Usage

<bruit-io> element to click </bruit-io>

with properties :

Framework integrations :

Javascript      Angular      React      Vue

Configuration

bruit-io webComponent has a config property.

config property take a BrtConfig value.

BrtConfig

BrtConfig is a JSON for configure and customize bruit-io component

attributetypedescriptionrequireddefault value
apiKeystringyour personal api key (create my api key)yes-
formarray<BrtField>input list for generate formyes-
closeModalOnSubmitbooleantrue for close modal directly on submit form and send feedback in backgroundnofalse
labelsBrtLabelslabels of the modal (title/button/...)nosee
logLevelsBrtLogLevelstype and number of log to sendnosee
maxLogLinesnumbernumber of log to sendno100
colorsBrtColorsmodal themingnosee
apiUrlstringif you want use your own api for send feedbacknohttps://api.bruit.io/feedback
  • import if using Typescript :
import { BrtConfig } from '@bruit/component';

BrtField

BrtConfig.form must be contains minimum one BrtField with id="agreement" and type="checkbox".

this field is used to check if the user agrees to send his personal data.

  • special ids :

    • agreement id is used for determinate the field to use for check if user agrees to send his personal data
    • title id is used for determinate the field tu use for make the title of feedback
  • format :

interface BrtField {
  id?: string;
  label: string;
  type: string;
  required?: boolean;
  value?: any;
}
  • import if using Typescript :
import { BrtField } from '@bruit/component';

BrtLabels

  • default value :
{
  "title": "bruit.io",
  "introduction": "send a feedback",
  "button": "send"
}
  • import if using Typescript :
import { BrtLabels } from '@bruit/component';

BrtColors

  • default value :
{
  "header": "#2D8297",
  "body": "#eee",
  "background": "#444444ee",
  "errors": "#c31313",
  "focus": "#1f5a69"
}
  • import if using Typescript :
import { BrtColors } from '@bruit/component';

BrtLogLevels

  • default value :
{
  "log": true,
  "debug": true,
  "info": true,
  "warn": true,
  "error": true,
  "network": true,
  "click": true,
  "url": true
}
  • import if using Typescript :
import { BrtLogLevels } from '@bruit/component';

BrtData

  • import if using Typescript :
import { BrtData } from '@bruit/component';

BrtError

  • import if using Typescript :
import { BrtError } from '@bruit/component';

Add data in feedback

Handle errors

Framework integrations

JavaScript

Integrating bruit-io component to a project without a JavaScript framework is straight forward. If you're using a simple HTML page, you can add bruit component via a script tag.

<!DOCTYPE html>
<html lang="en">
<head>
  <script src="https://unpkg.com/@bruit/component/dist/test-components.js"></script>
</head>
<body>
  <bruit-io></bruit-io>
    <script>
    var bruitCmp = document.querySelector('bruit-io');
    bruitCmp.config = {
      apiKey: 'xxxxxxxxxxxxxxxxx',
      form: [...]
    };
  </script>
</body>
</html>

from stencil documentation

Angular

Using bruit-io component within an Angular CLI project is a two-step process. We need to:

  1. Include the CUSTOM_ELEMENTS_SCHEMA in the modules that use the components
  2. Call defineCustomElements(window) from main.ts (or some other appropriate place)

Including the Custom Elements Schema

Including the CUSTOM_ELEMENTS_SCHEMA in the module allows the use of the web components in the HTML markup without the compiler producing errors. Here is an example of adding it to AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule],
  bootstrap: [AppComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule {}

The CUSTOM_ELEMENTS_SCHEMA needs to be included in any module that uses custom elements.

Calling defineCustomElements

Bruit component include a main function that is used to load the components in the collection. That function is called defineCustomElements() and it needs to be called once during the bootstrapping of your application. One convenient place to do this is in main.ts as such:

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

import { defineCustomElements } from '@bruit/component/dist/loader';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic()
  .bootstrapModule(AppModule)
  .catch(err => console.log(err));
defineCustomElements(window);

from stencil documentation

React

With an application built using the create-react-app script the easiest way to include the bruit-io component is to call defineCustomElements(window) from the index.js file.

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

import { defineCustomElements } from '@bruit/component/dist/loader';

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
defineCustomElements(window);

from stencil documentation

Vue

In order to use the bruit-io component within the Vue app, the application must be modified to define the custom elements and to inform the Vue compiler which elements to ignore during compilation. This can all be done within the main.js file. For example:

import Vue from 'vue';
import App from './App.vue';
import { defineCustomElements } from '@bruit/component/dist/loader';

Vue.config.productionTip = false;
Vue.config.ignoredElements = [/bruit-\w*/];

defineCustomElements(window);

new Vue({
  render: h => h(App)
}).$mount('#app');

from stencil documentation

Contributing

xxx

Having troubles ?

  • issues Github
  • stackoverflow

FAQs

Package last updated on 08 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc