1.2.2 • Published 3 years ago
@coveops/result-badge v1.2.2
ResultBadge
Disclaimer: This component was built by the community at large and is not an official Coveo JSUI Component. Use this component at your own risk.
Options:
- field: field you want to display on the result template
- textColor: color of the text inside the badge, any valid CSS values such as "white" or hex like "#ffffff" is acceptable
- backgroundColor: color of the background, any valid CSS values such as "white" or hex like "#ffffff" is acceptable
- shouldBeLocalized: boolean that tells us whether we should attempt to localize the field name within the component. By default set to
false. - tab: list of tabs to show the component in.
- tabNot: list of tabs to not to show the component in.
Getting Started
- Install the component into your project.
npm i @coveops/result-badge- Use the Component or extend it
Typescript:
import { ResultBadge, IResultBadgeOptions } from '@coveops/result-badge';Javascript
const ResultBadge = require('@coveops/result-badge').ResultBadge;- You can also expose the component alongside other components being built in your project.
export * from '@coveops/result-badge'- Or for quick testing, you can add the script from unpkg
<script src="https://unpkg.com/@coveops/result-badge@latest/dist/index.min.js"></script>Disclaimer: Unpkg should be used for testing but not for production.
- Include the CSS in the root
index.scss
@import '../../node_modules/@coveops/result-badge/dist/css/index.css';Or for quick testing, you can add the styles from unpkg
<link rel="stylesheet" href="https://unpkg.com/@coveops/result-badge@latest/dist/css/index.css" />- Include the component in your template as follows:
Place the component in your markup:
<div class="CoveoResultBadge"></div>Extending
Extending the component can be done as follows:
import { ResultBadge, IResultBadgeOptions } from "@coveops/result-badge";
export interface IExtendedResultBadgeOptions extends IResultBadgeOptions {}
export class ExtendedResultBadge extends ResultBadge {}Contribute
- Clone the project
- Copy
.env.distto.envand update the COVEO_ORG_ID and COVEO_TOKEN fields in the.envfile to use your Coveo credentials and SERVER_PORT to configure the port of the sandbox - it will use 8080 by default. - Build the code base:
npm run build - Serve the sandbox for live development
npm run serve