From 325c182fb42b02d8518cdb6fe7c3a66dce5ed247 Mon Sep 17 00:00:00 2001 From: Andrei Firsov Date: Tue, 13 Aug 2019 16:19:44 +0300 Subject: [PATCH] feat(Tab): adds component. --- ...b-test-js-components-tab-common-1-snap.png | Bin 0 -> 4309 bytes e2e/__tests__/tab.test.js | 12 +++++++ src/components/Tab/Tab.js | 19 ++++++++++ src/components/Tab/Tab.stories.js | 22 ++++++++++++ src/components/Tab/Tab.theme.js | 34 ++++++++++++++++++ src/components/Tab/index.js | 5 +++ src/components/components.js | 1 + src/components/theme.js | 2 ++ 8 files changed, 95 insertions(+) create mode 100644 e2e/__tests__/__image_snapshots__/tab-test-js-components-tab-common-1-snap.png create mode 100644 e2e/__tests__/tab.test.js create mode 100644 src/components/Tab/Tab.js create mode 100644 src/components/Tab/Tab.stories.js create mode 100644 src/components/Tab/Tab.theme.js create mode 100644 src/components/Tab/index.js diff --git a/e2e/__tests__/__image_snapshots__/tab-test-js-components-tab-common-1-snap.png b/e2e/__tests__/__image_snapshots__/tab-test-js-components-tab-common-1-snap.png new file mode 100644 index 0000000000000000000000000000000000000000..9e132d828d53f510957ce6451d10c4298da14df5 GIT binary patch literal 4309 zcmdT{cT`j9w#R$#=r~@6aZnsUz=Ap;=qS=l9ySaLai}WQ31uQBLP!EqV!48I6@r0K z1JS|21QetNLr74$N>3ySH3g-FfP@GM2?3JallRv9@2&UOTkEY^>wM=s-`VHvy}#YQ z-~R2gub2KeCg14k>FI+nob}Vw`x_2;&i{HVaQDCAxeb`MApE>e>(w*&&gSSvoV5*FSXPy!-o^h2f!B_iUQZ?y}!E^n;=O?@7kF@4uS*OA1F|kNNIaywTk5 zJ29#Z<~*o&;l-`WoM7!A(zJ!lix-P*$c6p0z{TZq{|0EL7ZeABfuT@nSy`E%|FL4u zhYufy5Pty(kvjsy!YZ<}vkSdRg=OXCM~8=p&D@XZ{-H$L+S*zLTI0RFAUYF;&x`(J}~)2;)STY%~EgFgq+k27Sr7J1I!3!>9HvhL-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p^p!e;Fp#*X>sxSGSeUL77ujSwhP5vib{UxA zyA0F~JFZB_sEEUlTo2gAfbw0JDvB<4DkaD~RVhT@*Jrh`u(q~|^>K?N+!Xz<67DeG z4m!eWmP4d5#r0vy?4;?@cHv0%6)0{mdf;d3hH#!bT?r#gxmMkIpcTVheI0lv1&o*M z*&Nric>e3eGh*kNniUM@yYhEsbM5s(-TX59`uHWW72t??v`ahU)la$(_Wz(^(=|_H zT#qY5+#&x+cavZTw0sx9_%`-U-hZQXogm;i_@5#C|2Hw;kK{*Ak^iTzV=Lp2|NQOj d|Jr=75QU$v-^pFy^IB(k@HyYJ^`|56{u@BG*n9v0 literal 0 HcmV?d00001 diff --git a/e2e/__tests__/tab.test.js b/e2e/__tests__/tab.test.js new file mode 100644 index 00000000..6d3ae4b6 --- /dev/null +++ b/e2e/__tests__/tab.test.js @@ -0,0 +1,12 @@ +import { baisy } from '../setup/TestSuiter'; + + +const SUITES = [ + baisy.suite('Components/Tab', 'common'), +]; + + +SUITES.map(suite => { + it(suite.getTestName(), suite.testStory, 20000); +}); + diff --git a/src/components/Tab/Tab.js b/src/components/Tab/Tab.js new file mode 100644 index 00000000..f78a3acf --- /dev/null +++ b/src/components/Tab/Tab.js @@ -0,0 +1,19 @@ +// @flow + +import React from 'react'; + +import { TabOuter } from './Tab.theme'; + +type TabProps = { + children: React$Node, + className?: string, +}; + +const Tab = ({ children, ...rest }: TabProps) => ( + + { children } + +); + +export { Tab }; + diff --git a/src/components/Tab/Tab.stories.js b/src/components/Tab/Tab.stories.js new file mode 100644 index 00000000..2ce19464 --- /dev/null +++ b/src/components/Tab/Tab.stories.js @@ -0,0 +1,22 @@ +// @flow + +import React from 'react'; +import { css } from 'react-emotion'; + +export default (asStory: *) => { + asStory('Components/Tab', module, (story, { Tab, Row }) => { + story + .add('common', () => ( +
+ + + Active Tab + + + Inactive Tab + + +
+ )); + }); +}; diff --git a/src/components/Tab/Tab.theme.js b/src/components/Tab/Tab.theme.js new file mode 100644 index 00000000..8b064d84 --- /dev/null +++ b/src/components/Tab/Tab.theme.js @@ -0,0 +1,34 @@ +import { createThemeTag } from '../../theme/createThemeTag'; + +const name = 'tab'; + +const [TabOuter, themeTabOuter] = createThemeTag(name, () => ({ + root: { + display: 'inline-flex', + justifyContent: 'center', + alignItems: 'center', + height: '32px', + padding: '6px 12px', + fontSize: '14px', + lineHeight: '20px', + color: '#323C47', + borderRadius: '5px 5px 0 0', + backgroundColor: '#FFFFFF', + cursor: 'pointer', + + '&:not(.active)': { + opacity: 0.7, + borderRadius: '5px 5px 0 0', + }, + }, +})); + +const theme = { + ...themeTabOuter, +}; + +export { + TabOuter, + theme, +}; + diff --git a/src/components/Tab/index.js b/src/components/Tab/index.js new file mode 100644 index 00000000..789bf04e --- /dev/null +++ b/src/components/Tab/index.js @@ -0,0 +1,5 @@ +// @flow + +export { Tab } from './Tab'; +export { theme } from './Tab.theme'; + diff --git a/src/components/components.js b/src/components/components.js index 25008dcb..a468c393 100644 --- a/src/components/components.js +++ b/src/components/components.js @@ -53,4 +53,5 @@ export { NoData } from './NoData'; export { Pagination } from './Pagination'; export { Indicator } from './Indicator'; export { Divider } from './Divider'; +export { Tab } from './Tab'; diff --git a/src/components/theme.js b/src/components/theme.js index f070fcfb..f1779be9 100644 --- a/src/components/theme.js +++ b/src/components/theme.js @@ -43,6 +43,7 @@ import { theme as tooltipTheme } from './Tooltip'; import { theme as topBarTheme } from './TopBar'; import { theme as treeSelectTheme } from './TreeSelect'; import { theme as dividerTheme } from './Divider'; +import { theme as tabTheme } from './Tab'; export const theme = { @@ -89,4 +90,5 @@ export const theme = { ...topBarTheme, ...treeSelectTheme, ...dividerTheme, + ...tabTheme, };