All files / Collapsible Collapsible.stories.tsx

78.57% Statements 22/28
100% Branches 0/0
45.45% Functions 5/11
78.57% Lines 22/28

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                                        1x 1x   1x       1x                                                                       1x 1x   1x       1x                                                                         1x 1x   1x       1x                                                                                 1x 1x   1x       1x                                                                                       1x 1x           1x   1x     1x                                         1x  
import React, { useState } from 'react';
import { Meta, Story } from '@storybook/react';
 
import Collapsible, { ICollapsibleProps } from './Collapsible';
import Button from '../Button/Button';
import SingleSelect from '../SingleSelect/SingleSelect';
 
export default {
	title: 'Utility/Collapsible',
	component: Collapsible,
	parameters: {
		docs: {
			description: {
				component: Collapsible.peek.description,
			},
		},
	},
} as Meta;
 
/* Toggle Expand */
export const ToggleExpand: Story<ICollapsibleProps> = (args) => {
	const [isExpanded, setIsExpanded] = useState(true);
 
	const handleToggle = () => {
		setIsExpanded(!isExpanded);
	};
 
	return (
		<section>
			<Button onClick={handleToggle}>toggle</Button>
 
			<Collapsible
				{...args}
				isExpanded={isExpanded}
				style={{ background: '#f4f2f2', padding: 10 }}
			>
				<p>
					Kitsch aesthetic gluten-free bitters affogato, you probably haven't
					heard of them DIY in cornhole sunt meditation man braid cardigan.
					Selfies stumptown sriracha, small batch williamsburg synth organic
					aute mlkshk beard venmo normcore XOXO freegan chambray. Freegan
					delectus next level nostrud intelligentsia swag. Pabst delectus
					selfies kale chips, duis pariatur locavore iPhone. Chia 3 wolf moon
					tofu messenger bag pop-up intelligentsia. Pinterest excepteur yuccie
					four dollar toast DIY. Plaid drinking vinegar locavore id mustache.
				</p>
				<p>
					Flexitarian gentrify taxidermy, bitters chambray swag etsy brunch kogi
					pork belly authentic. Direct trade put a bird on it ad bespoke,
					occaecat marfa cliche nisi aliquip kale chips synth readymade. Odio
					austin keytar pour-over fugiat. Pickled everyday carry laborum
					sartorial pinterest labore, organic voluptate banh mi kitsch. Leggings
					austin thundercats cliche. Neutra typewriter sapiente, intelligentsia
					semiotics +1 esse ex authentic aesthetic banh mi drinking vinegar
					knausgaard. Id tousled culpa, ut chia cillum actually fashion axe
					cronut forage assumenda tilde ramps.
				</p>
			</Collapsible>
		</section>
	);
};
 
/* Not Animated */
export const NotAnimated: Story<ICollapsibleProps> = (args) => {
	const [isExpanded, setIsExpanded] = useState(true);
 
	const handleToggle = () => {
		setIsExpanded(!isExpanded);
	};
 
	return (
		<section>
			<Button onClick={handleToggle}>toggle</Button>
 
			<Collapsible
				{...args}
				isAnimated={false}
				isExpanded={isExpanded}
				style={{ background: '#f4f2f2', padding: 10 }}
			>
				<p>
					Kitsch aesthetic gluten-free bitters affogato, you probably haven't
					heard of them DIY in cornhole sunt meditation man braid cardigan.
					Selfies stumptown sriracha, small batch williamsburg synth organic
					aute mlkshk beard venmo normcore XOXO freegan chambray. Freegan
					delectus next level nostrud intelligentsia swag. Pabst delectus
					selfies kale chips, duis pariatur locavore iPhone. Chia 3 wolf moon
					tofu messenger bag pop-up intelligentsia. Pinterest excepteur yuccie
					four dollar toast DIY. Plaid drinking vinegar locavore id mustache.
				</p>
				<p>
					Flexitarian gentrify taxidermy, bitters chambray swag etsy brunch kogi
					pork belly authentic. Direct trade put a bird on it ad bespoke,
					occaecat marfa cliche nisi aliquip kale chips synth readymade. Odio
					austin keytar pour-over fugiat. Pickled everyday carry laborum
					sartorial pinterest labore, organic voluptate banh mi kitsch. Leggings
					austin thundercats cliche. Neutra typewriter sapiente, intelligentsia
					semiotics +1 esse ex authentic aesthetic banh mi drinking vinegar
					knausgaard. Id tousled culpa, ut chia cillum actually fashion axe
					cronut forage assumenda tilde ramps.
				</p>
			</Collapsible>
		</section>
	);
};
 
