All files / Tabs Tabs.stories.tsx

100% Statements 24/24
100% Branches 0/0
100% Functions 10/10
100% Lines 24/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308                                          1x 1x                                 1x 1x                                                       1x   1x                         1x         1x                                                                         1x 1x                               1x 1x                                         1x 1x 1x                                         1x 1x                                   1x 1x 1x                                               1x 1x                                                                                                   1x 1x                                              
import React from 'react';
import { Meta, Story } from '@storybook/react';
 
import Tabs, { ITabsProps } from './Tabs';
import RadioGroup from '../RadioGroup/RadioGroup';
import Button from '../Button/Button';
import SearchField from '../SearchField/SearchField';
 
export default {
	title: 'Navigation/Tabs',
	component: Tabs,
	parameters: {
		docs: {
			description: {
				component: Tabs.peek.description,
			},
		},
	},
} as Meta;
 
/* Title As Prop */
export const TitleAsProp: Story<ITabsProps> = (args) => {
	return (
		<div>
			<Tabs {...args}>
				<Tabs.Tab Title='One' className='one'>
					One content
				</Tabs.Tab>
				<Tabs.Tab Title='Two' isDisabled={true}>
					Two content
				</Tabs.Tab>
				<Tabs.Tab Title='Three'>Three content</Tabs.Tab>
				<Tabs.Tab Title='Four'>Four content</Tabs.Tab>
			</Tabs>
		</div>
	);
};
 
/* Title As Child */
export const TitleAsChild: Story<ITabsProps> = (args) => {
	return (
		<div>
			<Tabs {...args}>
				<Tabs.Tab>
					<Tabs.Title>One</Tabs.Title>
					One content
				</Tabs.Tab>
 
				<Tabs.Tab isDisabled={true}>
					<Tabs.Title>Two</Tabs.Title>
					Two content
				</Tabs.Tab>
 
				<Tabs.Tab>
					<Tabs.Title>Three</Tabs.Title>
					Three content
				</Tabs.Tab>
 
				<Tabs.Tab>
					<Tabs.Title>Four</Tabs.Title>
					Four content
				</Tabs.Tab>
			</Tabs>
		</div>
	);
};
 
/* Complex Title As Child */
export const ComplexTitleAsChild: Story<ITabsProps> = (args) => {
	const titleThree = (
		<RadioGroup {...RadioGroup.defaultProps} selectedIndex={1}>
			<RadioGroup.RadioButton {...RadioGroup.RadioButton.defaultProps}>
				<RadioGroup.Label>Captain America</RadioGroup.Label>
			</RadioGroup.RadioButton>
			<RadioGroup.RadioButton {...RadioGroup.RadioButton.defaultProps}>
				<RadioGroup.Label>Iron Man</RadioGroup.Label>
			</RadioGroup.RadioButton>
			<RadioGroup.RadioButton {...RadioGroup.RadioButton.defaultProps}>
				<RadioGroup.Label>Thor</RadioGroup.Label>
			</RadioGroup.RadioButton>
		</RadioGroup>
	);
 
	const tabStyle = {
		height: '100px',
		width: '200px',
	};
 
	return (
		<div>
			<Tabs {...args} hasMultilineTitle={true}>
				<Tabs.Tab style={tabStyle}>
					<Tabs.Title>
						One
						<br />
						<Button {...Button.defaultProps}>Button</Button>
					</Tabs.Title>
					One content
				</Tabs.Tab>
 
				<Tabs.Tab style={tabStyle}>
					<Tabs.Title>
						Two
						<br />
						Line Two
						<SearchField />
					</Tabs.Title>
					Two content
				</Tabs.Tab>
 
				<Tabs.Tab style={tabStyle}>
					<Tabs.Title>{titleThree}</Tabs.Title>
					Three content
				</Tabs.Tab>
 
				<Tabs.Tab isDisabled={true} style={tabStyle}>
					<Tabs.Title>Four</Tabs.Title>
					Four content
				</Tabs.Tab>
			</Tabs>
		</div>
	);
};
 
/* Tab As Prop */
export const TabAsProp: Story<ITabsProps> = (args) => {
	return (
		<div>
			<Tabs
				{...args}
				Tab={
					[
						{ Title: 'Bert', children: 'Bert' },
						{ Title: 'Ernie', children: 'Ernie' },
					] as any
				}
			/>
		</div>
	);
};
 
/* Full Width */
export const FullWidth: Story<ITabsProps> = (args) => {
	return (
		<div>
			<Tabs {...args} hasFullWidthTabs={true}>
				<Tabs.Tab>
					<Tabs.Title>One</Tabs.Title>
					One content
				</Tabs.Tab>
				<Tabs.Tab>
					<Tabs.Title>Two</Tabs.Title>
					Two content
				</Tabs.Tab>
				<Tabs.Tab>
					<Tabs.Title>Three</Tabs.Title>
					Three content
				</Tabs.Tab>
			</Tabs>
		</div>
	);
};
 
