diff --git a/frontend/src/components/format/FormatConditionsTab.jsx b/frontend/src/components/format/FormatConditionsTab.jsx index 60f6694..a4f8b6f 100644 --- a/frontend/src/components/format/FormatConditionsTab.jsx +++ b/frontend/src/components/format/FormatConditionsTab.jsx @@ -22,6 +22,28 @@ const FormatConditionsTab = ({conditions, onConditionsChange}) => { onConditionsChange(conditions.filter((_, i) => i !== index)); }; + const handleMoveUp = index => { + if (index > 0) { + const newConditions = [...conditions]; + [newConditions[index - 1], newConditions[index]] = [ + newConditions[index], + newConditions[index - 1] + ]; + onConditionsChange(newConditions); + } + }; + + const handleMoveDown = index => { + if (index < conditions.length - 1) { + const newConditions = [...conditions]; + [newConditions[index], newConditions[index + 1]] = [ + newConditions[index + 1], + newConditions[index] + ]; + onConditionsChange(newConditions); + } + }; + if (isLoading) { return
Loading patterns...
; } @@ -55,6 +77,10 @@ const FormatConditionsTab = ({conditions, onConditionsChange}) => { } onDelete={() => handleConditionDelete(index)} patterns={patterns} + onMoveUp={() => handleMoveUp(index)} + onMoveDown={() => handleMoveDown(index)} + isFirst={index === 0} + isLast={index === conditions.length - 1} /> ))} @@ -62,9 +88,7 @@ const FormatConditionsTab = ({conditions, onConditionsChange}) => { {/* Add New Condition Card */}
+ className='bg-white dark:bg-gray-800 border-2 border-dashed border-gray-300 dark:border-gray-700 rounded-lg p-4 hover:border-blue-500 dark:hover:border-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/10 transition-colors cursor-pointer'>
diff --git a/frontend/src/components/format/conditions/ConditionCard.jsx b/frontend/src/components/format/conditions/ConditionCard.jsx index d035830..e81eeb8 100644 --- a/frontend/src/components/format/conditions/ConditionCard.jsx +++ b/frontend/src/components/format/conditions/ConditionCard.jsx @@ -1,9 +1,19 @@ import React from 'react'; import PropTypes from 'prop-types'; import {CONDITION_TYPES, createCondition} from './conditionTypes'; +import {ArrowUp, ArrowDown} from 'lucide-react'; import BrowserSelect from '@ui/BrowserSelect'; -const ConditionCard = ({condition, onChange, onDelete, patterns}) => { +const ConditionCard = ({ + condition, + onChange, + onDelete, + patterns, + onMoveUp, + onMoveDown, + isFirst, + isLast +}) => { const conditionType = CONDITION_TYPES[condition.type?.toUpperCase()]; const Component = conditionType?.component; @@ -25,95 +35,115 @@ const ConditionCard = ({condition, onChange, onDelete, patterns}) => { }; return ( -
- {/* Custom Name Input */} -
- - onChange({...condition, name: e.target.value}) - } - placeholder='Enter a condition name...' - className='w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 - rounded-md bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 - focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400' - /> +
+ {/* Main content with more right padding */} +
+ {/* Content remains the same */} + {/* Custom Name Input */} +
+ + onChange({...condition, name: e.target.value}) + } + placeholder='Enter a condition name...' + className='w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 + rounded-md bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 + focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400' + /> +
+ +
+ {/* Type Selection */} + + + {/* Render the specific condition component */} + {Component && ( + + )} + + {/* Universal Controls */} +
+ {/* Required Checkbox */} + + + {/* Negate Checkbox */} + + + {/* Delete Button */} + +
+
-
- {/* Type Selection */} - - - {/* Render the specific condition component */} - {Component && ( - - )} - - {/* Universal Controls */} -
- {/* Required Checkbox */} - - - {/* Negate Checkbox */} - - - {/* Delete Button */} - -
+ {/* Move Up/Down Buttons - Now positioned further right */} +
+ +
); @@ -133,7 +163,11 @@ ConditionCard.propTypes = { name: PropTypes.string.isRequired, description: PropTypes.string }) - ).isRequired + ).isRequired, + onMoveUp: PropTypes.func.isRequired, + onMoveDown: PropTypes.func.isRequired, + isFirst: PropTypes.bool.isRequired, + isLast: PropTypes.bool.isRequired }; export default ConditionCard;