diff --git a/jsapp/js/components/common/loader.stories.tsx b/jsapp/js/components/common/loader.stories.tsx new file mode 100644 index 0000000000..e81d961bbd --- /dev/null +++ b/jsapp/js/components/common/loader.stories.tsx @@ -0,0 +1,46 @@ +import {Center, Loader} from '@mantine/core'; +import type {Meta, StoryObj} from '@storybook/react'; + +/** + * Mantine [Loader](https://mantine.dev/core/loader/) component stories. + */ +const meta: Meta = { + title: 'Common/Loader', + component: Loader, + decorators: [ + (Story) => ( +
+ +
+ ), + ], + argTypes: { + type: { + description: 'Select loader type', + options: ['regular', 'big'], + control: 'radio', + }, + }, +}; + +type Story = StoryObj; + +/** + * Regular variant + */ +export const Regular: Story = { + args: { + type: 'regular', + }, +}; + +/** + * Big variant + */ +export const Big: Story = { + args: { + type: 'big', + }, +}; + +export default meta; diff --git a/jsapp/js/components/common/loadingOverlay.stories.tsx b/jsapp/js/components/common/loadingOverlay.stories.tsx new file mode 100644 index 0000000000..715521a683 --- /dev/null +++ b/jsapp/js/components/common/loadingOverlay.stories.tsx @@ -0,0 +1,77 @@ +import { + Button, + Card, + Center, + LoadingOverlay, + PasswordInput, + Stack, + Text, + TextInput, +} from '@mantine/core'; +import type {Meta, StoryObj} from '@storybook/react'; + +/** + * Mantine [LoadingOverlay](https://mantine.dev/core/loading-overlay/) component stories. + * + * Component used to display an overlay over the sibling content containing the Loader component + */ +const meta: Meta = { + title: 'Common/LoadingOverlay', + component: LoadingOverlay, + decorators: [ + (Story) => ( +
+ + + + + Sibling components... + + + + + + + +
+ ), + ], + argTypes: { + visible: { + description: 'Controls overlay visibility', + control: 'boolean', + }, + }, +}; + +type Story = StoryObj; + +/** + * LoadingOverlay component visible + */ +export const Visible: Story = { + args: { + visible: true, + }, +}; + +/** + * LoadingOverlay component not visible + */ +export const NotVisible: Story = { + args: { + visible: false, + }, +}; + +/** + * Using 'big' variant + */ +export const Big: Story = { + args: { + visible: true, + loaderProps: {type: 'big'}, + }, +}; + +export default meta; diff --git a/jsapp/js/theme/kobo/Loader.tsx b/jsapp/js/theme/kobo/Loader.tsx new file mode 100644 index 0000000000..e28c81a226 --- /dev/null +++ b/jsapp/js/theme/kobo/Loader.tsx @@ -0,0 +1,29 @@ +import type {MantineLoaderComponent} from '@mantine/core'; +import {Box, Loader} from '@mantine/core'; +import LoadingSpinner from 'jsapp/js/components/common/loadingSpinner'; +import {forwardRef} from 'react'; + +const KoboLoaderRegular: MantineLoaderComponent = forwardRef( + ({...others}, ref) => ( + + + + ) +); + +const KoboLoaderBig: MantineLoaderComponent = forwardRef(({...others}, ref) => ( + + + +)); + +export const LoaderThemeKobo = Loader.extend({ + defaultProps: { + loaders: { + ...Loader.defaultLoaders, + regular: KoboLoaderRegular, + big: KoboLoaderBig, + }, + type: 'regular', + }, +}); diff --git a/jsapp/js/theme/kobo/index.ts b/jsapp/js/theme/kobo/index.ts index 30167bd159..e897baaf68 100644 --- a/jsapp/js/theme/kobo/index.ts +++ b/jsapp/js/theme/kobo/index.ts @@ -6,6 +6,7 @@ import {TooltipThemeKobo} from './Tooltip'; import {MenuThemeKobo} from './Menu'; import {AlertThemeKobo} from './Alert'; import {SelectThemeKobo} from './Select'; +import {LoaderThemeKobo} from './Loader'; export const themeKobo = createTheme({ primaryColor: 'blue', @@ -83,8 +84,7 @@ export const themeKobo = createTheme({ lg: rem(16), xl: rem(18), }, - lineHeights: { - }, + lineHeights: {}, headings: { fontWeight: '500', }, @@ -109,5 +109,6 @@ export const themeKobo = createTheme({ Tooltip: TooltipThemeKobo, Table: TableThemeKobo, Select: SelectThemeKobo, + Loader: LoaderThemeKobo, }, });