Skip to content

🎥 Make videos programmatically with React

1.7 KB
Raw Blame
import type {SVGProps} from 'react';
import React from 'react';
import {
	CURRENT_COLOR,
	LIGHT_TEXT,
	TRANSPARENT,
	WHITE,
	WHITE_ALPHA_06,
} from '../../helpers/colors';
import {
	FOCUS_VISIBLE_ONLY_CLASS_NAME,
	HOVERABLE_CLASS_NAME,
	hoverableStyle,
} from '../../helpers/hoverable';
import {useZIndex} from '../../state/z-index';

const style: React.CSSProperties = {
	appearance: 'none',
	border: 'none',
	borderRadius: 4,
	cursor: 'default',
	display: 'inline-flex',
	justifyContent: 'center',
	alignItems: 'center',
	padding: 3,
	...hoverableStyle({
		idleBackground: TRANSPARENT,
		hoverBackground: WHITE_ALPHA_06,
		idleColor: LIGHT_TEXT,
		hoverColor: WHITE,
	}),
};

export const CancelIcon: React.FC<SVGProps<SVGSVGElement>> = (props) => {
	return (
		<svg viewBox="0 0 640 640" {...props}>
			<path
				fill={CURRENT_COLOR}
				d="M507.3 155.3C513.5 149.1 513.5 138.9 507.3 132.7C501.1 126.5 490.9 126.5 484.7 132.7L320 297.4L155.3 132.7C149.1 126.5 138.9 126.5 132.7 132.7C126.5 138.9 126.5 149.1 132.7 155.3L297.4 320L132.7 484.7C126.5 490.9 126.5 501.1 132.7 507.3C138.9 513.5 149.1 513.5 155.3 507.3L320 342.6L484.7 507.3C490.9 513.5 501.1 513.5 507.3 507.3C513.5 501.1 513.5 490.9 507.3 484.7L342.6 320L507.3 155.3z"
			/>
		</svg>
	);
};

export const CancelButton: React.FC<
	SVGProps<SVGSVGElement> & {
		readonly onPress: () => void;
		readonly 'aria-label': string;
	}
> = ({onPress, 'aria-label': ariaLabel, ...props}) => {
	const {tabIndex} = useZIndex();
	return (
		<button
			aria-label={ariaLabel}
			className={`${HOVERABLE_CLASS_NAME} ${FOCUS_VISIBLE_ONLY_CLASS_NAME}`}
			tabIndex={tabIndex}
			style={style}
			type="button"
			onClick={onPress}
		>
			<CancelIcon {...props} />
		</button>
	);
};