addon-ui 0.3.0 → 0.4.0
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/.commitlintrc.json +5 -0
- package/.gitattributes +6 -0
- package/.husky/commit-msg +5 -0
- package/.husky/pre-commit +6 -0
- package/.husky/pre-push +8 -0
- package/.mailmap +2 -0
- package/.release-it.cjs +256 -0
- package/LICENSE.md +21 -0
- package/README.md +110 -838
- package/package.json +32 -9
- package/src/components/Dialog/dialog.module.scss +3 -0
- package/src/components/Footer/footer.module.scss +24 -0
- package/src/components/ListItem/list-item.module.scss +4 -0
- package/src/components/Modal/Modal.tsx +4 -1
- package/src/components/Modal/modal.module.scss +42 -5
- package/src/components/Modal/types.ts +5 -0
- package/src/components/TextField/text-field.module.scss +1 -0
- package/src/components/Viewport/Provider.tsx +99 -0
- package/src/components/Viewport/context.ts +38 -0
- package/src/components/Viewport/index.ts +2 -0
- package/src/components/Viewport/viewport.module.scss +31 -0
- package/src/components/index.ts +1 -1
- package/src/plugin/index.ts +1 -1
- package/src/providers/theme/ThemeProvider.tsx +19 -9
- package/src/providers/theme/ThemeStorage.tsx +11 -4
- package/src/providers/theme/index.ts +2 -2
- package/src/providers/ui/UIProvider.tsx +29 -13
- package/src/providers/ui/styles/default.scss +7 -4
- package/src/styles/mixins.scss +30 -0
- package/src/components/Layout/Provider.tsx +0 -60
- package/src/components/Layout/context.ts +0 -24
- package/src/components/Layout/index.ts +0 -2
- package/src/components/Layout/layout.module.scss +0 -17
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import React, {FC, PropsWithChildren,
|
|
1
|
+
import React, {FC, PropsWithChildren, useEffect, useMemo} from "react";
|
|
2
|
+
import {getBrowser} from "adnbn";
|
|
3
|
+
|
|
2
4
|
import {merge} from "ts-deepmerge";
|
|
3
5
|
|
|
4
|
-
import {ExtraProvider
|
|
6
|
+
import {ExtraProvider} from "../extra";
|
|
7
|
+
import {IconsProvider} from "../icons";
|
|
8
|
+
import {ThemeProvider, ThemeProviderProps} from "../theme";
|
|
5
9
|
|
|
6
|
-
import {ThemeStorageContract} from "../../types/theme";
|
|
7
10
|
import {ComponentsProps, Config, ExtraProps, Icons} from "../../types/config";
|
|
8
11
|
|
|
9
12
|
import "./styles/default.scss";
|
|
@@ -12,23 +15,36 @@ import "addon-ui-style.scss";
|
|
|
12
15
|
|
|
13
16
|
import config from "addon-ui-config";
|
|
14
17
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
18
|
+
export interface UIProviderProps extends Partial<Config>, Pick<ThemeProviderProps, "storage"> {
|
|
19
|
+
view?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const UIProvider: FC<PropsWithChildren<UIProviderProps>> = ({
|
|
23
|
+
children,
|
|
24
|
+
components = {},
|
|
25
|
+
extra = {},
|
|
26
|
+
icons = {},
|
|
27
|
+
storage,
|
|
28
|
+
view,
|
|
29
|
+
}) => {
|
|
24
30
|
const componentsProps = useMemo<ComponentsProps>(() => merge(config.components || {}, components), [components]);
|
|
25
31
|
|
|
26
32
|
const extraProps = useMemo<ExtraProps>(() => merge(config.extra || {}, extra), [extra]);
|
|
27
33
|
|
|
28
34
|
const svgIcons = useMemo<Icons>(() => merge(config.icons || {}, icons), [icons]);
|
|
29
35
|
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const html = document.querySelector("html");
|
|
38
|
+
if (html) {
|
|
39
|
+
if (view) {
|
|
40
|
+
html.setAttribute("view", view);
|
|
41
|
+
}
|
|
42
|
+
html.setAttribute("browser", getBrowser());
|
|
43
|
+
}
|
|
44
|
+
}, [view]);
|
|
45
|
+
|
|
30
46
|
return (
|
|
31
|
-
<ThemeProvider components={componentsProps} storage={
|
|
47
|
+
<ThemeProvider components={componentsProps} storage={storage}>
|
|
32
48
|
<ExtraProvider extra={extraProps}>
|
|
33
49
|
<IconsProvider icons={svgIcons}>{children}</IconsProvider>
|
|
34
50
|
</ExtraProvider>
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
@use "../../../styles/mixins" as theme;
|
|
2
2
|
|
|
3
3
|
@include theme.light {
|
|
4
|
-
--
|
|
5
|
-
--
|
|
4
|
+
--viewport-height: var(--viewport-min-height);
|
|
5
|
+
--viewport-width: var(--viewport-min-width);
|
|
6
6
|
|
|
7
|
-
--min-
|
|
8
|
-
--max-
|
|
7
|
+
--viewport-min-height: 440px;
|
|
8
|
+
--viewport-max-height: 600px;
|
|
9
|
+
|
|
10
|
+
--viewport-min-width: 380px;
|
|
11
|
+
--viewport-max-width: var(--viewport-min-width);
|
|
9
12
|
|
|
10
13
|
--font-family: "Arial", sans-serif;
|
|
11
14
|
--font-size: 14px;
|
package/src/styles/mixins.scss
CHANGED
|
@@ -21,3 +21,33 @@
|
|
|
21
21
|
@content;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
@mixin browser($browser) {
|
|
26
|
+
html[browser="#{$browser}"] & {
|
|
27
|
+
@content;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@mixin chromeOnly() {
|
|
32
|
+
@include browser(chrome) {
|
|
33
|
+
@content;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@mixin edgeOnly() {
|
|
38
|
+
@include browser(edge) {
|
|
39
|
+
@content;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@mixin operaOnly() {
|
|
44
|
+
@include browser(opera) {
|
|
45
|
+
@content;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@mixin firefoxOnly() {
|
|
50
|
+
@include browser(firefox) {
|
|
51
|
+
@content;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
ComponentProps,
|
|
3
|
-
forwardRef,
|
|
4
|
-
ForwardRefRenderFunction,
|
|
5
|
-
PropsWithChildren,
|
|
6
|
-
useCallback,
|
|
7
|
-
useState,
|
|
8
|
-
} from "react";
|
|
9
|
-
|
|
10
|
-
import {expandType, LayoutContext} from "./context";
|
|
11
|
-
|
|
12
|
-
import classnames from "classnames";
|
|
13
|
-
|
|
14
|
-
import styles from "./layout.module.scss";
|
|
15
|
-
|
|
16
|
-
export type LayoutProps = ComponentProps<"div">;
|
|
17
|
-
|
|
18
|
-
const Provider: ForwardRefRenderFunction<HTMLDivElement, PropsWithChildren<LayoutProps>> = (
|
|
19
|
-
{children, className, style, ...props},
|
|
20
|
-
ref
|
|
21
|
-
) => {
|
|
22
|
-
const [isExpanded, setExpanded] = useState(false);
|
|
23
|
-
const [height, setHeight] = useState<number | string | undefined>(undefined);
|
|
24
|
-
const [width, setWidth] = useState<number | string | undefined>(undefined);
|
|
25
|
-
|
|
26
|
-
const expand = useCallback((value?: expandType) => {
|
|
27
|
-
setHeight(value?.height);
|
|
28
|
-
setWidth(value?.width);
|
|
29
|
-
setExpanded(true);
|
|
30
|
-
}, []);
|
|
31
|
-
|
|
32
|
-
const collapse = useCallback(() => {
|
|
33
|
-
setHeight(undefined);
|
|
34
|
-
setWidth(undefined);
|
|
35
|
-
setExpanded(false);
|
|
36
|
-
}, []);
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<LayoutContext.Provider value={{isExpanded, expand, collapse}}>
|
|
40
|
-
<div
|
|
41
|
-
ref={ref}
|
|
42
|
-
style={{minHeight: height, minWidth: width, ...style}}
|
|
43
|
-
className={classnames(
|
|
44
|
-
styles["layout"],
|
|
45
|
-
{
|
|
46
|
-
[styles["layout--expanded"]]: isExpanded,
|
|
47
|
-
},
|
|
48
|
-
className
|
|
49
|
-
)}
|
|
50
|
-
{...props}
|
|
51
|
-
>
|
|
52
|
-
{children}
|
|
53
|
-
</div>
|
|
54
|
-
</LayoutContext.Provider>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
Provider.displayName = "ViewportProvider";
|
|
59
|
-
|
|
60
|
-
export default forwardRef(Provider);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {createContext, useContext} from "react";
|
|
2
|
-
|
|
3
|
-
export type expandType = {
|
|
4
|
-
height?: number | string;
|
|
5
|
-
width?: number | string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export interface LayoutContract {
|
|
9
|
-
isExpanded?: boolean;
|
|
10
|
-
|
|
11
|
-
expand(value?: expandType): void;
|
|
12
|
-
|
|
13
|
-
collapse(): void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const LayoutContext = createContext<LayoutContract>({
|
|
17
|
-
isExpanded: false,
|
|
18
|
-
expand() {},
|
|
19
|
-
collapse() {},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
LayoutContext.displayName = "LayoutContext";
|
|
23
|
-
|
|
24
|
-
export const useLayout = () => useContext(LayoutContext);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
.layout {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
overflow: hidden;
|
|
5
|
-
min-width: var(--min-width);
|
|
6
|
-
max-width: var(--max-width);
|
|
7
|
-
min-height: var(--min-height);
|
|
8
|
-
max-height: var(--max-height);
|
|
9
|
-
transition:
|
|
10
|
-
min-height var(--transition-speed-md) ease-in-out,
|
|
11
|
-
min-width var(--transition-speed-md) ease-in-out;
|
|
12
|
-
|
|
13
|
-
&--expanded {
|
|
14
|
-
min-height: var(--max-height);
|
|
15
|
-
min-width: var(--max-width);
|
|
16
|
-
}
|
|
17
|
-
}
|