@homefile/components-v2 1.0.11 → 1.0.13
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/components/homeAssistant/HomeAssistantStepper.js +1 -1
- package/dist/components/homeAssistant/HomeAssistantSteps.js +2 -3
- package/dist/components/homeAssistant/panel/ApplianceSteps.js +12 -11
- package/dist/components/tour/HomeBoardTour.js +1 -1
- package/dist/components/tour/LaunchpadTour.js +1 -1
- package/dist/components/tour/RoomsBoardTour.js +1 -1
- package/dist/hooks/useComponentStyles.d.ts +7 -1
- package/dist/hooks/useComponentStyles.js +2 -2
- package/dist/interfaces/homeAssistant/ApplianceSteps.interface.d.ts +1 -1
- package/dist/interfaces/homeAssistant/HomeAssistantPanel.interface.d.ts +1 -1
- package/dist/stories/homeAssistant/panel/HomeAssistantPanel.stories.js +1 -0
- package/package.json +1 -1
- package/src/components/homeAssistant/HomeAssistantStepper.tsx +1 -1
- package/src/components/homeAssistant/HomeAssistantSteps.tsx +1 -3
- package/src/components/homeAssistant/panel/ApplianceSteps.tsx +19 -11
- package/src/components/tour/HomeBoardTour.tsx +1 -1
- package/src/components/tour/LaunchpadTour.tsx +1 -1
- package/src/components/tour/RoomsBoardTour.tsx +1 -1
- package/src/hooks/useComponentStyles.ts +12 -2
- package/src/interfaces/homeAssistant/ApplianceSteps.interface.ts +1 -1
- package/src/interfaces/homeAssistant/HomeAssistantPanel.interface.ts +1 -1
- package/src/stories/homeAssistant/panel/HomeAssistantPanel.stories.tsx +1 -0
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { t } from 'i18next';
|
|
3
3
|
import { Box, Flex, Stack, Text } from '@chakra-ui/react';
|
|
4
4
|
export const HomeAssistantStepper = ({ currentStep, totalSteps, }) => {
|
|
5
|
-
return (_jsx(Flex, { gap: "1px", w: "100%", children: Array.from({ length: totalSteps }).map((_, index) => {
|
|
5
|
+
return (_jsx(Flex, { gap: "1px", w: "100%", zIndex: "2", children: Array.from({ length: totalSteps }).map((_, index) => {
|
|
6
6
|
return (_jsxs(Stack, { flex: "1", spacing: "1", children: [_jsx(Text, { fontFamily: "secondary", fontSize: "xs", textTransform: "uppercase", color: setTextColor(index + 1, currentStep), textAlign: "center", children: `${currentStep} ${t('addItemWizard.of')} ${totalSteps}` }), _jsx(Box, { h: "16px", bg: setBgColor(index + 1, currentStep) })] }, index));
|
|
7
7
|
}) }));
|
|
8
8
|
};
|
|
@@ -4,7 +4,6 @@ import { HomeAssistantButton, HomeAssistantStepper } from '..';
|
|
|
4
4
|
import { homeAssistantSteps } from '../../helpers';
|
|
5
5
|
import { useComponentStyles } from '../../hooks';
|
|
6
6
|
export const HomeAssistantSteps = ({ currentStep, onStepClick, currentPanel, }) => {
|
|
7
|
-
const wrapperZIndex = currentPanel ? undefined : '2';
|
|
8
7
|
const stepId = `homeAssistantButton-${currentPanel}`;
|
|
9
8
|
const componentIds = currentPanel
|
|
10
9
|
? [
|
|
@@ -16,8 +15,8 @@ export const HomeAssistantSteps = ({ currentStep, onStepClick, currentPanel, })
|
|
|
16
15
|
'homeAssistantButton-6',
|
|
17
16
|
]
|
|
18
17
|
: [];
|
|
19
|
-
useComponentStyles(componentIds, stepId);
|
|
20
|
-
return (_jsxs(Stack, { spacing: "8", w: "fit-content", position: "relative", top: ['-10px', '-30px'],
|
|
18
|
+
useComponentStyles({ ids: componentIds, selectedId: stepId, zIndex: '2' });
|
|
19
|
+
return (_jsxs(Stack, { spacing: "8", w: "fit-content", position: "relative", top: ['-10px', '-30px'], children: [_jsx(HomeAssistantStepper, { currentStep: currentStep, totalSteps: 6 }), _jsx(SimpleGrid, { columns: [2, 3], spacing: "base", children: homeAssistantSteps.map((step, index) => (_jsx(Center, { w: "100%", children: _jsx(HomeAssistantButton, { currentStep: index + 1, onStepClick: onStepClick, status: getStatus(index + 1, currentStep), step: step }) }, step.title))) })] }));
|
|
21
20
|
};
|
|
22
21
|
const getStatus = (index, currentStep) => {
|
|
23
22
|
if (index === currentStep)
|
|
@@ -3,68 +3,69 @@ import { t } from 'i18next';
|
|
|
3
3
|
import { Center, SimpleGrid, Stack, Text } from '@chakra-ui/react';
|
|
4
4
|
import { ApplianceButton } from '../..';
|
|
5
5
|
import { Fridge, Freezer, Washer, Dryer, Dishwasher, CookTop, Oven, Hood, Microwave, Range, } from '../../../assets/images';
|
|
6
|
+
import { useState } from 'react';
|
|
6
7
|
export const ApplianceSteps = ({ onClick }) => {
|
|
7
|
-
|
|
8
|
+
const [appliances, setAppliances] = useState([]);
|
|
9
|
+
const handleClick = (id) => {
|
|
10
|
+
if (appliances.includes(id)) {
|
|
11
|
+
const newAppliances = appliances.filter((appliance) => appliance !== id);
|
|
12
|
+
onClick(newAppliances);
|
|
13
|
+
return setAppliances(newAppliances);
|
|
14
|
+
}
|
|
15
|
+
setAppliances([...appliances, id]);
|
|
16
|
+
onClick([...appliances, id]);
|
|
17
|
+
};
|
|
18
|
+
return (_jsxs(Stack, { spacing: "base", bg: "lightBlue.2", p: "base", children: [_jsx(Text, { fontFamily: "secondary", fontSize: "sm", children: t('homeAssistant.selectAppliances') }), _jsx(SimpleGrid, { columns: [4, 5], spacing: "base", children: steps.map((step) => (_jsx(Center, { w: "100%", children: _jsx(ApplianceButton, { onClick: handleClick, step: Object.assign(Object.assign({}, step), { isCompleted: appliances.includes(step.id) }) }) }, step.id))) })] }));
|
|
8
19
|
};
|
|
9
20
|
export const steps = [
|
|
10
21
|
{
|
|
11
22
|
id: 'fridge',
|
|
12
23
|
title: 'fridge',
|
|
13
24
|
icon: Fridge,
|
|
14
|
-
isCompleted: true,
|
|
15
25
|
},
|
|
16
26
|
{
|
|
17
27
|
id: 'freezer',
|
|
18
28
|
title: 'freezer',
|
|
19
29
|
icon: Freezer,
|
|
20
|
-
isCompleted: false,
|
|
21
30
|
},
|
|
22
31
|
{
|
|
23
32
|
id: 'washer',
|
|
24
33
|
title: 'washer',
|
|
25
34
|
icon: Washer,
|
|
26
|
-
isCompleted: false,
|
|
27
35
|
},
|
|
28
36
|
{
|
|
29
37
|
id: 'dryer',
|
|
30
38
|
title: 'Dryer',
|
|
31
39
|
icon: Dryer,
|
|
32
|
-
isCompleted: false,
|
|
33
40
|
},
|
|
34
41
|
{
|
|
35
42
|
id: 'dish-washer',
|
|
36
43
|
title: 'Dish Washer',
|
|
37
44
|
icon: Dishwasher,
|
|
38
|
-
isCompleted: false,
|
|
39
45
|
},
|
|
40
46
|
{
|
|
41
47
|
id: 'cook-top',
|
|
42
48
|
title: 'Cook Top',
|
|
43
49
|
icon: CookTop,
|
|
44
|
-
isCompleted: false,
|
|
45
50
|
},
|
|
46
51
|
{
|
|
47
52
|
id: 'oven',
|
|
48
53
|
title: 'oven',
|
|
49
54
|
icon: Oven,
|
|
50
|
-
isCompleted: false,
|
|
51
55
|
},
|
|
52
56
|
{
|
|
53
57
|
id: 'range',
|
|
54
58
|
title: 'range',
|
|
55
59
|
icon: Range,
|
|
56
|
-
isCompleted: false,
|
|
57
60
|
},
|
|
58
61
|
{
|
|
59
62
|
id: 'hood',
|
|
60
63
|
title: 'hood',
|
|
61
64
|
icon: Hood,
|
|
62
|
-
isCompleted: false,
|
|
63
65
|
},
|
|
64
66
|
{
|
|
65
67
|
id: 'microwave',
|
|
66
68
|
title: 'microwave',
|
|
67
69
|
icon: Microwave,
|
|
68
|
-
isCompleted: false,
|
|
69
70
|
},
|
|
70
71
|
];
|
|
@@ -22,7 +22,7 @@ export const HomeBoardTour = ({ currentStep = 'homeboard', bubbleWidth = '300px'
|
|
|
22
22
|
'addCatalog',
|
|
23
23
|
];
|
|
24
24
|
const { coordinates } = useComponentCoordinates(componentIds);
|
|
25
|
-
useComponentStyles(componentIds, currentStep);
|
|
25
|
+
useComponentStyles({ ids: componentIds, selectedId: currentStep });
|
|
26
26
|
const { windowDimensions: { width, height }, } = useWindowDimensions();
|
|
27
27
|
const parsedBubbleWidth = Number(bubbleWidth.replace('px', ''));
|
|
28
28
|
const panelBubbleArrowSize = 500 + parsedBubbleWidth + arrowSize;
|
|
@@ -20,7 +20,7 @@ export const LaunchpadTour = ({ currentStep = 'launchpad', handleStep, handleClo
|
|
|
20
20
|
'forwardReceipts',
|
|
21
21
|
];
|
|
22
22
|
const { coordinates } = useComponentCoordinates(componentIds);
|
|
23
|
-
useComponentStyles(componentIds, currentStep);
|
|
23
|
+
useComponentStyles({ ids: componentIds, selectedId: currentStep });
|
|
24
24
|
const { windowDimensions: { width, height }, } = useWindowDimensions();
|
|
25
25
|
const cardSize = 220;
|
|
26
26
|
const steps = {
|
|
@@ -16,7 +16,7 @@ export const RoomsBoardTour = ({ currentStep = 'addRooms', handleClose, handleSt
|
|
|
16
16
|
'addingItems',
|
|
17
17
|
];
|
|
18
18
|
const { coordinates } = useComponentCoordinates(componentIds);
|
|
19
|
-
useComponentStyles(componentIds, currentStep);
|
|
19
|
+
useComponentStyles({ ids: componentIds, selectedId: currentStep });
|
|
20
20
|
const { windowDimensions: { width, height }, } = useWindowDimensions();
|
|
21
21
|
const steps = {
|
|
22
22
|
addRooms: {
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
interface UseComponentStyles {
|
|
2
|
+
ids: string[];
|
|
3
|
+
selectedId: string;
|
|
4
|
+
zIndex?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const useComponentStyles: ({ ids, selectedId, zIndex, }: UseComponentStyles) => void;
|
|
7
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const useComponentStyles = (ids, selectedId) => {
|
|
1
|
+
export const useComponentStyles = ({ ids, selectedId, zIndex = 'auto', }) => {
|
|
2
2
|
if ((ids === null || ids === void 0 ? void 0 : ids.length) === 0)
|
|
3
3
|
return;
|
|
4
4
|
ids.forEach((id) => {
|
|
5
5
|
const component = document.getElementById(id);
|
|
6
6
|
if (component) {
|
|
7
|
-
component.style.zIndex =
|
|
7
|
+
component.style.zIndex = zIndex;
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
10
|
const currentComponent = document.getElementById(selectedId);
|
|
@@ -2,7 +2,7 @@ import { DynamicFormI } from '..';
|
|
|
2
2
|
export interface HomeAssistantPanelI {
|
|
3
3
|
currentForm: DynamicFormI['form'];
|
|
4
4
|
currentStep: number;
|
|
5
|
-
onApplianceClick: (
|
|
5
|
+
onApplianceClick: (selected: string[]) => void;
|
|
6
6
|
onBack: () => void;
|
|
7
7
|
onClose: () => void;
|
|
8
8
|
onNext: () => void;
|
|
@@ -9,6 +9,7 @@ export default {
|
|
|
9
9
|
args: {
|
|
10
10
|
currentStep: 4,
|
|
11
11
|
currentForm: homeAssitantStep1FormMock,
|
|
12
|
+
onApplianceClick: action('onApplianceClick'),
|
|
12
13
|
},
|
|
13
14
|
decorators: [
|
|
14
15
|
(Story) => (_jsx(RightPanel, { isOpen: true, onClose: action('onClose'), children: _jsx(Story, {}) })),
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ export const HomeAssistantStepper = ({
|
|
|
7
7
|
totalSteps,
|
|
8
8
|
}: HomeAssistantStepperI) => {
|
|
9
9
|
return (
|
|
10
|
-
<Flex gap="1px" w="100%">
|
|
10
|
+
<Flex gap="1px" w="100%" zIndex="2">
|
|
11
11
|
{Array.from({ length: totalSteps }).map((_, index) => {
|
|
12
12
|
return (
|
|
13
13
|
<Stack key={index} flex="1" spacing="1">
|
|
@@ -9,7 +9,6 @@ export const HomeAssistantSteps = ({
|
|
|
9
9
|
onStepClick,
|
|
10
10
|
currentPanel,
|
|
11
11
|
}: HomeAssistantStepsI) => {
|
|
12
|
-
const wrapperZIndex = currentPanel ? undefined : '2'
|
|
13
12
|
const stepId = `homeAssistantButton-${currentPanel}`
|
|
14
13
|
const componentIds = currentPanel
|
|
15
14
|
? [
|
|
@@ -22,14 +21,13 @@ export const HomeAssistantSteps = ({
|
|
|
22
21
|
]
|
|
23
22
|
: []
|
|
24
23
|
|
|
25
|
-
useComponentStyles(componentIds, stepId)
|
|
24
|
+
useComponentStyles({ ids: componentIds, selectedId: stepId, zIndex: '2' })
|
|
26
25
|
return (
|
|
27
26
|
<Stack
|
|
28
27
|
spacing="8"
|
|
29
28
|
w="fit-content"
|
|
30
29
|
position="relative"
|
|
31
30
|
top={['-10px', '-30px']}
|
|
32
|
-
zIndex={wrapperZIndex}
|
|
33
31
|
>
|
|
34
32
|
<HomeAssistantStepper currentStep={currentStep} totalSteps={6} />
|
|
35
33
|
<SimpleGrid columns={[2, 3]} spacing="base">
|
|
@@ -14,8 +14,20 @@ import {
|
|
|
14
14
|
Microwave,
|
|
15
15
|
Range,
|
|
16
16
|
} from '@/assets/images'
|
|
17
|
+
import { useState } from 'react'
|
|
17
18
|
|
|
18
19
|
export const ApplianceSteps = ({ onClick }: ApplianceStepsI) => {
|
|
20
|
+
const [appliances, setAppliances] = useState<string[]>([])
|
|
21
|
+
const handleClick = (id: string) => {
|
|
22
|
+
if (appliances.includes(id)) {
|
|
23
|
+
const newAppliances = appliances.filter((appliance) => appliance !== id)
|
|
24
|
+
onClick(newAppliances)
|
|
25
|
+
return setAppliances(newAppliances)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setAppliances([...appliances, id])
|
|
29
|
+
onClick([...appliances, id])
|
|
30
|
+
}
|
|
19
31
|
return (
|
|
20
32
|
<Stack spacing="base" bg="lightBlue.2" p="base">
|
|
21
33
|
<Text fontFamily="secondary" fontSize="sm">
|
|
@@ -24,7 +36,13 @@ export const ApplianceSteps = ({ onClick }: ApplianceStepsI) => {
|
|
|
24
36
|
<SimpleGrid columns={[4, 5]} spacing="base">
|
|
25
37
|
{steps.map((step) => (
|
|
26
38
|
<Center key={step.id} w="100%">
|
|
27
|
-
<ApplianceButton
|
|
39
|
+
<ApplianceButton
|
|
40
|
+
onClick={handleClick}
|
|
41
|
+
step={{
|
|
42
|
+
...step,
|
|
43
|
+
isCompleted: appliances.includes(step.id),
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
28
46
|
</Center>
|
|
29
47
|
))}
|
|
30
48
|
</SimpleGrid>
|
|
@@ -37,60 +55,50 @@ export const steps: ApplianceStepI[] = [
|
|
|
37
55
|
id: 'fridge',
|
|
38
56
|
title: 'fridge',
|
|
39
57
|
icon: Fridge,
|
|
40
|
-
isCompleted: true,
|
|
41
58
|
},
|
|
42
59
|
{
|
|
43
60
|
id: 'freezer',
|
|
44
61
|
title: 'freezer',
|
|
45
62
|
icon: Freezer,
|
|
46
|
-
isCompleted: false,
|
|
47
63
|
},
|
|
48
64
|
{
|
|
49
65
|
id: 'washer',
|
|
50
66
|
title: 'washer',
|
|
51
67
|
icon: Washer,
|
|
52
|
-
isCompleted: false,
|
|
53
68
|
},
|
|
54
69
|
{
|
|
55
70
|
id: 'dryer',
|
|
56
71
|
title: 'Dryer',
|
|
57
72
|
icon: Dryer,
|
|
58
|
-
isCompleted: false,
|
|
59
73
|
},
|
|
60
74
|
{
|
|
61
75
|
id: 'dish-washer',
|
|
62
76
|
title: 'Dish Washer',
|
|
63
77
|
icon: Dishwasher,
|
|
64
|
-
isCompleted: false,
|
|
65
78
|
},
|
|
66
79
|
{
|
|
67
80
|
id: 'cook-top',
|
|
68
81
|
title: 'Cook Top',
|
|
69
82
|
icon: CookTop,
|
|
70
|
-
isCompleted: false,
|
|
71
83
|
},
|
|
72
84
|
{
|
|
73
85
|
id: 'oven',
|
|
74
86
|
title: 'oven',
|
|
75
87
|
icon: Oven,
|
|
76
|
-
isCompleted: false,
|
|
77
88
|
},
|
|
78
89
|
{
|
|
79
90
|
id: 'range',
|
|
80
91
|
title: 'range',
|
|
81
92
|
icon: Range,
|
|
82
|
-
isCompleted: false,
|
|
83
93
|
},
|
|
84
94
|
{
|
|
85
95
|
id: 'hood',
|
|
86
96
|
title: 'hood',
|
|
87
97
|
icon: Hood,
|
|
88
|
-
isCompleted: false,
|
|
89
98
|
},
|
|
90
99
|
{
|
|
91
100
|
id: 'microwave',
|
|
92
101
|
title: 'microwave',
|
|
93
102
|
icon: Microwave,
|
|
94
|
-
isCompleted: false,
|
|
95
103
|
},
|
|
96
104
|
]
|
|
@@ -46,7 +46,7 @@ export const HomeBoardTour = ({
|
|
|
46
46
|
|
|
47
47
|
const { coordinates } = useComponentCoordinates(componentIds)
|
|
48
48
|
|
|
49
|
-
useComponentStyles(componentIds, currentStep)
|
|
49
|
+
useComponentStyles({ ids: componentIds, selectedId: currentStep })
|
|
50
50
|
|
|
51
51
|
const {
|
|
52
52
|
windowDimensions: { width, height },
|
|
@@ -41,7 +41,7 @@ export const LaunchpadTour = ({
|
|
|
41
41
|
|
|
42
42
|
const { coordinates } = useComponentCoordinates(componentIds)
|
|
43
43
|
|
|
44
|
-
useComponentStyles(componentIds, currentStep)
|
|
44
|
+
useComponentStyles({ ids: componentIds, selectedId: currentStep })
|
|
45
45
|
|
|
46
46
|
const {
|
|
47
47
|
windowDimensions: { width, height },
|
|
@@ -33,7 +33,7 @@ export const RoomsBoardTour = ({
|
|
|
33
33
|
|
|
34
34
|
const { coordinates } = useComponentCoordinates(componentIds)
|
|
35
35
|
|
|
36
|
-
useComponentStyles(componentIds, currentStep)
|
|
36
|
+
useComponentStyles({ ids: componentIds, selectedId: currentStep })
|
|
37
37
|
|
|
38
38
|
const {
|
|
39
39
|
windowDimensions: { width, height },
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
interface UseComponentStyles {
|
|
2
|
+
ids: string[]
|
|
3
|
+
selectedId: string
|
|
4
|
+
zIndex?: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const useComponentStyles = ({
|
|
8
|
+
ids,
|
|
9
|
+
selectedId,
|
|
10
|
+
zIndex = 'auto',
|
|
11
|
+
}: UseComponentStyles) => {
|
|
2
12
|
if (ids?.length === 0) return
|
|
3
13
|
|
|
4
14
|
ids.forEach((id) => {
|
|
5
15
|
const component = document.getElementById(id)
|
|
6
16
|
|
|
7
17
|
if (component) {
|
|
8
|
-
component.style.zIndex =
|
|
18
|
+
component.style.zIndex = zIndex
|
|
9
19
|
}
|
|
10
20
|
})
|
|
11
21
|
|
|
@@ -3,7 +3,7 @@ import { DynamicFormI } from '@/interfaces'
|
|
|
3
3
|
export interface HomeAssistantPanelI {
|
|
4
4
|
currentForm: DynamicFormI['form']
|
|
5
5
|
currentStep: number
|
|
6
|
-
onApplianceClick: (
|
|
6
|
+
onApplianceClick: (selected: string[]) => void
|
|
7
7
|
onBack: () => void
|
|
8
8
|
onClose: () => void
|
|
9
9
|
onNext: () => void
|