@cyber-harbour/ui 1.0.48 → 1.0.49
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 +33 -4
- package/dist/index.d.ts +33 -4
- package/dist/index.js +171 -137
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -125
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Core/Alert/Alert.tsx +81 -0
- package/src/Core/Alert/index.ts +1 -0
- package/src/Core/Box/Box.tsx +10 -4
- package/src/Core/Button/Button.tsx +22 -13
- package/src/Core/Flex/FlexContainer.tsx +5 -2
- package/src/Core/IconComponents/AlertIcon.tsx +1 -1
- package/src/Core/Line/Line.tsx +4 -2
- package/src/Core/Tag/Tag.tsx +18 -8
- package/src/Core/Typography/Typography.tsx +12 -7
- package/src/Core/index.ts +1 -0
- package/src/Layouts/Container/Container.tsx +8 -5
- package/src/Theme/componentFabric.ts +68 -45
- package/src/Theme/themes/dark.ts +18 -0
- package/src/Theme/themes/light.ts +18 -0
- package/src/Theme/types.ts +18 -0
package/package.json
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { FabricComponent, createComponent, generatePropertySpaceStyle } from '../../Theme';
|
|
4
|
+
import { AlertIcon } from '../IconComponents';
|
|
5
|
+
|
|
6
|
+
type AlertProps = FabricComponent<{
|
|
7
|
+
title?: any;
|
|
8
|
+
note?: any;
|
|
9
|
+
}> &
|
|
10
|
+
Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
11
|
+
|
|
12
|
+
export const Alert = ({ title, note, ...props }: AlertProps) => {
|
|
13
|
+
return (
|
|
14
|
+
<StyledContainer {...props}>
|
|
15
|
+
<IconWrapper>
|
|
16
|
+
<AlertIcon />
|
|
17
|
+
</IconWrapper>
|
|
18
|
+
<div>
|
|
19
|
+
{!!title && <Title>{title}</Title>}
|
|
20
|
+
{!!note && <Note>{note}</Note>}
|
|
21
|
+
</div>
|
|
22
|
+
</StyledContainer>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const IconWrapper = styled.div(
|
|
27
|
+
({ theme: { alert } }) => `
|
|
28
|
+
flex-shrink: 0;
|
|
29
|
+
color: ${alert.color.icon};
|
|
30
|
+
padding-top: ${alert.icon.paddingTop};
|
|
31
|
+
svg {
|
|
32
|
+
width: ${alert.icon.width};
|
|
33
|
+
height: ${alert.icon.height};
|
|
34
|
+
display: block;
|
|
35
|
+
}
|
|
36
|
+
`
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const Title = styled.h3(
|
|
40
|
+
({ theme: { alert } }) => `
|
|
41
|
+
margin: 0;
|
|
42
|
+
padding: 0;
|
|
43
|
+
font-size: ${alert.fontSize};
|
|
44
|
+
line-height: 1.2;
|
|
45
|
+
font-weight: 700;
|
|
46
|
+
color: ${alert.color.text};
|
|
47
|
+
&:not(:last-child) {
|
|
48
|
+
margin-bottom: 8px;
|
|
49
|
+
}
|
|
50
|
+
`
|
|
51
|
+
);
|
|
52
|
+
const Note = styled.p(
|
|
53
|
+
({ theme: { alert } }) => `
|
|
54
|
+
margin: 0;
|
|
55
|
+
padding: 0;
|
|
56
|
+
word-break: break-word;
|
|
57
|
+
font-size: ${alert.fontSize};
|
|
58
|
+
color: ${alert.color.text};
|
|
59
|
+
line-height: 1.5;
|
|
60
|
+
`
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const StyledContainer = createComponent(
|
|
64
|
+
styled.div<FabricComponent>(
|
|
65
|
+
({ theme, py = theme.alert.paddingBlock, pl = theme.alert.paddingLeft, pr = theme.alert.paddingRight }) => {
|
|
66
|
+
return `
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: flex-start;
|
|
69
|
+
justify-content: flex-start;
|
|
70
|
+
flex-wrap: nowrap;
|
|
71
|
+
gap: ${theme.alert.gap};
|
|
72
|
+
background-color: ${theme.alert.color.background};
|
|
73
|
+
border-radius: ${theme.alert.borderRadius};
|
|
74
|
+
${generatePropertySpaceStyle(theme, 'padding-block', py)};
|
|
75
|
+
${generatePropertySpaceStyle(theme, 'padding-right', pr)};
|
|
76
|
+
${generatePropertySpaceStyle(theme, 'padding-left', pl)};
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
{ ignoreStyles: ['padding-block', 'padding-right', 'padding-left'] }
|
|
81
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Alert';
|
package/src/Core/Box/Box.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent, FabricComponent } from '../../Theme';
|
|
1
|
+
import { createComponent, FabricComponent, generatePropertySpaceStyle } from '../../Theme';
|
|
2
2
|
import { styled } from 'styled-components';
|
|
3
3
|
|
|
4
4
|
type BoxProps = FabricComponent<
|
|
@@ -11,13 +11,19 @@ export const Box = ({ children, ...props }: BoxProps) => {
|
|
|
11
11
|
return <StyledBox {...props}>{children}</StyledBox>;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
const StyledBox =
|
|
15
|
-
(
|
|
16
|
-
|
|
14
|
+
const StyledBox = createComponent(
|
|
15
|
+
styled('div')<FabricComponent>(
|
|
16
|
+
({ theme, px = theme.box.padding, py = theme.box.padding }) => `
|
|
17
|
+
${generatePropertySpaceStyle(theme, 'padding-inline', px)}
|
|
18
|
+
${generatePropertySpaceStyle(theme, 'padding-block', py)}
|
|
17
19
|
border-radius: ${theme.box.borderRadius};
|
|
18
20
|
background-color: ${theme.box.background};
|
|
19
21
|
border-width: ${theme.box.border.width};
|
|
20
22
|
border-style: ${theme.box.border.style};
|
|
21
23
|
border-color: ${theme.box.border.color};
|
|
22
24
|
`
|
|
25
|
+
),
|
|
26
|
+
{
|
|
27
|
+
ignoreStyles: ['padding-inline', 'padding-block'],
|
|
28
|
+
}
|
|
23
29
|
);
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
ButtonElementStyle,
|
|
10
10
|
createComponent,
|
|
11
11
|
FabricComponent,
|
|
12
|
+
generatePropertySpaceStyle,
|
|
12
13
|
} from '../../Theme';
|
|
13
14
|
|
|
14
15
|
type BaseButtonProps = FabricComponent<{
|
|
@@ -59,7 +60,7 @@ const StyledIconWrapper = styled.span`
|
|
|
59
60
|
justify-content: center;
|
|
60
61
|
`;
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
type StyledButtonProps = {
|
|
63
64
|
$variant: ButtonVariant;
|
|
64
65
|
$color: ButtonColor;
|
|
65
66
|
$size: ButtonSize;
|
|
@@ -67,21 +68,28 @@ const StyledButton = styled(createComponent('button'))<{
|
|
|
67
68
|
$fullWidth: boolean;
|
|
68
69
|
$iconPosition: 'left' | 'right';
|
|
69
70
|
$iconVariant: 'filled' | 'empty';
|
|
70
|
-
}
|
|
71
|
-
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const Btn = styled.button<FabricComponent<StyledButtonProps>>(
|
|
74
|
+
({
|
|
75
|
+
$variant,
|
|
76
|
+
$color,
|
|
77
|
+
$size,
|
|
78
|
+
$disabled,
|
|
79
|
+
$fullWidth,
|
|
80
|
+
$iconPosition,
|
|
81
|
+
$iconVariant,
|
|
82
|
+
theme,
|
|
83
|
+
px = $variant !== 'empty' ? theme.button.sizes[$size].paddingInline : 0,
|
|
84
|
+
py = $variant !== 'empty' ? theme.button.sizes[$size].paddingBlock : 0,
|
|
85
|
+
}) => {
|
|
72
86
|
const sizes = getButtonSizeStyles(theme, $size);
|
|
73
87
|
return `
|
|
74
88
|
${getCss(getButtonStyles(theme, $variant, $color, 'default'))}
|
|
75
89
|
font-size: ${sizes.fontSize};
|
|
76
90
|
gap: ${sizes.gap};
|
|
77
|
-
${
|
|
78
|
-
|
|
79
|
-
? `
|
|
80
|
-
${!props.py ? `padding-block: ${sizes.paddingBlock};` : ''}
|
|
81
|
-
${!props.px ? `padding-inline: ${sizes.paddingInline};` : ''}
|
|
82
|
-
`
|
|
83
|
-
: ''
|
|
84
|
-
}
|
|
91
|
+
${generatePropertySpaceStyle(theme, 'padding-block', py)};
|
|
92
|
+
${generatePropertySpaceStyle(theme, 'padding-inline', px)};
|
|
85
93
|
border-radius: ${sizes.borderRadius};
|
|
86
94
|
border-width: ${sizes.borderWidth};
|
|
87
95
|
border-style: solid;
|
|
@@ -147,8 +155,9 @@ const StyledButton = styled(createComponent('button'))<{
|
|
|
147
155
|
: ``
|
|
148
156
|
}
|
|
149
157
|
`;
|
|
150
|
-
}
|
|
151
|
-
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
const StyledButton = createComponent(Btn);
|
|
152
161
|
|
|
153
162
|
export const Button = ({
|
|
154
163
|
children,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, forwardRef } from 'react';
|
|
2
|
+
import { createComponent, FabricComponent } from '../../Theme';
|
|
2
3
|
import styled from 'styled-components';
|
|
3
4
|
|
|
4
5
|
export type FlexDirection = 'row' | 'column' | 'row-reverse' | 'column-reverse';
|
|
@@ -7,7 +8,7 @@ export type FlexJustify = 'flex-start' | 'flex-end' | 'center' | 'space-between'
|
|
|
7
8
|
export type FlexAlign = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
|
|
8
9
|
export type FlexGap = string | number;
|
|
9
10
|
|
|
10
|
-
export interface FlexContainerProps {
|
|
11
|
+
export interface FlexContainerProps extends FabricComponent<Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>> {
|
|
11
12
|
children: any;
|
|
12
13
|
direction?: FlexDirection;
|
|
13
14
|
wrap?: FlexWrap;
|
|
@@ -70,7 +71,7 @@ interface StyledFlexContainerProps {
|
|
|
70
71
|
$columnGap?: FlexGap;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
const
|
|
74
|
+
const StyledContainer = styled.div<StyledFlexContainerProps>`
|
|
74
75
|
${({ $direction, $wrap, $justify, $align, $alignContent, $gap, $rowGap, $columnGap }) => `
|
|
75
76
|
display: flex;
|
|
76
77
|
width: 100%;
|
|
@@ -85,3 +86,5 @@ const StyledFlexContainer = styled.div<StyledFlexContainerProps>`
|
|
|
85
86
|
${$columnGap !== undefined ? `column-gap: ${typeof $columnGap === 'number' ? `${$columnGap}px` : $columnGap};` : ''}
|
|
86
87
|
`}
|
|
87
88
|
`;
|
|
89
|
+
|
|
90
|
+
const StyledFlexContainer = createComponent(StyledContainer);
|
|
@@ -6,7 +6,7 @@ interface AlertIconProps extends SVGProps<SVGSVGElement> {
|
|
|
6
6
|
|
|
7
7
|
export const AlertIcon = ({ fill = 'currentColor', ...props }: AlertIconProps) => {
|
|
8
8
|
return (
|
|
9
|
-
<svg
|
|
9
|
+
<svg viewBox="0 0 17 15" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
10
10
|
<path
|
|
11
11
|
fillRule="evenodd"
|
|
12
12
|
clipRule="evenodd"
|
package/src/Core/Line/Line.tsx
CHANGED
|
@@ -15,10 +15,12 @@ interface StyledLineProps {
|
|
|
15
15
|
$direction: 'horizontal' | 'vertical';
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const StyledLine =
|
|
19
|
-
(
|
|
18
|
+
const StyledLine = createComponent(
|
|
19
|
+
styled.div<StyledLineProps>(
|
|
20
|
+
({ theme, $direction }) => `
|
|
20
21
|
width: ${$direction === 'horizontal' ? '100%' : theme.line.size};
|
|
21
22
|
height: ${$direction === 'vertical' ? '100%' : theme.line.size};
|
|
22
23
|
background-color: ${theme.line.color};
|
|
23
24
|
`
|
|
25
|
+
)
|
|
24
26
|
);
|
package/src/Core/Tag/Tag.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
|
+
createComponent,
|
|
6
|
+
TagVariant,
|
|
7
|
+
TagColor,
|
|
8
|
+
hexToRgba,
|
|
9
|
+
generatePropertySpaceStyle,
|
|
10
|
+
} from '../../Theme';
|
|
4
11
|
import { CrossIcon } from '../IconComponents';
|
|
5
12
|
|
|
6
13
|
type TagProps = FabricComponent<{
|
|
@@ -81,7 +88,7 @@ const DeleteButton = styled.button`
|
|
|
81
88
|
}
|
|
82
89
|
`;
|
|
83
90
|
|
|
84
|
-
const
|
|
91
|
+
const Container = styled.div<FabricComponent<StyledProps>>(
|
|
85
92
|
({
|
|
86
93
|
theme,
|
|
87
94
|
$variant,
|
|
@@ -95,8 +102,6 @@ const StyledContainer = styled(createComponent<StyledProps>('div'))(
|
|
|
95
102
|
display: inline-flex;
|
|
96
103
|
align-items: center;
|
|
97
104
|
justify-content: center;
|
|
98
|
-
padding-block: 0;
|
|
99
|
-
padding-inline: 0;
|
|
100
105
|
min-width: 0;
|
|
101
106
|
border-width: ${theme.tag[$variant].borderWidth};
|
|
102
107
|
border-style: solid;
|
|
@@ -106,8 +111,8 @@ const StyledContainer = styled(createComponent<StyledProps>('div'))(
|
|
|
106
111
|
color: ${color};
|
|
107
112
|
|
|
108
113
|
${Content} {
|
|
109
|
-
padding-block
|
|
110
|
-
padding-inline
|
|
114
|
+
${generatePropertySpaceStyle(theme, 'padding-block', py)};
|
|
115
|
+
${generatePropertySpaceStyle(theme, 'padding-inline', px)};
|
|
111
116
|
color: ${color};
|
|
112
117
|
${
|
|
113
118
|
$clickable
|
|
@@ -122,8 +127,9 @@ const StyledContainer = styled(createComponent<StyledProps>('div'))(
|
|
|
122
127
|
}
|
|
123
128
|
}
|
|
124
129
|
${DeleteButton} {
|
|
125
|
-
padding-
|
|
126
|
-
padding-
|
|
130
|
+
${generatePropertySpaceStyle(theme, 'padding-block', py)};
|
|
131
|
+
${generatePropertySpaceStyle(theme, 'padding-right', px)};
|
|
132
|
+
|
|
127
133
|
&:hover {
|
|
128
134
|
color: ${hexToRgba(color, 0.7)};
|
|
129
135
|
}
|
|
@@ -131,3 +137,7 @@ const StyledContainer = styled(createComponent<StyledProps>('div'))(
|
|
|
131
137
|
`;
|
|
132
138
|
}
|
|
133
139
|
);
|
|
140
|
+
|
|
141
|
+
const StyledContainer = createComponent(Container, {
|
|
142
|
+
ignoreStyles: ['padding-block', 'padding-inline'],
|
|
143
|
+
});
|
|
@@ -13,26 +13,31 @@ type TypographyProps = FabricComponent<{
|
|
|
13
13
|
color?: ColorVariant | string;
|
|
14
14
|
className?: string;
|
|
15
15
|
ellipsis?: boolean;
|
|
16
|
-
}
|
|
16
|
+
}> &
|
|
17
|
+
Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
const StyledTypography = styled(createComponent('div'))<{
|
|
19
|
+
type StyledProps = {
|
|
20
20
|
$variant: TypographyVariant;
|
|
21
21
|
$weight?: CSSProperties['fontWeight'];
|
|
22
22
|
$style?: CSSProperties['fontStyle'];
|
|
23
23
|
$color?: ColorVariant | string;
|
|
24
24
|
$ellipsis?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Create a styled component that can be dynamically rendered as different HTML elements
|
|
28
|
+
const StyledTypography = createComponent(
|
|
29
|
+
styled('div')<StyledProps>(({ theme, $variant, $color, $weight = '400', $style = 'initial', $ellipsis }) => {
|
|
30
|
+
// Resolve color from theme if it's a theme color path, or use the direct color value
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
return `
|
|
29
33
|
font-size: ${theme.typography.variants[$variant].fontSize};
|
|
30
34
|
font-weight: ${$weight};
|
|
31
35
|
font-style: ${$style};
|
|
32
36
|
color: ${resolveThemeColor(theme, $color) || theme.colors.text.main};
|
|
33
37
|
${$ellipsis ? 'overflow: hidden; text-overflow: ellipsis; white-space: nowrap;' : ''}
|
|
34
38
|
`;
|
|
35
|
-
})
|
|
39
|
+
})
|
|
40
|
+
);
|
|
36
41
|
|
|
37
42
|
export const Typography = ({
|
|
38
43
|
variant = 'body',
|
package/src/Core/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent, FabricComponent, pxToRem } from '../../Theme';
|
|
1
|
+
import { createComponent, FabricComponent, generatePropertySpaceStyle, pxToRem } from '../../Theme';
|
|
2
2
|
import { styled } from 'styled-components';
|
|
3
3
|
|
|
4
4
|
type ContainerProps = FabricComponent<{
|
|
@@ -14,11 +14,14 @@ export const Container = ({ maxWidth, ...props }: ContainerProps) => {
|
|
|
14
14
|
return <StyledContainer {...props} $maxWidth={maxWidth} />;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const StyledContainer =
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const StyledContainer = createComponent(
|
|
18
|
+
styled.div<FabricComponent<StyledContainerProps>>(({ theme, $maxWidth, px = 20 }) => {
|
|
19
|
+
return `
|
|
20
|
+
${generatePropertySpaceStyle(theme, 'padding-inline', px)}
|
|
20
21
|
width: 100%;
|
|
21
22
|
min-width: 0;
|
|
22
23
|
max-width: ${typeof $maxWidth === 'number' ? pxToRem($maxWidth, theme.baseSize) : $maxWidth || '100%'};
|
|
23
24
|
`;
|
|
24
|
-
})
|
|
25
|
+
}),
|
|
26
|
+
{ ignoreStyles: ['padding-inline'] }
|
|
27
|
+
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import styled, { css, WebTarget } from 'styled-components';
|
|
1
|
+
import styled, { css, IStyledComponent, DefaultTheme, WebTarget } from 'styled-components';
|
|
2
|
+
import { pxToRem } from './utils';
|
|
2
3
|
|
|
3
4
|
type MarginProps = {
|
|
4
5
|
m?: string | number; // margin
|
|
@@ -19,52 +20,74 @@ type MarginProps = {
|
|
|
19
20
|
|
|
20
21
|
export type FabricComponent<T = object> = T & MarginProps;
|
|
21
22
|
|
|
22
|
-
const marginStyles =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
${
|
|
26
|
-
${
|
|
27
|
-
${
|
|
28
|
-
${
|
|
29
|
-
${
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
: ''
|
|
35
|
-
}
|
|
36
|
-
${
|
|
37
|
-
props.my
|
|
38
|
-
? `margin-top: ${typeof props.my === 'number' ? `${props.my}px` : props.my}; margin-bottom: ${
|
|
39
|
-
typeof props.my === 'number' ? `${props.my}px` : props.my
|
|
40
|
-
};`
|
|
41
|
-
: ''
|
|
42
|
-
}
|
|
43
|
-
${props.p ? `padding: ${typeof props.p === 'number' ? `${props.p}px` : props.p};` : ''}
|
|
44
|
-
${props.pt ? `padding-top: ${typeof props.pt === 'number' ? `${props.pt}px` : props.pt};` : ''}
|
|
45
|
-
${props.pr ? `padding-right: ${typeof props.pr === 'number' ? `${props.pr}px` : props.pr};` : ''}
|
|
46
|
-
${props.pb ? `padding-bottom: ${typeof props.pb === 'number' ? `${props.pb}px` : props.pb};` : ''}
|
|
47
|
-
${props.pl ? `padding-left: ${typeof props.pl === 'number' ? `${props.pl}px` : props.pl};` : ''}
|
|
48
|
-
${
|
|
49
|
-
props.px
|
|
50
|
-
? `padding-left: ${typeof props.px === 'number' ? `${props.px}px` : props.px}; padding-right: ${
|
|
51
|
-
typeof props.px === 'number' ? `${props.px}px` : props.px
|
|
52
|
-
};`
|
|
53
|
-
: ''
|
|
54
|
-
}
|
|
55
|
-
${
|
|
56
|
-
props.py
|
|
57
|
-
? `padding-top: ${typeof props.py === 'number' ? `${props.py}px` : props.py}; padding-bottom: ${
|
|
58
|
-
typeof props.py === 'number' ? `${props.py}px` : props.py
|
|
59
|
-
};`
|
|
60
|
-
: ''
|
|
61
|
-
}
|
|
23
|
+
const marginStyles = ({ ignoreStyles }: FabricComponentOptions = {}) =>
|
|
24
|
+
css<FabricComponent>(({ theme, ...props }) => {
|
|
25
|
+
return `
|
|
26
|
+
${generatePropertySpaceStyle(theme, 'margin', props.m, ignoreStyles)}
|
|
27
|
+
${generatePropertySpaceStyle(theme, 'margin-top', props.mt, ignoreStyles)}
|
|
28
|
+
${generatePropertySpaceStyle(theme, 'margin-right', props.mr, ignoreStyles)}
|
|
29
|
+
${generatePropertySpaceStyle(theme, 'margin-bottom', props.mb, ignoreStyles)}
|
|
30
|
+
${generatePropertySpaceStyle(theme, 'margin-left', props.ml, ignoreStyles)}
|
|
31
|
+
${generatePropertySpaceStyle(theme, 'margin-inline', props.mx, ignoreStyles)}
|
|
32
|
+
${generatePropertySpaceStyle(theme, 'margin-block', props.my, ignoreStyles)}
|
|
33
|
+
`;
|
|
34
|
+
});
|
|
62
35
|
|
|
36
|
+
const paddingStyles = ({ ignoreStyles }: FabricComponentOptions = {}) =>
|
|
37
|
+
css<FabricComponent>(({ theme, ...props }) => {
|
|
38
|
+
return `
|
|
39
|
+
${generatePropertySpaceStyle(theme, 'padding', props.p, ignoreStyles)}
|
|
40
|
+
${generatePropertySpaceStyle(theme, 'padding-top', props.pt, ignoreStyles)}
|
|
41
|
+
${generatePropertySpaceStyle(theme, 'padding-right', props.pr, ignoreStyles)}
|
|
42
|
+
${generatePropertySpaceStyle(theme, 'padding-bottom', props.pb, ignoreStyles)}
|
|
43
|
+
${generatePropertySpaceStyle(theme, 'padding-left', props.pl, ignoreStyles)}
|
|
44
|
+
${generatePropertySpaceStyle(theme, 'padding-inline', props.px, ignoreStyles)}
|
|
45
|
+
${generatePropertySpaceStyle(theme, 'padding-block', props.py, ignoreStyles)}
|
|
63
46
|
`;
|
|
64
|
-
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
type GeneratedFabricMarginProperties =
|
|
50
|
+
| 'margin'
|
|
51
|
+
| 'margin-top'
|
|
52
|
+
| 'margin-right'
|
|
53
|
+
| 'margin-bottom'
|
|
54
|
+
| 'margin-left'
|
|
55
|
+
| 'margin-inline'
|
|
56
|
+
| 'margin-block'
|
|
57
|
+
| 'padding'
|
|
58
|
+
| 'padding-top'
|
|
59
|
+
| 'padding-right'
|
|
60
|
+
| 'padding-bottom'
|
|
61
|
+
| 'padding-left'
|
|
62
|
+
| 'padding-inline'
|
|
63
|
+
| 'padding-block';
|
|
64
|
+
|
|
65
|
+
export const generatePropertySpaceStyle = (
|
|
66
|
+
theme: DefaultTheme,
|
|
67
|
+
property: GeneratedFabricMarginProperties,
|
|
68
|
+
value?: string | number,
|
|
69
|
+
ignoredOptions?: GeneratedFabricMarginProperties[]
|
|
70
|
+
) => {
|
|
71
|
+
if (ignoredOptions && ignoredOptions.includes(property)) {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
if (value !== undefined) {
|
|
75
|
+
const t = typeof value === 'number';
|
|
76
|
+
return `${property}: ${typeof value === 'number' ? `${pxToRem(value, theme.baseSize)}` : value};`;
|
|
77
|
+
}
|
|
78
|
+
return '';
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
type FabricComponentOptions = {
|
|
82
|
+
ignoreStyles?: GeneratedFabricMarginProperties[] | undefined; // Ignore margin styles
|
|
83
|
+
};
|
|
65
84
|
|
|
66
|
-
export const createComponent = <T
|
|
67
|
-
|
|
68
|
-
|
|
85
|
+
export const createComponent = <T extends object = {}>(
|
|
86
|
+
component: React.ComponentType<T>,
|
|
87
|
+
options?: FabricComponentOptions
|
|
88
|
+
) => {
|
|
89
|
+
return styled(component)<T & FabricComponent>`
|
|
90
|
+
${marginStyles(options)}
|
|
91
|
+
${paddingStyles(options)}
|
|
69
92
|
`;
|
|
70
93
|
};
|
package/src/Theme/themes/dark.ts
CHANGED
|
@@ -736,6 +736,24 @@ export const darkThemePx: Theme = {
|
|
|
736
736
|
},
|
|
737
737
|
},
|
|
738
738
|
},
|
|
739
|
+
alert: {
|
|
740
|
+
paddingBlock: 16,
|
|
741
|
+
paddingLeft: 16,
|
|
742
|
+
paddingRight: 44,
|
|
743
|
+
borderRadius: 5,
|
|
744
|
+
fontSize: 14,
|
|
745
|
+
gap: 12,
|
|
746
|
+
icon: {
|
|
747
|
+
width: 16,
|
|
748
|
+
height: 14,
|
|
749
|
+
paddingTop: 2,
|
|
750
|
+
},
|
|
751
|
+
color: {
|
|
752
|
+
icon: '#FDC700',
|
|
753
|
+
text: '#894B00',
|
|
754
|
+
background: '#FFFBE0',
|
|
755
|
+
},
|
|
756
|
+
},
|
|
739
757
|
};
|
|
740
758
|
|
|
741
759
|
export const darkTheme = convertPaletteToRem(darkThemePx, darkThemePx.baseSize) as DefaultTheme;
|
|
@@ -735,6 +735,24 @@ export const lightThemePx: Theme = {
|
|
|
735
735
|
},
|
|
736
736
|
},
|
|
737
737
|
},
|
|
738
|
+
alert: {
|
|
739
|
+
paddingBlock: 16,
|
|
740
|
+
paddingLeft: 16,
|
|
741
|
+
paddingRight: 44,
|
|
742
|
+
borderRadius: 5,
|
|
743
|
+
fontSize: 14,
|
|
744
|
+
gap: 12,
|
|
745
|
+
icon: {
|
|
746
|
+
width: 16,
|
|
747
|
+
height: 14,
|
|
748
|
+
paddingTop: 2,
|
|
749
|
+
},
|
|
750
|
+
color: {
|
|
751
|
+
icon: '#FDC700',
|
|
752
|
+
text: '#894B00',
|
|
753
|
+
background: '#FFFBE0',
|
|
754
|
+
},
|
|
755
|
+
},
|
|
738
756
|
};
|
|
739
757
|
|
|
740
758
|
export const lightTheme = convertPaletteToRem(lightThemePx, lightThemePx.baseSize) as DefaultTheme;
|
package/src/Theme/types.ts
CHANGED
|
@@ -247,6 +247,24 @@ export type Theme = {
|
|
|
247
247
|
background: string;
|
|
248
248
|
};
|
|
249
249
|
tag: Record<TagVariant, TagElementStyle>;
|
|
250
|
+
alert: {
|
|
251
|
+
paddingBlock: number | string;
|
|
252
|
+
paddingLeft: number | string;
|
|
253
|
+
paddingRight: number | string;
|
|
254
|
+
borderRadius: number | string;
|
|
255
|
+
fontSize: number | string;
|
|
256
|
+
gap: number | string;
|
|
257
|
+
icon: {
|
|
258
|
+
width: number | string;
|
|
259
|
+
height: number | string;
|
|
260
|
+
paddingTop: number | string;
|
|
261
|
+
};
|
|
262
|
+
color: {
|
|
263
|
+
icon: string;
|
|
264
|
+
text: string;
|
|
265
|
+
background: string;
|
|
266
|
+
};
|
|
267
|
+
};
|
|
250
268
|
};
|
|
251
269
|
|
|
252
270
|
//TODO check and refactoring
|