Skip to content

Commit fad661a

Browse files
committed
feat: added compromise to defaultStatements loader
1 parent d65335f commit fad661a

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

src/components/statements/ActionForm.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const ActionForm: React.FC<ActionFormProps> = ({
2626
};
2727

2828
return (
29-
<div className='flex items-center bg-gray-50 p-2 rounded space-x-2'>
29+
<div className='flex items-center cursor-pointer hover:bg-gray-100 border border-dashed border-gray-300 p-1 rounded'>
3030
<Input
3131
placeholder='Action text'
3232
value={text}
@@ -43,15 +43,15 @@ const ActionForm: React.FC<ActionFormProps> = ({
4343
variant='ghost'
4444
size='sm'
4545
onClick={handleSave}
46-
className='text-green-500 hover:text-green-700'
46+
className='text-green-500 hover:text-green-700 m-0'
4747
>
4848
<Save size={16} />
4949
</Button>
5050
<Button
5151
variant='ghost'
5252
size='sm'
5353
onClick={onCancel}
54-
className='text-gray-500 hover:text-gray-700'
54+
className='text-gray-500 hover:text-gray-700 m-0'
5555
>
5656
<X size={16} />
5757
</Button>

src/components/statements/ActionPreview.tsx renamed to src/components/statements/ActionLine.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const ActionPreview: React.FC<ActionPreviewProps> = ({
6565
};
6666

6767
return (
68-
<div className='space-y-2'>
68+
<div className='space-y-2 '>
6969
{actions.map((action) => {
7070
const isEditing = editingActionId === action.id;
7171
if (!isEditing) {
@@ -78,7 +78,7 @@ const ActionPreview: React.FC<ActionPreviewProps> = ({
7878
return (
7979
<div
8080
key={action.id}
81-
className='flex items-center justify-between bg-gray-50 p-2 rounded'
81+
className='flex items-center justify-between bg-white p-2 rounded border border-gray-200 shadow-sm'
8282
>
8383
<span className='flex-1'>{action.text}</span>
8484
<span className='mx-4 text-sm text-gray-500'>
@@ -123,7 +123,7 @@ const ActionPreview: React.FC<ActionPreviewProps> = ({
123123
{/* Add new action: either show the "+ Add Action" row or the inline form */}
124124
{!isAddingNew ? (
125125
<div
126-
className='flex items-center justify-between bg-gray-50 p-2 rounded cursor-pointer hover:bg-gray-100'
126+
className=' cursor-pointer hover:bg-gray-100 border border-dashed border-gray-300 p-2 rounded'
127127
onClick={handleStartAdd}
128128
>
129129
<span className='flex-1'>+ Add Action</span>

src/components/statements/ActionsCounter.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
import React from 'react';
2+
import { ChevronDown, ChevronUp } from 'lucide-react';
23

3-
/**
4-
* Props:
5-
* - count: The total number of actions.
6-
* - expanded?: whether the actions are expanded (to style differently).
7-
*
8-
* Behavior:
9-
* - Displays a small pill with "no actions" if count is 0,
10-
* or "1 action" if count is 1, or "X actions" otherwise.
11-
*/
124
interface ActionsCounterProps {
135
count: number;
146
expanded?: boolean;
@@ -20,19 +12,19 @@ const ActionsCounter: React.FC<ActionsCounterProps> = ({
2012
}) => {
2113
const baseClasses =
2214
'inline-flex items-center rounded-full px-3 py-1 text-sm transition-colors cursor-pointer';
23-
const normalClasses = 'bg-gray-100 text-gray-600';
24-
const expandedClasses = 'bg-blue-100 text-blue-600';
25-
15+
const backgroundClasses =
16+
count > 0 ? 'bg-brand-pink text-white' : 'bg-gray-100 text-gray-600';
2617
const displayText =
2718
count === 0
2819
? 'no actions'
2920
: `${count} ${count === 1 ? 'action' : 'actions'}`;
3021

3122
return (
32-
<span
33-
className={`${baseClasses} ${expanded ? expandedClasses : normalClasses}`}
34-
>
23+
<span className={`${baseClasses} ${backgroundClasses} flex items-center`}>
3524
{displayText}
25+
<span className='ml-1'>
26+
{expanded ? <ChevronUp size={16} /> : <ChevronDown size={16} />}
27+
</span>
3628
</span>
3729
);
3830
};

src/components/statements/StatementItem.tsx renamed to src/components/statements/StatementLine.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
DropdownMenuItem,
1313
} from '../ui/dropdown-menu';
1414
import ActionsCounter from './ActionsCounter';
15-
import ActionPreview from './ActionPreview';
15+
import ActionPreview from './ActionLine';
1616

1717
export interface StatementItemProps {
1818
statement: Statement;

src/components/statements/StatementList.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { useStatements } from '../../hooks/useStatements';
55
import { ConfirmationDialog } from '../ui/confirmation-dialog';
66
import type { Statement } from '../../../types/types';
77
import preStatements from '../../../data/preStatements.json';
8-
import StatementItem from './StatementItem';
8+
import nlp from 'compromise';
9+
import StatementItem from './StatementLine';
910
import { updateStatement } from '../../api/statementsApi';
1011

1112
const StatementList: React.FC<{ username: string }> = ({ username }) => {
@@ -43,9 +44,17 @@ const StatementList: React.FC<{ username: string }> = ({ username }) => {
4344
const subject = stmt.descriptor
4445
? `${username}'s ${stmt.descriptor}`
4546
: username;
47+
const presentTenseVerb = nlp(stmt.verb)
48+
.verbs()
49+
.toPresentTense()
50+
.text()
51+
.toLowerCase();
52+
const objectLower = stmt.object.toLowerCase();
4653
return {
4754
...stmt,
4855
subject,
56+
verb: presentTenseVerb,
57+
object: objectLower,
4958
id:
5059
Date.now().toString() + Math.random().toString(36).substring(2, 7),
5160
};

0 commit comments

Comments
 (0)