Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oakfang/untrigger
A DraftJS plugin for sentiment analysis
https://github.com/oakfang/untrigger
Last synced: 6 days ago
JSON representation
A DraftJS plugin for sentiment analysis
- Host: GitHub
- URL: https://github.com/oakfang/untrigger
- Owner: oakfang
- License: mit
- Created: 2020-02-11T09:08:20.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T06:58:32.000Z (about 2 years ago)
- Last Synced: 2024-11-09T18:19:21.329Z (2 months ago)
- Language: TypeScript
- Size: 2.84 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# untrigger
## Usage with DraftJS
```js
import styled from 'styled-components';
import { CompositeDecorator } from 'draft-js';
import { createSentimentDecorators } from 'untrigger/draftjs';
import { myDecorator } from './my-decorators';export default new CompositeDecorator([
myDecorator,
...createSentimentDecorators({
negativeComponent: styled.span`
color: red;
text-decoration: line-through;
`,
positiveComponent: styled.span`
color: green;
`,
}),
]);
```## Usage with React (using [`sentiment`](https://www.npmjs.com/package/sentiment))
```js
import React, { useState } from 'react';
import styled from 'styled-components';
import { useSentimentAnalysis } from 'untrigger/hooks';export function EmojiTextBox() {
const [text, setText] = useState('');
const { score } = useSentimentAnalysis(text);
let emoji = '😐';
if (score < 0) {
emoji = '🤬';
} else if (score > 0) {
emoji = '😊';
}
return (
setText(e.target.value)} />
{emoji}
);
}const Container = styled.div`
display: flex;
`;
```