@js-empire/emperor-ui 1.0.1 → 1.2.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.
Files changed (189) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/.storybook/main.ts +2 -11
  3. package/.storybook/preview.ts +1 -1
  4. package/.storybook/vitest.setup.ts +3 -3
  5. package/.vscode/extensions.json +1 -0
  6. package/README.md +47 -1
  7. package/dist/emperor-ui.js +69 -3169
  8. package/dist/emperor-ui.umd.cjs +45 -2
  9. package/dist/features-animation-D_Ss-HYx.js +1938 -0
  10. package/dist/globals.css +1 -0
  11. package/dist/icons/emperor-ui-logo.ico +0 -0
  12. package/dist/images/avatar-female.jpg +0 -0
  13. package/dist/images/avatar-male.jpg +0 -0
  14. package/dist/images/emperor-ui-logo.png +0 -0
  15. package/dist/index-C3mfrNCk.js +1630 -0
  16. package/dist/index-CZpTSGZs.js +5 -0
  17. package/dist/index-SRvFgjzo.js +26257 -0
  18. package/dist/index.d.ts +552 -46
  19. package/dist/src-UW24ZMRV-Ducut0ty.js +5 -0
  20. package/eslint.config.js +5 -14
  21. package/package.json +19 -7
  22. package/public/icons/emperor-ui-logo.ico +0 -0
  23. package/public/images/avatar-female.jpg +0 -0
  24. package/public/images/avatar-male.jpg +0 -0
  25. package/public/images/emperor-ui-logo.png +0 -0
  26. package/src/components/atoms/brand/brand.stories.tsx +27 -0
  27. package/src/components/atoms/brand/brand.tsx +56 -0
  28. package/src/components/atoms/brand/index.ts +1 -0
  29. package/src/components/atoms/brand/styles/classes.ts +9 -0
  30. package/src/components/atoms/brand/styles/index.ts +2 -0
  31. package/src/components/atoms/brand/styles/styles.ts +0 -0
  32. package/src/components/atoms/column/column.stories.tsx +37 -0
  33. package/src/components/atoms/column/column.tsx +21 -0
  34. package/src/components/atoms/column/index.ts +1 -0
  35. package/src/components/atoms/container/column.stories.tsx +37 -0
  36. package/src/components/atoms/container/container.tsx +28 -0
  37. package/src/components/atoms/container/index.ts +1 -0
  38. package/src/components/atoms/index.ts +6 -0
  39. package/src/components/atoms/portal/index.ts +1 -0
  40. package/src/components/atoms/portal/portal.stories.tsx +43 -0
  41. package/src/components/atoms/portal/portal.tsx +25 -0
  42. package/src/components/atoms/row/index.ts +1 -0
  43. package/src/components/atoms/row/row.stories.tsx +37 -0
  44. package/src/components/atoms/row/row.tsx +26 -0
  45. package/src/components/atoms/uploader/avatar-label.tsx +83 -0
  46. package/src/components/atoms/uploader/index.ts +7 -0
  47. package/src/components/atoms/uploader/stories/uploader.stories.tsx +160 -0
  48. package/src/components/atoms/uploader/upload-file-error-box.tsx +29 -0
  49. package/src/components/atoms/uploader/upload-file-input.tsx +36 -0
  50. package/src/components/atoms/uploader/upload-file-label.tsx +74 -0
  51. package/src/components/atoms/uploader/upload-file-listing.tsx +55 -0
  52. package/src/components/atoms/uploader/uploader.tsx +55 -0
  53. package/src/components/atoms/uploader/view-image-modal.tsx +40 -0
  54. package/src/components/index.ts +4 -8
  55. package/src/components/{filter → molecules/filter}/filter.tsx +2 -2
  56. package/src/components/molecules/index.ts +5 -0
  57. package/src/components/molecules/item-card/item-card.tsx +6 -0
  58. package/src/components/molecules/nav-bar/index.ts +3 -0
  59. package/src/components/molecules/nav-bar/nav-bar-item.tsx +70 -0
  60. package/src/components/molecules/nav-bar/nav-bar.tsx +65 -0
  61. package/src/components/molecules/nav-bar/stories/hover-effect/nav-bar-hover-effect.stories.tsx +52 -0
  62. package/src/components/molecules/nav-bar/stories/nav-bar.stories.tsx +50 -0
  63. package/src/components/molecules/nav-bar/styles/classes.ts +68 -0
  64. package/src/components/molecules/nav-bar/styles/index.ts +2 -0
  65. package/src/components/molecules/nav-bar/styles/styles.ts +85 -0
  66. package/src/components/molecules/nav-bar/sub-items-box.tsx +57 -0
  67. package/src/components/molecules/scaffold/scaffold.stories.tsx +21 -0
  68. package/src/components/molecules/scaffold/scaffold.tsx +36 -0
  69. package/src/components/molecules/side-bar/compact-side-bar.tsx +75 -0
  70. package/src/components/molecules/side-bar/index.ts +1 -0
  71. package/src/components/molecules/side-bar/side-bar-drawer.tsx +124 -0
  72. package/src/components/molecules/side-bar/side-bar.stories.tsx +111 -0
  73. package/src/components/molecules/side-bar/side-bar.tsx +31 -0
  74. package/src/components/molecules/side-bar/styles/classes.ts +28 -0
  75. package/src/components/molecules/side-bar/styles/index.ts +2 -0
  76. package/src/components/molecules/side-bar/styles/styles.ts +13 -0
  77. package/src/components/organisms/footer/copy-rights-box.tsx +27 -0
  78. package/src/components/organisms/footer/footer.tsx +75 -0
  79. package/src/components/organisms/footer/index.ts +5 -0
  80. package/src/components/organisms/footer/policies-box.tsx +26 -0
  81. package/src/components/organisms/footer/quick-links-box.tsx +45 -0
  82. package/src/components/organisms/footer/social-links-box.tsx +32 -0
  83. package/src/components/organisms/footer/stories/footer.stories.tsx +61 -0
  84. package/src/components/organisms/footer/styles/classes.ts +71 -0
  85. package/src/components/organisms/footer/styles/index.ts +2 -0
  86. package/src/components/organisms/footer/styles/styles.ts +6 -0
  87. package/src/components/organisms/header/header.tsx +94 -0
  88. package/src/components/organisms/header/segmented-header-content.tsx +37 -0
  89. package/src/components/organisms/header/stories/header.stories.tsx +144 -0
  90. package/src/components/organisms/header/styles/classes.ts +22 -0
  91. package/src/components/organisms/header/styles/index.ts +2 -0
  92. package/src/components/organisms/header/styles/styles.ts +39 -0
  93. package/src/components/organisms/index.ts +4 -0
  94. package/src/components/{item-details → organisms/item-details}/item-details.tsx +2 -2
  95. package/src/components/{listings → organisms/listings}/listings.tsx +2 -2
  96. package/src/components/templates/index.ts +1 -0
  97. package/src/components/templates/landing-page/index.ts +1 -0
  98. package/src/components/templates/landing-page/landing-page.stories.tsx +21 -0
  99. package/src/components/templates/landing-page/landing-page.tsx +57 -0
  100. package/src/components/templates/landing-page/styles/classes.ts +11 -0
  101. package/src/components/templates/landing-page/styles/index.ts +1 -0
  102. package/src/constants/defaults.ts +43 -8
  103. package/src/constants/fake.ts +5 -0
  104. package/src/constants/footer.tsx +157 -0
  105. package/src/constants/index.ts +3 -0
  106. package/src/constants/uploader.ts +27 -0
  107. package/src/context/emperor-ui-context.ts +4 -4
  108. package/src/context/index.ts +2 -0
  109. package/src/context/navigation-context.ts +6 -0
  110. package/src/context/uploader-context.ts +6 -0
  111. package/src/enums/index.ts +2 -0
  112. package/src/enums/placeholders.ts +4 -0
  113. package/src/enums/preserved-keys.ts +3 -0
  114. package/src/hooks/index.ts +3 -0
  115. package/src/hooks/use-emperor-ui.ts +1 -1
  116. package/src/hooks/use-navigation.ts +12 -0
  117. package/src/hooks/use-uploader-context.ts +14 -0
  118. package/src/hooks/use-uploader.tsx +151 -0
  119. package/src/index.ts +9 -5
  120. package/src/main.tsx +3 -0
  121. package/src/mocks/header.tsx +118 -0
  122. package/src/mocks/index.ts +1 -0
  123. package/src/providers/config-provider.tsx +54 -0
  124. package/src/providers/emperor-ui-provider.tsx +17 -24
  125. package/src/providers/index.ts +3 -0
  126. package/src/providers/navigation-provider.tsx +42 -0
  127. package/src/providers/uploader-provider.tsx +53 -0
  128. package/src/styles/globals.css +13 -0
  129. package/src/styles/hero.ts +2 -0
  130. package/src/types/components/atoms/brand.ts +13 -0
  131. package/src/types/components/atoms/column.ts +3 -0
  132. package/src/types/components/atoms/container.ts +3 -0
  133. package/src/types/components/atoms/index.ts +6 -0
  134. package/src/types/components/atoms/portal.ts +6 -0
  135. package/src/types/components/atoms/row.ts +3 -0
  136. package/src/types/components/atoms/uploader.ts +97 -0
  137. package/src/types/components/index.ts +3 -8
  138. package/src/types/components/{filter → molecules/filter}/filter.ts +1 -1
  139. package/src/types/components/molecules/footer/footer.ts +68 -0
  140. package/src/types/components/molecules/header/header.ts +51 -0
  141. package/src/types/components/molecules/index.ts +9 -0
  142. package/src/types/components/{item-card → molecules/item-card}/item-card.ts +1 -1
  143. package/src/types/components/{item-details → molecules/item-details}/item-details.ts +1 -1
  144. package/src/types/components/{listings → molecules/listings}/listings.ts +1 -1
  145. package/src/types/components/molecules/nav-bar/nav-bar.ts +66 -0
  146. package/src/types/components/{scaffold → molecules/scaffold}/scaffold.ts +1 -1
  147. package/src/types/components/molecules/side-bar/index.ts +1 -0
  148. package/src/types/components/molecules/side-bar/side-bar.ts +40 -0
  149. package/src/types/components/templates/index.ts +1 -0
  150. package/src/types/components/templates/landing-page.ts +10 -0
  151. package/src/types/context/config.ts +54 -0
  152. package/src/types/context/index.ts +2 -1
  153. package/src/types/context/navigation.ts +17 -0
  154. package/src/types/shared/components.ts +4 -0
  155. package/src/utils/compress-images.ts +36 -0
  156. package/src/utils/index.ts +3 -0
  157. package/src/utils/storybook.tsx +15 -0
  158. package/src/utils/uploader.ts +148 -0
  159. package/tsconfig.app.json +1 -9
  160. package/tsconfig.node.json +0 -1
  161. package/vite.config.ts +3 -8
  162. package/vitest.shims.d.ts +1 -1
  163. package/src/components/footer/footer.tsx +0 -6
  164. package/src/components/footer/index.ts +0 -1
  165. package/src/components/header/header.tsx +0 -49
  166. package/src/components/item-card/item-card.tsx +0 -6
  167. package/src/components/nav-bar/index.ts +0 -1
  168. package/src/components/nav-bar/nav-bar.tsx +0 -6
  169. package/src/components/scaffold/scaffold.tsx +0 -15
  170. package/src/index.css +0 -1
  171. package/src/types/components/footer/footer.ts +0 -9
  172. package/src/types/components/header/header.ts +0 -21
  173. package/src/types/components/nav-bar/nav-bar.ts +0 -9
  174. package/src/types/context/emperor-ui.ts +0 -37
  175. package/tailwind.config.js +0 -6
  176. /package/src/components/{filter → molecules/filter}/index.ts +0 -0
  177. /package/src/components/{item-card → molecules/item-card}/index.ts +0 -0
  178. /package/src/components/{scaffold → molecules/scaffold}/index.ts +0 -0
  179. /package/src/components/{header → organisms/header}/index.ts +0 -0
  180. /package/src/components/{item-details → organisms/item-details}/index.ts +0 -0
  181. /package/src/components/{listings → organisms/listings}/index.ts +0 -0
  182. /package/src/types/components/{filter → molecules/filter}/index.ts +0 -0
  183. /package/src/types/components/{footer → molecules/footer}/index.ts +0 -0
  184. /package/src/types/components/{header → molecules/header}/index.ts +0 -0
  185. /package/src/types/components/{item-card → molecules/item-card}/index.ts +0 -0
  186. /package/src/types/components/{item-details → molecules/item-details}/index.ts +0 -0
  187. /package/src/types/components/{listings → molecules/listings}/index.ts +0 -0
  188. /package/src/types/components/{nav-bar → molecules/nav-bar}/index.ts +0 -0
  189. /package/src/types/components/{scaffold → molecules/scaffold}/index.ts +0 -0
