@homefile/components-v2 2.17.0 → 2.17.2

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.
@@ -1,2 +1,2 @@
1
1
  import { HomeMonitorButtonI } from '../../interfaces';
2
- export declare const HomeMonitorButton: ({ currentStep, onStepClick, status, step, }: HomeMonitorButtonI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const HomeMonitorButton: ({ alertCount, currentStep, onStepClick, status, step, }: HomeMonitorButtonI) => import("react/jsx-runtime").JSX.Element;
@@ -1,26 +1,51 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Center, Image, Stack, Text } from '@chakra-ui/react';
3
3
  import { getIconAltText } from '../../utils';
4
- export const HomeMonitorButton = ({ currentStep, onStepClick, status = 'ok', step, }) => {
4
+ import { keyframes } from '@emotion/react';
5
+ export const HomeMonitorButton = ({ alertCount = 0, currentStep, onStepClick, status = 'ok', step, }) => {
5
6
  const buttonId = `homeMonitorButton-${currentStep}`;
6
7
  const iconAltText = getIconAltText(step.icon);
7
- return (_jsx(Box, { position: "relative", id: buttonId, zIndex: "2", children: _jsxs(Box, { position: "relative", bg: "neutral.white", borderRadius: "lg", boxShadow: "lg", zIndex: "2", children: [_jsx(Box, { bg: status === 'alert' ? 'error.2' : 'green.1', boxSize: "10px", borderRadius: "full", position: "absolute", top: "6px", left: "6px", zIndex: "8" }), _jsxs(Stack, Object.assign({ position: "relative", zIndex: "2", as: "button", spacing: "2", border: "1px solid transparent", align: "center", h: "96px", w: "100%", p: "base" }, setStyles(status), { onClick: () => onStepClick(currentStep), children: [_jsx(Center, { h: "60%", marginTop: "2", children: _jsx(Image, { src: step.icon, alt: iconAltText, w: "auto", h: "28px" }) }), _jsx(Center, { h: "40%", children: _jsx(Text, { fontSize: "xs", textTransform: "uppercase", textAlign: "center", lineHeight: "14px", children: step.title }) })] }))] }) }));
8
+ const alert = status === 'alert';
9
+ const ok = status === 'ok';
10
+ return (_jsx(Box, Object.assign({ position: "relative", id: buttonId, zIndex: "2", boxShadow: "lg" }, setStyles(status), { children: _jsxs(Box, { position: "relative", bg: "neutral.white", borderRadius: "lg", zIndex: "2", children: [_jsx(Box, { bg: alert ? 'error.2' : 'green.1', boxSize: "10px", borderRadius: "full", position: "absolute", top: "6px", left: "6px", zIndex: "8" }), _jsxs(Stack, { position: "relative", zIndex: "2", as: "button", spacing: "2", border: "1px solid transparent", align: "center", h: "96px", w: "100%", p: "base", onClick: () => onStepClick(currentStep), filter: ok ? 'grayscale(1) opacity(0.6)' : '', children: [_jsxs(Center, { h: "60%", marginTop: "2", children: [!alert && (_jsx(Image, { src: step.icon, alt: iconAltText, w: "auto", h: "28px" })), alert && (_jsx(Center, { boxSize: "32px", bg: "error.2", borderRadius: "full", color: "neutral.white", lineHeight: "1", fontWeight: "bold", children: alertCount }))] }), _jsx(Center, { h: "40%", children: _jsx(Text, { fontSize: "xs", textTransform: "uppercase", textAlign: "center", lineHeight: "14px", children: step.title }) })] })] }) })));
8
11
  };
12
+ const alertGradient = keyframes `
13
+ 0% {
14
+ background-position: 0% 50%;
15
+ }
16
+ 100% {
17
+ background-position: 100% 50%;
18
+ }
19
+ `;
9
20
  const setStyles = (status) => {
10
21
  switch (status) {
11
22
  case 'alert':
12
23
  return {
24
+ background: 'white',
13
25
  cursor: 'pointer',
14
- border: '1px solid',
15
- borderColor: 'error.2',
16
26
  transition: 'all 0.3s',
27
+ borderRadius: 'lg',
28
+ border: 'none',
29
+ _before: {
30
+ content: '""',
31
+ position: 'absolute',
32
+ inset: '-2px',
33
+ borderRadius: 'inherit',
34
+ background: 'linear-gradient(270deg,rgb(123, 6, 105),rgb(233, 175, 236), #F544DA)',
35
+ backgroundSize: '400% 400%',
36
+ animation: `${alertGradient} 2s linear infinite`,
37
+ animationDirection: 'alternate',
38
+ zIndex: -1,
39
+ pointerEvents: 'none',
40
+ },
17
41
  _hover: {
18
42
  bg: 'lightGreen.7',
19
43
  },
20
44
  };
21
45
  case 'ok':
22
46
  return {
23
- filter: 'grayscale(1) opacity(0.6)',
47
+ bg: 'neutral.white',
48
+ borderRadius: 'lg',
24
49
  };
25
50
  }
26
51
  };
@@ -1,2 +1,2 @@
1
1
  import { HomeMonitortStepsI } from '../../interfaces';
2
- export declare const HomeMonitorSteps: ({ menuItems, onStepClick, stepsWithAlerts, }: HomeMonitortStepsI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const HomeMonitorSteps: ({ alerts, menuItems, onStepClick, stepsWithAlerts, }: HomeMonitortStepsI) => import("react/jsx-runtime").JSX.Element;
@@ -4,13 +4,17 @@ import { Box, Flex } from '@chakra-ui/react';
4
4
  import { HomeMonitorButton, IconMenu, MoreHorizontal } from '..';
5
5
  import { homeAssistantSteps } from '../../helpers';
6
6
  import { homeAssistantProxy } from '../../proxies';
7
- export const HomeMonitorSteps = ({ menuItems = [], onStepClick, stepsWithAlerts, }) => {
7
+ export const HomeMonitorSteps = ({ alerts = [], menuItems = [], onStepClick, stepsWithAlerts = [], }) => {
8
8
  const { setSelectedId } = homeAssistantProxy;
9
9
  const isDisabled = menuItems.length === 0;
10
10
  const handleStepClick = (step) => onStepClick(step);
11
- return (_jsx(Flex, { gap: "base", justify: "center", children: homeAssistantSteps.map((step, index) => (_jsx(Box, { position: "relative", flex: "1", children: _jsxs(Fragment, { children: [_jsx(HomeMonitorButton, { currentStep: index + 1, onStepClick: handleStepClick, status: getStatus(index + 1, stepsWithAlerts), step: step }), _jsx(Box, { position: "absolute", top: "-2px", right: "4px", zIndex: "1400", children: _jsx(IconMenu, { zIndex: "2", icon: _jsx(MoreHorizontal, { size: 26 }), itemForm: index + 1, menuItems: menuItems, disabled: isDisabled, onClick: () => setSelectedId(`homeMonitorButton-${index + 1}`) }) })] }) }, step === null || step === void 0 ? void 0 : step.title))) }));
11
+ return (_jsx(Flex, { gap: "base", justify: "center", children: homeAssistantSteps.map((step, index) => {
12
+ var _a;
13
+ return (_jsx(Box, { position: "relative", flex: "1", children: _jsxs(Fragment, { children: [_jsx(HomeMonitorButton, { alertCount: (_a = alerts.find((alert) => alert.step === index + 1)) === null || _a === void 0 ? void 0 : _a.count, currentStep: index + 1, onStepClick: handleStepClick, status: getStatus(index + 1, stepsWithAlerts, alerts), step: step }), _jsx(Box, { position: "absolute", top: "-2px", right: "4px", zIndex: "1400", children: _jsx(IconMenu, { zIndex: "2", icon: _jsx(MoreHorizontal, { size: 26 }), itemForm: index + 1, menuItems: menuItems, disabled: isDisabled, onClick: () => setSelectedId(`homeMonitorButton-${index + 1}`) }) })] }) }, step === null || step === void 0 ? void 0 : step.title));
14
+ }) }));
12
15
  };
13
- const getStatus = (index, stepsWithAlerts) => {
14
- const hasAlert = stepsWithAlerts.includes(index);
16
+ const getStatus = (index, stepsWithAlerts, alerts) => {
17
+ const hasAlert = (stepsWithAlerts === null || stepsWithAlerts === void 0 ? void 0 : stepsWithAlerts.includes(index)) ||
18
+ (alerts === null || alerts === void 0 ? void 0 : alerts.some((alert) => alert.step === index));
15
19
  return hasAlert ? 'alert' : 'ok';
16
20
  };
@@ -1,12 +1,19 @@
1
1
  import { HomeAssistantStepI, MenuItemI } from '..';
2
+ interface AlertI {
3
+ step: number;
4
+ count: number;
5
+ }
2
6
  export interface HomeMonitortStepsI {
7
+ alerts?: AlertI[];
3
8
  menuItems: MenuItemI[];
4
- stepsWithAlerts: number[];
9
+ stepsWithAlerts?: number[];
5
10
  onStepClick: (step: number) => void;
6
11
  }
7
12
  export interface HomeMonitorButtonI {
13
+ alertCount?: number;
8
14
  currentStep: number;
9
15
  onStepClick: HomeMonitortStepsI['onStepClick'];
10
16
  status: 'alert' | 'ok';
11
17
  step: HomeAssistantStepI;
12
18
  }
19
+ export {};
@@ -0,0 +1,5 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { HomeMonitortStepsI } from '../../interfaces';
3
+ declare const _default: Meta<HomeMonitortStepsI>;
4
+ export default _default;
5
+ export declare const HomeMonitorStepsComponent: (args: HomeMonitortStepsI) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { HomeMonitorSteps } from '../../components';
3
+ import { Box } from '@chakra-ui/react';
4
+ import { action } from '@storybook/addon-actions';
5
+ import { menuMock } from '../../mocks';
6
+ export default {
7
+ title: 'Components/HomeAssistant',
8
+ component: HomeMonitorSteps,
9
+ args: {
10
+ alerts: [
11
+ { step: 2, count: 3 },
12
+ { step: 1, count: 2 },
13
+ { step: 6, count: 2 },
14
+ ],
15
+ menuItems: menuMock,
16
+ onStepClick: action('onStepClick'),
17
+ },
18
+ decorators: [
19
+ (Story) => (_jsx(Box, { p: "base", w: ['full', '800px'], h: "fit-content", children: _jsx(Story, {}) })),
20
+ ],
21
+ };
22
+ export const HomeMonitorStepsComponent = (args) => {
23
+ return _jsx(HomeMonitorSteps, Object.assign({}, args));
24
+ };
@@ -0,0 +1,5 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { AddToHomefileI } from '../../interfaces';
3
+ declare const _default: Meta<AddToHomefileI>;
4
+ export default _default;
5
+ export declare const AddToHomefileComponent: (args: AddToHomefileI) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from '@chakra-ui/react';
3
+ import { AddToHomefile } from '../../components';
4
+ import { action } from '@storybook/addon-actions';
5
+ export default {
6
+ title: 'Components/HomeBoard',
7
+ component: AddToHomefile,
8
+ args: {
9
+ onItemClick: action('onItemClick'),
10
+ documentList: [],
11
+ },
12
+ };
13
+ export const AddToHomefileComponent = (args) => {
14
+ return (_jsx(Box, { w: ['full', '300px'], children: _jsx(AddToHomefile, Object.assign({}, args)) }));
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.17.0",
3
+ "version": "2.17.2",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -1,8 +1,10 @@
1
1
  import { Box, Center, Image, Stack, Text } from '@chakra-ui/react'
2
2
  import { HomeMonitorButtonI } from '@/interfaces'
3
3
  import { getIconAltText } from '@/utils'
4
+ import { keyframes } from '@emotion/react'
4
5
 
5
6
  export const HomeMonitorButton = ({
7
+ alertCount = 0,
6
8
  currentStep,
7
9
  onStepClick,
8
10
  status = 'ok',
@@ -10,18 +12,20 @@ export const HomeMonitorButton = ({
10
12
  }: HomeMonitorButtonI) => {
11
13
  const buttonId = `homeMonitorButton-${currentStep}`
12
14
  const iconAltText = getIconAltText(step.icon)
15
+ const alert = status === 'alert'
16
+ const ok = status === 'ok'
13
17
 
14
18
  return (
15
- <Box position="relative" id={buttonId} zIndex="2">
16
- <Box
17
- position="relative"
18
- bg="neutral.white"
19
- borderRadius="lg"
20
- boxShadow="lg"
21
- zIndex="2"
22
- >
19
+ <Box
20
+ position="relative"
21
+ id={buttonId}
22
+ zIndex="2"
23
+ boxShadow="lg"
24
+ {...setStyles(status)}
25
+ >
26
+ <Box position="relative" bg="neutral.white" borderRadius="lg" zIndex="2">
23
27
  <Box
24
- bg={status === 'alert' ? 'error.2' : 'green.1'}
28
+ bg={alert ? 'error.2' : 'green.1'}
25
29
  boxSize="10px"
26
30
  borderRadius="full"
27
31
  position="absolute"
@@ -40,11 +44,25 @@ export const HomeMonitorButton = ({
40
44
  h="96px"
41
45
  w="100%"
42
46
  p="base"
43
- {...setStyles(status)}
44
47
  onClick={() => onStepClick(currentStep)}
48
+ filter={ok ? 'grayscale(1) opacity(0.6)' : ''}
45
49
  >
46
50
  <Center h="60%" marginTop="2">
47
- <Image src={step.icon} alt={iconAltText} w="auto" h="28px" />
51
+ {!alert && (
52
+ <Image src={step.icon} alt={iconAltText} w="auto" h="28px" />
53
+ )}
54
+ {alert && (
55
+ <Center
56
+ boxSize="32px"
57
+ bg="error.2"
58
+ borderRadius="full"
59
+ color="neutral.white"
60
+ lineHeight="1"
61
+ fontWeight="bold"
62
+ >
63
+ {alertCount}
64
+ </Center>
65
+ )}
48
66
  </Center>
49
67
  <Center h="40%">
50
68
  <Text
@@ -62,21 +80,45 @@ export const HomeMonitorButton = ({
62
80
  )
63
81
  }
64
82
 
83
+ const alertGradient = keyframes`
84
+ 0% {
85
+ background-position: 0% 50%;
86
+ }
87
+ 100% {
88
+ background-position: 100% 50%;
89
+ }
90
+ `
91
+
65
92
  const setStyles = (status: HomeMonitorButtonI['status']) => {
66
93
  switch (status) {
67
94
  case 'alert':
68
95
  return {
96
+ background: 'white',
69
97
  cursor: 'pointer',
70
- border: '1px solid',
71
- borderColor: 'error.2',
72
98
  transition: 'all 0.3s',
99
+ borderRadius: 'lg',
100
+ border: 'none',
101
+ _before: {
102
+ content: '""',
103
+ position: 'absolute',
104
+ inset: '-2px',
105
+ borderRadius: 'inherit',
106
+ background:
107
+ 'linear-gradient(270deg,rgb(123, 6, 105),rgb(233, 175, 236), #F544DA)',
108
+ backgroundSize: '400% 400%',
109
+ animation: `${alertGradient} 2s linear infinite`,
110
+ animationDirection: 'alternate',
111
+ zIndex: -1,
112
+ pointerEvents: 'none',
113
+ },
73
114
  _hover: {
74
115
  bg: 'lightGreen.7',
75
116
  },
76
117
  }
77
118
  case 'ok':
78
119
  return {
79
- filter: 'grayscale(1) opacity(0.6)',
120
+ bg: 'neutral.white',
121
+ borderRadius: 'lg',
80
122
  }
81
123
  }
82
124
  }
@@ -6,9 +6,10 @@ import { homeAssistantSteps } from '@/helpers'
6
6
  import { homeAssistantProxy } from '@/proxies'
7
7
 
8
8
  export const HomeMonitorSteps = ({
9
+ alerts = [],
9
10
  menuItems = [],
10
11
  onStepClick,
11
- stepsWithAlerts,
12
+ stepsWithAlerts = [],
12
13
  }: HomeMonitortStepsI) => {
13
14
  const { setSelectedId } = homeAssistantProxy
14
15
 
@@ -21,9 +22,12 @@ export const HomeMonitorSteps = ({
21
22
  <Box key={step?.title} position="relative" flex="1">
22
23
  <Fragment>
23
24
  <HomeMonitorButton
25
+ alertCount={
26
+ alerts.find((alert) => alert.step === index + 1)?.count
27
+ }
24
28
  currentStep={index + 1}
25
29
  onStepClick={handleStepClick}
26
- status={getStatus(index + 1, stepsWithAlerts)}
30
+ status={getStatus(index + 1, stepsWithAlerts, alerts)}
27
31
  step={step}
28
32
  />
29
33
  <Box position="absolute" top="-2px" right="4px" zIndex="1400">
@@ -43,7 +47,13 @@ export const HomeMonitorSteps = ({
43
47
  )
44
48
  }
45
49
 
46
- const getStatus = (index: number, stepsWithAlerts: number[]) => {
47
- const hasAlert = stepsWithAlerts.includes(index)
50
+ const getStatus = (
51
+ index: number,
52
+ stepsWithAlerts: number[],
53
+ alerts: HomeMonitortStepsI['alerts']
54
+ ) => {
55
+ const hasAlert =
56
+ stepsWithAlerts?.includes(index) ||
57
+ alerts?.some((alert) => alert.step === index)
48
58
  return hasAlert ? 'alert' : 'ok'
49
59
  }
@@ -1,12 +1,19 @@
1
1
  import { HomeAssistantStepI, MenuItemI } from '@/interfaces'
2
2
 
3
+ interface AlertI {
4
+ step: number
5
+ count: number
6
+ }
7
+
3
8
  export interface HomeMonitortStepsI {
9
+ alerts?: AlertI[]
4
10
  menuItems: MenuItemI[]
5
- stepsWithAlerts: number[]
11
+ stepsWithAlerts?: number[]
6
12
  onStepClick: (step: number) => void
7
13
  }
8
14
 
9
15
  export interface HomeMonitorButtonI {
16
+ alertCount?: number
10
17
  currentStep: number
11
18
  onStepClick: HomeMonitortStepsI['onStepClick']
12
19
  status: 'alert' | 'ok'
@@ -0,0 +1,31 @@
1
+ import { Meta } from '@storybook/react'
2
+ import { HomeMonitorSteps } from '@/components'
3
+ import { Box } from '@chakra-ui/react'
4
+ import { action } from '@storybook/addon-actions'
5
+ import { menuMock } from '@/mocks'
6
+ import { HomeMonitortStepsI } from '@/interfaces'
7
+
8
+ export default {
9
+ title: 'Components/HomeAssistant',
10
+ component: HomeMonitorSteps,
11
+ args: {
12
+ alerts: [
13
+ { step: 2, count: 3 },
14
+ { step: 1, count: 2 },
15
+ { step: 6, count: 2 },
16
+ ],
17
+ menuItems: menuMock,
18
+ onStepClick: action('onStepClick'),
19
+ },
20
+ decorators: [
21
+ (Story: any) => (
22
+ <Box p="base" w={['full', '800px']} h="fit-content">
23
+ <Story />
24
+ </Box>
25
+ ),
26
+ ],
27
+ } as Meta<HomeMonitortStepsI>
28
+
29
+ export const HomeMonitorStepsComponent = (args: HomeMonitortStepsI) => {
30
+ return <HomeMonitorSteps {...args} />
31
+ }
@@ -0,0 +1,22 @@
1
+ import { Meta } from '@storybook/react'
2
+ import { Box } from '@chakra-ui/react'
3
+ import { AddToHomefile } from '@/components'
4
+ import { AddToHomefileI } from '@/interfaces'
5
+ import { action } from '@storybook/addon-actions'
6
+
7
+ export default {
8
+ title: 'Components/HomeBoard',
9
+ component: AddToHomefile,
10
+ args: {
11
+ onItemClick: action('onItemClick'),
12
+ documentList: [],
13
+ },
14
+ } as Meta<AddToHomefileI>
15
+
16
+ export const AddToHomefileComponent = (args: AddToHomefileI) => {
17
+ return (
18
+ <Box w={['full', '300px']}>
19
+ <AddToHomefile {...args} />
20
+ </Box>
21
+ )
22
+ }