@js-empire/emperor-ui 1.0.1 → 1.1.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/.husky/pre-commit +4 -0
- package/.storybook/main.ts +2 -11
- package/.storybook/preview.ts +1 -1
- package/.vscode/extensions.json +3 -0
- package/README.md +68 -1
- package/package.json +16 -4
- package/public/icons/emperor-ui-logo.ico +0 -0
- package/public/images/avatar-female.jpg +0 -0
- package/public/images/avatar-male.jpg +0 -0
- package/public/images/emperor-ui-logo.png +0 -0
- package/src/components/atoms/brand/brand.stories.tsx +27 -0
- package/src/components/atoms/brand/brand.tsx +56 -0
- package/src/components/atoms/brand/index.ts +1 -0
- package/src/components/atoms/brand/styles/classes.ts +9 -0
- package/src/components/atoms/brand/styles/index.ts +2 -0
- package/src/components/atoms/brand/styles/styles.ts +0 -0
- package/src/components/atoms/column/column.stories.tsx +36 -0
- package/src/components/atoms/column/column.tsx +21 -0
- package/src/components/atoms/column/index.ts +1 -0
- package/src/components/atoms/container/column.stories.tsx +36 -0
- package/src/components/atoms/container/container.tsx +28 -0
- package/src/components/atoms/container/index.ts +1 -0
- package/src/components/atoms/index.ts +6 -0
- package/src/components/atoms/portal/index.ts +1 -0
- package/src/components/atoms/portal/portal.stories.tsx +43 -0
- package/src/components/atoms/portal/portal.tsx +23 -0
- package/src/components/atoms/row/index.ts +1 -0
- package/src/components/atoms/row/row.stories.tsx +36 -0
- package/src/components/atoms/row/row.tsx +26 -0
- package/src/components/atoms/uploader/avatar-label.tsx +83 -0
- package/src/components/atoms/uploader/index.ts +7 -0
- package/src/components/atoms/uploader/stories/uploader.stories.tsx +41 -0
- package/src/components/atoms/uploader/upload-file-error-box.tsx +29 -0
- package/src/components/atoms/uploader/upload-file-input.tsx +36 -0
- package/src/components/atoms/uploader/upload-file-label.tsx +74 -0
- package/src/components/atoms/uploader/upload-file-listing.tsx +53 -0
- package/src/components/atoms/uploader/uploader.tsx +55 -0
- package/src/components/atoms/uploader/view-image-modal.tsx +39 -0
- package/src/components/index.ts +4 -8
- package/src/components/molecules/index.ts +5 -0
- package/src/components/molecules/item-card/item-card.tsx +6 -0
- package/src/components/molecules/nav-bar/index.ts +3 -0
- package/src/components/molecules/nav-bar/nav-bar-item.tsx +70 -0
- package/src/components/molecules/nav-bar/nav-bar.tsx +65 -0
- package/src/components/molecules/nav-bar/stories/hover-effect/nav-bar-hover-effect.stories.tsx +52 -0
- package/src/components/molecules/nav-bar/stories/nav-bar.stories.tsx +50 -0
- package/src/components/molecules/nav-bar/styles/classes.ts +68 -0
- package/src/components/molecules/nav-bar/styles/index.ts +2 -0
- package/src/components/molecules/nav-bar/styles/styles.ts +84 -0
- package/src/components/molecules/nav-bar/sub-items-box.tsx +57 -0
- package/src/components/molecules/scaffold/scaffold.stories.tsx +21 -0
- package/src/components/molecules/scaffold/scaffold.tsx +36 -0
- package/src/components/molecules/side-bar/compact-side-bar.tsx +73 -0
- package/src/components/molecules/side-bar/index.ts +1 -0
- package/src/components/molecules/side-bar/side-bar-drawer.tsx +124 -0
- package/src/components/molecules/side-bar/side-bar.stories.tsx +110 -0
- package/src/components/molecules/side-bar/side-bar.tsx +31 -0
- package/src/components/molecules/side-bar/styles/classes.ts +28 -0
- package/src/components/molecules/side-bar/styles/index.ts +2 -0
- package/src/components/molecules/side-bar/styles/styles.ts +13 -0
- package/src/components/organisms/footer/footer.tsx +20 -0
- package/src/components/organisms/footer/styles/classes.ts +15 -0
- package/src/components/organisms/footer/styles/index.ts +2 -0
- package/src/components/organisms/footer/styles/styles.ts +9 -0
- package/src/components/organisms/header/header.tsx +94 -0
- package/src/components/organisms/header/segmented-header-content.tsx +37 -0
- package/src/components/organisms/header/stories/header.stories.tsx +143 -0
- package/src/components/organisms/header/styles/classes.ts +22 -0
- package/src/components/organisms/header/styles/index.ts +2 -0
- package/src/components/organisms/header/styles/styles.ts +39 -0
- package/src/components/organisms/index.ts +4 -0
- package/src/components/templates/index.ts +1 -0
- package/src/components/templates/landing-page/index.ts +1 -0
- package/src/components/templates/landing-page/landing-page.stories.tsx +21 -0
- package/src/components/templates/landing-page/landing-page.tsx +57 -0
- package/src/components/templates/landing-page/styles/classes.ts +11 -0
- package/src/components/templates/landing-page/styles/index.ts +1 -0
- package/src/constants/defaults.ts +42 -7
- package/src/constants/fake.ts +2 -0
- package/src/constants/index.ts +2 -0
- package/src/constants/uploader.ts +27 -0
- package/src/context/emperor-ui-context.ts +4 -4
- package/src/context/index.ts +2 -0
- package/src/context/navigation-context.ts +6 -0
- package/src/context/uploader-context.ts +6 -0
- package/src/enums/index.ts +2 -0
- package/src/enums/placeholders.ts +4 -0
- package/src/enums/preserved-keys.ts +3 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/use-navigation.ts +12 -0
- package/src/hooks/use-uploader-context.ts +14 -0
- package/src/hooks/use-uploader.tsx +215 -0
- package/src/index.ts +9 -5
- package/src/main.tsx +3 -0
- package/src/mocks/header.tsx +118 -0
- package/src/mocks/index.ts +1 -0
- package/src/providers/config-provider.tsx +54 -0
- package/src/providers/emperor-ui-provider.tsx +17 -24
- package/src/providers/index.ts +3 -0
- package/src/providers/navigation-provider.tsx +42 -0
- package/src/providers/uploader-provider.tsx +53 -0
- package/src/styles/globals.css +13 -0
- package/src/styles/hero.ts +2 -0
- package/src/types/components/atoms/brand.ts +13 -0
- package/src/types/components/atoms/column.ts +3 -0
- package/src/types/components/atoms/container.ts +3 -0
- package/src/types/components/atoms/index.ts +6 -0
- package/src/types/components/atoms/portal.ts +6 -0
- package/src/types/components/atoms/row.ts +3 -0
- package/src/types/components/atoms/uploader.ts +104 -0
- package/src/types/components/index.ts +3 -8
- package/src/types/components/molecules/header/header.ts +51 -0
- package/src/types/components/molecules/index.ts +9 -0
- package/src/types/components/molecules/nav-bar/nav-bar.ts +65 -0
- package/src/types/components/molecules/side-bar/index.ts +1 -0
- package/src/types/components/molecules/side-bar/side-bar.ts +40 -0
- package/src/types/components/templates/index.ts +1 -0
- package/src/types/components/templates/landing-page.ts +10 -0
- package/src/types/context/config.ts +54 -0
- package/src/types/context/index.ts +2 -1
- package/src/types/context/navigation.ts +17 -0
- package/src/types/shared/components.ts +4 -0
- package/src/utils/compress-images.ts +36 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/storybook.tsx +15 -0
- package/tsconfig.app.json +3 -2
- package/tsconfig.node.json +0 -1
- package/vite.config.ts +4 -0
- package/dist/emperor-ui.js +0 -3171
- package/dist/emperor-ui.umd.cjs +0 -6
- package/dist/index.d.ts +0 -200
- package/src/components/footer/footer.tsx +0 -6
- package/src/components/header/header.tsx +0 -49
- package/src/components/item-card/item-card.tsx +0 -6
- package/src/components/nav-bar/index.ts +0 -1
- package/src/components/nav-bar/nav-bar.tsx +0 -6
- package/src/components/scaffold/scaffold.tsx +0 -15
- package/src/index.css +0 -1
- package/src/types/components/header/header.ts +0 -21
- package/src/types/components/nav-bar/nav-bar.ts +0 -9
- package/src/types/context/emperor-ui.ts +0 -37
- package/tailwind.config.js +0 -6
- /package/src/components/{filter → molecules/filter}/filter.tsx +0 -0
- /package/src/components/{filter → molecules/filter}/index.ts +0 -0
- /package/src/components/{item-card → molecules/item-card}/index.ts +0 -0
- /package/src/components/{scaffold → molecules/scaffold}/index.ts +0 -0
- /package/src/components/{footer → organisms/footer}/index.ts +0 -0
- /package/src/components/{header → organisms/header}/index.ts +0 -0
- /package/src/components/{item-details → organisms/item-details}/index.ts +0 -0
- /package/src/components/{item-details → organisms/item-details}/item-details.tsx +0 -0
- /package/src/components/{listings → organisms/listings}/index.ts +0 -0
- /package/src/components/{listings → organisms/listings}/listings.tsx +0 -0
- /package/src/types/components/{filter → molecules/filter}/filter.ts +0 -0
- /package/src/types/components/{filter → molecules/filter}/index.ts +0 -0
- /package/src/types/components/{footer → molecules/footer}/footer.ts +0 -0
- /package/src/types/components/{footer → molecules/footer}/index.ts +0 -0
- /package/src/types/components/{header → molecules/header}/index.ts +0 -0
- /package/src/types/components/{item-card → molecules/item-card}/index.ts +0 -0
- /package/src/types/components/{item-card → molecules/item-card}/item-card.ts +0 -0
- /package/src/types/components/{item-details → molecules/item-details}/index.ts +0 -0
- /package/src/types/components/{item-details → molecules/item-details}/item-details.ts +0 -0
- /package/src/types/components/{listings → molecules/listings}/index.ts +0 -0
- /package/src/types/components/{listings → molecules/listings}/listings.ts +0 -0
- /package/src/types/components/{nav-bar → molecules/nav-bar}/index.ts +0 -0
- /package/src/types/components/{scaffold → molecules/scaffold}/index.ts +0 -0
- /package/src/types/components/{scaffold → molecules/scaffold}/scaffold.ts +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useEmperorUI } from "@hooks";
|
|
2
|
+
import type { HeaderProps, NavBarHoverEffect, NavBarVariant } from "@types";
|
|
3
|
+
import { cn } from "@utils";
|
|
4
|
+
import { VariantProps } from "class-variance-authority";
|
|
5
|
+
import { ComponentProps, forwardRef } from "react";
|
|
6
|
+
import { Brand, NavBar, SideBar } from "@components";
|
|
7
|
+
import { headerClasses, headerStyles } from "./styles";
|
|
8
|
+
import { useDisclosure } from "@heroui/react";
|
|
9
|
+
import { MOCK_HEADER_ITEMS, MOCK_HEADER_ACTIONS } from "@mocks";
|
|
10
|
+
import { SegmentedHeaderContent } from "./segmented-header-content";
|
|
11
|
+
|
|
12
|
+
export const Header = forwardRef<
|
|
13
|
+
HTMLElement,
|
|
14
|
+
ComponentProps<"header"> & VariantProps<typeof headerClasses> & HeaderProps
|
|
15
|
+
>(
|
|
16
|
+
(
|
|
17
|
+
{ className, variant = "default", glassEffect, children, ...props },
|
|
18
|
+
ref,
|
|
19
|
+
) => {
|
|
20
|
+
const { config } = useEmperorUI();
|
|
21
|
+
const { isOpen, onOpenChange } = useDisclosure();
|
|
22
|
+
|
|
23
|
+
const primaryColor = config?.theme?.colors?.primary;
|
|
24
|
+
const foregroundColor = config?.theme?.colors?.foreground;
|
|
25
|
+
|
|
26
|
+
const content = children || (
|
|
27
|
+
<>
|
|
28
|
+
<SideBar
|
|
29
|
+
items={MOCK_HEADER_ITEMS}
|
|
30
|
+
actions={MOCK_HEADER_ACTIONS}
|
|
31
|
+
isOpen={isOpen}
|
|
32
|
+
onOpenChange={onOpenChange}
|
|
33
|
+
header={<Brand className="text-white" />}
|
|
34
|
+
triggerProps={{
|
|
35
|
+
startContent: (
|
|
36
|
+
<Brand
|
|
37
|
+
className="text-white"
|
|
38
|
+
classNames={{
|
|
39
|
+
logo: "size-6",
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
),
|
|
43
|
+
isIconOnly: false,
|
|
44
|
+
variant: "light",
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
<NavBar
|
|
49
|
+
className="hidden md:flex mx-auto"
|
|
50
|
+
items={MOCK_HEADER_ITEMS}
|
|
51
|
+
hoverEffect={
|
|
52
|
+
{
|
|
53
|
+
default: "default",
|
|
54
|
+
floating: "underline",
|
|
55
|
+
light: "underline",
|
|
56
|
+
"segmented-floating": "default",
|
|
57
|
+
}[variant] as NavBarHoverEffect
|
|
58
|
+
}
|
|
59
|
+
variant={
|
|
60
|
+
{
|
|
61
|
+
default: "default",
|
|
62
|
+
floating: "default",
|
|
63
|
+
light: "default",
|
|
64
|
+
"segmented-floating": "default",
|
|
65
|
+
}[variant] as NavBarVariant
|
|
66
|
+
}
|
|
67
|
+
/>
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<header
|
|
73
|
+
ref={ref}
|
|
74
|
+
data-slot="emperor-header"
|
|
75
|
+
className={cn(headerClasses({ variant, className }))}
|
|
76
|
+
style={headerStyles({
|
|
77
|
+
primaryColor,
|
|
78
|
+
foregroundColor,
|
|
79
|
+
variant,
|
|
80
|
+
glassEffect,
|
|
81
|
+
})}
|
|
82
|
+
{...props}
|
|
83
|
+
>
|
|
84
|
+
{variant === "segmented-floating" ? (
|
|
85
|
+
<SegmentedHeaderContent glassEffect={glassEffect}>
|
|
86
|
+
{content}
|
|
87
|
+
</SegmentedHeaderContent>
|
|
88
|
+
) : (
|
|
89
|
+
content
|
|
90
|
+
)}
|
|
91
|
+
</header>
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SegmentedHeaderContentProps } from "@types";
|
|
2
|
+
import { Children } from "react";
|
|
3
|
+
import { Row } from "@components";
|
|
4
|
+
import { useEmperorUI } from "@hooks";
|
|
5
|
+
import { getGlassEffectStyles } from "./styles/styles";
|
|
6
|
+
|
|
7
|
+
export const SegmentedHeaderContent = ({
|
|
8
|
+
children,
|
|
9
|
+
glassEffect,
|
|
10
|
+
}: SegmentedHeaderContentProps) => {
|
|
11
|
+
const { config } = useEmperorUI();
|
|
12
|
+
|
|
13
|
+
const primaryColor = config?.theme?.colors?.primary;
|
|
14
|
+
const foregroundColor = config?.theme?.colors?.foreground;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Row className="w-full min-h-12 justify-between">
|
|
18
|
+
{Children.toArray(children).map((child, index) => (
|
|
19
|
+
<Row
|
|
20
|
+
className="rounded-full min-h-12 px-5"
|
|
21
|
+
key={index}
|
|
22
|
+
style={{
|
|
23
|
+
backgroundColor: primaryColor,
|
|
24
|
+
color: foregroundColor,
|
|
25
|
+
...(glassEffect
|
|
26
|
+
? getGlassEffectStyles({
|
|
27
|
+
glassEffect,
|
|
28
|
+
})
|
|
29
|
+
: {}),
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
{child}
|
|
33
|
+
</Row>
|
|
34
|
+
))}
|
|
35
|
+
</Row>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Brand, Header, NavBar } from "@components";
|
|
3
|
+
import { getStorybookDecorators } from "@utils";
|
|
4
|
+
import { FAKE_PARAGRAPH } from "@constants";
|
|
5
|
+
import { MOCK_HEADER_ITEMS } from "@mocks";
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Header> = {
|
|
8
|
+
title: "Molecules/Header",
|
|
9
|
+
component: Header,
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: "fullscreen",
|
|
12
|
+
},
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
decorators: getStorybookDecorators({}),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
|
|
21
|
+
const GLASS_EFFECT_CONFIG = {
|
|
22
|
+
enabled: true,
|
|
23
|
+
blur: 10,
|
|
24
|
+
backgroundColor: "#006fed",
|
|
25
|
+
foregroundColor: "#fff",
|
|
26
|
+
opacity: 40,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Default: Story = {
|
|
30
|
+
args: {},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const Floating: Story = {
|
|
34
|
+
args: {
|
|
35
|
+
variant: "floating",
|
|
36
|
+
},
|
|
37
|
+
render: (args) => {
|
|
38
|
+
return (
|
|
39
|
+
<div>
|
|
40
|
+
<Header {...args} />
|
|
41
|
+
|
|
42
|
+
<main className="w-full container mx-auto p-5 pt-24 flex flex-col gap-6">
|
|
43
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
44
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
45
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
46
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
47
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
48
|
+
</main>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const Light: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
variant: "light",
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const WithGlassEffect: Story = {
|
|
61
|
+
args: {
|
|
62
|
+
variant: "floating",
|
|
63
|
+
glassEffect: GLASS_EFFECT_CONFIG,
|
|
64
|
+
},
|
|
65
|
+
render: (args) => {
|
|
66
|
+
return (
|
|
67
|
+
<div>
|
|
68
|
+
<Header {...args} />
|
|
69
|
+
|
|
70
|
+
<main className="w-full container mx-auto p-5 pt-24 flex flex-col gap-6">
|
|
71
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
72
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
73
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
74
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
75
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
76
|
+
</main>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const SegmentedFloating: Story = {
|
|
83
|
+
args: {
|
|
84
|
+
variant: "segmented-floating",
|
|
85
|
+
},
|
|
86
|
+
render: (args) => {
|
|
87
|
+
return (
|
|
88
|
+
<div>
|
|
89
|
+
<Header {...args}>
|
|
90
|
+
<Brand />
|
|
91
|
+
|
|
92
|
+
<NavBar
|
|
93
|
+
items={MOCK_HEADER_ITEMS}
|
|
94
|
+
hoverEffect="none"
|
|
95
|
+
variant="default"
|
|
96
|
+
className="hidden md:flex"
|
|
97
|
+
subItemsColumns={4}
|
|
98
|
+
/>
|
|
99
|
+
</Header>
|
|
100
|
+
|
|
101
|
+
<main className="w-full container mx-auto p-5 pt-24 flex flex-col gap-6">
|
|
102
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
103
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
104
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
105
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
106
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
107
|
+
</main>
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const SegmentedFloatingWithGlassEffect: Story = {
|
|
114
|
+
args: {
|
|
115
|
+
variant: "segmented-floating",
|
|
116
|
+
glassEffect: GLASS_EFFECT_CONFIG,
|
|
117
|
+
},
|
|
118
|
+
render: (args) => {
|
|
119
|
+
return (
|
|
120
|
+
<div>
|
|
121
|
+
<Header {...args}>
|
|
122
|
+
<Brand />
|
|
123
|
+
|
|
124
|
+
<NavBar
|
|
125
|
+
items={MOCK_HEADER_ITEMS}
|
|
126
|
+
hoverEffect="none"
|
|
127
|
+
variant="default"
|
|
128
|
+
className="hidden md:flex"
|
|
129
|
+
subItemsColumns={4}
|
|
130
|
+
/>
|
|
131
|
+
</Header>
|
|
132
|
+
|
|
133
|
+
<main className="w-full container mx-auto p-5 pt-24 flex flex-col gap-6">
|
|
134
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
135
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
136
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
137
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
138
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
139
|
+
</main>
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
},
|
|
143
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export const headerClasses = cva(
|
|
4
|
+
["flex min-h-16 items-center justify-between gap-4 px-6 w-full"],
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: ["flex-nowrap w-full"],
|
|
9
|
+
floating: [
|
|
10
|
+
"fixed min-h-14 w-[90vw] rounded-full shadow-lg",
|
|
11
|
+
"top-3 left-1/2 -translate-x-1/2 z-10",
|
|
12
|
+
],
|
|
13
|
+
light: [],
|
|
14
|
+
"segmented-floating": [
|
|
15
|
+
"fixed min-h-12 w-[90vw] top-3 left-1/2 -translate-x-1/2 z-10",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {},
|
|
20
|
+
compoundVariants: [],
|
|
21
|
+
},
|
|
22
|
+
);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
import { HeaderGlassEffect, HeaderStylesProps } from "@types";
|
|
3
|
+
|
|
4
|
+
export const getGlassEffectStyles = ({
|
|
5
|
+
glassEffect,
|
|
6
|
+
}: {
|
|
7
|
+
glassEffect: HeaderGlassEffect;
|
|
8
|
+
}): CSSProperties => ({
|
|
9
|
+
backgroundColor: glassEffect?.backgroundColor
|
|
10
|
+
? `${glassEffect?.backgroundColor}${glassEffect?.opacity ?? 30}`
|
|
11
|
+
: "transparent",
|
|
12
|
+
backdropFilter: `blur(${glassEffect?.blur ?? 0}px)`,
|
|
13
|
+
color: glassEffect?.foregroundColor,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const headerStyles = ({
|
|
17
|
+
primaryColor,
|
|
18
|
+
foregroundColor,
|
|
19
|
+
variant,
|
|
20
|
+
glassEffect,
|
|
21
|
+
}: HeaderStylesProps): CSSProperties => {
|
|
22
|
+
if (glassEffect?.enabled && variant !== "segmented-floating") {
|
|
23
|
+
return getGlassEffectStyles({
|
|
24
|
+
glassEffect: {
|
|
25
|
+
...glassEffect,
|
|
26
|
+
foregroundColor: glassEffect?.foregroundColor ?? foregroundColor,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (["default", "floating"].includes(variant ?? "")) {
|
|
32
|
+
return {
|
|
33
|
+
backgroundColor: primaryColor,
|
|
34
|
+
color: foregroundColor,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {};
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./landing-page";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./landing-page";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { LandingPage } from "@components";
|
|
3
|
+
import { getStorybookDecorators } from "@utils";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof LandingPage> = {
|
|
6
|
+
title: "Templates/LandingPage",
|
|
7
|
+
component: LandingPage,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "fullscreen",
|
|
10
|
+
},
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
decorators: getStorybookDecorators({}),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
18
|
+
|
|
19
|
+
export const Default: Story = {
|
|
20
|
+
args: {},
|
|
21
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { forwardRef, ComponentProps } from "react";
|
|
2
|
+
import { VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "@utils";
|
|
4
|
+
import { LandingPageProps } from "@types";
|
|
5
|
+
import { landingPageClasses } from "./styles";
|
|
6
|
+
import { Brand, Header, NavBar } from "@components";
|
|
7
|
+
import { MOCK_HEADER_ITEMS_WITH_SUB_ITEMS } from "@mocks";
|
|
8
|
+
import { FAKE_PARAGRAPH } from "@constants";
|
|
9
|
+
|
|
10
|
+
const GLASS_EFFECT_CONFIG = {
|
|
11
|
+
enabled: true,
|
|
12
|
+
blur: 10,
|
|
13
|
+
backgroundColor: "#006fed",
|
|
14
|
+
foregroundColor: "#fff",
|
|
15
|
+
opacity: 40,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This component is not for general use nor it is reusable, it is intended to be used as a demo page.
|
|
20
|
+
*/
|
|
21
|
+
export const LandingPage = forwardRef<
|
|
22
|
+
HTMLDivElement,
|
|
23
|
+
ComponentProps<"main"> &
|
|
24
|
+
VariantProps<typeof landingPageClasses> &
|
|
25
|
+
LandingPageProps
|
|
26
|
+
>(({ className, variant = "default", children, ...props }, ref) => {
|
|
27
|
+
return (
|
|
28
|
+
<main
|
|
29
|
+
ref={ref}
|
|
30
|
+
data-slot="emperor-landing-page"
|
|
31
|
+
className={cn(landingPageClasses({ className }))}
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
<Header variant="floating" glassEffect={GLASS_EFFECT_CONFIG}>
|
|
35
|
+
<Brand />
|
|
36
|
+
|
|
37
|
+
<NavBar
|
|
38
|
+
items={MOCK_HEADER_ITEMS_WITH_SUB_ITEMS}
|
|
39
|
+
hoverEffect="none"
|
|
40
|
+
variant="default"
|
|
41
|
+
className="hidden md:flex"
|
|
42
|
+
subItemsColumns={4}
|
|
43
|
+
/>
|
|
44
|
+
</Header>
|
|
45
|
+
|
|
46
|
+
<main className="w-full container mx-auto p-5 pt-24 flex flex-col gap-6">
|
|
47
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
48
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
49
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
50
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
51
|
+
<p>{FAKE_PARAGRAPH}</p>
|
|
52
|
+
</main>
|
|
53
|
+
|
|
54
|
+
{children}
|
|
55
|
+
</main>
|
|
56
|
+
);
|
|
57
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./classes";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { ColorsPalette, EmperorUIConfig } from "@types";
|
|
2
2
|
|
|
3
3
|
export const defaultColorsPalette: ColorsPalette = {
|
|
4
|
-
primary: "#
|
|
5
|
-
secondary: "#
|
|
6
|
-
background: "#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
warning: "#
|
|
4
|
+
primary: "#006FEE",
|
|
5
|
+
secondary: "#9353d3",
|
|
6
|
+
background: "#3f3f46",
|
|
7
|
+
foreground: "#ECEDEE",
|
|
8
|
+
success: "#17c964",
|
|
9
|
+
warning: "#f5a524",
|
|
10
|
+
danger: "#f31260",
|
|
10
11
|
info: "#3B82F6",
|
|
11
|
-
success: "#16A34A",
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export const defaultEmperorUIConfig: EmperorUIConfig = {
|
|
@@ -19,4 +19,39 @@ export const defaultEmperorUIConfig: EmperorUIConfig = {
|
|
|
19
19
|
layout: {
|
|
20
20
|
withScaffold: true,
|
|
21
21
|
},
|
|
22
|
+
interLocalization: {
|
|
23
|
+
lang: "en",
|
|
24
|
+
languages: ["en", "ar"],
|
|
25
|
+
defaultLanguage: "en",
|
|
26
|
+
dir: "ltr",
|
|
27
|
+
isMultiLingual: false,
|
|
28
|
+
locales: {
|
|
29
|
+
en: {
|
|
30
|
+
dropHere: "Drop file here",
|
|
31
|
+
selectFile: "Select a file or drag and drop here",
|
|
32
|
+
selectionTypes: "JPG, PNG or PDF, file size no more than 10MB",
|
|
33
|
+
selectBtn: "Select file",
|
|
34
|
+
errorUploadingFile: "No file was uploaded",
|
|
35
|
+
maxNumImages: "Maximum number of uploaded images exceeded: ",
|
|
36
|
+
errorUploadedTypes: "You can only upload files within these types: ",
|
|
37
|
+
maxSizeExceededError:
|
|
38
|
+
"You can only upload files/images with less than MAX_FILE_SIZE Mega Bytes, you're file's size is UPLOADED_FILE_SIZE Mega Bytes",
|
|
39
|
+
duplicatesDenied:
|
|
40
|
+
"You can't upload images with duplicate names, you may rename them before the upload process",
|
|
41
|
+
},
|
|
42
|
+
ar: {
|
|
43
|
+
dropHere: "أسقط الملف هنا",
|
|
44
|
+
selectFile: "حدد ملفًا أو اسحبه وأفلته هنا",
|
|
45
|
+
selectionTypes: "JPG, PNG أو PDF، حجم الملف لا يزيد عن 10MB",
|
|
46
|
+
selectBtn: "حدد ملف",
|
|
47
|
+
errorUploadingFile: "لم يتم تحميل أي ملف",
|
|
48
|
+
maxNumImages: "تم تجاوز الحد الأقصى للصور المرفوعة: ",
|
|
49
|
+
errorUploadedTypes: "يمكنك فقط تحميل الملفات من الأنواع التالية: ",
|
|
50
|
+
maxSizeExceededError:
|
|
51
|
+
"يمكنك فقط رفع ملفات/صور بحجم أقل من MAX_FILE_SIZE ميغابايت، بينما حجم الملف الذي رفعته هو UPLOADED_FILE_SIZE ميغابايت",
|
|
52
|
+
duplicatesDenied:
|
|
53
|
+
"لا يمكنك رفع صور تحمل نفس الاسم، يمكنك إعادة تسميتها قبل عملية الرفع",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
22
57
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export const FAKE_PARAGRAPH =
|
|
2
|
+
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,";
|
package/src/constants/index.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const ALLOWED_IMAGES_TYPES = [
|
|
2
|
+
"image/jpeg",
|
|
3
|
+
"image/jpg",
|
|
4
|
+
"image/png",
|
|
5
|
+
"image/webp",
|
|
6
|
+
"image/gif",
|
|
7
|
+
"image/bmp",
|
|
8
|
+
"image/svg+xml",
|
|
9
|
+
"image/tiff",
|
|
10
|
+
"image/x-icon",
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export const ALLOWED_PDF_TYPES = ["application/pdf"];
|
|
14
|
+
|
|
15
|
+
export const ALLOWED_DOC_TYPES = [
|
|
16
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export const ONE_MEGABYTE = 1024;
|
|
20
|
+
|
|
21
|
+
export const fileTypesMapping: { [key: string]: string[] } = {
|
|
22
|
+
image: [".jpg", ".jpeg", ".png"],
|
|
23
|
+
doc: [".doc", ".docx"],
|
|
24
|
+
pdf: [".pdf"],
|
|
25
|
+
video: [".mp4"],
|
|
26
|
+
sheet: [".xlsx", ".xlx"],
|
|
27
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConfigContextState } from "@types";
|
|
2
2
|
import { createContext } from "react";
|
|
3
3
|
|
|
4
|
-
export const EmperorUIContext = createContext<
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export const EmperorUIContext = createContext<ConfigContextState | undefined>(
|
|
5
|
+
undefined,
|
|
6
|
+
);
|
package/src/context/index.ts
CHANGED
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NavigationContext } from "@context";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
|
|
4
|
+
export function useNavigation() {
|
|
5
|
+
const context = useContext(NavigationContext);
|
|
6
|
+
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error("useNavigation must be used within a NavigationProvider");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { UploaderContext } from "@context";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
|
|
4
|
+
export function useUploaderContext() {
|
|
5
|
+
const context = useContext(UploaderContext);
|
|
6
|
+
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
"useUploaderContext must be used within a UploaderProvider",
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return context;
|
|
14
|
+
}
|