/* Variable Width */
export const VariableWidth: Story<ITabsProps> = (args) => {
	const tabStyle = { width: '100px' };
	return (
		<div>
			<Tabs {...args} hasFullWidthTabs={false}>
				<Tabs.Tab style={tabStyle}>
					<Tabs.Title>One</Tabs.Title>
					One content
				</Tabs.Tab>
				<Tabs.Tab style={tabStyle}>
					<Tabs.Title>Two</Tabs.Title>
					Two content
				</Tabs.Tab>
				<Tabs.Tab style={tabStyle}>
					<Tabs.Title>Three</Tabs.Title>
					Three content
				</Tabs.Tab>
			</Tabs>
		</div>
	);
};
 
/* Progression */
export const Progression: Story<ITabsProps> = (args) => {
	return (
		<div>
			<Tabs {...args} isOpen={false} isProgressive={true}>
				<Tabs.Tab Title='One'>One content</Tabs.Tab>
				<Tabs.Tab Title='Two'>Two content</Tabs.Tab>
				<Tabs.Tab Title='Three'>Three content</Tabs.Tab>
				<Tabs.Tab Title='Disabled' isDisabled={true}>
					Disabled Content
				</Tabs.Tab>
				<Tabs.Tab Title='Five' isDisabled={true}>
					Four content
				</Tabs.Tab>
			</Tabs>
		</div>
	);
};
 
/* Progression Variable Width */
export const ProgressionVariableWidth = (args) => {
	const tabStyle = { width: '100px' };
	return (
		<div>
			<Tabs {...args} hasFullWidthTabs={false} isOpen={false} isProgressive>
				<Tabs.Tab style={tabStyle} Title='One'>
					One content
				</Tabs.Tab>
				<Tabs.Tab style={tabStyle} Title='Two'>
					Two content
				</Tabs.Tab>
				<Tabs.Tab style={tabStyle} Title='Three'>
					Three content
				</Tabs.Tab>
				<Tabs.Tab style={tabStyle} Title='Disabled' isDisabled={true}>
					Disabled Content
				</Tabs.Tab>
				<Tabs.Tab style={tabStyle} Title='Five' isDisabled={true}>
					Four content
				</Tabs.Tab>
			</Tabs>
		</div>
	);
};
 
/* With Count */
export const WithCount: Story<ITabsProps> = (args) => {
	return (
		<div>
			<h4>Static Width</h4>
			<Tabs {...args} hasFullWidthTabs={false}>
				<Tabs.Tab count={12}>
					<Tabs.Title>One</Tabs.Title>
					One content
				</Tabs.Tab>
				<Tabs.Tab count={15}>
					<Tabs.Title>Two</Tabs.Title>
					Two content
				</Tabs.Tab>
				<Tabs.Tab count={7}>
					<Tabs.Title>Three</Tabs.Title>
					Three content
				</Tabs.Tab>
				<Tabs.Tab count={3} isDisabled>
					<Tabs.Title>Four</Tabs.Title>
					Four content
				</Tabs.Tab>
				<Tabs.Tab count={0} isDisabled>
					<Tabs.Title>Five</Tabs.Title>
					Five content
				</Tabs.Tab>
			</Tabs>
 
			<h4>Variable Width</h4>
			<Tabs {...args} hasFullWidthTabs={false}>
				<Tabs.Tab count={1231321} isVariableCountWidth={true}>
					<Tabs.Title>One</Tabs.Title>
					One content
				</Tabs.Tab>
				<Tabs.Tab count={6546541612} isVariableCountWidth={true}>
					<Tabs.Title>Two</Tabs.Title>
					Two content
				</Tabs.Tab>
				<Tabs.Tab count={7} isVariableCountWidth={true}>
					<Tabs.Title>Three</Tabs.Title>
					Three content
				</Tabs.Tab>
				<Tabs.Tab count={123} isDisabled isVariableCountWidth={true}>
					<Tabs.Title>Four</Tabs.Title>
					Four content
				</Tabs.Tab>
			</Tabs>
		</div>
	);
};
 
/* 10 Floating */
export const Floating: Story<ITabsProps> = (args) => {
	return (
		<div>
			<Tabs {...args} hasFullWidthTabs={false} isFloating>
				<Tabs.Tab count={12}>
					<Tabs.Title>One</Tabs.Title>
					One content
				</Tabs.Tab>
				<Tabs.Tab count={15}>
					<Tabs.Title>Two</Tabs.Title>
					Two content
				</Tabs.Tab>
				<Tabs.Tab count={7}>
					<Tabs.Title>Three</Tabs.Title>
					Three content
				</Tabs.Tab>
				<Tabs.Tab count={3} isDisabled>
					<Tabs.Title>Three</Tabs.Title>
					Three content
				</Tabs.Tab>
			</Tabs>
		</div>
	);
};