@heliosgraphics/ui 2.0.0-alpha.69 → 2.0.0-alpha.70
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/components/Flex/Flex.meta.ts +1 -1
- package/components/Flex/Flex.types.ts +2 -2
- package/components/Flex/Flex.utils.spec.ts +2 -2
- package/components/Flex/Flex.utils.ts +3 -1
- package/components/Layout/Layout.types.ts +2 -0
- package/components/Layout/components/LayoutMain/LayoutMain.module.css +5 -0
- package/components/Layout/components/LayoutNavigation/LayoutNavigation.module.css +0 -1
- package/components/Layout/components/LayoutSubNavigation/LayoutSubNavigation.meta.ts +15 -0
- package/components/Layout/components/LayoutSubNavigation/LayoutSubNavigation.module.css +12 -0
- package/components/Layout/components/LayoutSubNavigation/LayoutSubNavigation.tsx +22 -0
- package/components/Layout/components/LayoutSubNavigation/LayoutSubNavigation.types.ts +5 -0
- package/components/Layout/components/LayoutSubNavigation/index.ts +1 -0
- package/components/Layout/index.ts +2 -0
- package/package.json +1 -1
|
@@ -37,7 +37,7 @@ export const meta: HeliosAttributeMeta<FlexBaseProps> = {
|
|
|
37
37
|
paddingX: { type: "HeliosScale", isOptional: true },
|
|
38
38
|
paddingY: { type: "HeliosScale", isOptional: true },
|
|
39
39
|
ref: { type: "RefObject<HTMLDivElement>", isOptional: true },
|
|
40
|
-
withBackground: { type: "
|
|
40
|
+
withBackground: { type: "HeliosEmphasisType", isOptional: true },
|
|
41
41
|
withRadius: { type: "ResponsiveRadiusType", isOptional: true },
|
|
42
42
|
xAlign: { type: '"start" | "end" | "center"', isOptional: true },
|
|
43
43
|
yAlign: { type: '"start" | "end" | "baseline"', isOptional: true },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HTMLAttributes, MouseEventHandler, PropsWithChildren, ForwardedRef } from "react"
|
|
2
|
-
import type { HeliosScaleType, HeliosRadiusType } from "../.."
|
|
2
|
+
import type { HeliosScaleType, HeliosRadiusType, HeliosEmphasisType } from "../.."
|
|
3
3
|
|
|
4
4
|
export type ResponsiveScaleType = HeliosScaleType | [HeliosScaleType, HeliosScaleType, HeliosScaleType]
|
|
5
5
|
export type ResponsiveRadiusType = HeliosRadiusType | [HeliosRadiusType, HeliosRadiusType, HeliosRadiusType]
|
|
@@ -25,7 +25,7 @@ export interface FlexBaseProps {
|
|
|
25
25
|
paddingX?: HeliosScaleType
|
|
26
26
|
paddingY?: HeliosScaleType
|
|
27
27
|
ref?: ForwardedRef<HTMLDivElement>
|
|
28
|
-
withBackground?:
|
|
28
|
+
withBackground?: HeliosEmphasisType
|
|
29
29
|
withRadius?: ResponsiveRadiusType
|
|
30
30
|
xAlign?: "start" | "end" | "center"
|
|
31
31
|
yAlign?: "start" | "end" | "baseline"
|
|
@@ -29,12 +29,12 @@ describe("getFlexUtility", () => {
|
|
|
29
29
|
it("Generates empty flex without attrs", () => expect(getFlexUtility(MOCK_FLEX)).toEqual(MOCK_FLEX_CLASSES))
|
|
30
30
|
it("Generates empty flex with undefined", () => expect(getFlexUtility(undefined)).toEqual(MOCK_FLEX_CLASSES))
|
|
31
31
|
|
|
32
|
-
const MOCK_FLEX_DUPLICATE_CLASSES = `flex flex-center ui-bg`
|
|
32
|
+
const MOCK_FLEX_DUPLICATE_CLASSES = `flex flex-center ui-bg-primary`
|
|
33
33
|
const MOCK_FLEX_DUPLICATE: FlexProps = {
|
|
34
34
|
children: null,
|
|
35
35
|
isCentered: true,
|
|
36
36
|
className: "flex",
|
|
37
|
-
withBackground:
|
|
37
|
+
withBackground: "primary",
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
it("Generates without duplicated classes", () =>
|
|
@@ -47,7 +47,9 @@ export const getFlexUtility = (props?: FlexProps): string => {
|
|
|
47
47
|
if (props.paddingX) flexClasses.add(`px-${props.paddingX}`)
|
|
48
48
|
|
|
49
49
|
if (props.className) flexClasses.add(props.className)
|
|
50
|
-
if (props.withBackground) flexClasses.add("ui-bg")
|
|
50
|
+
if (props.withBackground === "primary") flexClasses.add("ui-bg-primary")
|
|
51
|
+
if (props.withBackground === "secondary") flexClasses.add("ui-bg-secondary")
|
|
52
|
+
if (props.withBackground === "tertiary") flexClasses.add("ui-bg-tertiary")
|
|
51
53
|
|
|
52
54
|
return Array.from(flexClasses).join(" ")
|
|
53
55
|
}
|
|
@@ -2,6 +2,7 @@ import type { FC, ReactElement, PropsWithChildren } from "react"
|
|
|
2
2
|
import type { LayoutAsideComposition } from "./components/LayoutAside/LayoutAside.types"
|
|
3
3
|
import type { LayoutMainComposition } from "./components/LayoutMain/LayoutMain.types"
|
|
4
4
|
import type { LayoutNavigationProps } from "./components/LayoutNavigation/LayoutNavigation.types"
|
|
5
|
+
import type { LayoutSubNavigationProps } from "./components/LayoutSubNavigation/LayoutSubNavigation.types"
|
|
5
6
|
|
|
6
7
|
export type LayoutBaseProps = {
|
|
7
8
|
isFullHeight?: boolean
|
|
@@ -14,4 +15,5 @@ export interface LayoutComposition {
|
|
|
14
15
|
Aside: LayoutAsideComposition
|
|
15
16
|
Main: LayoutMainComposition
|
|
16
17
|
Navigation: FC<LayoutNavigationProps>
|
|
18
|
+
SubNavigation: FC<LayoutSubNavigationProps>
|
|
17
19
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HeliosAttributeMeta } from "../../../.."
|
|
2
|
+
import type { LayoutSubNavigationBaseProps } from "./LayoutSubNavigation.types"
|
|
3
|
+
|
|
4
|
+
export const meta: HeliosAttributeMeta<LayoutSubNavigationBaseProps> = {
|
|
5
|
+
_patterns: [
|
|
6
|
+
{
|
|
7
|
+
id: "ui-layout-sub-navigation-default",
|
|
8
|
+
description: "default",
|
|
9
|
+
content: `<Layout.SubNavigation>{CHILDREN}</Layout.SubNavigation>`,
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
_status: "internal",
|
|
13
|
+
_category: "layout",
|
|
14
|
+
_extends: ["FlexProps"],
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getFlexUtility, getSafeFlexProps } from "../../../Flex/Flex.utils"
|
|
2
|
+
import { getClasses } from "@heliosgraphics/utils"
|
|
3
|
+
import styles from "./LayoutSubNavigation.module.css"
|
|
4
|
+
import type { FC } from "react"
|
|
5
|
+
import type { LayoutSubNavigationProps } from "./LayoutSubNavigation.types"
|
|
6
|
+
|
|
7
|
+
export const LayoutSubNavigation: FC<LayoutSubNavigationProps> = (props) => {
|
|
8
|
+
const mainNavigationFlexClasses: string = getFlexUtility({
|
|
9
|
+
...props,
|
|
10
|
+
isYCentered: props.isYCentered ?? true,
|
|
11
|
+
paddingX: props.paddingX ?? 8,
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const navigationClasses: string = getClasses(mainNavigationFlexClasses, styles.layoutNavigation)
|
|
15
|
+
const safeProps = getSafeFlexProps(props)
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<nav {...safeProps} className={navigationClasses} data-ui-component="Layout.SubNavigation">
|
|
19
|
+
{props.children}
|
|
20
|
+
</nav>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LayoutSubNavigation } from "./LayoutSubNavigation"
|
|
@@ -2,6 +2,7 @@ import type { LayoutComposition } from "./Layout.types"
|
|
|
2
2
|
import { LayoutAside } from "./components/LayoutAside"
|
|
3
3
|
import { LayoutMain } from "./components/LayoutMain"
|
|
4
4
|
import { LayoutNavigation } from "./components/LayoutNavigation/LayoutNavigation"
|
|
5
|
+
import { LayoutSubNavigation } from "./components/LayoutSubNavigation"
|
|
5
6
|
import { Layout as LC } from "./Layout"
|
|
6
7
|
import type { LayoutAsideComposition } from "./components/LayoutAside/LayoutAside.types"
|
|
7
8
|
import type { LayoutMainComposition } from "./components/LayoutMain/LayoutMain.types"
|
|
@@ -11,5 +12,6 @@ const LayoutComponent = LC as LayoutComposition
|
|
|
11
12
|
LayoutComponent.Aside = LayoutAside as LayoutAsideComposition
|
|
12
13
|
LayoutComponent.Main = LayoutMain as LayoutMainComposition
|
|
13
14
|
LayoutComponent.Navigation = LayoutNavigation
|
|
15
|
+
LayoutComponent.SubNavigation = LayoutSubNavigation
|
|
14
16
|
|
|
15
17
|
export { LayoutComponent as Layout }
|