@@ -0,0 +1,13 @@
1
+ import { SideBarItemStylesProps } from "@/types";
2
+ import { CSSProperties } from "react";
3
+
4
+ export const sideBarItemStyles = ({
5
+ foregroundColor,
6
+ primaryColor,
7
+ isHovered,
8
+ }: SideBarItemStylesProps): CSSProperties => {
9
+ return {
10
+ color: isHovered ? foregroundColor : "inherit",
11
+ backgroundColor: isHovered ? primaryColor : "transparent",
12
+ };
13
+ };
@@ -0,0 +1,27 @@
1
+ import { cn } from "@heroui/react";
2
+ import { FooterProps } from "@/types";
3
+ import { copyRightsClasses } from "./styles";
4
+
5
+ export function CopyRightsBox({ copyRights, classNames }: FooterProps) {
6
+ return (
7
+ <section
8
+ data-slot="emperor-footer-policies"
9
+ className={cn(
10
+ copyRightsClasses({
11
+ className: cn(classNames?.copyRightsWrapper),
12
+ }),
13
+ )}
14
+ >
15
+ <p
16
+ className={cn(
17
+ "flex items-center gap-1 text-sm text-gray-400 text-center",
18
+ classNames?.copyRightsText,
19
+ )}
20
+ >
21
+ <span>©</span>
22
+ <span>{copyRights?.year}</span>
23
+ <span>{copyRights?.text}</span>
24
+ </p>
25
+ </section>
26
+ );
27
+ }
@@ -0,0 +1,75 @@
1
+ import type { FooterProps } from "@/types";
2
+ import { cn } from "@/utils";
3
+ import { VariantProps } from "class-variance-authority";
4
+ import { ComponentProps, forwardRef } from "react";
5
+ import { contentClasses, footerClasses, footerStyles } from "./styles";
6
+ import {
7
+ PoliciesBox,
8
+ QuickLinksBox,
9
+ SocialLinksBox,
10
+ CopyRightsBox,
11
+ } from "@/components";
12
+ import { Divider } from "@heroui/react";
13
+
14
+ export const Footer = forwardRef<
15
+ HTMLElement,
16
+ ComponentProps<"footer"> & VariantProps<typeof footerClasses> & FooterProps
17
+ >(
18
+ (
19
+ {
20
+ className,
21
+ classNames,
22
+ policies,
23
+ copyRights,
24
+ socialLinks,
25
+ contacts,
26
+ quickLinks,
27
+ variant = "default",
28
+ children,
29
+ ...props
30
+ },
31
+ ref,
32
+ ) => {
33
+ return (
34
+ <footer
35
+ ref={ref}
36
+ data-slot="emperor-footer"
37
+ className={cn(
38
+ footerClasses({
39
+ variant,
40
+ className: cn(className, classNames?.base),
41
+ }),
42
+ )}
43
+ style={footerStyles({})}
44
+ {...props}
45
+ >
46
+ <div
47
+ data-slot="emperor-footer-content"
48
+ className={cn(
49
+ contentClasses({
50
+ className: cn(className, classNames?.content),
51
+ }),
52
+ )}
53
+ >
54
+ {children}
55
+ </div>
56
+
57
+ <QuickLinksBox quickLinks={quickLinks} classNames={classNames} />
58
+
59
+ <Divider className="col-span-full bg-background/30" />
60
+
61
+ <div
62
+ className={cn(
63
+ "col-span-full flex flex-col gap-4 justify-between items-center w-full",
64
+ "md:flex-row",
65
+ )}
66
+ >
67
+ <SocialLinksBox socialLinks={socialLinks} classNames={classNames} />
68
+ <PoliciesBox policies={policies} classNames={classNames} />
69
+ </div>
70
+
71
+ <CopyRightsBox copyRights={copyRights} classNames={classNames} />
72
+ </footer>
73
+ );
74
+ },
75
+ );
@@ -0,0 +1,5 @@
1
+ export * from "./footer";
2
+ export * from "./policies-box";
3
+ export * from "./copy-rights-box";
4
+ export * from "./social-links-box";
5
+ export * from "./quick-links-box";
@@ -0,0 +1,26 @@
1
+ import { cn, Link } from "@heroui/react";
2
+ import { FooterProps } from "@/types";
3
+ import { policiesClasses } from "./styles";
4
+
5
+ export function PoliciesBox({ policies, classNames }: FooterProps) {
6
+ return (
7
+ <section
8
+ data-slot="emperor-footer-policies"
9
+ className={cn(
10
+ policiesClasses({
11
+ className: cn(classNames?.policiesWrapper),
12
+ }),
13
+ )}
14
+ >
15
+ {policies?.map((policy) => (
16
+ <Link
17
+ key={policy.href}
18
+ href={policy.href}
19
+ className={cn(classNames?.policy)}
20
+ >
21
+ {policy.label}
22
+ </Link>
23
+ ))}
24
+ </section>
25
+ );
26
+ }
@@ -0,0 +1,45 @@
1
+ import { cn, Link } from "@heroui/react";
2
+ import { FooterProps } from "@/types";
3
+ import { quickLinksClasses } from "./styles";
4
+
5
+ export function QuickLinksBox({ quickLinks, classNames }: FooterProps) {
6
+ return (
7
+ <section
8
+ data-slot="emperor-footer-quick-links"
9
+ className={cn(
10
+ quickLinksClasses({
11
+ className: cn(classNames?.quickLinksWrapper),
12
+ }),
13
+ )}
14
+ >
15
+ {quickLinks?.map(({ links, title }) => (
16
+ <div
17
+ key={title}
18
+ className={cn("flex flex-col gap-4", classNames?.quickLinksItem)}
19
+ >
20
+ <h3
21
+ className={cn("text-lg font-semibold", classNames?.quickLinksTitle)}
22
+ >
23
+ {title}
24
+ </h3>
25
+
26
+ <ul className={cn("flex flex-col gap-2", classNames?.quickLinksList)}>
27
+ {links?.map(({ href, label, isExternal }) => (
28
+ <Link
29
+ key={href}
30
+ href={href}
31
+ target={isExternal ? "_blank" : "_self"}
32
+ className={cn(
33
+ " text-gray-400 hover:text-white transition-all duration-300 ease-in-out",
34
+ classNames?.quickLinksLink,
35
+ )}
36
+ >
37
+ {label}
38
+ </Link>
39
+ ))}
40
+ </ul>
41
+ </div>
42
+ ))}
43
+ </section>
44
+ );
45
+ }
@@ -0,0 +1,32 @@
1
+ import { cn, Link } from "@heroui/react";
2
+ import { FooterProps } from "@/types";
3
+ import { socialLinksClasses } from "./styles";
4
+
5
+ export function SocialLinksBox({ socialLinks, classNames }: FooterProps) {
6
+ return (
7
+ <section
8
+ data-slot="emperor-footer-social-links"
9
+ className={cn(
10
+ socialLinksClasses({
11
+ className: cn(classNames?.socialLinksWrapper),
12
+ }),
13
+ )}
14
+ >
15
+ {socialLinks?.map(({ href, icon, label }) => (
16
+ <Link
17
+ key={href}
18
+ href={href}
19
+ className={cn(
20
+ "flex items-center gap-2 text-sm text-gray-400 hover:text-white transition-all duration-300 ease-in-out",
21
+ classNames?.socialLink,
22
+ )}
23
+ target="_blank"
24
+ rel="noopener noreferrer"
25
+ >
26
+ {icon}
27
+ {label}
28
+ </Link>
29
+ ))}
30
+ </section>
31
+ );
32
+ }
@@ -0,0 +1,61 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { Brand, Footer } from "@/components";
3
+ import { getStorybookDecorators } from "@/utils";
4
+ import { FooterProps } from "@/types";
5
+ import {
6
+ FAKE_PARAGRAPH,
7
+ FAKE_SENTENCE,
8
+ quickLinks,
9
+ policies,
10
+ copyRights,
11
+ contacts,
12
+ socialLinks,
13
+ } from "@/constants";
14
+ import { Button } from "@heroui/react";
15
+
16
+ const meta: Meta<typeof Footer> = {
17
+ title: "Organisms/Footer",
18
+ component: Footer,
19
+ parameters: {
20
+ layout: "fullscreen",
21
+ },
22
+ tags: ["autodocs"],
23
+ decorators: getStorybookDecorators({}),
24
+ };
25
+
26
+ export default meta;
27
+
28
+ type Story = StoryObj<typeof meta>;
29
+
30
+ export const Default: Story = {
31
+ args: {
32
+ quickLinks,
33
+ policies,
34
+ copyRights,
35
+ contacts,
36
+ socialLinks,
37
+ },
38
+ render: (args: FooterProps) => {
39
+ return (
40
+ <div className="flex flex-col gap-6">
41
+ <main className="w-full container mx-auto p-5 flex flex-col gap-6">
42
+ <p>{FAKE_PARAGRAPH}</p>
43
+ </main>
44
+
45
+ <Footer
46
+ classNames={{
47
+ content: "p-5 gap-8 items-center md:items-start",
48
+ }}
49
+ {...args}
50
+ >
51
+ <Brand />
52
+ <p className="text-center md:text-left">{FAKE_SENTENCE}</p>
53
+
54
+ <Button color="primary" className="w-fit">
55
+ Join now
56
+ </Button>
57
+ </Footer>
58
+ </div>
59
+ );
60
+ },
61
+ };
@@ -0,0 +1,71 @@
1
+ import { cva } from "class-variance-authority";
2
+
3
+ export const footerClasses = cva(
4
+ [
5
+ "w-full grid md:grid-cols-[1fr_2fr] gap-4 p-5 min-h-80",
6
+ "bg-foreground text-background",
7
+ ],
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: [],
12
+ },
13
+ },
14
+ defaultVariants: {},
15
+ compoundVariants: [],
16
+ },
17
+ );
18
+
19
+ export const contentClasses = cva(["flex flex-col gap-4"], {
20
+ variants: {},
21
+ defaultVariants: {},
22
+ compoundVariants: [],
23
+ });
24
+
25
+ export const policiesClasses = cva(
26
+ [
27
+ "col-span-full w-fit flex flex-col items-center gap-4 p-5 text-center",
28
+ "md:flex-row",
29
+ ],
30
+ {
31
+ variants: {},
32
+ defaultVariants: {},
33
+ compoundVariants: [],
34
+ },
35
+ );
36
+
37
+ export const socialLinksClasses = cva(
38
+ ["w-fit flex p-5 gap-4 items-center flex-wrap"],
39
+ {
40
+ variants: {},
41
+ defaultVariants: {},
42
+ compoundVariants: [],
43
+ },
44
+ );
45
+
46
+ export const copyRightsClasses = cva(
47
+ ["col-span-full w-fit flex p-2 mx-auto text-center"],
48
+ {
49
+ variants: {},
50
+ defaultVariants: {},
51
+ compoundVariants: [],
52
+ },
53
+ );
54
+
55
+ export const contactsClasses = cva([""], {
56
+ variants: {},
57
+ defaultVariants: {},
58
+ compoundVariants: [],
59
+ });
60
+
61
+ export const quickLinksClasses = cva(
62
+ [
63
+ "grid gap-4 p-5 w-fit mx-auto",
64
+ "sm:w-full sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",
65
+ ],
66
+ {
67
+ variants: {},
68
+ defaultVariants: {},
69
+ compoundVariants: [],
70
+ },
71
+ );
@@ -0,0 +1,2 @@
1
+ export * from "./classes";
2
+ export * from "./styles";
@@ -0,0 +1,6 @@
1
+ import { CSSProperties } from "react";
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type, no-empty-pattern
4
+ export const footerStyles = ({}: {}): CSSProperties => {
5
+ return {};
6
+ };
@@ -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,144 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
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
+ import { HeaderProps } from "@/types";
7
+
8
+ const meta: Meta<typeof Header> = {
9
+ title: "Organisms/Header",
10
+ component: Header,
11
+ parameters: {
12
+ layout: "fullscreen",
13
+ },
14
+ tags: ["autodocs"],
15
+ decorators: getStorybookDecorators({}),
16
+ };
17
+
18
+ export default meta;
19
+
20
+ type Story = StoryObj<typeof meta>;
21
+
22
+ const GLASS_EFFECT_CONFIG = {
23
+ enabled: true,
24
+ blur: 10,
25
+ backgroundColor: "#006fed",
26
+ foregroundColor: "#fff",
27
+ opacity: 40,
28
+ };
29
+
30
+ export const Default: Story = {
31
+ args: {},
32
+ };
33
+
34
+ export const Floating: Story = {
35
+ args: {
36
+ variant: "floating",
37
+ },
38
+ render: (args: HeaderProps) => {
39
+ return (
40
+ <div>
41
+ <Header {...args} />
42
+
43
+ <main className="w-full container mx-auto p-5 pt-24 flex flex-col gap-6">
44
+ <p>{FAKE_PARAGRAPH}</p>
45
+ <p>{FAKE_PARAGRAPH}</p>
46
+ <p>{FAKE_PARAGRAPH}</p>
47
+ <p>{FAKE_PARAGRAPH}</p>
48
+ <p>{FAKE_PARAGRAPH}</p>
49
+ </main>
50
+ </div>
51
+ );
52
+ },
53
+ };
54
+
55
+ export const Light: Story = {
56
+ args: {
57
+ variant: "light",
58
+ },
59
+ };
60
+
61
+ export const WithGlassEffect: Story = {
62
+ args: {
63
+ variant: "floating",
64
+ glassEffect: GLASS_EFFECT_CONFIG,
65
+ },
66
+ render: (args) => {
67
+ return (
68
+ <div>
69
+ <Header {...args} />
70
+
71
+ <main className="w-full container mx-auto p-5 pt-24 flex flex-col gap-6">
72
+ <p>{FAKE_PARAGRAPH}</p>
73
+ <p>{FAKE_PARAGRAPH}</p>
74
+ <p>{FAKE_PARAGRAPH}</p>
75
+ <p>{FAKE_PARAGRAPH}</p>
76
+ <p>{FAKE_PARAGRAPH}</p>
77
+ </main>
78
+ </div>
79
+ );
80
+ },
81
+ };
82
+
83
+ export const SegmentedFloating: Story = {
84
+ args: {
85
+ variant: "segmented-floating",
86
+ },
87
+ render: (args) => {
88
+ return (
89
+ <div>
90
+ <Header {...args}>
91
+ <Brand />
92
+
93
+ <NavBar
94
+ items={MOCK_HEADER_ITEMS}
95
+ hoverEffect="none"
96
+ variant="default"
97
+ className="hidden md:flex"
98
+ subItemsColumns={4}
99
+ />
100
+ </Header>
101
+
102
+ <main className="w-full container mx-auto p-5 pt-24 flex flex-col gap-6">
103
+ <p>{FAKE_PARAGRAPH}</p>
104
+ <p>{FAKE_PARAGRAPH}</p>
105
+ <p>{FAKE_PARAGRAPH}</p>
106
+ <p>{FAKE_PARAGRAPH}</p>
107
+ <p>{FAKE_PARAGRAPH}</p>
108
+ </main>
109
+ </div>
110
+ );
111
+ },
112
+ };
113
+
114
+ export const SegmentedFloatingWithGlassEffect: Story = {
115
+ args: {
116
+ variant: "segmented-floating",
117
+ glassEffect: GLASS_EFFECT_CONFIG,
118
+ },
119
+ render: (args) => {
120
+ return (
121
+ <div>
122
+ <Header {...args}>
123
+ <Brand />
124
+
125
+ <NavBar
126
+ items={MOCK_HEADER_ITEMS}
127
+ hoverEffect="none"
128
+ variant="default"
129
+ className="hidden md:flex"
130
+ subItemsColumns={4}
131
+ />
132
+ </Header>
133
+
134
+ <main className="w-full container mx-auto p-5 pt-24 flex flex-col gap-6">
135
+ <p>{FAKE_PARAGRAPH}</p>
136
+ <p>{FAKE_PARAGRAPH}</p>
137
+ <p>{FAKE_PARAGRAPH}</p>
138
+ <p>{FAKE_PARAGRAPH}</p>
139
+ <p>{FAKE_PARAGRAPH}</p>
140
+ </main>
141
+ </div>
142
+ );
143
+ },
144
+ };
@@ -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,2 @@
1
+ export * from "./classes";
2
+ export * from "./styles";