/* Unmount Children On Collapse */
export const UnmountChildrenOnCollapse: Story<ICollapsibleProps> = (args) => {
	const [isExpanded, setIsExpanded] = useState(true);
 
	const handleToggle = () => {
		setIsExpanded(!isExpanded);
	};
 
	return (
		<section>
			<Button onClick={handleToggle}>toggle</Button>
 
			<Collapsible
				{...args}
				isExpanded={isExpanded}
				style={{ background: '#f4f2f2', padding: 10 }}
			>
				<p>
					Kitsch aesthetic gluten-free bitters affogato, you probably haven't
					heard of them DIY in cornhole sunt meditation man braid cardigan.
					Selfies stumptown sriracha, small batch williamsburg synth organic
					aute mlkshk beard venmo normcore XOXO freegan chambray. Freegan
					delectus next level nostrud intelligentsia swag. Pabst delectus
					selfies kale chips, duis pariatur locavore iPhone. Chia 3 wolf moon
					tofu messenger bag pop-up intelligentsia. Pinterest excepteur yuccie
					four dollar toast DIY. Plaid drinking vinegar locavore id mustache.
				</p>
				<SingleSelect DropMenu={{ isExpanded: true }}>
					<SingleSelect.Option>Will</SingleSelect.Option>
					<SingleSelect.Option>Not</SingleSelect.Option>
					<SingleSelect.Option>Remain</SingleSelect.Option>
				</SingleSelect>
				<p>
					Flexitarian gentrify taxidermy, bitters chambray swag etsy brunch kogi
					pork belly authentic. Direct trade put a bird on it ad bespoke,
					occaecat marfa cliche nisi aliquip kale chips synth readymade. Odio
					austin keytar pour-over fugiat. Pickled everyday carry laborum
					sartorial pinterest labore, organic voluptate banh mi kitsch. Leggings
					austin thundercats cliche. Neutra typewriter sapiente, intelligentsia
					semiotics +1 esse ex authentic aesthetic banh mi drinking vinegar
					knausgaard. Id tousled culpa, ut chia cillum actually fashion axe
					cronut forage assumenda tilde ramps.
				</p>
			</Collapsible>
		</section>
	);
};
 
/* Render Children On Collapse */
export const RenderChildrenOnCollapse: Story<ICollapsibleProps> = (args) => {
	const [isExpanded, setIsExpanded] = useState(true);
 
	const handleToggle = () => {
		setIsExpanded(!isExpanded);
	};
 
	return (
		<section>
			<Button onClick={handleToggle}>toggle</Button>
 
			<Collapsible
				{...args}
				isMountControlled={false}
				isExpanded={isExpanded}
				style={{ background: '#f4f2f2', padding: 10 }}
			>
				<p>
					Kitsch aesthetic gluten-free bitters affogato, you probably haven't
					heard of them DIY in cornhole sunt meditation man braid cardigan.
					Selfies stumptown sriracha, small batch williamsburg synth organic
					aute mlkshk beard venmo normcore XOXO freegan chambray. Freegan
					delectus next level nostrud intelligentsia swag. Pabst delectus
					selfies kale chips, duis pariatur locavore iPhone. Chia 3 wolf moon
					tofu messenger bag pop-up intelligentsia. Pinterest excepteur yuccie
					four dollar toast DIY. Plaid drinking vinegar locavore id mustache.
				</p>
				<div style={{ display: 'flex', justifyContent: 'center' }}>
					<SingleSelect DropMenu={{ isExpanded: true }}>
						<SingleSelect.Option>Will</SingleSelect.Option>
						<SingleSelect.Option>Stay</SingleSelect.Option>
						<SingleSelect.Option>Rendered</SingleSelect.Option>
					</SingleSelect>
				</div>
				<p>
					Flexitarian gentrify taxidermy, bitters chambray swag etsy brunch kogi
					pork belly authentic. Direct trade put a bird on it ad bespoke,
					occaecat marfa cliche nisi aliquip kale chips synth readymade. Odio
					austin keytar pour-over fugiat. Pickled everyday carry laborum
					sartorial pinterest labore, organic voluptate banh mi kitsch. Leggings
					austin thundercats cliche. Neutra typewriter sapiente, intelligentsia
					semiotics +1 esse ex authentic aesthetic banh mi drinking vinegar
					knausgaard. Id tousled culpa, ut chia cillum actually fashion axe
					cronut forage assumenda tilde ramps.
				</p>
			</Collapsible>
		</section>
	);
};
 
/* Toggle With On Rest Callback */
export const ToggleWithOnRestCallback: Story<ICollapsibleProps> = (args) => {
	const onRest = () => {
		alert(
			'I am and always will be the optimist. The hoper of far-flung hopes and the dreamer of improbable dreams.'
		);
	};
 
	const [isExpanded, setIsExpanded] = useState(false);
 
	const handleToggle = () => {
		setIsExpanded(!isExpanded);
	};
	return (
		<section>
			<Button onClick={handleToggle}>toggle</Button>
 
			<Collapsible
				{...args}
				isExpanded={isExpanded}
				style={{ background: '#f4f2f2', padding: 10 }}
				onRest={onRest}
			>
				<p>
					Everybody knows that everybody dies. But not every day. Not today.
					Some days are special. Some days are so, so blessed. Some days, nobody
					dies at all. Now and then, every once in a very long while, every day
					in a million days, when the wind stands fair and the Doctor comes to
					call, everybody lives.
				</p>
			</Collapsible>
		</section>
	);
};
ToggleWithOnRestCallback.storyName = 'Toggle With OnRest Callback';