tabs

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
244
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
5 months ago
subject
Tabs are elements that help you organize and navigate multiple documents in a single container. They can be used for switching between items in the container.
Like
Use tabs in your project ?
Copied
npm i @bit/digiaonline.react-foundation.tabs
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
components/tabs.js
113 Lines(72 sloc)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import React from 'react';
import PropTypes from 'prop-types';
import { GeneralPropTypes, FlexboxPropTypes, createClassName, generalClassNames, removeProps, objectKeys } from '../utils';

/**
 * Tabs component.
 * http://foundation.zurb.com/sites/docs/tabs.html
 *
 * @param {Object} props
 * @returns {Object}
 */
export const Tabs = (props) => {
  const className = createClassName(
    props.noDefaultClassName ? null : 'tabs',
    props.className,
    {
      'vertical': props.isVertical
    },
    generalClassNames(props)
  );

  const passProps = removeProps(props, objectKeys(Tabs.propTypes));

  return <ul {...passProps} className={className}/>;
};

Tabs.propTypes = {
  ...GeneralPropTypes,
  ...FlexboxPropTypes,
  isVertical: PropTypes.bool
};

/**
 * Tab item component.
 *
 * @param {Object} props
 * @returns {Object}
 */
export const TabItem = (props) => {
  const className = createClassName(
    props.noDefaultClassName ? null : 'tabs-title',
    props.className,
    {
      'is-active': props.isActive
    },
    generalClassNames(props)
  );

  const passProps = removeProps(props, objectKeys(TabItem.propTypes));

  return <li {...passProps} className={className}/>;
};

TabItem.propTypes = {
  ...GeneralPropTypes,
  ...FlexboxPropTypes,
  isActive: PropTypes.bool
};

/**
 * Tab panel container component.
 *
 * @param {Object} props
 * @returns {Object}
 */
export const TabsContent = (props) => {
  const className = createClassName(
    props.noDefaultClassName ? null : 'tabs-content',
    props.className,
    {
      'vertical': props.isVertical
    },
    generalClassNames(props)
  );

  const passProps = removeProps(props, objectKeys(TabsContent.propTypes));

  return <div {...passProps} className={className}/>;
};

TabsContent.propTypes = {
  ...GeneralPropTypes,
  ...FlexboxPropTypes,
  isActive: PropTypes.bool,
  isVertical: PropTypes.bool
};

/**
 * Tab panel item component.
 *
 * @param {Object} props
 * @returns {Object}
 */
export const TabPanel = (props) => {
  const className = createClassName(
    props.noDefaultClassName ? null : 'tabs-panel',
    props.className,
    {
      'is-active': props.isActive
    },
    generalClassNames(props)
  );

  const passProps = removeProps(props, objectKeys(TabPanel.propTypes));

  return <div {...passProps} className={className}/>;
};

TabPanel.propTypes = {
  ...GeneralPropTypes,
  ...FlexboxPropTypes,
  isActive: PropTypes.bool
};