@fortawesome/free-solid-svg-icons#faRulerCombined TypeScript Examples

The following examples show how to use @fortawesome/free-solid-svg-icons#faRulerCombined. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AngleParam.tsx    From ble with Apache License 2.0 5 votes vote down vote up
AngleParam: FunctionComponent<Props> = ({ params }) => {
	const { undoManager } = useStore();

	const onChangeAngleSlider = (ev: ChangeEvent<HTMLInputElement>): void => {
		params.setAngle(ev.target.valueAsNumber * DEG_TO_RAD);
	};

	const onChangeAngleInput = (angle: number): void => {
		params.setAngle(angle * DEG_TO_RAD);
	};

	function onFocus(): void {
		undoManager.startGroup();
	}
	function onBlur(): void {
		undoManager.stopGroup();
	}

	// remove floating point inaccuracies by flooring
	const angleDegrees = Math.floor(params.angle * RAD_TO_DEG);

	return (
		<Container>
			<label>
				<FontAwesomeIcon icon={faRulerCombined}/>
				&#32;
				angle:
				&#32;
				<AngleInput
					min={-180}
					max={180}
					step={1}
					value={angleDegrees}
					onChange={onChangeAngleInput}
					onFocus={onFocus}
					onBlur={onBlur}
				/>
			</label>
			<input
				type="range"
				min="-180"
				max="180"
				step="1"
				value={angleDegrees}
				onChange={onChangeAngleSlider}
				onFocus={onFocus}
				onBlur={onBlur}
			/>
		</Container>
	);
}