mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-15 13:43:39 +01:00
30 lines
790 B
TypeScript
30 lines
790 B
TypeScript
import type { Environment } from '@yaakapp-internal/models';
|
|
import classNames from 'classnames';
|
|
import { showColorPicker } from '../lib/showColorPicker';
|
|
|
|
export function EnvironmentColorIndicator({
|
|
environment,
|
|
clickToEdit,
|
|
}: {
|
|
environment: Environment | null;
|
|
clickToEdit?: boolean;
|
|
}) {
|
|
if (environment?.color == null) return null;
|
|
|
|
const style = { backgroundColor: environment.color };
|
|
const className =
|
|
'inline-block w-[0.75em] h-[0.75em] rounded-full mr-1.5 border border-transparent';
|
|
|
|
if (clickToEdit) {
|
|
return (
|
|
<button
|
|
onClick={() => showColorPicker(environment)}
|
|
style={style}
|
|
className={classNames(className, 'hover:border-text')}
|
|
/>
|
|
);
|
|
} else {
|
|
return <span style={style} className={className} />;
|
|
}
|
|
}
|