This commit is contained in:
Jeremy Rangel
2025-11-30 00:50:56 -08:00
commit f1e7005b26
12 changed files with 844 additions and 0 deletions

32
JustificationControl.js Normal file
View File

@ -0,0 +1,32 @@
import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
import { justifyLeft, justifyCenter, justifyRight } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
export default function JustificationControl({ value, onChange, label = __('Justification', 'directory-listings') }) {
const options = [
{ icon: justifyLeft, value: 'left', label: __('Left', 'directory-listings') },
{ icon: justifyCenter, value: 'center', label: __('Center', 'directory-listings') },
{ icon: justifyRight, value: 'right', label: __('Right', 'directory-listings') },
];
return (
<div className="justification-control">
{/* Label above toolbar */}
<div className="justification-control__label" style={{ marginBottom: '4px', display: 'block' }}>
{label}
</div>
<ToolbarGroup label={label}>
{options.map((option) => (
<ToolbarButton
key={option.value}
icon={option.icon}
label={option.label} // accessible for screen readers
isPressed={value === option.value}
onClick={() => onChange(option.value)}
/>
))}
</ToolbarGroup>
</div>
);
}