trepur_components 2.3.3 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +43 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc.json +22 -0
- package/archive/Breadcrumbs/Breadcrumbs.stories.tsx +46 -0
- package/archive/Breadcrumbs/index.tsx +42 -0
- package/archive/BreadcrumbsBordered/BreadcrumbsBordered.stories.tsx +52 -0
- package/archive/BreadcrumbsBordered/index.tsx +44 -0
- package/archive/BreadcrumbsItem/BreadcrumbsItem.stories.tsx +40 -0
- package/archive/BreadcrumbsItem/index.tsx +149 -0
- package/archive/Button/Button.stories.tsx +150 -0
- package/archive/Button/index.tsx +111 -0
- package/archive/Button/style.module.css +76 -0
- package/archive/Calendar/Calendar.stories.tsx +82 -0
- package/archive/Calendar/index.tsx +76 -0
- package/archive/Calendar/style.css +233 -0
- package/archive/Card/Card.stories.tsx +75 -0
- package/archive/Card/index.tsx +102 -0
- package/archive/Card/style.module.css +75 -0
- package/archive/CardWithTopImage/CardWithTopImage.stories.tsx +50 -0
- package/archive/CardWithTopImage/index.tsx +39 -0
- package/archive/CardWithTopImage/style.module.css +11 -0
- package/archive/Carousel/Carousel.stories.tsx +451 -0
- package/archive/Carousel/index.tsx +388 -0
- package/archive/Carousel/style.module.css +99 -0
- package/archive/CarouselThumbnail/CarouselThumbnail.stories.tsx +350 -0
- package/archive/CarouselThumbnail/index.tsx +302 -0
- package/archive/CarouselThumbnail/style.module.css +67 -0
- package/archive/Checkbox/Checkbox.mdx +33 -0
- package/archive/Checkbox/Checkbox.stories.tsx +34 -0
- package/archive/Checkbox/index.tsx +51 -0
- package/archive/Checkbox/style.module.css +15 -0
- package/archive/Collapsible/Collapsible.stories.tsx +67 -0
- package/archive/Collapsible/index.tsx +116 -0
- package/archive/Collapsible/style.module.css +47 -0
- package/archive/Column/Column.stories.tsx +89 -0
- package/archive/Column/index.tsx +119 -0
- package/archive/Column/style.module.css +151 -0
- package/archive/ComponentWrapper/ComponentWrapper.stories.tsx +40 -0
- package/archive/ComponentWrapper/index.tsx +55 -0
- package/archive/ComponentWrapper/style.module.css +40 -0
- package/archive/Container/Container.stories.tsx +40 -0
- package/archive/Container/index.tsx +24 -0
- package/archive/Container/style.module.css +4 -0
- package/archive/Counter/Counter.stories.tsx +19 -0
- package/archive/Counter/index.tsx +66 -0
- package/archive/Counter/style.module.css +19 -0
- package/archive/DetailUpdater/DetailUpdater.stories.tsx +96 -0
- package/archive/DetailUpdater/index.tsx +112 -0
- package/archive/DetailUpdater/style.module.css +31 -0
- package/archive/Dialog/Dialog.stories.tsx +131 -0
- package/archive/Dialog/index.tsx +91 -0
- package/archive/Dialog/style.module.css +44 -0
- package/archive/DropdownMenu/DropdownMenu.stories.tsx +59 -0
- package/archive/DropdownMenu/index.tsx +51 -0
- package/archive/DropdownMenu/style.module.css +38 -0
- package/archive/DynamicTextSection/DynamicTextSection.stories.tsx +74 -0
- package/archive/DynamicTextSection/index.tsx +36 -0
- package/archive/DynamicTextSection/style.module.css +0 -0
- package/archive/FileUploader/FilePreview.tsx +48 -0
- package/archive/FileUploader/FileUploader.stories.tsx +28 -0
- package/archive/FileUploader/index.tsx +135 -0
- package/archive/FileUploader/style.module.css +54 -0
- package/archive/FilterItem/FilterItem.stories.tsx +33 -0
- package/archive/FilterItem/index.tsx +101 -0
- package/archive/FilterItem/style.module.css +27 -0
- package/archive/Footer/Footer.stories.tsx +59 -0
- package/archive/Footer/index.tsx +50 -0
- package/archive/Footer/style.module.css +19 -0
- package/archive/FooterNav/FooterNav.stories.tsx +125 -0
- package/archive/FooterNav/index.tsx +57 -0
- package/archive/FooterNav/style.module.css +32 -0
- package/archive/FooterNavItem/FooterNavItem.stories.tsx +53 -0
- package/archive/FooterNavItem/index.tsx +80 -0
- package/archive/FooterNavItem/style.module.css +139 -0
- package/archive/Form/Form.stories.tsx +86 -0
- package/archive/Form/index.tsx +61 -0
- package/archive/Form/style.module.css +0 -0
- package/archive/FyreCard/FyreCard.stories.tsx +31 -0
- package/archive/FyreCard/index.tsx +52 -0
- package/archive/FyreCard/style.module.css +19 -0
- package/archive/Greeting/Greeting.stories.tsx +41 -0
- package/archive/Greeting/index.tsx +32 -0
- package/archive/HamburgerIcon/HamburgerIcon.stories.tsx +32 -0
- package/archive/HamburgerIcon/index.tsx +103 -0
- package/archive/HamburgerIcon/style.module.css +85 -0
- package/archive/HorizontalLine/HorizontalLine.stories.tsx +54 -0
- package/archive/HorizontalLine/index.tsx +40 -0
- package/archive/HorizontalLine/style.module.css +55 -0
- package/archive/Icon/Icon.stories.tsx +164 -0
- package/archive/Icon/index.tsx +115 -0
- package/archive/Icon/style.module.css +253 -0
- package/archive/IconCard/IconCard.stories.tsx +46 -0
- package/archive/IconCard/index.tsx +57 -0
- package/archive/IconCard/style.module.css +18 -0
- package/archive/Image/Image.stories.tsx +87 -0
- package/archive/Image/index.tsx +132 -0
- package/archive/Image/style.module.css +109 -0
- package/archive/ImageInfo/ImageInfo.stories.tsx +39 -0
- package/archive/ImageInfo/index.tsx +95 -0
- package/archive/ImageInfo/style.module.css +47 -0
- package/archive/ImageLink/ImageLink.stories.tsx +37 -0
- package/archive/ImageLink/index.tsx +49 -0
- package/archive/ImageLink/style.module.css +23 -0
- package/archive/ImageLinkList/ImageLinkList.stories.tsx +34 -0
- package/archive/ImageLinkList/index.tsx +33 -0
- package/archive/ImageLinkList/style.module.css +3 -0
- package/archive/InformationIcon/InformationIcon.stories.tsx +83 -0
- package/archive/InformationIcon/index.tsx +128 -0
- package/archive/InformationIcon/style.module.css +71 -0
- package/archive/InformationIconBlock/InformationIconBlock.stories.tsx +32 -0
- package/archive/InformationIconBlock/index.tsx +63 -0
- package/archive/InformationIconBlock/style.module.css +7 -0
- package/archive/Input/Input.stories.tsx +84 -0
- package/archive/Input/index.tsx +131 -0
- package/archive/Input/style.module.css +60 -0
- package/archive/Jumbotron/Jumbotron.stories.tsx +21 -0
- package/archive/Jumbotron/index.tsx +31 -0
- package/archive/Jumbotron/style.module.css +8 -0
- package/archive/MenuButton/MenuButton.stories.tsx +46 -0
- package/archive/MenuButton/index.tsx +82 -0
- package/archive/MenuButton/style.module.css +45 -0
- package/archive/Modal/Modal.stories.tsx +86 -0
- package/archive/Modal/index.tsx +74 -0
- package/archive/Modal/style.module.css +35 -0
- package/archive/NavItem/NavItem.stories.tsx +90 -0
- package/archive/NavItem/index.tsx +65 -0
- package/archive/NavItem/style.module.css +71 -0
- package/archive/NavOld/NavOld.stories.tsx +193 -0
- package/archive/NavOld/StickyNav.tsx +191 -0
- package/archive/NavOld/index.tsx +273 -0
- package/archive/NavOld/style.module.css +156 -0
- package/archive/NavTwo/Dropdown.tsx +35 -0
- package/archive/NavTwo/Nav.stories.tsx +38 -0
- package/archive/NavTwo/Sidebar.tsx +34 -0
- package/archive/NavTwo/StickyNav.tsx +34 -0
- package/archive/NavTwo/index.tsx +45 -0
- package/archive/NavTwo/style.module.css +35 -0
- package/archive/NewsCard/NewsCard.stories.tsx +72 -0
- package/archive/NewsCard/index.tsx +57 -0
- package/archive/NewsCard/style.module.css +15 -0
- package/archive/Pill/Pill.stories.tsx +44 -0
- package/archive/Pill/index.tsx +64 -0
- package/archive/Pill/style.module.css +32 -0
- package/archive/ProductCard/ProductCard.stories.tsx +61 -0
- package/archive/ProductCard/index.tsx +111 -0
- package/archive/ProductCard/style.module.css +53 -0
- package/archive/ProductCardV2/ProductCardV2.stories.tsx +50 -0
- package/archive/ProductCardV2/index.tsx +119 -0
- package/archive/ProductCardV2/style.module.css +59 -0
- package/archive/Proficiencies/Proficiencies.stories.tsx +50 -0
- package/archive/Proficiencies/index.tsx +63 -0
- package/archive/Proficiencies/style.module.css +31 -0
- package/archive/Profile/Profile.stories.tsx +49 -0
- package/archive/Profile/index.tsx +103 -0
- package/archive/Profile/style.module.css +47 -0
- package/archive/Row/Row.stories.tsx +53 -0
- package/archive/Row/index.tsx +23 -0
- package/archive/Row/style.module.css +3 -0
- package/archive/Search/Search.stories.tsx +63 -0
- package/archive/Search/index.tsx +68 -0
- package/archive/Search/style.module.css +23 -0
- package/archive/Select/Select.stories.tsx +56 -0
- package/archive/Select/index.tsx +106 -0
- package/archive/Select/style.module.css +52 -0
- package/archive/Showcase/Showcase.stories.tsx +30 -0
- package/archive/Showcase/index.tsx +75 -0
- package/archive/Showcase/style.module.css +47 -0
- package/archive/SideNav/SideNav.stories.tsx +50 -0
- package/archive/SideNav/index.tsx +46 -0
- package/archive/SideNav/style.module.css +43 -0
- package/archive/SocialBlock/SocialBlock.stories.tsx +58 -0
- package/archive/SocialBlock/index.tsx +63 -0
- package/archive/SocialButton/SocialButton.stories.tsx +88 -0
- package/archive/SocialButton/index.tsx +71 -0
- package/archive/SocialButton/style.module.css +77 -0
- package/archive/StarRating/StarRating.stories.tsx +23 -0
- package/archive/StarRating/index.tsx +71 -0
- package/archive/Testimonial/Testimonial.stories.tsx +110 -0
- package/archive/Testimonial/index.tsx +61 -0
- package/archive/Testimonial/style.module.css +27 -0
- package/archive/TextAndTitle/TextAndTitle.stories.tsx +70 -0
- package/archive/TextAndTitle/index.tsx +123 -0
- package/archive/TextAndTitle/style.module.css +75 -0
- package/archive/TextArea/TextArea.stories.tsx +55 -0
- package/archive/TextArea/index.tsx +125 -0
- package/archive/TextArea/style.module.css +60 -0
- package/archive/Timeline/Timeline.stories.tsx +92 -0
- package/archive/Timeline/index.tsx +254 -0
- package/archive/Timeline/style.module.css +134 -0
- package/archive/TimelineV2/TimelineV2.stories.tsx +95 -0
- package/archive/TimelineV2/index.tsx +70 -0
- package/archive/TimelineV2/style.module.css +28 -0
- package/archive/Tubestops/Tubestops.stories.tsx +42 -0
- package/archive/Tubestops/index.tsx +58 -0
- package/archive/Tubestops/style.module.css +54 -0
- package/archive/UserIcon/UserIcon.stories.tsx +52 -0
- package/archive/UserIcon/index.tsx +46 -0
- package/archive/UserIcon/style.module.css +19 -0
- package/archive/Video/Video.stories.tsx +23 -0
- package/archive/Video/index.tsx +47 -0
- package/archive/fonts/Sora/OFL.txt +93 -0
- package/archive/fonts/Sora/README.txt +70 -0
- package/archive/fonts/Sora/Sora-VariableFont_wght.ttf +0 -0
- package/archive/fonts/Sora/static/Sora-Bold.ttf +0 -0
- package/archive/fonts/Sora/static/Sora-ExtraBold.ttf +0 -0
- package/archive/fonts/Sora/static/Sora-ExtraLight.ttf +0 -0
- package/archive/fonts/Sora/static/Sora-Light.ttf +0 -0
- package/archive/fonts/Sora/static/Sora-Medium.ttf +0 -0
- package/archive/fonts/Sora/static/Sora-Regular.ttf +0 -0
- package/archive/fonts/Sora/static/Sora-SemiBold.ttf +0 -0
- package/archive/fonts/Sora/static/Sora-Thin.ttf +0 -0
- package/archive/theme.ts +39 -0
- package/archive/typography/Fonts/Fonts.stories.tsx +14 -0
- package/archive/typography/Fonts/Fonts.tsx +181 -0
- package/lib/components/Accordion/index.js +10 -10
- package/lib/components/AlertBar/index.js +10 -10
- package/lib/components/index.d.ts +4 -0
- package/lib/index.js +1 -7
- package/lib/styles/base.css +1 -0
- package/package.json +6 -8
- package/postcss.config.js +8 -0
- package/src/components/Accordion/Accordion.stories.tsx +116 -0
- package/src/components/Accordion/index.tsx +30 -0
- package/src/components/AlertBar/AlertBar.stories.tsx +95 -0
- package/src/components/AlertBar/index.tsx +115 -0
- package/src/components/Avatar/Avatar.stories.tsx +19 -0
- package/src/components/Avatar/index.tsx +495 -0
- package/src/components/index.ts +119 -0
- package/src/documentation/Colours.mdx +192 -0
- package/src/documentation/Introduction.mdx +9 -0
- package/src/index.ts +1 -0
- package/src/styles/base.css +117 -0
- package/src/utils/controls.ts +44 -0
- package/src/utils/matchMedia.ts +9 -0
- package/src/utils/screens.ts +7 -0
- package/svg.d.ts +4 -0
- package/tailwind.config.ts +81 -0
- package/tsconfig.json +43 -0
- package/tsconfig.node.json +12 -0
- package/vite.config.mjs +64 -0
- package/lib/archive/Breadcrumbs/index.js +0 -12
- package/lib/archive/BreadcrumbsBordered/index.js +0 -25
- package/lib/archive/BreadcrumbsItem/index.js +0 -117
- package/lib/src/components/index.d.ts +0 -7
- /package/lib/{src/components → components}/Accordion/Accordion.stories.d.ts +0 -0
- /package/lib/{src/components → components}/Accordion/index.d.ts +0 -0
- /package/lib/{src/components → components}/AlertBar/AlertBar.stories.d.ts +0 -0
- /package/lib/{src/components → components}/AlertBar/index.d.ts +0 -0
- /package/lib/{src/components → components}/Avatar/Avatar.stories.d.ts +0 -0
- /package/lib/{src/components → components}/Avatar/index.d.ts +0 -0
- /package/lib/{src/index.d.ts → index.d.ts} +0 -0
- /package/lib/{src/utils → utils}/controls.d.ts +0 -0
- /package/lib/{src/utils → utils}/matchMedia.d.ts +0 -0
- /package/lib/{src/utils → utils}/screens.d.ts +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{/* Checkbox.mdx */}
|
|
2
|
+
|
|
3
|
+
import { Meta, Primary, Controls, Story } from '@storybook/blocks';
|
|
4
|
+
|
|
5
|
+
import * as CheckboxStories from './Checkbox.stories';
|
|
6
|
+
|
|
7
|
+
<Meta of={CheckboxStories} />
|
|
8
|
+
|
|
9
|
+
# Checkbox
|
|
10
|
+
|
|
11
|
+
A checkbox is an interactive component with and optional label.
|
|
12
|
+
|
|
13
|
+
It is able to display two states to the end user.
|
|
14
|
+
|
|
15
|
+
The state of the checkbox can toggled by clicking on the component.
|
|
16
|
+
|
|
17
|
+
<Primary />
|
|
18
|
+
|
|
19
|
+
## Props
|
|
20
|
+
|
|
21
|
+
<Controls />
|
|
22
|
+
|
|
23
|
+
## Variants
|
|
24
|
+
|
|
25
|
+
A checkbox can exist in two different states:
|
|
26
|
+
|
|
27
|
+
### Checked
|
|
28
|
+
|
|
29
|
+
<Story of={CheckboxStories.Checked} />
|
|
30
|
+
|
|
31
|
+
### Unchecked
|
|
32
|
+
|
|
33
|
+
<Story of={CheckboxStories.Unchecked} />
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
2
|
+
import { idAndClassName } from '@utils/controls';
|
|
3
|
+
|
|
4
|
+
import Checkbox from '.';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/Checkbox',
|
|
8
|
+
component: Checkbox,
|
|
9
|
+
argTypes: {
|
|
10
|
+
...idAndClassName,
|
|
11
|
+
label: {
|
|
12
|
+
description: '',
|
|
13
|
+
table: {},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
args: {
|
|
17
|
+
label: '{{ label }}',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default meta;
|
|
22
|
+
type Story = StoryObj<typeof Checkbox>;
|
|
23
|
+
|
|
24
|
+
export const Checked: Story = {
|
|
25
|
+
args: {
|
|
26
|
+
checked: true,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Unchecked: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
checked: false,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export interface Props {
|
|
8
|
+
id?: string;
|
|
9
|
+
label: string;
|
|
10
|
+
onClick?: (label: string, isChecked: boolean) => void;
|
|
11
|
+
|
|
12
|
+
checked?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Checkbox: React.FC<Props> = ({
|
|
16
|
+
id,
|
|
17
|
+
label,
|
|
18
|
+
onClick,
|
|
19
|
+
checked = false,
|
|
20
|
+
}: Props): JSX.Element => {
|
|
21
|
+
const [isChecked, setIsChecked] = useState(checked);
|
|
22
|
+
|
|
23
|
+
const classList = classNames('checkbox-wrapper theme-local');
|
|
24
|
+
const checkBoxClassList = classNames(
|
|
25
|
+
{
|
|
26
|
+
[style.checked]: isChecked,
|
|
27
|
+
},
|
|
28
|
+
style.checkbox,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div id={id} className={classList}>
|
|
33
|
+
<label className={style.label}>
|
|
34
|
+
<input
|
|
35
|
+
className={checkBoxClassList}
|
|
36
|
+
onChange={() => {
|
|
37
|
+
setIsChecked(!isChecked);
|
|
38
|
+
}}
|
|
39
|
+
onClick={() => {
|
|
40
|
+
onClick?.(label, !isChecked);
|
|
41
|
+
}}
|
|
42
|
+
type="checkbox"
|
|
43
|
+
checked={isChecked}
|
|
44
|
+
/>
|
|
45
|
+
<span className={style.span}>{label}</span>
|
|
46
|
+
</label>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default Checkbox;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { idAndClassName } from '@utils/controls';
|
|
3
|
+
|
|
4
|
+
import Collapsible from '.';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/Collapsible',
|
|
8
|
+
component: Collapsible,
|
|
9
|
+
parameters: {},
|
|
10
|
+
argTypes: {
|
|
11
|
+
...idAndClassName,
|
|
12
|
+
|
|
13
|
+
preText: {
|
|
14
|
+
description: '',
|
|
15
|
+
control: 'text',
|
|
16
|
+
table: {
|
|
17
|
+
category: '',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
title: {
|
|
21
|
+
description: '',
|
|
22
|
+
control: 'text',
|
|
23
|
+
table: {
|
|
24
|
+
category: '',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
subtitle: {
|
|
28
|
+
description: '',
|
|
29
|
+
control: 'text',
|
|
30
|
+
table: {
|
|
31
|
+
category: '',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
children: {
|
|
35
|
+
description: '',
|
|
36
|
+
control: 'array',
|
|
37
|
+
table: {
|
|
38
|
+
category: '',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
args: {
|
|
43
|
+
preText: 'this is some text',
|
|
44
|
+
title: 'Sheffield Hallam University',
|
|
45
|
+
subtitle: 'This is a subtitle',
|
|
46
|
+
imageProps: {
|
|
47
|
+
src: 'https://picsum.photos/500/300',
|
|
48
|
+
},
|
|
49
|
+
children: (
|
|
50
|
+
<p>
|
|
51
|
+
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Error, unde
|
|
52
|
+
perferendis quibusdam eos repellendus vero rerum sunt reiciendis velit
|
|
53
|
+
autem odio, fuga molestiae perspiciatis dolor voluptatum mollitia quos
|
|
54
|
+
ipsa! Doloribus? Lorem ipsum, dolor sit amet consectetur adipisicing
|
|
55
|
+
elit. Reiciendis ducimus, dolorum tempore unde earum aspernatur placeat
|
|
56
|
+
magnam, alias neque, blanditiis esse tenetur dignissimos in optio nihil
|
|
57
|
+
libero cum cupiditate debitis?
|
|
58
|
+
</p>
|
|
59
|
+
),
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default meta;
|
|
64
|
+
|
|
65
|
+
type Story = StoryObj<typeof meta>;
|
|
66
|
+
|
|
67
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import HorizontalLine from '@components/HorizontalLine';
|
|
4
|
+
import Icon from '@components/Icon';
|
|
5
|
+
import Image, { type Props as imageProps } from '@components/Image';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export interface Props {
|
|
11
|
+
id?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
preText?: string;
|
|
14
|
+
title?: string;
|
|
15
|
+
subtitle?: string;
|
|
16
|
+
imageProps?: imageProps;
|
|
17
|
+
children?: string | JSX.Element;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const Collapsible = ({
|
|
21
|
+
id,
|
|
22
|
+
className,
|
|
23
|
+
preText,
|
|
24
|
+
title,
|
|
25
|
+
subtitle,
|
|
26
|
+
imageProps,
|
|
27
|
+
children,
|
|
28
|
+
}: Props): JSX.Element => {
|
|
29
|
+
const [expanded, setExpanded] = useState(false);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const coll = document.getElementsByClassName('collapsible');
|
|
33
|
+
let i: number;
|
|
34
|
+
|
|
35
|
+
for (i = 0; i < coll.length; i++) {
|
|
36
|
+
coll[i].addEventListener('click', function (this: any, err: any) {
|
|
37
|
+
const content = this.nextElementSibling;
|
|
38
|
+
|
|
39
|
+
const scrollHeight: string = content.scrollHeight.toString();
|
|
40
|
+
if (content.style.maxHeight === '0px') {
|
|
41
|
+
content.style.maxHeight = `${scrollHeight}px`;
|
|
42
|
+
} else {
|
|
43
|
+
content.style.maxHeight = '0px';
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const classList = classNames(
|
|
50
|
+
className,
|
|
51
|
+
style.classList,
|
|
52
|
+
'transition-opactiy theme-local',
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const contentWrapperClassList = classNames(
|
|
56
|
+
{
|
|
57
|
+
[style.expanded]: expanded,
|
|
58
|
+
[style.collapsed]: !expanded,
|
|
59
|
+
},
|
|
60
|
+
style.contentWrapperClassList,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const expandItem = (e: any): void => {
|
|
64
|
+
const content = e.currentTarget.nextElementSibling;
|
|
65
|
+
const scrollHeight: string = content.scrollHeight.toString();
|
|
66
|
+
if (!expanded) {
|
|
67
|
+
content.style.maxHeight = `${scrollHeight}px`;
|
|
68
|
+
} else {
|
|
69
|
+
content.style.maxHeight = '0px';
|
|
70
|
+
}
|
|
71
|
+
setExpanded(!expanded);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div id={id} className={classList}>
|
|
76
|
+
<div
|
|
77
|
+
onClick={(e) => {
|
|
78
|
+
expandItem(e);
|
|
79
|
+
}}
|
|
80
|
+
className={style.heading}
|
|
81
|
+
>
|
|
82
|
+
{imageProps !== undefined && (
|
|
83
|
+
<Image {...imageProps} width={3} height={3} className={style.image} />
|
|
84
|
+
)}
|
|
85
|
+
<div className={style.textWrapper}>
|
|
86
|
+
{preText !== undefined && (
|
|
87
|
+
<h4 className={style.preText}>{preText}</h4>
|
|
88
|
+
)}
|
|
89
|
+
{title !== undefined && <h4 className={style.title}>{title}</h4>}
|
|
90
|
+
{subtitle !== undefined && (
|
|
91
|
+
<h5 className={style.subtitle}>{subtitle}</h5>
|
|
92
|
+
)}
|
|
93
|
+
</div>
|
|
94
|
+
{children !== undefined && (
|
|
95
|
+
<div className={style.iconWrapper}>
|
|
96
|
+
<Icon
|
|
97
|
+
className={style.icon}
|
|
98
|
+
type={expanded ? 'chevron-up' : 'chevron-down'}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
{children !== undefined && (
|
|
104
|
+
<div
|
|
105
|
+
className={contentWrapperClassList}
|
|
106
|
+
style={{ transition: 'max-height 0.2s ease-out' }}
|
|
107
|
+
>
|
|
108
|
+
<HorizontalLine colour="grey" />
|
|
109
|
+
<div className={style.children}>{children}</div>
|
|
110
|
+
</div>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default Collapsible;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.classList {
|
|
2
|
+
@apply w-full border-b border-lightest-grey duration-300 hover:cursor-pointer;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.heading {
|
|
6
|
+
@apply flex h-24 px-4 sm:pr-8;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.image {
|
|
10
|
+
@apply my-auto flex-none rounded-2xl;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.textWrapper {
|
|
14
|
+
@apply mx-4 my-auto grid w-full;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.preText {
|
|
18
|
+
@apply truncate text-xxs text-light-grey md:text-xs;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.title {
|
|
22
|
+
@apply truncate text-sm md:text-md;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.subtitle {
|
|
26
|
+
@apply truncate text-xs md:text-sm;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.contentWrapperClassList {
|
|
30
|
+
@apply w-auto overflow-hidden px-4;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.expanded {
|
|
34
|
+
@apply mb-4 mt-2 max-h-max;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.collapsed {
|
|
38
|
+
@apply max-h-0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.children {
|
|
42
|
+
@apply pb-2 pt-4;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.iconWrapper {
|
|
46
|
+
@apply my-auto flex-none;
|
|
47
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import CardWithTopImage from '@components/CardWithTopImage';
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { idAndClassName } from '@utils/controls';
|
|
4
|
+
|
|
5
|
+
import Column from '.';
|
|
6
|
+
|
|
7
|
+
const cardChild = (
|
|
8
|
+
<CardWithTopImage
|
|
9
|
+
id="cardwithtopimage"
|
|
10
|
+
imageProps={{
|
|
11
|
+
src: 'https://picsum.photos/200/200',
|
|
12
|
+
roundedFull: true,
|
|
13
|
+
}}
|
|
14
|
+
>
|
|
15
|
+
<p>This is some text</p>
|
|
16
|
+
<p>This is some more text</p>
|
|
17
|
+
<p>This is a bit more text</p>
|
|
18
|
+
<p>
|
|
19
|
+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorem odit ad
|
|
20
|
+
sed, quam recusandae voluptatem provident eveniet beatae omnis vero minus
|
|
21
|
+
unde facilis. Quia commodi quas odit iusto ut enim!
|
|
22
|
+
</p>
|
|
23
|
+
</CardWithTopImage>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const meta = {
|
|
27
|
+
title: 'Components/Column',
|
|
28
|
+
component: Column,
|
|
29
|
+
parameters: {},
|
|
30
|
+
argTypes: {
|
|
31
|
+
...idAndClassName,
|
|
32
|
+
sm: {
|
|
33
|
+
type: { name: 'number', required: false },
|
|
34
|
+
description:
|
|
35
|
+
'The number of sections out of 12 that the component should span on sm screens',
|
|
36
|
+
table: {
|
|
37
|
+
type: { summary: 'number' },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
md: {
|
|
41
|
+
type: { name: 'number', required: false },
|
|
42
|
+
description:
|
|
43
|
+
'The number of sections out of 12 that the component should span on md screens',
|
|
44
|
+
table: {
|
|
45
|
+
type: { summary: 'number' },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
lg: {
|
|
49
|
+
type: { name: 'number', required: false },
|
|
50
|
+
description:
|
|
51
|
+
'The number of sections out of 12 that the component should span on lg screens',
|
|
52
|
+
table: {
|
|
53
|
+
type: { summary: 'number' },
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
xl: {
|
|
57
|
+
type: { name: 'number', required: false },
|
|
58
|
+
description:
|
|
59
|
+
'The number of sections out of 12 that the component should span on xl screens',
|
|
60
|
+
table: {
|
|
61
|
+
type: { summary: 'number' },
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
children: {
|
|
65
|
+
type: { name: 'other', value: 'string | React.ReactNode' },
|
|
66
|
+
description: 'The child elements to show in the component',
|
|
67
|
+
table: {
|
|
68
|
+
type: {
|
|
69
|
+
summary: 'Array',
|
|
70
|
+
},
|
|
71
|
+
defaultValue: { summary: 'undefined' },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
args: {
|
|
76
|
+
sm: 12,
|
|
77
|
+
md: 8,
|
|
78
|
+
lg: 4,
|
|
79
|
+
xl: 2,
|
|
80
|
+
className: 'bg-facebook md:bg-twitter lg-whatsapp xl:bg-linkedin border',
|
|
81
|
+
children: cardChild,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default meta;
|
|
86
|
+
|
|
87
|
+
type Story = StoryObj<typeof meta>;
|
|
88
|
+
|
|
89
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export interface Props {
|
|
8
|
+
id?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
sm?: number;
|
|
11
|
+
md?: number;
|
|
12
|
+
lg?: number;
|
|
13
|
+
xl?: number;
|
|
14
|
+
children?: any;
|
|
15
|
+
}
|
|
16
|
+
const Column: React.FC<Props> = ({
|
|
17
|
+
id,
|
|
18
|
+
className,
|
|
19
|
+
sm = 1,
|
|
20
|
+
md = 1,
|
|
21
|
+
lg = 1,
|
|
22
|
+
xl = 1,
|
|
23
|
+
children,
|
|
24
|
+
}: Props): JSX.Element => {
|
|
25
|
+
const widthOptions = [
|
|
26
|
+
{ 1: [style.size1] },
|
|
27
|
+
{ 2: [style.size2] },
|
|
28
|
+
{ 3: [style.size3] },
|
|
29
|
+
{ 4: [style.size4] },
|
|
30
|
+
{ 5: [style.size5] },
|
|
31
|
+
{ 6: [style.size6] },
|
|
32
|
+
{ 7: [style.size7] },
|
|
33
|
+
{ 8: [style.size8] },
|
|
34
|
+
{ 9: [style.size9] },
|
|
35
|
+
{ 10: [style.size10] },
|
|
36
|
+
{ 11: [style.size11] },
|
|
37
|
+
{ 12: [style.size12] },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const mdWidthOptions = [
|
|
41
|
+
{ 1: [style.mdSize1] },
|
|
42
|
+
{ 2: [style.mdSize2] },
|
|
43
|
+
{ 3: [style.mdSize3] },
|
|
44
|
+
{ 4: [style.mdSize4] },
|
|
45
|
+
{ 5: [style.mdSize5] },
|
|
46
|
+
{ 6: [style.mdSize6] },
|
|
47
|
+
{ 7: [style.mdSize7] },
|
|
48
|
+
{ 8: [style.mdSize8] },
|
|
49
|
+
{ 9: [style.mdSize9] },
|
|
50
|
+
{ 10: [style.mdSize10] },
|
|
51
|
+
{ 11: [style.mdSize11] },
|
|
52
|
+
{ 12: [style.mdSize12] },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const lgWidthOptions = [
|
|
56
|
+
{ 1: [style.lgSize1] },
|
|
57
|
+
{ 2: [style.lgSize2] },
|
|
58
|
+
{ 3: [style.lgSize3] },
|
|
59
|
+
{ 4: [style.lgSize4] },
|
|
60
|
+
{ 5: [style.lgSize5] },
|
|
61
|
+
{ 6: [style.lgSize6] },
|
|
62
|
+
{ 7: [style.lgSize7] },
|
|
63
|
+
{ 8: [style.lgSize8] },
|
|
64
|
+
{ 9: [style.lgSize9] },
|
|
65
|
+
{ 10: [style.lgSize10] },
|
|
66
|
+
{ 11: [style.lgSize11] },
|
|
67
|
+
{ 12: [style.lgSize12] },
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
const xlWidthOptions = [
|
|
71
|
+
{ 1: [style.xlSize1] },
|
|
72
|
+
{ 2: [style.xlSize2] },
|
|
73
|
+
{ 3: [style.xlSize3] },
|
|
74
|
+
{ 4: [style.xlSize4] },
|
|
75
|
+
{ 5: [style.xlSize5] },
|
|
76
|
+
{ 6: [style.xlSize6] },
|
|
77
|
+
{ 7: [style.xlSize7] },
|
|
78
|
+
{ 8: [style.xlSize8] },
|
|
79
|
+
{ 9: [style.xlSize9] },
|
|
80
|
+
{ 10: [style.xlSize10] },
|
|
81
|
+
{ 11: [style.xlSize11] },
|
|
82
|
+
{ 12: [style.xlSize12] },
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
const calculateWidth = (screen: any, size: number): string => {
|
|
86
|
+
switch (screen) {
|
|
87
|
+
case 'sm':
|
|
88
|
+
return Object.values(widthOptions[size - 1]).toString();
|
|
89
|
+
case 'md':
|
|
90
|
+
return Object.values(mdWidthOptions[size - 1]).toString();
|
|
91
|
+
case 'lg':
|
|
92
|
+
return Object.values(lgWidthOptions[size - 1]).toString();
|
|
93
|
+
case 'xl':
|
|
94
|
+
return Object.values(xlWidthOptions[size - 1]).toString();
|
|
95
|
+
default:
|
|
96
|
+
return Object.values(widthOptions[size - 1]).toString();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const classList = classNames(
|
|
101
|
+
{
|
|
102
|
+
[calculateWidth('sm', sm)]: sm,
|
|
103
|
+
[calculateWidth('md', md)]: md,
|
|
104
|
+
[calculateWidth('lg', lg)]: lg,
|
|
105
|
+
[calculateWidth('xl', xl)]: xl,
|
|
106
|
+
},
|
|
107
|
+
className,
|
|
108
|
+
style.classList,
|
|
109
|
+
'theme-local',
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div id={id} className={classList}>
|
|
114
|
+
{children}
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export default Column;
|