trepur_components 1.0.2 → 1.0.3
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/dist/src/lib/components/Carousel/index.d.ts +0 -1
- package/dist/src/lib/components/Carousel/index.js +1 -1
- package/dist/src/lib/components/Carousel/index.js.map +1 -1
- package/dist/src/lib/components/FooterBar/{footerBar.stories.d.ts → FooterBar.stories.d.ts} +0 -0
- package/dist/src/lib/components/FooterBar/{footerBar.stories.js → FooterBar.stories.js} +1 -1
- package/dist/src/lib/components/FooterBar/{footerBar.stories.js.map → FooterBar.stories.js.map} +1 -1
- package/dist/src/lib/components/Nav/index.js +2 -2
- package/dist/src/lib/components/Nav/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/Accordion/Accordion.stories.tsx +0 -88
- package/dist/components/Accordion/index.tsx +0 -31
- package/dist/components/AlertBar/AlertBar.stories.tsx +0 -105
- package/dist/components/AlertBar/index.tsx +0 -127
- package/dist/components/Breadcrumbs/Breadcrumbs.stories.tsx +0 -60
- package/dist/components/Breadcrumbs/index.tsx +0 -55
- package/dist/components/BreadcrumbsBordered/BreadcrumbsBordered.stories.tsx +0 -52
- package/dist/components/BreadcrumbsBordered/index.tsx +0 -44
- package/dist/components/BreadcrumbsItem/BreadcrumbsItem.stories.tsx +0 -54
- package/dist/components/BreadcrumbsItem/index.tsx +0 -151
- package/dist/components/Button/button.stories.tsx +0 -148
- package/dist/components/Button/index.tsx +0 -91
- package/dist/components/Card/Card.stories.tsx +0 -150
- package/dist/components/Card/index.tsx +0 -162
- package/dist/components/CardWithTopImage/CardWithTopImage.stories.tsx +0 -48
- package/dist/components/CardWithTopImage/index.tsx +0 -40
- package/dist/components/Carousel/Carousel.stories.tsx +0 -369
- package/dist/components/Carousel/index.tsx +0 -267
- package/dist/components/ChevronCard/ChevronCard.stories.tsx +0 -21
- package/dist/components/ChevronCard/index.tsx +0 -39
- package/dist/components/Collapsible/Collapsible.stories.tsx +0 -70
- package/dist/components/Collapsible/index.tsx +0 -124
- package/dist/components/Column/Column.stories.tsx +0 -82
- package/dist/components/Column/index.tsx +0 -114
- package/dist/components/Container/Container.stories.tsx +0 -38
- package/dist/components/Container/index.tsx +0 -30
- package/dist/components/FooterBar/FooterBar.stories.tsx +0 -57
- package/dist/components/FooterBar/index.tsx +0 -44
- package/dist/components/Form/Form.stories.tsx +0 -93
- package/dist/components/Form/index.tsx +0 -58
- package/dist/components/FyreCard/FyreCard.stories.tsx +0 -29
- package/dist/components/FyreCard/index.tsx +0 -46
- package/dist/components/Greeting/Greeting.stories.tsx +0 -42
- package/dist/components/Greeting/index.tsx +0 -46
- package/dist/components/HamburgerIcon/HamburgerIcon.stories.tsx +0 -50
- package/dist/components/HamburgerIcon/index.tsx +0 -65
- package/dist/components/Icon/Icon.stories.tsx +0 -102
- package/dist/components/Icon/index.tsx +0 -112
- package/dist/components/Image/Image.stories.tsx +0 -88
- package/dist/components/Image/index.tsx +0 -113
- package/dist/components/ImageLink/ImageLink.stories.tsx +0 -60
- package/dist/components/ImageLink/index.tsx +0 -62
- package/dist/components/ImageLinkList/ImageLinkList.stories.tsx +0 -34
- package/dist/components/ImageLinkList/index.tsx +0 -33
- package/dist/components/InformationIcon/InformationIcon.stories.tsx +0 -86
- package/dist/components/InformationIcon/index.tsx +0 -84
- package/dist/components/Input/Input.stories.tsx +0 -99
- package/dist/components/Input/index.tsx +0 -126
- package/dist/components/Jumbotron/Jumbotron.stories.tsx +0 -22
- package/dist/components/Jumbotron/index.tsx +0 -25
- package/dist/components/Nav/Nav.stories.tsx +0 -155
- package/dist/components/Nav/index.tsx +0 -180
- package/dist/components/NavItem/NavItem.stories.tsx +0 -89
- package/dist/components/NavItem/index.tsx +0 -65
- package/dist/components/NewsCard/NewsCard.stories.tsx +0 -71
- package/dist/components/NewsCard/index.tsx +0 -48
- package/dist/components/Profile/Profile.stories.tsx +0 -50
- package/dist/components/Profile/index.tsx +0 -87
- package/dist/components/Row/Row.stories.tsx +0 -51
- package/dist/components/Row/index.tsx +0 -24
- package/dist/components/Search/Search.stories.tsx +0 -58
- package/dist/components/Search/index.tsx +0 -58
- package/dist/components/SocialBlock/SocialBlock.stories.tsx +0 -114
- package/dist/components/SocialBlock/index.tsx +0 -161
- package/dist/components/StarRating/StarRating.stories.tsx +0 -23
- package/dist/components/StarRating/index.tsx +0 -71
- package/dist/components/Testimonial/Testimonial.stories.tsx +0 -110
- package/dist/components/Testimonial/index.tsx +0 -50
- package/dist/components/TextAndTitle/TextAndTitle.stories.tsx +0 -65
- package/dist/components/TextAndTitle/index.tsx +0 -257
- package/dist/components/TextArea/TextArea.stories.tsx +0 -67
- package/dist/components/TextArea/index.tsx +0 -97
- package/dist/components/Timeline/Timeline.stories.tsx +0 -100
- package/dist/components/Timeline/index.css +0 -133
- package/dist/components/Timeline/index.tsx +0 -315
- package/dist/components/Tubestops/Tubestops.stories.tsx +0 -66
- package/dist/components/Tubestops/index.css +0 -92
- package/dist/components/Tubestops/index.tsx +0 -77
- package/dist/components/UserIcon/UserIcon.stories.tsx +0 -67
- package/dist/components/UserIcon/index.tsx +0 -42
- package/dist/components/Video/Video.stories.tsx +0 -23
- package/dist/components/Video/index.tsx +0 -49
- package/dist/fonts/Sora/OFL.txt +0 -93
- package/dist/fonts/Sora/README.txt +0 -70
- package/dist/fonts/Sora/Sora-VariableFont_wght.ttf +0 -0
- package/dist/fonts/Sora/static/Sora-Bold.ttf +0 -0
- package/dist/fonts/Sora/static/Sora-ExtraBold.ttf +0 -0
- package/dist/fonts/Sora/static/Sora-ExtraLight.ttf +0 -0
- package/dist/fonts/Sora/static/Sora-Light.ttf +0 -0
- package/dist/fonts/Sora/static/Sora-Medium.ttf +0 -0
- package/dist/fonts/Sora/static/Sora-Regular.ttf +0 -0
- package/dist/fonts/Sora/static/Sora-SemiBold.ttf +0 -0
- package/dist/fonts/Sora/static/Sora-Thin.ttf +0 -0
- package/dist/index.js +0 -272
- package/dist/styles/base.css +0 -73
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
// import 'keen-slider/keen-slider.min.css'
|
|
3
|
-
import { useKeenSlider, KeenSliderInstance, KeenSliderHooks, KeenSliderOptions } from 'keen-slider/react'
|
|
4
|
-
import classNames from 'classnames'
|
|
5
|
-
import Icon from '@components/Icon'
|
|
6
|
-
// https://keen-slider.io/docs#usage-in-react
|
|
7
|
-
|
|
8
|
-
export interface Props {
|
|
9
|
-
id?: string
|
|
10
|
-
className?: string
|
|
11
|
-
breakpoints?: { [key: string]: Omit<KeenSliderOptions<{}, {}, KeenSliderHooks>, 'breakpoints'> }
|
|
12
|
-
defaultAnimation?: { duration?: number, easing?: (t: number) => number }
|
|
13
|
-
disabled: boolean
|
|
14
|
-
drag?: boolean
|
|
15
|
-
dragSpeed?: number
|
|
16
|
-
initial?: number
|
|
17
|
-
loop?: boolean
|
|
18
|
-
mode?: 'snap' | 'free' | 'free-snap'
|
|
19
|
-
range?: { align?: boolean, min?: number, max?: number }
|
|
20
|
-
renderMode?: 'precision' | 'performance' | 'custom'
|
|
21
|
-
rtl?: boolean
|
|
22
|
-
rubberband?: boolean
|
|
23
|
-
slides?: any[]
|
|
24
|
-
vertical?: boolean
|
|
25
|
-
animationStarted?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
26
|
-
animationStopped?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
27
|
-
animationEnded?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
28
|
-
created?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
29
|
-
destroyed?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
30
|
-
detailsChanged?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
31
|
-
dragged?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
32
|
-
dragStarted?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
33
|
-
dragChecked?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
34
|
-
dragEnded?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
35
|
-
beforeOptionsChanged?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
36
|
-
optionsChanged?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
37
|
-
slideChanged?: boolean
|
|
38
|
-
updated?: (slider: KeenSliderInstance<{}, {}, KeenSliderHooks>) => void
|
|
39
|
-
perView?: number
|
|
40
|
-
spacing?: number
|
|
41
|
-
number?: number
|
|
42
|
-
origin?: number | 'auto' | 'center'
|
|
43
|
-
arrows?: { visible: boolean, onClick?: () => void }
|
|
44
|
-
dots?: { visible: boolean, activeColours: string, colours: string }
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const Carousel: React.FC<Props> = ({
|
|
48
|
-
id,
|
|
49
|
-
className,
|
|
50
|
-
breakpoints,
|
|
51
|
-
defaultAnimation,
|
|
52
|
-
disabled,
|
|
53
|
-
drag,
|
|
54
|
-
dragSpeed,
|
|
55
|
-
initial,
|
|
56
|
-
loop = true,
|
|
57
|
-
mode = 'snap',
|
|
58
|
-
range,
|
|
59
|
-
renderMode,
|
|
60
|
-
rtl,
|
|
61
|
-
rubberband,
|
|
62
|
-
slides,
|
|
63
|
-
vertical,
|
|
64
|
-
animationStarted,
|
|
65
|
-
animationStopped,
|
|
66
|
-
animationEnded,
|
|
67
|
-
created,
|
|
68
|
-
destroyed,
|
|
69
|
-
detailsChanged,
|
|
70
|
-
dragged,
|
|
71
|
-
dragStarted,
|
|
72
|
-
dragChecked,
|
|
73
|
-
dragEnded,
|
|
74
|
-
beforeOptionsChanged,
|
|
75
|
-
optionsChanged,
|
|
76
|
-
slideChanged,
|
|
77
|
-
updated,
|
|
78
|
-
perView = 1,
|
|
79
|
-
spacing,
|
|
80
|
-
number,
|
|
81
|
-
origin,
|
|
82
|
-
arrows,
|
|
83
|
-
dots
|
|
84
|
-
}) => {
|
|
85
|
-
const classList = className
|
|
86
|
-
const [currentSlide, setCurrentSlide] = useState(0)
|
|
87
|
-
const [loaded, setLoaded] = useState(false)
|
|
88
|
-
|
|
89
|
-
const wheelControls = (slider: any): void => {
|
|
90
|
-
let touchTimeout: any
|
|
91
|
-
let position: any
|
|
92
|
-
let wheelActive: boolean
|
|
93
|
-
|
|
94
|
-
function dispatch (e: any, name: string): void {
|
|
95
|
-
position.x -= e.deltaX
|
|
96
|
-
position.y -= e.deltaY
|
|
97
|
-
slider.container.dispatchEvent(
|
|
98
|
-
new CustomEvent(name, {
|
|
99
|
-
detail: {
|
|
100
|
-
x: position.x,
|
|
101
|
-
y: position.y
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function wheelStart (e: any): void {
|
|
108
|
-
position = {
|
|
109
|
-
x: e.pageX,
|
|
110
|
-
y: e.pageY
|
|
111
|
-
}
|
|
112
|
-
dispatch(e, 'ksDragStart')
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function wheel (e: any): void {
|
|
116
|
-
dispatch(e, 'ksDrag')
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function wheelEnd (e: any): void {
|
|
120
|
-
dispatch(e, 'ksDragEnd')
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function eventWheel (e: any): void {
|
|
124
|
-
e.preventDefault()
|
|
125
|
-
if (!wheelActive) {
|
|
126
|
-
wheelStart(e)
|
|
127
|
-
wheelActive = true
|
|
128
|
-
}
|
|
129
|
-
wheel(e)
|
|
130
|
-
clearTimeout(touchTimeout)
|
|
131
|
-
touchTimeout = setTimeout(() => {
|
|
132
|
-
wheelActive = false
|
|
133
|
-
wheelEnd(e)
|
|
134
|
-
}, 50)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
slider.on('created', () => {
|
|
138
|
-
slider.container.addEventListener('wheel', eventWheel, {
|
|
139
|
-
passive: false
|
|
140
|
-
})
|
|
141
|
-
})
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const [sliderRef, instanceRef] = useKeenSlider<HTMLDivElement>({
|
|
145
|
-
initial,
|
|
146
|
-
breakpoints,
|
|
147
|
-
defaultAnimation,
|
|
148
|
-
disabled,
|
|
149
|
-
drag,
|
|
150
|
-
dragSpeed,
|
|
151
|
-
loop,
|
|
152
|
-
mode,
|
|
153
|
-
range,
|
|
154
|
-
renderMode,
|
|
155
|
-
rtl,
|
|
156
|
-
rubberband,
|
|
157
|
-
vertical,
|
|
158
|
-
slideChanged (slider) {
|
|
159
|
-
setCurrentSlide(slider.track.details.rel)
|
|
160
|
-
},
|
|
161
|
-
// slideChanged: slideChanged,
|
|
162
|
-
created () {
|
|
163
|
-
setLoaded(true)
|
|
164
|
-
},
|
|
165
|
-
// created: created,
|
|
166
|
-
animationStarted,
|
|
167
|
-
animationStopped,
|
|
168
|
-
animationEnded,
|
|
169
|
-
destroyed,
|
|
170
|
-
detailsChanged,
|
|
171
|
-
dragged,
|
|
172
|
-
dragStarted,
|
|
173
|
-
dragChecked,
|
|
174
|
-
dragEnded,
|
|
175
|
-
beforeOptionsChanged,
|
|
176
|
-
optionsChanged,
|
|
177
|
-
updated,
|
|
178
|
-
slides: {
|
|
179
|
-
perView,
|
|
180
|
-
spacing,
|
|
181
|
-
origin,
|
|
182
|
-
number
|
|
183
|
-
}
|
|
184
|
-
}, [wheelControls])
|
|
185
|
-
|
|
186
|
-
return (
|
|
187
|
-
<>
|
|
188
|
-
<div id={id} className={classNames(classList, arrows?.visible === true && 'flex justify-between', 'navigation-wrapper w-full')}>
|
|
189
|
-
{arrows?.visible === true && loaded && (instanceRef.current !== undefined) && (
|
|
190
|
-
<div className='my-auto'>
|
|
191
|
-
<Arrow
|
|
192
|
-
left
|
|
193
|
-
onClick={(e: any) => e.stopPropagation() !== undefined || instanceRef.current?.prev()}
|
|
194
|
-
disabled={currentSlide === 0}
|
|
195
|
-
arrows={arrows}
|
|
196
|
-
/>
|
|
197
|
-
</div>
|
|
198
|
-
)}
|
|
199
|
-
<div ref={sliderRef} className='keen-slider w-full'>
|
|
200
|
-
{(slides != null) && slides}
|
|
201
|
-
</div>
|
|
202
|
-
{arrows?.visible === true && loaded && (instanceRef.current !== undefined) && (
|
|
203
|
-
<div className='my-auto'>
|
|
204
|
-
<Arrow
|
|
205
|
-
right
|
|
206
|
-
onClick={(e: any) =>
|
|
207
|
-
e.stopPropagation() !== undefined || instanceRef.current?.next()}
|
|
208
|
-
disabled={
|
|
209
|
-
currentSlide === instanceRef?.current?.track?.details?.slides?.length
|
|
210
|
-
}
|
|
211
|
-
arrows={arrows}
|
|
212
|
-
/>
|
|
213
|
-
</div>
|
|
214
|
-
)}
|
|
215
|
-
</div>
|
|
216
|
-
{dots?.visible === true && loaded && (instanceRef.current != null) && (
|
|
217
|
-
<div className='flex py-8 justify-center'>
|
|
218
|
-
{[...Array(instanceRef?.current?.track?.details?.slides?.length).keys()].map((idx, i) => {
|
|
219
|
-
return (
|
|
220
|
-
<Dot
|
|
221
|
-
key={`dot_${i}`}
|
|
222
|
-
isActive={currentSlide === idx}
|
|
223
|
-
onClick={() => {
|
|
224
|
-
instanceRef.current?.moveToIdx(idx)
|
|
225
|
-
}}
|
|
226
|
-
/>
|
|
227
|
-
)
|
|
228
|
-
})}
|
|
229
|
-
</div>
|
|
230
|
-
)}
|
|
231
|
-
</>
|
|
232
|
-
)
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function Arrow (props: { onClick?: (e: any) => void, disabled?: boolean, left?: boolean, right?: boolean, arrows?: { visible?: boolean, colours?: string, disabledColours?: string } }): JSX.Element {
|
|
236
|
-
return (
|
|
237
|
-
<div className='w-full'>
|
|
238
|
-
<a onClick={props?.onClick}>
|
|
239
|
-
<Icon
|
|
240
|
-
type={props?.left === true ? 'chevron-left' : 'chevron-right'}
|
|
241
|
-
className='mx-auto hover:cursor-pointer'
|
|
242
|
-
size={3}
|
|
243
|
-
rounded
|
|
244
|
-
bgColour='white'
|
|
245
|
-
colour='primary'
|
|
246
|
-
/>
|
|
247
|
-
</a>
|
|
248
|
-
</div>
|
|
249
|
-
)
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function Dot (props: { onClick: (e: any) => void, isActive: boolean }): JSX.Element {
|
|
253
|
-
return (
|
|
254
|
-
<a onClick={props?.onClick}>
|
|
255
|
-
<Icon
|
|
256
|
-
type='circle'
|
|
257
|
-
className='mx-1 hover:cursor-pointer'
|
|
258
|
-
size={1}
|
|
259
|
-
rounded
|
|
260
|
-
bgColour={props?.isActive ? 'primary' : 'secondary'}
|
|
261
|
-
colour={props?.isActive ? 'primary' : 'secondary'}
|
|
262
|
-
/>
|
|
263
|
-
</a>
|
|
264
|
-
)
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export default Carousel
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { idAndClassName } from '@utils/controls'
|
|
3
|
-
import ChevronCard from './index'
|
|
4
|
-
import { ComponentStory, ComponentMeta } from '@storybook/react'
|
|
5
|
-
|
|
6
|
-
const componentMeta: ComponentMeta<typeof ChevronCard> = {
|
|
7
|
-
title: 'Trepur Components/Other/Organisms/Chevron Card',
|
|
8
|
-
component: ChevronCard,
|
|
9
|
-
parameters: {},
|
|
10
|
-
argTypes: {
|
|
11
|
-
...idAndClassName
|
|
12
|
-
},
|
|
13
|
-
args: {
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const Template: ComponentStory<typeof ChevronCard> = (args) => <ChevronCard {...args} />
|
|
18
|
-
|
|
19
|
-
export const _ChevronCard = Template.bind({})
|
|
20
|
-
|
|
21
|
-
export default componentMeta
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
export interface Props {
|
|
5
|
-
id?: string
|
|
6
|
-
className?: string
|
|
7
|
-
}
|
|
8
|
-
const ChevronCard: React.FC<Props> = ({
|
|
9
|
-
id,
|
|
10
|
-
className
|
|
11
|
-
}: Props): JSX.Element => {
|
|
12
|
-
const classList = classNames(className, 'flex border-l border-t border-b h-20 w-32 z-10 bg-white')
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<>
|
|
16
|
-
<div id={id} className={`${classList} flex`}>
|
|
17
|
-
<div className='border-l border-t border-b h-20 w-32 z-10 bg-white' />
|
|
18
|
-
<div id='chevronLeft' className='border h-14 w-14 -ml-7 mt-3 rotate-45' />
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
<div id={id} className='flex-col my-8'>
|
|
22
|
-
<div className='border-l border-t border-r h-32 w-20 z-20 bg-white' />
|
|
23
|
-
<div id='chevronLeft' className='border h-14 w-14 -mt-7 ml-3 rotate-45 z-0' />
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
<div id={id} className='flex-col my-16'>
|
|
27
|
-
<div className='border h-14 w-14 -mb-7 ml-3 rotate-45 z-0' />
|
|
28
|
-
<div id={id} className='border-l border-b border-r h-32 w-20 z-20 bg-white' />
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
<div id={id} className='flex'>
|
|
32
|
-
<div className='border h-14 w-14 -mr-7 mt-3 rotate-45' />
|
|
33
|
-
<div id={id} className='border-r border-t border-b h-20 w-32 z-10 bg-white' />
|
|
34
|
-
</div>
|
|
35
|
-
</>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default ChevronCard
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import Collapsible from './index'
|
|
3
|
-
import { ComponentStory, ComponentMeta } from '@storybook/react'
|
|
4
|
-
|
|
5
|
-
const componentMeta: ComponentMeta<typeof Collapsible> = {
|
|
6
|
-
title: 'Trepur Components/Other/Atoms/Collapsible',
|
|
7
|
-
component: Collapsible,
|
|
8
|
-
parameters: {},
|
|
9
|
-
argTypes: {
|
|
10
|
-
title: {
|
|
11
|
-
description: '',
|
|
12
|
-
control: 'text',
|
|
13
|
-
table: {
|
|
14
|
-
category: ''
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
subtitle: {
|
|
18
|
-
description: '',
|
|
19
|
-
control: 'text',
|
|
20
|
-
table: {
|
|
21
|
-
category: ''
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
borderTop: {
|
|
25
|
-
description: '',
|
|
26
|
-
control: 'boolean',
|
|
27
|
-
table: {
|
|
28
|
-
category: ''
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
borderBottom: {
|
|
32
|
-
description: '',
|
|
33
|
-
control: 'boolean',
|
|
34
|
-
table: {
|
|
35
|
-
category: ''
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
showBottomLine: {
|
|
39
|
-
description: '',
|
|
40
|
-
control: 'boolean',
|
|
41
|
-
table: {
|
|
42
|
-
category: ''
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
children: {
|
|
46
|
-
description: '',
|
|
47
|
-
control: 'array',
|
|
48
|
-
table: {
|
|
49
|
-
category: ''
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
args: {
|
|
54
|
-
title: 'This is a title',
|
|
55
|
-
subtitle: 'This is a subtitle',
|
|
56
|
-
showBottomLine: true,
|
|
57
|
-
iconProps: {
|
|
58
|
-
type: 'heart',
|
|
59
|
-
colour: 'white',
|
|
60
|
-
bgColour: 'primary'
|
|
61
|
-
},
|
|
62
|
-
children: <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Error, unde perferendis quibusdam eos repellendus vero rerum sunt reiciendis velit autem odio, fuga molestiae perspiciatis dolor voluptatum mollitia quos ipsa! Doloribus? Lorem ipsum, dolor sit amet consectetur adipisicing elit. Reiciendis ducimus, dolorum tempore unde earum aspernatur placeat magnam, alias neque, blanditiis esse tenetur dignissimos in optio nihil libero cum cupiditate debitis?</p>
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const Template: ComponentStory<typeof Collapsible> = (args) => <Collapsible {...args} />
|
|
67
|
-
|
|
68
|
-
export const _Collapsible = Template.bind({})
|
|
69
|
-
|
|
70
|
-
export default componentMeta
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import Icon, { Props as iconProps } from '@components/Icon'
|
|
3
|
-
import classNames from 'classnames'
|
|
4
|
-
|
|
5
|
-
export interface Props {
|
|
6
|
-
id?: string
|
|
7
|
-
className?: string
|
|
8
|
-
title?: string
|
|
9
|
-
subtitle?: string
|
|
10
|
-
boldTitle?: boolean
|
|
11
|
-
borderTop?: boolean
|
|
12
|
-
borderBottom?: boolean
|
|
13
|
-
showBottomLine?: boolean
|
|
14
|
-
iconProps?: iconProps
|
|
15
|
-
children?: string | JSX.Element
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const Collapsible = ({
|
|
19
|
-
id,
|
|
20
|
-
className,
|
|
21
|
-
title,
|
|
22
|
-
subtitle,
|
|
23
|
-
boldTitle,
|
|
24
|
-
borderTop,
|
|
25
|
-
borderBottom,
|
|
26
|
-
showBottomLine,
|
|
27
|
-
iconProps,
|
|
28
|
-
children
|
|
29
|
-
}: Props): JSX.Element => {
|
|
30
|
-
const [expanded, setExpanded] = useState(false)
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
const coll = document.getElementsByClassName('collapsible')
|
|
34
|
-
let i: number
|
|
35
|
-
|
|
36
|
-
for (i = 0; i < coll.length; i++) {
|
|
37
|
-
coll[i].addEventListener('click', function (this: any, err: any) {
|
|
38
|
-
const content = this.nextElementSibling
|
|
39
|
-
|
|
40
|
-
const scrollHeight: string = content.scrollHeight.toString()
|
|
41
|
-
if (content.style.maxHeight === '0px') {
|
|
42
|
-
content.style.maxHeight = `${scrollHeight}px`
|
|
43
|
-
} else {
|
|
44
|
-
content.style.maxHeight = '0px'
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
const headingClassList = classNames({
|
|
51
|
-
'border-b': borderBottom,
|
|
52
|
-
'border-t': borderTop
|
|
53
|
-
}, 'w-auto flex text-center collapsible')
|
|
54
|
-
|
|
55
|
-
const classList = classNames(className, 'bg-primary text-white hover:bg-white hover:text-primary transition-opactiy duration-300')
|
|
56
|
-
|
|
57
|
-
const padding = classNames({
|
|
58
|
-
'pt-7': title !== undefined && subtitle !== undefined,
|
|
59
|
-
'pt-4': title !== undefined && subtitle === undefined
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
const textSubstitutePadding = classNames({
|
|
63
|
-
'pb-4': title === undefined && subtitle === undefined
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
const contentWrapperClassList = classNames({
|
|
67
|
-
'max-h-max my-2': expanded,
|
|
68
|
-
'max-h-0': !expanded
|
|
69
|
-
}, 'w-auto overflow-hidden px-4 bg-white text-primary')
|
|
70
|
-
|
|
71
|
-
const childrenClassList = classNames(padding, 'w-full pr-8 text-right')
|
|
72
|
-
|
|
73
|
-
const expandItem = (e: any): void => {
|
|
74
|
-
const content = e.currentTarget.nextElementSibling
|
|
75
|
-
const scrollHeight: string = content.scrollHeight.toString()
|
|
76
|
-
if (!expanded) {
|
|
77
|
-
content.style.maxHeight = `${scrollHeight}px`
|
|
78
|
-
} else {
|
|
79
|
-
content.style.maxHeight = '0px'
|
|
80
|
-
}
|
|
81
|
-
setExpanded(!expanded)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<div
|
|
86
|
-
id={id}
|
|
87
|
-
className={classList}
|
|
88
|
-
>
|
|
89
|
-
<div
|
|
90
|
-
onClick={e => expandItem(e)}
|
|
91
|
-
className={headingClassList}
|
|
92
|
-
>
|
|
93
|
-
{(iconProps !== undefined) &&
|
|
94
|
-
<div
|
|
95
|
-
className={`pl-4 text-left ${padding} ${textSubstitutePadding}`}
|
|
96
|
-
>
|
|
97
|
-
<Icon {...iconProps} />
|
|
98
|
-
</div>}
|
|
99
|
-
{(title !== undefined || subtitle !== undefined) &&
|
|
100
|
-
<div className='w-full pl-4 py-4 text-left'>
|
|
101
|
-
{title !== undefined && <h4>{title}</h4>}
|
|
102
|
-
{subtitle !== undefined && <h5><small>{subtitle}</small></h5>}
|
|
103
|
-
</div>}
|
|
104
|
-
{children !== undefined &&
|
|
105
|
-
<div className={childrenClassList}>
|
|
106
|
-
<Icon
|
|
107
|
-
type={expanded ? 'chevron-up' : 'chevron-down'}
|
|
108
|
-
colour='white'
|
|
109
|
-
bgColour='primary'
|
|
110
|
-
/>
|
|
111
|
-
</div>}
|
|
112
|
-
</div>
|
|
113
|
-
{children !== undefined &&
|
|
114
|
-
<div
|
|
115
|
-
className={contentWrapperClassList}
|
|
116
|
-
style={{ transition: 'max-height 0.2s ease-out' }}
|
|
117
|
-
>
|
|
118
|
-
{children}
|
|
119
|
-
</div>}
|
|
120
|
-
</div>
|
|
121
|
-
)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export default Collapsible
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import Column from './index'
|
|
3
|
-
import { idAndClassName } from '@utils/controls'
|
|
4
|
-
import CardWithTopImage from '@components/CardWithTopImage'
|
|
5
|
-
import logo from '@assets/images/primary-logo.png'
|
|
6
|
-
import { ComponentStory, ComponentMeta } from '@storybook/react'
|
|
7
|
-
|
|
8
|
-
const cardChild = (
|
|
9
|
-
<CardWithTopImage
|
|
10
|
-
id='cardwithtopimage'
|
|
11
|
-
imageProps={{
|
|
12
|
-
image: logo,
|
|
13
|
-
roundedFull: true
|
|
14
|
-
}}
|
|
15
|
-
>
|
|
16
|
-
<p>This is some text</p>
|
|
17
|
-
<p>This is some more text</p>
|
|
18
|
-
<p>This is a bit more text</p>
|
|
19
|
-
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorem odit ad sed, quam recusandae voluptatem provident eveniet beatae omnis vero minus unde facilis. Quia commodi quas odit iusto ut enim!</p>
|
|
20
|
-
</CardWithTopImage>
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
const componentMeta: ComponentMeta<typeof Column> = {
|
|
24
|
-
title: 'Trepur Components/Rupert Bennett/Atoms/Column',
|
|
25
|
-
component: Column,
|
|
26
|
-
parameters: {},
|
|
27
|
-
argTypes: {
|
|
28
|
-
...idAndClassName,
|
|
29
|
-
sm: {
|
|
30
|
-
type: { name: 'number', required: false },
|
|
31
|
-
description: 'The number of sections out of 12 that the component should span on sm screens',
|
|
32
|
-
table: {
|
|
33
|
-
type: { summary: 'number' }
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
md: {
|
|
37
|
-
type: { name: 'number', required: false },
|
|
38
|
-
description: 'The number of sections out of 12 that the component should span on md screens',
|
|
39
|
-
table: {
|
|
40
|
-
type: { summary: 'number' }
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
lg: {
|
|
44
|
-
type: { name: 'number', required: false },
|
|
45
|
-
description: 'The number of sections out of 12 that the component should span on lg screens',
|
|
46
|
-
table: {
|
|
47
|
-
type: { summary: 'number' }
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
xl: {
|
|
51
|
-
type: { name: 'number', required: false },
|
|
52
|
-
description: 'The number of sections out of 12 that the component should span on xl screens',
|
|
53
|
-
table: {
|
|
54
|
-
type: { summary: 'number' }
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
children: {
|
|
58
|
-
type: { name: 'other', value: 'string | React.ReactNode' },
|
|
59
|
-
description: 'The child elements to show in the component',
|
|
60
|
-
table: {
|
|
61
|
-
type: {
|
|
62
|
-
summary: 'Array'
|
|
63
|
-
},
|
|
64
|
-
defaultValue: { summary: 'undefined' }
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
args: {
|
|
69
|
-
sm: 12,
|
|
70
|
-
md: 8,
|
|
71
|
-
lg: 4,
|
|
72
|
-
xl: 2,
|
|
73
|
-
className: 'bg-facebook md:bg-twitter lg-whatsapp xl:bg-linkedin border',
|
|
74
|
-
children: cardChild
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const Template: ComponentStory<typeof Column> = (args) => <Column {...args} />
|
|
79
|
-
|
|
80
|
-
export const _Column = Template.bind({})
|
|
81
|
-
|
|
82
|
-
export default componentMeta
|