Skip to content

Commit

Permalink
stories: common LoadingTemplateWithSwitch
Browse files Browse the repository at this point in the history
  • Loading branch information
zbigg committed Sep 7, 2023
1 parent b4e2dbb commit 07e6e1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import React from 'react';
import { Skeleton } from '@mui/material';
import { Box, Skeleton } from '@mui/material';

const FormulaSkeleton = () => {
return <Skeleton height={24} width={120} />;
return (
<Box pt={0.5}>
<Skeleton height={24} width={120} />
</Box>
);
};

export default FormulaSkeleton;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import FormulaWidgetUI from '../../../src/widgets/FormulaWidgetUI/FormulaWidgetUI';
import { Label, ThinContainer } from '../../utils/storyStyles';
import LoadingTemplateWithSwitch from './LoadingTemplateWithSwitch';

const options = {
title: 'Widgets/FormulaWidgetUI',
Expand All @@ -27,23 +28,7 @@ const Template = (args) => {
return <FormulaWidgetUI {...args} />;
};

const LoadingTemplate = (args) => {
return (
<>
<Label variant='body1' mb={3}>
{'Limited width'}
</Label>
<ThinContainer>
<FormulaWidgetUI {...args} />
</ThinContainer>

<Label variant='body1' mt={8} mb={3}>
{'Responsive'}
</Label>
<FormulaWidgetUI {...args} />
</>
);
};
const LoadingTemplate = LoadingTemplateWithSwitch(FormulaWidgetUI);

const data = 10000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import TimeSeriesWidgetUI from '../../../src/widgets/TimeSeriesWidgetUI/TimeSeri
import { GroupDateTypes } from '@carto/react-core';
import { TIME_SERIES_CHART_TYPES } from '@carto/react-ui';
import { Label, ThinContainer } from '../../utils/storyStyles';
import LoadingTemplateWithSwitch from './LoadingTemplateWithSwitch';

const data = [
{ name: 1514761200000, value: 310 },
Expand Down Expand Up @@ -183,40 +184,24 @@ const Template = (args) => {
);
};

const LoadingTemplate = (args) => {
const TimeSeriesWidgetUIWithDefaults = (args) => {
if (args.timeWindow && !Array.isArray(args.timeWindow)) {
args.timeWindow = [];
}

const [selectedCategories, setSelectedCategories] = React.useState([]);
const [isLoading, setIsLoading] = React.useState(args.isLoading);
return (
<>
<Label variant='body1' mb={3}>
{'Limited width'} <button onClick={() => setIsLoading(!isLoading)}>toggle</button>
</Label>
<ThinContainer>
<TimeSeriesWidgetUI
{...args}
isLoading={isLoading}
selectedCategories={selectedCategories}
onSelectedCategoriesChange={setSelectedCategories}
/>
</ThinContainer>

<Label variant='body1' mt={8} mb={3}>
{'Responsive'}
</Label>
<TimeSeriesWidgetUI
{...args}
isLoading={isLoading}
selectedCategories={selectedCategories}
onSelectedCategoriesChange={setSelectedCategories}
/>
</>
return (
<TimeSeriesWidgetUI
{...args}
selectedCategories={selectedCategories}
onSelectedCategoriesChange={setSelectedCategories}
/>
);
};

const LoadingTemplate = LoadingTemplateWithSwitch(TimeSeriesWidgetUIWithDefaults);

const requiredProps = {
data,
stepSize: GroupDateTypes.WEEKS,
Expand Down

0 comments on commit 07e6e1f

Please sign in to comment.