@yandex/ui
Version:
Yandex UI components
23 lines (22 loc) • 1.43 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Direction = void 0;
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var bundle_1 = require("@yandex-lego/components/Button/desktop/bundle");
var bundle_2 = require("@yandex-lego/components/Tooltip/desktop/bundle");
var Popup_1 = require("@yandex-lego/components/Popup");
var Direction = function () {
var _a = tslib_1.__read(react_1.useState(true), 2), visible = _a[0], setVisible = _a[1];
var _b = tslib_1.__read(react_1.useState(0), 2), directionIndex = _b[0], setDirectionIndex = _b[1];
var anchorRef = react_1.useRef(null);
return (react_1.default.createElement("div", { style: { margin: 32, display: 'flex', justifyContent: 'center' } },
react_1.default.createElement(bundle_1.Button, { size: "m", view: "default", innerRef: anchorRef, onClick: function () {
setVisible(true);
setDirectionIndex((directionIndex + 1) % Popup_1.directions.length);
} },
"Current direction: ",
Popup_1.directions[directionIndex]),
react_1.default.createElement(bundle_2.Tooltip, { hasTail: true, key: Popup_1.directions[directionIndex], direction: Popup_1.directions[directionIndex], anchor: anchorRef, view: "default", visible: visible, size: "s" }, Popup_1.directions[directionIndex])));
};
exports.Direction = Direction;