react-elegant-ui
Version:
Elegant UI components, made by BEM best practices for react
128 lines • 3.33 kB
JavaScript
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
} catch (error) {
e = {
error: error
};
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};
import React, { useState } from 'react';
import { Button } from '../../Button/Button.bundle/desktop';
import { TabsMenu } from '../../TabsMenu/TabsMenu.bundle/desktop';
import { TabsPanes } from '../TabsPanes.bundle/desktop';
/**
* Demo component with inner state
*/
var Counter = function () {
var _a = __read(useState(0), 2),
counter = _a[0],
setCounter = _a[1];
return /*#__PURE__*/React.createElement(Button, {
onPress: function () {
return setCounter(function (num) {
return num + 1;
});
}
}, "Cick me: ", counter);
};
export var WithTabsMenu = function () {
var _a = __read(useState('counter'), 2),
activeTab = _a[0],
setActiveTab = _a[1];
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TabsMenu, {
view: "default",
layout: "horizontal",
size: "m",
activeTab: activeTab,
setActiveTab: setActiveTab,
tabs: [{
id: 'counter',
content: 'Click counter'
}, {
id: 'search',
content: 'Search'
}, {
id: 'images',
content: 'Images'
}, {
id: 'video',
content: 'Video'
}]
}), /*#__PURE__*/React.createElement(TabsPanes, {
activePane: activeTab,
style: {
padding: 'var(--typography-controls-indent-l) 0px'
},
panes: [{
id: 'counter',
content: ( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Counter, null), " i will rerender with switch tab"))
}, {
id: 'search',
content: 'Search content'
}, {
id: 'images',
content: 'Images content'
}, {
id: 'video',
content: 'Video content'
}]
}));
};
export var WithRenderAll = function () {
var _a = __read(useState('counter'), 2),
activeTab = _a[0],
setActiveTab = _a[1];
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TabsMenu, {
view: "default",
layout: "horizontal",
size: "m",
activeTab: activeTab,
setActiveTab: setActiveTab,
tabs: [{
id: 'counter',
content: 'Click counter'
}, {
id: 'search',
content: 'Search'
}, {
id: 'images',
content: 'Images'
}, {
id: 'video',
content: 'Video'
}]
}), /*#__PURE__*/React.createElement(TabsPanes, {
renderAll: true,
activePane: activeTab,
style: {
padding: 'var(--typography-controls-indent-l) 0px'
},
panes: [{
id: 'counter',
content: ( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Counter, null), " i will keep value"))
}, {
id: 'search',
content: 'Search content'
}, {
id: 'images',
content: 'Images content'
}, {
id: 'video',
content: 'Video content'
}]
}));
};