UNPKG

brightyui

Version:

Brighty UI library

23 lines 1.35 kB
var _this = this; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useState } from 'react'; import styles from '../../../src/styles/Tab.module.scss'; import { cnb } from 'cnbuilder'; import Typography from '../Typography/Typography'; import { EColors } from '../../types/EColors'; var Tab = function (_a) { var _b, _c; var tabs = _a.tabs, onClick = _a.onClick; var _d = useState(tabs[0]), activeTab = _d[0], setActiveTab = _d[1]; var handleClick = function (value) { setActiveTab(value); onClick(value); }; return (_jsxs("div", { className: styles.root, children: [_jsx("div", { className: cnb(styles.tab, (_b = {}, _b[styles.tab__active] = activeTab === tabs[0], _b)), onClick: handleClick.bind(_this, tabs[0]), children: _jsx(Typography, { variant: 'pSmallRegular', color: activeTab === tabs[0] ? EColors.text0 : EColors.text2, children: tabs[0] }) }), _jsx("div", { className: cnb(styles.tab, (_c = {}, _c[styles.tab__active] = activeTab === tabs[1], _c)), onClick: handleClick.bind(_this, tabs[1]), children: _jsx(Typography, { variant: 'pSmallRegular', color: activeTab === tabs[1] ? EColors.text0 : EColors.text2, children: tabs[1] }) })] })); }; export default Tab; //# sourceMappingURL=Tab.js.map