import { IconAlignRight } from '@tabler/icons-react';

import ActionButton from '../components/ActionButton';
import { useTextArea } from '../context';

const AlignRight = ({ title }: { title: string }) => {
  const { editor } = useTextArea();

  if (!editor) {
    return null;
  }

  return (
    <ActionButton
      title={title}
      icon={<IconAlignRight />}
      onClick={() => editor.chain().focus().toggleTextAlign('right').run()}
      isActive={editor.isActive({ textAlign: 'right' })}
    />
  );
};

export default AlignRight;
