@kirill.konshin/utils 0.0.8 → 0.0.10
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/.ctirc +10 -0
- package/.storybook/main.ts +21 -0
- package/.storybook/preview.ts +17 -0
- package/.turbo/turbo-build.log +67 -0
- package/.turbo/turbo-test.log +118 -0
- package/CHANGELOG.md +12 -0
- package/README.md +59 -0
- package/builders/.swcrc +18 -0
- package/builders/build.config.ts +11 -0
- package/builders/bun.build.js +23 -0
- package/builders/package.json +209 -0
- package/builders/perf.mjs +63 -0
- package/builders/rollup.config.mjs +50 -0
- package/builders/rslib.config.ts +26 -0
- package/builders/tsconfig.json +21 -0
- package/builders/tsup.config.ts +20 -0
- package/builders/turbo.json +24 -0
- package/builders/vite.config.ts +37 -0
- package/demo/cache-demo.ts +2 -1
- package/package.json +166 -22
- package/src/bootstrap/adaptiveContainer.tsx +12 -0
- package/src/bootstrap/controls.stories.tsx +62 -0
- package/src/bootstrap/controls.tsx +119 -0
- package/src/bootstrap/error.stories.tsx +34 -0
- package/src/bootstrap/error.tsx +40 -0
- package/src/bootstrap/field.stories.tsx +42 -0
- package/src/bootstrap/field.tsx +35 -0
- package/src/bootstrap/footer.tsx +49 -0
- package/src/bootstrap/globalLoading.stories.tsx +25 -0
- package/src/bootstrap/globalLoading.tsx +17 -0
- package/src/bootstrap/index.ts +12 -0
- package/src/bootstrap/loading.stories.tsx +35 -0
- package/src/bootstrap/loading.tsx +22 -0
- package/src/bootstrap/main.scss +86 -0
- package/src/bootstrap/responsiveHelper.tsx +50 -0
- package/src/bootstrap/screen.stories.tsx +160 -0
- package/src/bootstrap/screen.tsx +144 -0
- package/src/bootstrap/toaster.stories.tsx +32 -0
- package/src/bootstrap/toaster.tsx +38 -0
- package/src/bootstrap/useModal.stories.tsx +51 -0
- package/src/bootstrap/useModal.tsx +88 -0
- package/src/bootstrap/useWrappedForm.ts +40 -0
- package/src/core/cache.test.ts +121 -0
- package/src/electron/README.md +13 -0
- package/src/electron/createWindow.ts +234 -0
- package/src/electron/index.ts +2 -0
- package/src/electron/updater.ts +54 -0
- package/src/electron-builder/builder.ts +150 -0
- package/src/electron-builder/images.ts +33 -0
- package/src/electron-builder/index.ts +2 -0
- package/src/mui/README.md +3 -0
- package/src/mui/formControlFieldset.stories.tsx +71 -0
- package/src/mui/formControlFieldset.tsx +26 -0
- package/src/mui/formLabelLegend.tsx +11 -0
- package/src/mui/genericControl.tsx +20 -0
- package/src/mui/index.ts +4 -0
- package/src/mui/readOnly.tsx +6 -0
- package/src/next/appLink.tsx +39 -0
- package/src/next/index.ts +5 -0
- package/src/next/measure.ts +7 -0
- package/src/next/noSSR.tsx +17 -0
- package/src/next/redirect.tsx +13 -0
- package/src/next/useIsInner.ts +13 -0
- package/src/react/apiCall.ts +25 -0
- package/src/react/form/client.tsx +62 -0
- package/src/react/form/form.tsx +109 -0
- package/src/react/form/index.ts +2 -0
- package/src/react/index.ts +4 -0
- package/src/react/useFetch.ts +29 -0
- package/src/react/useFetcher.ts +49 -0
- package/src/react-native/index.ts +3 -0
- package/src/react-native/share.ts +31 -0
- package/src/react-native/update.tsx +40 -0
- package/src/react-native/useAppState.ts +18 -0
- package/src/tailwind/fullpage.tsx +11 -0
- package/src/tailwind/index.ts +2 -0
- package/src/tailwind/responsiveHelper.tsx +16 -0
- package/src-todo/auth0.tsx +177 -0
- package/tsconfig.json +15 -18
- package/turbo.json +2 -11
- package/vite.config.ts +47 -0
- package/vite.exports.ts +121 -0
- package/build/cache.d.ts +0 -120
- package/build/cache.js +0 -191
- package/build/errors.d.ts +0 -1
- package/build/errors.js +0 -14
- package/build/index.d.ts +0 -5
- package/build/index.js +0 -5
- package/build/measure.d.ts +0 -34
- package/build/measure.js +0 -48
- package/build/mutex.d.ts +0 -5
- package/build/mutex.js +0 -23
- package/build/worker.d.ts +0 -83
- package/build/worker.js +0 -250
- package/tsconfig.tsbuildinfo +0 -1
- package/src/{cache.ts → core/cache.ts} +0 -0
- package/src/{errors.ts → core/errors.ts} +0 -0
- package/src/{index.ts → core/index.ts} +1 -1
- /package/src/{measure.ts → core/measure.ts} +0 -0
- /package/src/{mutex.ts → core/mutex.ts} +0 -0
- /package/src/{worker.ts → core/worker.ts} +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { fn } from '@storybook/test';
|
|
4
|
+
|
|
5
|
+
import { FieldGroup } from './field';
|
|
6
|
+
import { FormControl } from 'react-bootstrap';
|
|
7
|
+
|
|
8
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
9
|
+
const meta = {
|
|
10
|
+
title: 'Bootstrap / FieldGroup',
|
|
11
|
+
component: FieldGroup,
|
|
12
|
+
parameters: {
|
|
13
|
+
layout: 'centered',
|
|
14
|
+
},
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
argTypes: {
|
|
17
|
+
text: { control: 'text' },
|
|
18
|
+
label: { control: 'text' },
|
|
19
|
+
horizontal: { control: 'check' },
|
|
20
|
+
},
|
|
21
|
+
args: { onClick: fn() },
|
|
22
|
+
} satisfies Meta<typeof FieldGroup>;
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
|
|
26
|
+
type Story = StoryObj<typeof meta>;
|
|
27
|
+
|
|
28
|
+
export const Vertical: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
label: 'Label',
|
|
31
|
+
children: <FormControl placeholder="Input" />,
|
|
32
|
+
text: 'Text',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Horizontal: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
label: 'Label',
|
|
39
|
+
children: <FormControl placeholder="Input" />,
|
|
40
|
+
horizontal: true,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Form, FormGroupProps, FormLabelProps, FormTextProps } from 'react-bootstrap';
|
|
3
|
+
|
|
4
|
+
export function FieldGroup({
|
|
5
|
+
label,
|
|
6
|
+
labelProps = {},
|
|
7
|
+
text,
|
|
8
|
+
textProps = {},
|
|
9
|
+
horizontal,
|
|
10
|
+
children,
|
|
11
|
+
...props
|
|
12
|
+
}: FormGroupProps & {
|
|
13
|
+
label?: any;
|
|
14
|
+
labelProps?: FormLabelProps;
|
|
15
|
+
text?: any;
|
|
16
|
+
textProps?: FormTextProps;
|
|
17
|
+
horizontal?: boolean;
|
|
18
|
+
}) {
|
|
19
|
+
if (horizontal) {
|
|
20
|
+
props.className = 'hstack gap-3 ' + (props.className || '');
|
|
21
|
+
labelProps.className = 'm-0 ' + (labelProps.className || '');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (text && horizontal) {
|
|
25
|
+
throw new Error('Cannot use text and horizontal together');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Form.Group {...props}>
|
|
30
|
+
{label && <Form.Label {...labelProps}>{label}</Form.Label>}
|
|
31
|
+
{children}
|
|
32
|
+
{text && !horizontal && <Form.Text {...textProps}>{text}</Form.Text>}{' '}
|
|
33
|
+
</Form.Group>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Nav, Navbar } from 'react-bootstrap';
|
|
3
|
+
import { useBreakpoint } from './responsiveHelper';
|
|
4
|
+
import { AdaptiveContainer } from './adaptiveContainer';
|
|
5
|
+
|
|
6
|
+
export function FooterNavItem({ href, icon, active = false, children = '' }) {
|
|
7
|
+
// const pathname = usePathname();
|
|
8
|
+
|
|
9
|
+
const isFilepath = icon.includes('.');
|
|
10
|
+
let iconElement;
|
|
11
|
+
|
|
12
|
+
if (isFilepath) {
|
|
13
|
+
iconElement = <img src={icon} alt="icon" className="me-lg-2" />;
|
|
14
|
+
} else {
|
|
15
|
+
iconElement = <span className={`lead me-lg-2 ${icon}`} />;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// const active = isActivePath(href, pathname);
|
|
19
|
+
|
|
20
|
+
const link = (
|
|
21
|
+
<Nav.Link
|
|
22
|
+
// as={Link}
|
|
23
|
+
href={href}
|
|
24
|
+
// active={active} // has no effect when not pills or tabs
|
|
25
|
+
className={`px-0 px-lg-3 d-flex align-items-center flex-column flex-lg-row ${active ? 'text-primary' : ''}`}
|
|
26
|
+
>
|
|
27
|
+
{iconElement}
|
|
28
|
+
{children}
|
|
29
|
+
</Nav.Link>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return <Nav.Item style={{ flex: 1 }}>{link}</Nav.Item>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function Footer({ children }) {
|
|
36
|
+
const { isDesktop } = useBreakpoint();
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
// border-bottom
|
|
40
|
+
<div className={isDesktop ? '' : 'border-top'}>
|
|
41
|
+
<Navbar className={isDesktop ? '' : 'py-0'}>
|
|
42
|
+
<AdaptiveContainer>
|
|
43
|
+
{isDesktop && <Navbar.Brand href="/">Le Brand</Navbar.Brand>}
|
|
44
|
+
<Nav className={isDesktop ? 'me-auto' : 'justify-content-center flex-nowrap w-100'}>{children}</Nav>
|
|
45
|
+
</AdaptiveContainer>
|
|
46
|
+
</Navbar>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { GlobalLoading } from './globalLoading';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Bootstrap / GlobalLoading',
|
|
7
|
+
component: GlobalLoading,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'centered',
|
|
10
|
+
},
|
|
11
|
+
tags: ['autodocs'],
|
|
12
|
+
argTypes: {
|
|
13
|
+
loading: { control: 'check' },
|
|
14
|
+
},
|
|
15
|
+
} satisfies Meta<typeof GlobalLoading>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
loading: true,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
// import { useLoading, useLoadingTimeout } from '../redux/loadingSlice';
|
|
3
|
+
import { Loading } from './loading';
|
|
4
|
+
|
|
5
|
+
export function GlobalLoading({ loading }: { loading: boolean }) {
|
|
6
|
+
// const { loading } = useLoading();
|
|
7
|
+
|
|
8
|
+
// useLoadingTimeout(15000); // escape latch if something is stuck
|
|
9
|
+
|
|
10
|
+
if (!loading) return null;
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div className="bg-white position-absolute top-0 start-0 w-100 h-100 z-3 d-flex align-items-center justify-content-center">
|
|
14
|
+
<Loading />
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './adaptiveContainer';
|
|
2
|
+
export * from './controls';
|
|
3
|
+
export * from './error';
|
|
4
|
+
export * from './field';
|
|
5
|
+
export * from './footer';
|
|
6
|
+
export * from './globalLoading';
|
|
7
|
+
export * from './loading';
|
|
8
|
+
export * from './responsiveHelper';
|
|
9
|
+
export * from './screen';
|
|
10
|
+
export * from './toaster';
|
|
11
|
+
export * from './useModal';
|
|
12
|
+
export * from './useWrappedForm';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { Loading } from './loading';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Bootstrap / Loading',
|
|
7
|
+
component: Loading,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'centered',
|
|
10
|
+
},
|
|
11
|
+
tags: ['autodocs'],
|
|
12
|
+
argTypes: {
|
|
13
|
+
children: { control: 'text' },
|
|
14
|
+
show: { control: 'check' },
|
|
15
|
+
size: { control: 'select', options: ['sm', 'md'] },
|
|
16
|
+
},
|
|
17
|
+
} satisfies Meta<typeof Loading>;
|
|
18
|
+
|
|
19
|
+
export default meta;
|
|
20
|
+
|
|
21
|
+
type Story = StoryObj<typeof meta>;
|
|
22
|
+
|
|
23
|
+
export const Default: Story = {};
|
|
24
|
+
|
|
25
|
+
export const Children: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
children: 'Custom Loading...',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const Size: Story = {
|
|
32
|
+
args: {
|
|
33
|
+
size: 'sm',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Spinner, SpinnerProps, Stack } from 'react-bootstrap';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
export function Loading({
|
|
5
|
+
children = 'Loading...' as any,
|
|
6
|
+
show = true,
|
|
7
|
+
className = '',
|
|
8
|
+
size,
|
|
9
|
+
}: {
|
|
10
|
+
children?: any;
|
|
11
|
+
show?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
size?: SpinnerProps['size'];
|
|
14
|
+
}) {
|
|
15
|
+
if (!show) return null;
|
|
16
|
+
return (
|
|
17
|
+
<Stack direction="horizontal" gap={3} className={`align-self-auto ${className}`}>
|
|
18
|
+
<Spinner animation="border" role="status" size={size as any} />
|
|
19
|
+
<span>{children}</span>
|
|
20
|
+
</Stack>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
$primary: darken(#fd7e14, 6%) !default; // in order to accomodate MCR=3
|
|
2
|
+
$secondary: #0d6efd !default;
|
|
3
|
+
$danger: #dc3545 !default;
|
|
4
|
+
$warning: #fd7e14 !default;
|
|
5
|
+
$success: #198754 !default;
|
|
6
|
+
|
|
7
|
+
$theme-colors: (
|
|
8
|
+
'primary': $primary,
|
|
9
|
+
'secondary': $secondary,
|
|
10
|
+
'success': $success,
|
|
11
|
+
// "info": $info,
|
|
12
|
+
'warning': $warning,
|
|
13
|
+
'danger': $danger,
|
|
14
|
+
// non-bootstrap colors
|
|
15
|
+
'light': #dddddd,
|
|
16
|
+
'dark': #2c2414,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
$min-contrast-ratio: 3 !default; // 4.5 produces black on orange @see https://stackoverflow.com/a/68303393/5125659
|
|
20
|
+
|
|
21
|
+
@import 'bootstrap/scss/functions.scss';
|
|
22
|
+
@import 'bootstrap/scss/variables.scss';
|
|
23
|
+
@import 'bootstrap/scss/mixins.scss';
|
|
24
|
+
@import 'bootstrap/scss/bootstrap.scss';
|
|
25
|
+
|
|
26
|
+
// Nav
|
|
27
|
+
|
|
28
|
+
.btn-nav {
|
|
29
|
+
@extend .btn-outline-primary; // just vars to control styling
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.main-nav .btn-nav {
|
|
33
|
+
border-width: 0;
|
|
34
|
+
|
|
35
|
+
@include media-breakpoint-down(md) {
|
|
36
|
+
--bs-btn-active-color: var(--bs-primary);
|
|
37
|
+
--bs-btn-hover-color: var(--bs-primary);
|
|
38
|
+
background: none !important;
|
|
39
|
+
padding: 0;
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
font-weight: 500;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&.disabled {
|
|
45
|
+
color: var(--bs-gray-600);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Dropdowns
|
|
50
|
+
|
|
51
|
+
.dropdown-toggle-no-arrow::after,
|
|
52
|
+
.dropdown-toggle-no-arrow > .dropdown-toggle::after {
|
|
53
|
+
display: none !important;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.dropdown > button {
|
|
57
|
+
display: block; // fixes small padding on dropdowns
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Tables
|
|
61
|
+
|
|
62
|
+
.table {
|
|
63
|
+
//fixes table borders & margins
|
|
64
|
+
margin-bottom: 0;
|
|
65
|
+
|
|
66
|
+
& > :not(caption) > * > * {
|
|
67
|
+
background: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
& > :not(caption) > tr:last-of-type > * {
|
|
71
|
+
border-bottom: none;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Badges
|
|
76
|
+
|
|
77
|
+
.badge {
|
|
78
|
+
--bs-badge-font-weight: normal;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Icons
|
|
82
|
+
|
|
83
|
+
.icon-thick {
|
|
84
|
+
webkit-text-stroke: 1px;
|
|
85
|
+
text-stroke: 1px;
|
|
86
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
export function useBreakpoint() {
|
|
6
|
+
const [breakpoint, setBreakpoint] = React.useState('xs');
|
|
7
|
+
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
const updateBreakpoint = () => {
|
|
10
|
+
const width = window.innerWidth;
|
|
11
|
+
if (width < 576) {
|
|
12
|
+
setBreakpoint('xs');
|
|
13
|
+
} else if (width < 768) {
|
|
14
|
+
setBreakpoint('sm');
|
|
15
|
+
} else if (width < 992) {
|
|
16
|
+
setBreakpoint('md');
|
|
17
|
+
} else if (width < 1200) {
|
|
18
|
+
setBreakpoint('lg');
|
|
19
|
+
} else if (width < 1400) {
|
|
20
|
+
setBreakpoint('xl');
|
|
21
|
+
} else {
|
|
22
|
+
setBreakpoint('xxl');
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
updateBreakpoint();
|
|
27
|
+
window.addEventListener('resize', updateBreakpoint);
|
|
28
|
+
|
|
29
|
+
return () => {
|
|
30
|
+
window.removeEventListener('resize', updateBreakpoint);
|
|
31
|
+
};
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
34
|
+
const isMobile = ['xs', 'sm', 'md'].includes(breakpoint);
|
|
35
|
+
|
|
36
|
+
return { breakpoint, isMobile, isDesktop: !isMobile };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function ResponsiveHelperBS() {
|
|
40
|
+
return (
|
|
41
|
+
<span className="small position-fixed bottom-0 z-3" style={{ fontSize: '9px', right: 1, lineHeight: 1 }}>
|
|
42
|
+
<small className="d-block d-sm-none">XS</small>
|
|
43
|
+
<small className="d-none d-sm-block d-md-none">SM</small>
|
|
44
|
+
<small className="d-none d-md-block d-lg-none">MD</small>
|
|
45
|
+
<small className="d-none d-lg-block d-xl-none">LG</small>
|
|
46
|
+
<small className="d-none d-xl-block d-xxl-none">XL</small>
|
|
47
|
+
<small className="d-none d-xxl-block">XXL</small>
|
|
48
|
+
</span>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { fn } from '@storybook/test';
|
|
4
|
+
|
|
5
|
+
import { Screen } from './screen';
|
|
6
|
+
import { Loading } from './loading';
|
|
7
|
+
import { Dropdown, DropdownButton, Form, Nav, Navbar } from 'react-bootstrap';
|
|
8
|
+
import { Footer, FooterNavItem } from './footer';
|
|
9
|
+
import { AdaptiveContainer } from './adaptiveContainer';
|
|
10
|
+
|
|
11
|
+
const lorem = (
|
|
12
|
+
<>
|
|
13
|
+
<p>
|
|
14
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
15
|
+
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
|
|
16
|
+
ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
17
|
+
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
|
|
18
|
+
anim id est laborum.
|
|
19
|
+
</p>
|
|
20
|
+
<h2>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC</h2>
|
|
21
|
+
<p>
|
|
22
|
+
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem
|
|
23
|
+
aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
|
|
24
|
+
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni
|
|
25
|
+
dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor
|
|
26
|
+
sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore
|
|
27
|
+
magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis
|
|
28
|
+
suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in
|
|
29
|
+
ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas
|
|
30
|
+
nulla pariatur?
|
|
31
|
+
</p>
|
|
32
|
+
<h2>1914 translation by H. Rackham</h2>
|
|
33
|
+
<p>
|
|
34
|
+
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I
|
|
35
|
+
will give you a complete account of the system, and expound the actual teachings of the great explorer of
|
|
36
|
+
the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself,
|
|
37
|
+
because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter
|
|
38
|
+
consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain
|
|
39
|
+
pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can
|
|
40
|
+
procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical
|
|
41
|
+
exercise, except to obtain some advantage from it? But who has any right to find fault with a man who
|
|
42
|
+
chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no
|
|
43
|
+
resultant pleasure?
|
|
44
|
+
</p>
|
|
45
|
+
</>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const meta = {
|
|
49
|
+
title: 'Bootstrap / Screen',
|
|
50
|
+
component: Screen,
|
|
51
|
+
parameters: {
|
|
52
|
+
layout: 'fullscreen',
|
|
53
|
+
},
|
|
54
|
+
tags: ['autodocs'],
|
|
55
|
+
argTypes: {
|
|
56
|
+
children: { control: 'text' },
|
|
57
|
+
title: { control: 'text' },
|
|
58
|
+
footer: { control: 'text' },
|
|
59
|
+
},
|
|
60
|
+
args: {
|
|
61
|
+
children: lorem,
|
|
62
|
+
title: 'Title',
|
|
63
|
+
menu: (
|
|
64
|
+
<Footer>
|
|
65
|
+
<FooterNavItem href="/application/process" icon="bi-cup-hot-fill" active>
|
|
66
|
+
Coffee
|
|
67
|
+
</FooterNavItem>
|
|
68
|
+
<FooterNavItem href="/application/transcribe" icon="bi-pen-fill">
|
|
69
|
+
Assistant
|
|
70
|
+
</FooterNavItem>
|
|
71
|
+
<FooterNavItem href="/application/documents" icon="bi-star-fill">
|
|
72
|
+
Docs
|
|
73
|
+
</FooterNavItem>
|
|
74
|
+
</Footer>
|
|
75
|
+
),
|
|
76
|
+
backCb: fn(),
|
|
77
|
+
},
|
|
78
|
+
} satisfies Meta<typeof Screen>;
|
|
79
|
+
|
|
80
|
+
export default meta;
|
|
81
|
+
|
|
82
|
+
type Story = StoryObj<typeof meta>;
|
|
83
|
+
|
|
84
|
+
export const Default: Story = {};
|
|
85
|
+
|
|
86
|
+
export const LongContent: Story = {
|
|
87
|
+
args: {
|
|
88
|
+
header: <AdaptiveContainer>Header</AdaptiveContainer>,
|
|
89
|
+
footer: <div>Footer</div>,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const Loader: Story = {
|
|
94
|
+
parameters: {
|
|
95
|
+
docs: {
|
|
96
|
+
description: {
|
|
97
|
+
story: 'Centered content with hidden header and footer',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
args: {
|
|
102
|
+
children: <Loading />,
|
|
103
|
+
centerContent: true,
|
|
104
|
+
noHeader: true,
|
|
105
|
+
noFooter: true,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const Centered: Story = {
|
|
110
|
+
args: {
|
|
111
|
+
children: 'Nothing to see here',
|
|
112
|
+
centerContent: true,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const ForwardCb: Story = {
|
|
117
|
+
args: {
|
|
118
|
+
forwardCb: fn(),
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const ForwardIcon: Story = {
|
|
123
|
+
args: {
|
|
124
|
+
forwardCb: fn(),
|
|
125
|
+
forwardIcon: 'bi-trash',
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const ForwardBtn: Story = {
|
|
130
|
+
args: {
|
|
131
|
+
forwardBtn: (
|
|
132
|
+
<DropdownButton
|
|
133
|
+
title={<span className="bi-three-dots" />}
|
|
134
|
+
// size="sm"
|
|
135
|
+
align="end"
|
|
136
|
+
variant="nav"
|
|
137
|
+
className={`dropdown-toggle-no-arrow`}
|
|
138
|
+
>
|
|
139
|
+
<Dropdown.Item>Preview</Dropdown.Item>
|
|
140
|
+
<Dropdown.Divider />
|
|
141
|
+
<Dropdown.Item className="text-danger">Remove</Dropdown.Item>
|
|
142
|
+
</DropdownButton>
|
|
143
|
+
),
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const HeaderForm: Story = {
|
|
148
|
+
args: {
|
|
149
|
+
header: (
|
|
150
|
+
<Navbar className="pt-0 py-lg-3">
|
|
151
|
+
<AdaptiveContainer>
|
|
152
|
+
<div className="position-relative w-100">
|
|
153
|
+
<span className="bi-search position-absolute" style={{ right: '8px', top: '3px' }} />
|
|
154
|
+
<Form.Control placeholder="Search" size="sm" />
|
|
155
|
+
</div>
|
|
156
|
+
</AdaptiveContainer>
|
|
157
|
+
</Navbar>
|
|
158
|
+
),
|
|
159
|
+
},
|
|
160
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, Navbar, Nav, Stack } from 'react-bootstrap';
|
|
3
|
+
import { useBreakpoint } from './responsiveHelper';
|
|
4
|
+
import { AdaptiveContainer } from './adaptiveContainer';
|
|
5
|
+
|
|
6
|
+
//TODO Footer -> menu
|
|
7
|
+
export function Screen({
|
|
8
|
+
backBtn,
|
|
9
|
+
backCb,
|
|
10
|
+
backIcon,
|
|
11
|
+
forwardBtn,
|
|
12
|
+
forwardIcon,
|
|
13
|
+
forwardCb,
|
|
14
|
+
footer,
|
|
15
|
+
menu,
|
|
16
|
+
header,
|
|
17
|
+
children,
|
|
18
|
+
noContentPadding = false,
|
|
19
|
+
contentClassName = '',
|
|
20
|
+
title = '',
|
|
21
|
+
centerContent = false,
|
|
22
|
+
noHeader = false,
|
|
23
|
+
noFooter = false,
|
|
24
|
+
noMenu = false,
|
|
25
|
+
// noFolders = false,
|
|
26
|
+
}: {
|
|
27
|
+
backBtn?;
|
|
28
|
+
backCb?;
|
|
29
|
+
backIcon?;
|
|
30
|
+
forwardBtn?;
|
|
31
|
+
forwardIcon?;
|
|
32
|
+
forwardCb?;
|
|
33
|
+
children: any;
|
|
34
|
+
contentClassName?: string;
|
|
35
|
+
noContentPadding?: boolean;
|
|
36
|
+
header?: any; // resides on top panel in mobile, does not scroll, before content on desktop
|
|
37
|
+
footer?: any; // resides on bottom menu panel in mobile, does not scroll, or after content on desktop
|
|
38
|
+
menu?: any;
|
|
39
|
+
title?: any;
|
|
40
|
+
centerContent?: boolean;
|
|
41
|
+
noHeader?: boolean;
|
|
42
|
+
noFooter?: boolean;
|
|
43
|
+
noMenu?: boolean;
|
|
44
|
+
// noFolders?: boolean;
|
|
45
|
+
}) {
|
|
46
|
+
// const router = useRouter();
|
|
47
|
+
|
|
48
|
+
backBtn =
|
|
49
|
+
backBtn ||
|
|
50
|
+
(backCb ? (
|
|
51
|
+
// backCb === true ? () => router.back() : backCb
|
|
52
|
+
<Button onClick={backCb} variant="nav">
|
|
53
|
+
{
|
|
54
|
+
<>
|
|
55
|
+
<span className={backIcon || 'bi-chevron-left icon-thick'} />
|
|
56
|
+
<span className="d-none d-lg-inline ms-2">Back</span>
|
|
57
|
+
</>
|
|
58
|
+
}
|
|
59
|
+
</Button>
|
|
60
|
+
) : null);
|
|
61
|
+
|
|
62
|
+
forwardBtn =
|
|
63
|
+
forwardBtn ||
|
|
64
|
+
(forwardCb ? (
|
|
65
|
+
<Button onClick={forwardCb}>{forwardIcon ? <span className={forwardIcon}></span> : 'Next'}</Button>
|
|
66
|
+
) : null);
|
|
67
|
+
|
|
68
|
+
const { isMobile, isDesktop } = useBreakpoint();
|
|
69
|
+
|
|
70
|
+
// useLoadingTimeout(1000); // less jerky UI
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div className={`d-flex flex-column flex-grow-1 flex-lg-grow-0 ${isMobile ? 'vh-100' : ''}`} data-id="screen">
|
|
74
|
+
{/* HEADER */}
|
|
75
|
+
|
|
76
|
+
{/* FIXME postition fixed does not assign z-index automatically https://getbootstrap.com/docs/4.0/layout/overview/#z-index*/}
|
|
77
|
+
{!noHeader && (
|
|
78
|
+
<header className={isDesktop ? '' : 'shadow-sm border-bottom'} data-id="header">
|
|
79
|
+
{/* {!noFolders && <FolderBar />} */}
|
|
80
|
+
|
|
81
|
+
{/* {isDesktop && !noFooter && <Footer />} */}
|
|
82
|
+
{isDesktop && !noMenu && menu}
|
|
83
|
+
|
|
84
|
+
{title && (
|
|
85
|
+
// (isDesktop ? 'border-bottom' : '')
|
|
86
|
+
<Navbar expand className="main-nav">
|
|
87
|
+
<AdaptiveContainer className="gap-2">
|
|
88
|
+
{backBtn && <Nav className="hstack gap-3">{backBtn}</Nav>}
|
|
89
|
+
<Navbar.Brand className="me-auto">{title}</Navbar.Brand>
|
|
90
|
+
{forwardBtn && <Nav className="hstack gap-3">{forwardBtn}</Nav>}
|
|
91
|
+
</AdaptiveContainer>
|
|
92
|
+
</Navbar>
|
|
93
|
+
)}
|
|
94
|
+
|
|
95
|
+
{header}
|
|
96
|
+
</header>
|
|
97
|
+
)}
|
|
98
|
+
|
|
99
|
+
{/* CONTENT */}
|
|
100
|
+
|
|
101
|
+
<AdaptiveContainer
|
|
102
|
+
as="main"
|
|
103
|
+
className={[
|
|
104
|
+
isMobile ? 'overflow-y-auto overflow-x-hidden' : 'gap-3',
|
|
105
|
+
`flex-grow-1 d-flex flex-column`,
|
|
106
|
+
centerContent ? 'align-items-center justify-content-center' : 'justify-content-start',
|
|
107
|
+
contentClassName,
|
|
108
|
+
noContentPadding ? 'p-0' : 'py-3',
|
|
109
|
+
]
|
|
110
|
+
.filter(Boolean)
|
|
111
|
+
.join(' ')}
|
|
112
|
+
data-id="content"
|
|
113
|
+
>
|
|
114
|
+
{children}
|
|
115
|
+
|
|
116
|
+
{/* Repeat screen buttons at the bottom on desktop */}
|
|
117
|
+
{isDesktop && !noFooter && (
|
|
118
|
+
<>
|
|
119
|
+
{footer}
|
|
120
|
+
|
|
121
|
+
{/* TODO Possibly introduce a prop desktopFooterBeforeButtons */}
|
|
122
|
+
{(forwardBtn || backBtn) && (
|
|
123
|
+
// Navbar screws up the popper
|
|
124
|
+
<Stack gap={3} direction="horizontal">
|
|
125
|
+
{/* No container since already in container */}
|
|
126
|
+
{backBtn && <Nav className="hstack gap-3">{backBtn}</Nav>}
|
|
127
|
+
{forwardBtn && <Nav className="hstack gap-3 flex-grow-1">{forwardBtn}</Nav>}
|
|
128
|
+
</Stack>
|
|
129
|
+
)}
|
|
130
|
+
</>
|
|
131
|
+
)}
|
|
132
|
+
</AdaptiveContainer>
|
|
133
|
+
|
|
134
|
+
{/* FOOTER */}
|
|
135
|
+
|
|
136
|
+
{!noMenu && !noFooter && (
|
|
137
|
+
<footer className="shadow-lg border-top d-block d-lg-none" data-id="footer">
|
|
138
|
+
{!noFooter && footer}
|
|
139
|
+
{!noMenu && menu}
|
|
140
|
+
</footer>
|
|
141
|
+
)}
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
}
|