@cyber-harbour/ui 1.0.60 → 1.0.62
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/index.d.mts +517 -46
- package/dist/index.d.ts +517 -46
- package/dist/index.js +244 -237
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +245 -238
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Core/Alert/Alert.tsx +11 -5
- package/src/Core/Box/Box.tsx +19 -17
- package/src/Core/Button/Button.tsx +59 -55
- package/src/Core/Checkbox/Checkbox.tsx +6 -7
- package/src/Core/ContentLoader/ContentLoader.tsx +13 -0
- package/src/Core/ContentLoader/index.ts +1 -0
- package/src/Core/Drawer/Drawer.tsx +29 -14
- package/src/Core/Flex/FlexContainer.tsx +47 -45
- package/src/Core/Flex/FlexItem.tsx +19 -26
- package/src/Core/IconComponents/FlashIcon.tsx +16 -0
- package/src/Core/IconComponents/UserInCircle.tsx +24 -0
- package/src/Core/IconComponents/index.ts +2 -0
- package/src/Core/Label/Label.tsx +31 -30
- package/src/Core/Line/Line.tsx +5 -5
- package/src/Core/LinerProgress/LinerProgress.tsx +14 -20
- package/src/Core/Switch/Switch.tsx +4 -4
- package/src/Core/Tag/Tag.tsx +40 -39
- package/src/Core/Tooltip/Tooltip.tsx +45 -41
- package/src/Core/Typography/Typography.tsx +31 -33
- package/src/Core/index.ts +1 -0
- package/src/FullscreenCard/FullscreenCard.tsx +21 -26
- package/src/Layouts/Container/Container.tsx +13 -7
- package/src/Theme/Breakpoint.tsx +50 -0
- package/src/Theme/ThemeProvider.tsx +5 -2
- package/src/Theme/{componentFabric.ts → componentFabric.tsx} +90 -36
- package/src/Theme/index.ts +1 -0
package/src/Core/Label/Label.tsx
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
FabricComponent,
|
|
5
|
+
LabelSize,
|
|
6
|
+
createComponent,
|
|
7
|
+
createStyledComponent,
|
|
8
|
+
generatePropertySpaceStyle,
|
|
9
|
+
propToRem,
|
|
10
|
+
} from '../../Theme';
|
|
4
11
|
|
|
5
12
|
type LabelProps = FabricComponent<{
|
|
6
13
|
label?: any;
|
|
@@ -22,40 +29,34 @@ type LabelDirection = {
|
|
|
22
29
|
direction?: Omit<React.CSSProperties['flexDirection'], 'row' | 'row-reverse'>;
|
|
23
30
|
};
|
|
24
31
|
|
|
25
|
-
export const Label = (
|
|
26
|
-
label,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
direction = 'column',
|
|
30
|
-
size = 'small',
|
|
31
|
-
errorText,
|
|
32
|
-
fullWidth,
|
|
33
|
-
...props
|
|
34
|
-
}: LabelProps) => {
|
|
35
|
-
const $isRow = direction === 'row' || direction === 'row-reverse';
|
|
36
|
-
const $width = $isRow ? (props as LabelDirectionRaw).childrenWidth || '50%' : '100%';
|
|
32
|
+
export const Label = createComponent<LabelProps>(
|
|
33
|
+
({ label, helpText, children, direction = 'column', size = 'small', errorText, fullWidth, ...props }) => {
|
|
34
|
+
const $isRow = direction === 'row' || direction === 'row-reverse';
|
|
35
|
+
const $width = $isRow ? (props as LabelDirectionRaw).childrenWidth || '50%' : '100%';
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
37
|
+
return (
|
|
38
|
+
<StyledLabel $size={size} $direction={direction} $fullWidth={fullWidth} $isRow={$isRow} {...props}>
|
|
39
|
+
{Boolean(label || helpText) && (
|
|
40
|
+
<LabelWrapper $width={$width}>
|
|
41
|
+
{!!label && <LabelText $size={size}>{label}</LabelText>}
|
|
42
|
+
{!!helpText && <HelpText $size={size}>{helpText}</HelpText>}
|
|
43
|
+
</LabelWrapper>
|
|
44
|
+
)}
|
|
45
|
+
<Wrapper $width={$width}>
|
|
46
|
+
{children}
|
|
47
|
+
{!!errorText && <ErrorText $size={size}>{errorText}</ErrorText>}
|
|
48
|
+
</Wrapper>
|
|
49
|
+
</StyledLabel>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
53
|
|
|
54
54
|
type StyledProps = {
|
|
55
55
|
$size: LabelSize;
|
|
56
56
|
$direction?: LabelDirection['direction'] | LabelDirectionRaw['direction'];
|
|
57
57
|
$fullWidth?: boolean;
|
|
58
58
|
$isRow: boolean;
|
|
59
|
+
children?: any;
|
|
59
60
|
};
|
|
60
61
|
|
|
61
62
|
type WrapperProps = { $width: number | string };
|
|
@@ -107,8 +108,8 @@ const ErrorText = styled.div<TextProps>(
|
|
|
107
108
|
`
|
|
108
109
|
);
|
|
109
110
|
|
|
110
|
-
const StyledLabel =
|
|
111
|
-
styled.label
|
|
111
|
+
const StyledLabel = createStyledComponent<FabricComponent<StyledProps>>(
|
|
112
|
+
styled.label(
|
|
112
113
|
({
|
|
113
114
|
theme,
|
|
114
115
|
$direction = 'column',
|
package/src/Core/Line/Line.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent, FabricComponent } from '../../Theme';
|
|
1
|
+
import { createComponent, createStyledComponent, FabricComponent, StyledFabricComponent } from '../../Theme';
|
|
2
2
|
import { styled } from 'styled-components';
|
|
3
3
|
|
|
4
4
|
type LineProps = FabricComponent<
|
|
@@ -7,16 +7,16 @@ type LineProps = FabricComponent<
|
|
|
7
7
|
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'children'>
|
|
8
8
|
>;
|
|
9
9
|
|
|
10
|
-
export const Line = ({ direction = 'horizontal', ...props }
|
|
10
|
+
export const Line = createComponent<LineProps>(({ direction = 'horizontal', ...props }) => {
|
|
11
11
|
return <StyledLine {...props} $direction={direction} />;
|
|
12
|
-
};
|
|
12
|
+
});
|
|
13
13
|
|
|
14
14
|
interface StyledLineProps {
|
|
15
15
|
$direction: 'horizontal' | 'vertical';
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const StyledLine =
|
|
19
|
-
styled.div
|
|
18
|
+
const StyledLine = createStyledComponent<StyledFabricComponent<StyledLineProps>>(
|
|
19
|
+
styled.div(
|
|
20
20
|
({ theme, $direction }) => `
|
|
21
21
|
width: ${$direction === 'horizontal' ? '100%' : theme.line.size};
|
|
22
22
|
height: ${$direction === 'vertical' ? '100%' : theme.line.size};
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import { createComponent,
|
|
1
|
+
import { createComponent, createStyledComponent, propToRem, pxToRem, StyledFabricComponent } from '../../Theme';
|
|
2
2
|
import { styled } from 'styled-components';
|
|
3
3
|
|
|
4
4
|
type Direction = 'horizontal' | 'vertical';
|
|
5
5
|
|
|
6
|
-
type LinerProgressProps =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'children'>
|
|
13
|
-
>;
|
|
6
|
+
type LinerProgressProps = {
|
|
7
|
+
height?: number;
|
|
8
|
+
width?: string | number;
|
|
9
|
+
direction?: Direction;
|
|
10
|
+
value: number;
|
|
11
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'children'>;
|
|
14
12
|
|
|
15
|
-
export const LinerProgress = (
|
|
16
|
-
height = 21,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
...props
|
|
21
|
-
}: LinerProgressProps) => {
|
|
22
|
-
return <StyledLine {...props} $height={height} $value={value} $width={width} $direction={direction} />;
|
|
23
|
-
};
|
|
13
|
+
export const LinerProgress = createComponent<LinerProgressProps>(
|
|
14
|
+
({ height = 21, width = '100%', direction = 'horizontal', value, ...props }: LinerProgressProps) => {
|
|
15
|
+
return <StyledLine {...props} $height={height} $value={value} $width={width} $direction={direction} />;
|
|
16
|
+
}
|
|
17
|
+
);
|
|
24
18
|
|
|
25
19
|
interface StyledLineProps {
|
|
26
20
|
$height: number;
|
|
@@ -29,8 +23,8 @@ interface StyledLineProps {
|
|
|
29
23
|
$direction: Direction;
|
|
30
24
|
}
|
|
31
25
|
|
|
32
|
-
const StyledLine =
|
|
33
|
-
styled.div
|
|
26
|
+
const StyledLine = createStyledComponent<StyledFabricComponent<StyledLineProps>>(
|
|
27
|
+
styled.div(
|
|
34
28
|
({ theme, $height, $value, $width, $direction }) => `
|
|
35
29
|
width: ${propToRem($width, theme.baseSize)};
|
|
36
30
|
height: ${propToRem($height, theme.baseSize)};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { InputHTMLAttributes } from 'react';
|
|
2
|
-
import { createComponent, destructSpaceProps, FabricComponent, pxToRem } from '../../Theme';
|
|
2
|
+
import { createComponent, createStyledComponent, destructSpaceProps, FabricComponent, pxToRem } from '../../Theme';
|
|
3
3
|
import { styled } from 'styled-components';
|
|
4
4
|
|
|
5
5
|
type SwitchProps = FabricComponent<Omit<InputHTMLAttributes<HTMLInputElement>, 'type'>>;
|
|
6
6
|
|
|
7
|
-
export const Switch = ({ className, ...props }
|
|
7
|
+
export const Switch = createComponent<SwitchProps>(({ className, ...props }) => {
|
|
8
8
|
const spaceProps = destructSpaceProps(props);
|
|
9
9
|
return (
|
|
10
10
|
<StyledLabel className={className} {...spaceProps}>
|
|
@@ -12,7 +12,7 @@ export const Switch = ({ className, ...props }: SwitchProps) => {
|
|
|
12
12
|
<StyledSwitch />
|
|
13
13
|
</StyledLabel>
|
|
14
14
|
);
|
|
15
|
-
};
|
|
15
|
+
});
|
|
16
16
|
|
|
17
17
|
const StyledSwitch = styled.span(
|
|
18
18
|
({ theme }) => `
|
|
@@ -63,7 +63,7 @@ const HiddenInput = styled.input(
|
|
|
63
63
|
`
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
-
const StyledLabel =
|
|
66
|
+
const StyledLabel = createStyledComponent(
|
|
67
67
|
styled.label`
|
|
68
68
|
position: relative;
|
|
69
69
|
display: inline-block;
|
package/src/Core/Tag/Tag.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
TagColor,
|
|
8
8
|
hexToRgba,
|
|
9
9
|
generatePropertySpaceStyle,
|
|
10
|
+
createStyledComponent,
|
|
10
11
|
} from '../../Theme';
|
|
11
12
|
import { CrossIcon } from '../IconComponents';
|
|
12
13
|
|
|
@@ -22,41 +23,33 @@ type TagProps = FabricComponent<{
|
|
|
22
23
|
}> &
|
|
23
24
|
Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
24
25
|
|
|
25
|
-
export const Tag = (
|
|
26
|
-
children,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}}
|
|
53
|
-
>
|
|
54
|
-
<CrossIcon />
|
|
55
|
-
</DeleteButton>
|
|
56
|
-
)}
|
|
57
|
-
</StyledContainer>
|
|
58
|
-
);
|
|
59
|
-
};
|
|
26
|
+
export const Tag = createComponent<TagProps>(
|
|
27
|
+
({ children, variant = 'fill', color = 'default', className, disabled, icon, onClick, onDelete, ...props }) => {
|
|
28
|
+
return (
|
|
29
|
+
<StyledContainer
|
|
30
|
+
$variant={variant}
|
|
31
|
+
$color={color}
|
|
32
|
+
$clickable={!!onClick && !disabled}
|
|
33
|
+
onClick={!disabled ? onClick : undefined}
|
|
34
|
+
className={className}
|
|
35
|
+
{...props}
|
|
36
|
+
>
|
|
37
|
+
{!!children && <Content>{children}</Content>}
|
|
38
|
+
{!!onDelete && !disabled && (
|
|
39
|
+
<DeleteButton
|
|
40
|
+
aria-label="delete"
|
|
41
|
+
onClick={(e) => {
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
onDelete();
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<CrossIcon />
|
|
47
|
+
</DeleteButton>
|
|
48
|
+
)}
|
|
49
|
+
</StyledContainer>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
60
53
|
|
|
61
54
|
type StyledProps = {
|
|
62
55
|
$variant: TagVariant;
|
|
@@ -64,17 +57,25 @@ type StyledProps = {
|
|
|
64
57
|
$clickable: boolean;
|
|
65
58
|
};
|
|
66
59
|
|
|
67
|
-
const Content = styled.span
|
|
60
|
+
const Content = styled.span(
|
|
61
|
+
({ theme }) => `
|
|
68
62
|
display: inline-flex;
|
|
63
|
+
flex-wrap: wrap;
|
|
69
64
|
align-items: center;
|
|
70
|
-
justify-content:
|
|
65
|
+
justify-content: flex-start;
|
|
71
66
|
min-width: 0;
|
|
67
|
+
word-break: break-word;
|
|
72
68
|
|
|
73
69
|
font-size: 14px;
|
|
74
70
|
line-height: 16px;
|
|
75
|
-
|
|
71
|
+
@media (min-width: ${theme.breakpoints.m}) {
|
|
72
|
+
justify-content: center;
|
|
73
|
+
}
|
|
74
|
+
`
|
|
75
|
+
);
|
|
76
76
|
|
|
77
77
|
const DeleteButton = styled.button`
|
|
78
|
+
align-self: flex-start;
|
|
78
79
|
border: none;
|
|
79
80
|
outline: none;
|
|
80
81
|
background-color: transparent;
|
|
@@ -138,6 +139,6 @@ const Container = styled.div<FabricComponent<StyledProps>>(
|
|
|
138
139
|
}
|
|
139
140
|
);
|
|
140
141
|
|
|
141
|
-
const StyledContainer =
|
|
142
|
+
const StyledContainer = createStyledComponent(Container, {
|
|
142
143
|
ignoreStyles: ['padding-block', 'padding-inline'],
|
|
143
144
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useState } from 'react';
|
|
2
2
|
import { Popover, PopoverAlign, PopoverPosition } from 'react-tiny-popover';
|
|
3
|
-
import { pxToRem } from '../../Theme';
|
|
3
|
+
import { createComponent, pxToRem } from '../../Theme';
|
|
4
4
|
import { styled } from 'styled-components';
|
|
5
5
|
|
|
6
6
|
interface TooltipProps {
|
|
@@ -13,50 +13,54 @@ interface TooltipProps {
|
|
|
13
13
|
offset?: number;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const Tooltip = (
|
|
17
|
-
className,
|
|
18
|
-
|
|
19
|
-
align = 'center',
|
|
20
|
-
anchorClassName,
|
|
21
|
-
content,
|
|
22
|
-
offset = 6,
|
|
23
|
-
children,
|
|
24
|
-
}: TooltipProps) => {
|
|
25
|
-
const [isOpen, setIsOpen] = useState<boolean>(false);
|
|
16
|
+
export const Tooltip = createComponent<TooltipProps>(
|
|
17
|
+
({ className, positions = ['top'], align = 'center', anchorClassName, content, offset = 6, children }) => {
|
|
18
|
+
const [isOpen, setIsOpen] = useState<boolean>(false);
|
|
26
19
|
|
|
27
|
-
|
|
20
|
+
const position = Array.isArray(positions) ? positions[0] : positions;
|
|
28
21
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
const handleMouseEnter = useCallback(() => {
|
|
23
|
+
if (content) setIsOpen(true);
|
|
24
|
+
}, [content]);
|
|
32
25
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
const handleClose = useCallback(() => {
|
|
27
|
+
setIsOpen(false);
|
|
28
|
+
}, []);
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
30
|
+
const handleClickOrTouch = useCallback(() => {
|
|
31
|
+
if (content) setIsOpen((prev) => !prev);
|
|
32
|
+
}, [content]);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Popover
|
|
36
|
+
padding={offset}
|
|
37
|
+
positions={positions}
|
|
38
|
+
isOpen={isOpen}
|
|
39
|
+
align={align}
|
|
40
|
+
onClickOutside={handleClose}
|
|
41
|
+
content={
|
|
42
|
+
!!content && (
|
|
43
|
+
<StyledContent className={className} $position={position} $offset={offset}>
|
|
44
|
+
{content}
|
|
45
|
+
</StyledContent>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
containerStyle={{
|
|
49
|
+
zIndex: `${9999}`,
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<StyledAnchor
|
|
53
|
+
onMouseEnter={handleMouseEnter}
|
|
54
|
+
onMouseLeave={handleClose}
|
|
55
|
+
className={anchorClassName}
|
|
56
|
+
onTouchStart={handleClickOrTouch}
|
|
57
|
+
>
|
|
58
|
+
{children}
|
|
59
|
+
</StyledAnchor>
|
|
60
|
+
</Popover>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
60
64
|
const StyledAnchor = styled.div`
|
|
61
65
|
display: inline-block;
|
|
62
66
|
`;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import { CSSProperties, ElementType } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ColorVariant,
|
|
5
|
+
createComponent,
|
|
6
|
+
createStyledComponent,
|
|
7
|
+
FabricComponent,
|
|
8
|
+
StyledFabricComponent,
|
|
9
|
+
TypographyVariant,
|
|
10
|
+
} from '../../Theme';
|
|
4
11
|
import { resolveThemeColor } from '../../Theme/utils';
|
|
5
12
|
|
|
6
13
|
type TypographyProps = FabricComponent<{
|
|
@@ -25,8 +32,8 @@ type StyledProps = {
|
|
|
25
32
|
};
|
|
26
33
|
|
|
27
34
|
// Create a styled component that can be dynamically rendered as different HTML elements
|
|
28
|
-
const StyledTypography =
|
|
29
|
-
styled('div')
|
|
35
|
+
const StyledTypography = createStyledComponent<StyledFabricComponent<StyledProps>>(
|
|
36
|
+
styled('div')(({ theme, $variant, $color, $weight = '400', $style = 'initial', $ellipsis }) => {
|
|
30
37
|
// Resolve color from theme if it's a theme color path, or use the direct color value
|
|
31
38
|
|
|
32
39
|
return `
|
|
@@ -39,34 +46,25 @@ const StyledTypography = createComponent(
|
|
|
39
46
|
})
|
|
40
47
|
);
|
|
41
48
|
|
|
42
|
-
export const Typography = (
|
|
43
|
-
variant = 'body',
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
weight,
|
|
47
|
-
fontStyle,
|
|
48
|
-
color,
|
|
49
|
-
className,
|
|
50
|
-
style,
|
|
51
|
-
ellipsis = false,
|
|
52
|
-
...props
|
|
53
|
-
}: TypographyProps) => {
|
|
54
|
-
// Determine which HTML element to render based on the variant if not explicitly specified
|
|
55
|
-
const Element = element || (variant.startsWith('h') ? variant : 'p');
|
|
49
|
+
export const Typography = createComponent<TypographyProps>(
|
|
50
|
+
({ variant = 'body', element, children, weight, fontStyle, color, className, style, ellipsis = false, ...props }) => {
|
|
51
|
+
// Determine which HTML element to render based on the variant if not explicitly specified
|
|
52
|
+
const Element = element || (variant.startsWith('h') ? variant : 'p');
|
|
56
53
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
54
|
+
return (
|
|
55
|
+
<StyledTypography
|
|
56
|
+
as={Element}
|
|
57
|
+
$variant={variant}
|
|
58
|
+
$weight={weight}
|
|
59
|
+
$style={fontStyle}
|
|
60
|
+
$color={color}
|
|
61
|
+
$ellipsis={ellipsis}
|
|
62
|
+
className={className}
|
|
63
|
+
style={style}
|
|
64
|
+
{...props}
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
</StyledTypography>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
);
|
package/src/Core/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
import { pxToRem } from '../Theme';
|
|
2
|
+
import { createComponent, pxToRem } from '../Theme';
|
|
3
3
|
|
|
4
4
|
interface FullscreenCardProps {
|
|
5
5
|
children: any;
|
|
@@ -12,27 +12,21 @@ interface FullscreenCardProps {
|
|
|
12
12
|
bottom?: number;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const FullscreenCard = (
|
|
16
|
-
isActive,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
$right={right}
|
|
31
|
-
$bottom={bottom}
|
|
32
|
-
{...props}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
15
|
+
export const FullscreenCard = createComponent<FullscreenCardProps>(
|
|
16
|
+
({ isActive, position, top = 0, left = 0, right, bottom, ...props }) => {
|
|
17
|
+
return (
|
|
18
|
+
<StyledContainer
|
|
19
|
+
$isActive={isActive}
|
|
20
|
+
$position={position}
|
|
21
|
+
$top={top}
|
|
22
|
+
$left={left}
|
|
23
|
+
$right={right}
|
|
24
|
+
$bottom={bottom}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
);
|
|
36
30
|
|
|
37
31
|
const StyledContainer = styled.div<{
|
|
38
32
|
$isActive: boolean;
|
|
@@ -48,10 +42,11 @@ ${
|
|
|
48
42
|
? `
|
|
49
43
|
position: ${$position};
|
|
50
44
|
z-index: 1000;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
${typeof $top === 'number' ? `top: ${pxToRem($top, theme.baseSize)};` : ''}
|
|
46
|
+
${typeof $left === 'number' ? `left: ${pxToRem($left, theme.baseSize)};` : ''}
|
|
47
|
+
${typeof $right === 'number' ? `right: ${pxToRem($right, theme.baseSize)};` : ''}
|
|
48
|
+
${typeof $bottom === 'number' ? `bottom: ${pxToRem($bottom, theme.baseSize)};` : ''}
|
|
49
|
+
|
|
55
50
|
`
|
|
56
51
|
: ''
|
|
57
52
|
}
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createComponent,
|
|
3
|
+
createStyledComponent,
|
|
4
|
+
FabricComponent,
|
|
5
|
+
generatePropertySpaceStyle,
|
|
6
|
+
pxToRem,
|
|
7
|
+
} from '../../Theme';
|
|
2
8
|
import { styled } from 'styled-components';
|
|
3
9
|
|
|
4
|
-
type ContainerProps =
|
|
10
|
+
type ContainerProps = {
|
|
5
11
|
children: any;
|
|
6
12
|
maxWidth?: string | number;
|
|
7
|
-
}
|
|
13
|
+
};
|
|
8
14
|
|
|
9
15
|
type StyledContainerProps = {
|
|
10
16
|
$maxWidth?: string | number;
|
|
11
17
|
};
|
|
12
18
|
|
|
13
|
-
export const Container = ({ maxWidth, ...props }
|
|
19
|
+
export const Container = createComponent<ContainerProps>(({ maxWidth, ...props }) => {
|
|
14
20
|
return <StyledContainer {...props} $maxWidth={maxWidth} />;
|
|
15
|
-
};
|
|
21
|
+
});
|
|
16
22
|
|
|
17
|
-
const StyledContainer =
|
|
18
|
-
styled.div
|
|
23
|
+
const StyledContainer = createStyledComponent<FabricComponent<StyledContainerProps>>(
|
|
24
|
+
styled.div(({ theme, $maxWidth, px = 20 }) => {
|
|
19
25
|
return `
|
|
20
26
|
${generatePropertySpaceStyle(theme, 'padding-inline', px)}
|
|
21
27
|
width: 100%;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { Theme } from './types';
|
|
3
|
+
import { useTheme } from 'styled-components';
|
|
4
|
+
import { breakpoints } from './themes/config';
|
|
5
|
+
|
|
6
|
+
type Breakpoint = keyof Theme['breakpoints'];
|
|
7
|
+
|
|
8
|
+
const getBreakpoint = (breakpoints: Theme['breakpoints']): Breakpoint => {
|
|
9
|
+
if (window !== undefined) {
|
|
10
|
+
const width = window.innerWidth;
|
|
11
|
+
for (const [key, value] of Object.entries(breakpoints)) {
|
|
12
|
+
if (width < value) {
|
|
13
|
+
return key as Breakpoint;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const keys = Object.keys(breakpoints) as Breakpoint[];
|
|
18
|
+
|
|
19
|
+
return keys[keys.length - 1];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const BreakpointContext = createContext<Breakpoint>(getBreakpoint(breakpoints));
|
|
23
|
+
|
|
24
|
+
export const BreakpointProvider = ({ children }: { children: any }) => {
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
const [breakpoint, setBreakpoint] = useState<Breakpoint>(getBreakpoint(theme.breakpoints));
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const handleResize = () => {
|
|
30
|
+
const newBreakpoint = getBreakpoint(theme.breakpoints);
|
|
31
|
+
if (newBreakpoint !== breakpoint) {
|
|
32
|
+
setBreakpoint(newBreakpoint);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
window.addEventListener('resize', handleResize);
|
|
37
|
+
return () => {
|
|
38
|
+
window.removeEventListener('resize', handleResize);
|
|
39
|
+
};
|
|
40
|
+
}, [breakpoint]);
|
|
41
|
+
|
|
42
|
+
return <BreakpointContext.Provider value={breakpoint}>{children}</BreakpointContext.Provider>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const useBreakpoint = () => {
|
|
46
|
+
const currentBreakpoint = useContext(BreakpointContext);
|
|
47
|
+
const theme = useTheme();
|
|
48
|
+
const breakpointsOrder = useMemo(() => Object.keys(theme.breakpoints) as Breakpoint[], [theme.breakpoints]);
|
|
49
|
+
return { currentBreakpoint, breakpointsOrder: breakpointsOrder };
|
|
50
|
+
};
|