@stackshift-ui/section 6.0.2 → 6.0.4-beta.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/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@stackshift-ui/section",
3
3
  "description": "",
4
- "version": "6.0.2",
4
+ "version": "6.0.4-beta.0",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",
10
10
  "files": [
11
- "dist/**"
11
+ "dist/**",
12
+ "src"
12
13
  ],
13
14
  "author": "WebriQ <info@webriq.com>",
14
15
  "devDependencies": {
@@ -28,16 +29,16 @@
28
29
  "typescript": "^5.6.2",
29
30
  "vite-tsconfig-paths": "^5.0.1",
30
31
  "vitest": "^2.1.1",
31
- "@stackshift-ui/typescript-config": "6.0.2",
32
- "@stackshift-ui/eslint-config": "6.0.2"
32
+ "@stackshift-ui/typescript-config": "6.0.3-beta.0",
33
+ "@stackshift-ui/eslint-config": "6.0.3-beta.0"
33
34
  },
34
35
  "dependencies": {
35
36
  "classnames": "^2.5.1",
36
- "@stackshift-ui/scripts": "6.0.2",
37
- "@stackshift-ui/system": "6.0.2"
37
+ "@stackshift-ui/scripts": "6.0.3-beta.0",
38
+ "@stackshift-ui/system": "6.0.4-beta.0"
38
39
  },
39
40
  "peerDependencies": {
40
- "@stackshift-ui/system": ">=0.0.0",
41
+ "@stackshift-ui/system": ">=6.0.4-beta.0",
41
42
  "@types/react": "16.8 - 19",
42
43
  "next": "10 - 14",
43
44
  "react": "16.8 - 19",
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ "use client";
2
+
3
+ // component exports
4
+ export * from "./section";
@@ -0,0 +1,13 @@
1
+ import { cleanup, render, screen } from "@testing-library/react";
2
+ import { afterEach, describe, test } from "vitest";
3
+ import { Section } from "./section";
4
+
5
+ describe.concurrent("section", () => {
6
+ afterEach(cleanup);
7
+
8
+ test("Layout: Section - test if renders without errors", ({ expect }) => {
9
+ const clx = "section-class";
10
+ render(<Section className={clx} />);
11
+ expect(screen.getByTestId("div").classList).toContain(clx);
12
+ });
13
+ });
@@ -0,0 +1,53 @@
1
+ import { DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
2
+ import type { ElementType, HTMLProps, ReactNode } from "react";
3
+ import cn from "classnames";
4
+
5
+ type Width = "sm" | "md" | "lg" | "xl" | "2xl" | "full" | number;
6
+
7
+ export interface SectionProps extends Omit<HTMLProps<HTMLElement>, "as"> {
8
+ children?: ReactNode;
9
+ className?: string;
10
+ maxWidth?: Width;
11
+ as?: ElementType;
12
+ }
13
+
14
+ const displayName = "Section";
15
+
16
+ export const Section: React.FC<SectionProps> = ({
17
+ children,
18
+ className,
19
+ maxWidth = "full",
20
+ as,
21
+ ...props
22
+ }) => {
23
+ const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
24
+
25
+ const widthVariants = {
26
+ sm: "384px",
27
+ md: "448px",
28
+ lg: "512px",
29
+ xl: "576px",
30
+ "2xl": "672px",
31
+ full: "100%",
32
+ };
33
+
34
+ const widthClass =
35
+ typeof maxWidth === "number" ? `${maxWidth.toString()}px` : widthVariants[maxWidth];
36
+
37
+ const width = widthClass ?? "80rem";
38
+
39
+ const classes = "mx-auto w-full px-4";
40
+
41
+ return (
42
+ <Component
43
+ as={as}
44
+ className={cn(classes, className)}
45
+ style={{ maxWidth: width }}
46
+ {...props}
47
+ data-testid={displayName}>
48
+ {children}
49
+ </Component>
50
+ );
51
+ };
52
+
53
+ Section.displayName = displayName;