@yandex/ui
Version:
Yandex UI components
19 lines (18 loc) • 1.17 kB
JavaScript
import { __read } from "tslib";
import React, { useRef, useState } from 'react';
import { Button } from '@yandex-lego/components/Button/desktop/bundle';
import { Tooltip } from '@yandex-lego/components/Tooltip/desktop/bundle';
import { directions } from '@yandex-lego/components/Popup';
export var Direction = function () {
var _a = __read(useState(true), 2), visible = _a[0], setVisible = _a[1];
var _b = __read(useState(0), 2), directionIndex = _b[0], setDirectionIndex = _b[1];
var anchorRef = useRef(null);
return (React.createElement("div", { style: { margin: 32, display: 'flex', justifyContent: 'center' } },
React.createElement(Button, { size: "m", view: "default", innerRef: anchorRef, onClick: function () {
setVisible(true);
setDirectionIndex((directionIndex + 1) % directions.length);
} },
"Current direction: ",
directions[directionIndex]),
React.createElement(Tooltip, { hasTail: true, key: directions[directionIndex], direction: directions[directionIndex], anchor: anchorRef, view: "default", visible: visible, size: "s" }, directions[directionIndex])));
};