@sproutsocial/seeds-react-container 0.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/.eslintignore ADDED
@@ -0,0 +1,6 @@
1
+ # Node modules
2
+ node_modules/
3
+
4
+ # Build output
5
+ dist/
6
+ coverage/
package/.eslintrc.js ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ["eslint-config-seeds/racine"],
4
+ };
@@ -0,0 +1,21 @@
1
+ yarn run v1.22.22
2
+ $ tsup --dts
3
+ CLI Building entry: src/index.ts
4
+ CLI Using tsconfig: tsconfig.json
5
+ CLI tsup v8.5.0
6
+ CLI Using tsup config: /home/runner/work/seeds/seeds/seeds-react/seeds-react-container/tsup.config.ts
7
+ CLI Target: es2022
8
+ CLI Cleaning output folder
9
+ CJS Build start
10
+ ESM Build start
11
+ CJS dist/index.js 4.40 KB
12
+ CJS dist/index.js.map 3.99 KB
13
+ CJS ⚡️ Build success in 238ms
14
+ ESM dist/esm/index.js 2.20 KB
15
+ ESM dist/esm/index.js.map 3.94 KB
16
+ ESM ⚡️ Build success in 248ms
17
+ DTS Build start
18
+ DTS ⚡️ Build success in 30962ms
19
+ DTS dist/index.d.ts 503.00 B
20
+ DTS dist/index.d.mts 503.00 B
21
+ Done in 38.60s.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @sproutsocial/seeds-react-container
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5f6fee3: Created new component called Container that accepts a title, subtitle, header action, and can display a loading state"
@@ -0,0 +1,70 @@
1
+ // src/Container.tsx
2
+ import "react";
3
+ import { Box as Box2 } from "@sproutsocial/seeds-react-box";
4
+ import { Text } from "@sproutsocial/seeds-react-text";
5
+ import { Loader } from "@sproutsocial/seeds-react-loader";
6
+
7
+ // src/styles.ts
8
+ import styled from "styled-components";
9
+ import { Box } from "@sproutsocial/seeds-react-box";
10
+ var ContainerStyles = styled.section`
11
+ background: ${({ theme }) => theme.colors.container.background.base};
12
+ border: ${({ theme }) => theme.borderWidths[500]} solid
13
+ ${({ theme }) => theme.colors.container.border.base};
14
+ border-radius: ${({ theme }) => theme.radii.outer};
15
+ `;
16
+ var ContainerHeader = styled(Box)`
17
+ display: flex;
18
+ justify-content: space-between;
19
+ align-items: center;
20
+ border-bottom: ${({ theme }) => theme.borderWidths[500]} solid
21
+ ${({ theme }) => theme.colors.container.border.base};
22
+ color: ${({ theme }) => theme.colors.text.headline};
23
+ padding: ${({ theme }) => theme.space[400]};
24
+ `;
25
+ var ContainerContent = styled(Box)`
26
+ padding: ${({ theme }) => theme.space[400]};
27
+ `;
28
+
29
+ // src/Container.tsx
30
+ import { jsx, jsxs } from "react/jsx-runtime";
31
+ var Container = ({
32
+ title,
33
+ subtitle,
34
+ titleAs = "h2",
35
+ subtitleAs = "h3",
36
+ content,
37
+ isLoading,
38
+ headerActions,
39
+ contentProps,
40
+ ...boxProps
41
+ }) => {
42
+ return /* @__PURE__ */ jsxs(ContainerStyles, { as: "section", ...boxProps, children: [
43
+ /* @__PURE__ */ jsxs(ContainerHeader, { children: [
44
+ /* @__PURE__ */ jsxs(Box2, { children: [
45
+ /* @__PURE__ */ jsx(Text.Headline, { as: titleAs, children: title }),
46
+ /* @__PURE__ */ jsx(Text.Byline, { as: subtitleAs, fontWeight: "normal", children: subtitle })
47
+ ] }),
48
+ headerActions && /* @__PURE__ */ jsx(Box2, { children: headerActions })
49
+ ] }),
50
+ /* @__PURE__ */ jsx(
51
+ Box2,
52
+ {
53
+ p: 400,
54
+ ...contentProps,
55
+ borderBottomLeftRadius: "outer",
56
+ borderBottomRightRadius: "outer",
57
+ children: isLoading ? /* @__PURE__ */ jsx(Box2, { my: 400, children: /* @__PURE__ */ jsx(Loader, { delay: false }) }) : content
58
+ }
59
+ )
60
+ ] });
61
+ };
62
+ var Container_default = Container;
63
+
64
+ // src/index.ts
65
+ var index_default = Container_default;
66
+ export {
67
+ Container_default as Container,
68
+ index_default as default
69
+ };
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Container.tsx","../../src/styles.ts","../../src/index.ts"],"sourcesContent":["import React from \"react\";\nimport { Box } from \"@sproutsocial/seeds-react-box\";\nimport { Text } from \"@sproutsocial/seeds-react-text\";\nimport { Loader } from \"@sproutsocial/seeds-react-loader\";\nimport { ContainerHeader, ContainerStyles } from \"./styles\";\n\nexport interface ContainerProps {\n title: string;\n subtitle: string;\n titleAs: \"h1\" | \"h2\" | \"h3\" | \"h4\";\n subtitleAs: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"p\";\n isLoading?: boolean;\n content?: React.ReactNode;\n headerActions?: React.ReactNode;\n contentProps?: React.ComponentProps<typeof Box>;\n}\n\nconst Container: React.FC<ContainerProps> = ({\n title,\n subtitle,\n titleAs = \"h2\",\n subtitleAs = \"h3\",\n content,\n isLoading,\n headerActions,\n contentProps,\n ...boxProps\n}) => {\n return (\n <ContainerStyles as=\"section\" {...boxProps}>\n <ContainerHeader>\n <Box>\n <Text.Headline as={titleAs}>{title}</Text.Headline>\n <Text.Byline as={subtitleAs} fontWeight=\"normal\">\n {subtitle}\n </Text.Byline>\n </Box>\n {headerActions && <Box>{headerActions}</Box>}\n </ContainerHeader>\n <Box\n p={400}\n {...contentProps}\n borderBottomLeftRadius=\"outer\"\n borderBottomRightRadius=\"outer\"\n >\n {isLoading ? (\n <Box my={400}>\n <Loader delay={false} />\n </Box>\n ) : (\n content\n )}\n </Box>\n </ContainerStyles>\n );\n};\n\nexport default Container;\n","import styled from \"styled-components\";\nimport { Box } from \"@sproutsocial/seeds-react-box\";\n\nexport const ContainerStyles = styled.section`\n background: ${({ theme }) => theme.colors.container.background.base};\n border: ${({ theme }) => theme.borderWidths[500]} solid\n ${({ theme }) => theme.colors.container.border.base};\n border-radius: ${({ theme }) => theme.radii.outer};\n`;\n\nexport const ContainerHeader = styled(Box)`\n display: flex;\n justify-content: space-between;\n align-items: center;\n border-bottom: ${({ theme }) => theme.borderWidths[500]} solid\n ${({ theme }) => theme.colors.container.border.base};\n color: ${({ theme }) => theme.colors.text.headline};\n padding: ${({ theme }) => theme.space[400]};\n`;\n\nexport const ContainerContent = styled(Box)`\n padding: ${({ theme }) => theme.space[400]};\n`;\n","import Container from \"./Container\";\n\nexport type { ContainerProps } from \"./Container\";\n\nexport default Container;\nexport { Container };\n"],"mappings":";AAAA,OAAkB;AAClB,SAAS,OAAAA,YAAW;AACpB,SAAS,YAAY;AACrB,SAAS,cAAc;;;ACHvB,OAAO,YAAY;AACnB,SAAS,WAAW;AAEb,IAAM,kBAAkB,OAAO;AAAA,gBACtB,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,WAAW,IAAI;AAAA,YACzD,CAAC,EAAE,MAAM,MAAM,MAAM,aAAa,GAAG,CAAC;AAAA,MAC5C,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA,mBACpC,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,KAAK;AAAA;AAG5C,IAAM,kBAAkB,OAAO,GAAG;AAAA;AAAA;AAAA;AAAA,mBAItB,CAAC,EAAE,MAAM,MAAM,MAAM,aAAa,GAAG,CAAC;AAAA,MACnD,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA,WAC5C,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,KAAK,QAAQ;AAAA,aACvC,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAGrC,IAAM,mBAAmB,OAAO,GAAG;AAAA,aAC7B,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;;;ADUpC,SACE,KADF;AAdR,IAAM,YAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SACE,qBAAC,mBAAgB,IAAG,WAAW,GAAG,UAChC;AAAA,yBAAC,mBACC;AAAA,2BAACC,MAAA,EACC;AAAA,4BAAC,KAAK,UAAL,EAAc,IAAI,SAAU,iBAAM;AAAA,QACnC,oBAAC,KAAK,QAAL,EAAY,IAAI,YAAY,YAAW,UACrC,oBACH;AAAA,SACF;AAAA,MACC,iBAAiB,oBAACA,MAAA,EAAK,yBAAc;AAAA,OACxC;AAAA,IACA;AAAA,MAACA;AAAA,MAAA;AAAA,QACC,GAAG;AAAA,QACF,GAAG;AAAA,QACJ,wBAAuB;AAAA,QACvB,yBAAwB;AAAA,QAEvB,sBACC,oBAACA,MAAA,EAAI,IAAI,KACP,8BAAC,UAAO,OAAO,OAAO,GACxB,IAEA;AAAA;AAAA,IAEJ;AAAA,KACF;AAEJ;AAEA,IAAO,oBAAQ;;;AErDf,IAAO,gBAAQ;","names":["Box","Box"]}
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { Box } from '@sproutsocial/seeds-react-box';
3
+
4
+ interface ContainerProps {
5
+ title: string;
6
+ subtitle: string;
7
+ titleAs: "h1" | "h2" | "h3" | "h4";
8
+ subtitleAs: "h2" | "h3" | "h4" | "h5" | "p";
9
+ isLoading?: boolean;
10
+ content?: React.ReactNode;
11
+ headerActions?: React.ReactNode;
12
+ contentProps?: React.ComponentProps<typeof Box>;
13
+ }
14
+ declare const Container: React.FC<ContainerProps>;
15
+
16
+ export { Container, type ContainerProps, Container as default };
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { Box } from '@sproutsocial/seeds-react-box';
3
+
4
+ interface ContainerProps {
5
+ title: string;
6
+ subtitle: string;
7
+ titleAs: "h1" | "h2" | "h3" | "h4";
8
+ subtitleAs: "h2" | "h3" | "h4" | "h5" | "p";
9
+ isLoading?: boolean;
10
+ content?: React.ReactNode;
11
+ headerActions?: React.ReactNode;
12
+ contentProps?: React.ComponentProps<typeof Box>;
13
+ }
14
+ declare const Container: React.FC<ContainerProps>;
15
+
16
+ export { Container, type ContainerProps, Container as default };
package/dist/index.js ADDED
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Container: () => Container_default,
34
+ default: () => index_default
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+
38
+ // src/Container.tsx
39
+ var import_react = require("react");
40
+ var import_seeds_react_box2 = require("@sproutsocial/seeds-react-box");
41
+ var import_seeds_react_text = require("@sproutsocial/seeds-react-text");
42
+ var import_seeds_react_loader = require("@sproutsocial/seeds-react-loader");
43
+
44
+ // src/styles.ts
45
+ var import_styled_components = __toESM(require("styled-components"));
46
+ var import_seeds_react_box = require("@sproutsocial/seeds-react-box");
47
+ var ContainerStyles = import_styled_components.default.section`
48
+ background: ${({ theme }) => theme.colors.container.background.base};
49
+ border: ${({ theme }) => theme.borderWidths[500]} solid
50
+ ${({ theme }) => theme.colors.container.border.base};
51
+ border-radius: ${({ theme }) => theme.radii.outer};
52
+ `;
53
+ var ContainerHeader = (0, import_styled_components.default)(import_seeds_react_box.Box)`
54
+ display: flex;
55
+ justify-content: space-between;
56
+ align-items: center;
57
+ border-bottom: ${({ theme }) => theme.borderWidths[500]} solid
58
+ ${({ theme }) => theme.colors.container.border.base};
59
+ color: ${({ theme }) => theme.colors.text.headline};
60
+ padding: ${({ theme }) => theme.space[400]};
61
+ `;
62
+ var ContainerContent = (0, import_styled_components.default)(import_seeds_react_box.Box)`
63
+ padding: ${({ theme }) => theme.space[400]};
64
+ `;
65
+
66
+ // src/Container.tsx
67
+ var import_jsx_runtime = require("react/jsx-runtime");
68
+ var Container = ({
69
+ title,
70
+ subtitle,
71
+ titleAs = "h2",
72
+ subtitleAs = "h3",
73
+ content,
74
+ isLoading,
75
+ headerActions,
76
+ contentProps,
77
+ ...boxProps
78
+ }) => {
79
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ContainerStyles, { as: "section", ...boxProps, children: [
80
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ContainerHeader, { children: [
81
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_seeds_react_box2.Box, { children: [
82
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_text.Text.Headline, { as: titleAs, children: title }),
83
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_text.Text.Byline, { as: subtitleAs, fontWeight: "normal", children: subtitle })
84
+ ] }),
85
+ headerActions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_box2.Box, { children: headerActions })
86
+ ] }),
87
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
88
+ import_seeds_react_box2.Box,
89
+ {
90
+ p: 400,
91
+ ...contentProps,
92
+ borderBottomLeftRadius: "outer",
93
+ borderBottomRightRadius: "outer",
94
+ children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_box2.Box, { my: 400, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_loader.Loader, { delay: false }) }) : content
95
+ }
96
+ )
97
+ ] });
98
+ };
99
+ var Container_default = Container;
100
+
101
+ // src/index.ts
102
+ var index_default = Container_default;
103
+ // Annotate the CommonJS export names for ESM import in node:
104
+ 0 && (module.exports = {
105
+ Container
106
+ });
107
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/Container.tsx","../src/styles.ts"],"sourcesContent":["import Container from \"./Container\";\n\nexport type { ContainerProps } from \"./Container\";\n\nexport default Container;\nexport { Container };\n","import React from \"react\";\nimport { Box } from \"@sproutsocial/seeds-react-box\";\nimport { Text } from \"@sproutsocial/seeds-react-text\";\nimport { Loader } from \"@sproutsocial/seeds-react-loader\";\nimport { ContainerHeader, ContainerStyles } from \"./styles\";\n\nexport interface ContainerProps {\n title: string;\n subtitle: string;\n titleAs: \"h1\" | \"h2\" | \"h3\" | \"h4\";\n subtitleAs: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"p\";\n isLoading?: boolean;\n content?: React.ReactNode;\n headerActions?: React.ReactNode;\n contentProps?: React.ComponentProps<typeof Box>;\n}\n\nconst Container: React.FC<ContainerProps> = ({\n title,\n subtitle,\n titleAs = \"h2\",\n subtitleAs = \"h3\",\n content,\n isLoading,\n headerActions,\n contentProps,\n ...boxProps\n}) => {\n return (\n <ContainerStyles as=\"section\" {...boxProps}>\n <ContainerHeader>\n <Box>\n <Text.Headline as={titleAs}>{title}</Text.Headline>\n <Text.Byline as={subtitleAs} fontWeight=\"normal\">\n {subtitle}\n </Text.Byline>\n </Box>\n {headerActions && <Box>{headerActions}</Box>}\n </ContainerHeader>\n <Box\n p={400}\n {...contentProps}\n borderBottomLeftRadius=\"outer\"\n borderBottomRightRadius=\"outer\"\n >\n {isLoading ? (\n <Box my={400}>\n <Loader delay={false} />\n </Box>\n ) : (\n content\n )}\n </Box>\n </ContainerStyles>\n );\n};\n\nexport default Container;\n","import styled from \"styled-components\";\nimport { Box } from \"@sproutsocial/seeds-react-box\";\n\nexport const ContainerStyles = styled.section`\n background: ${({ theme }) => theme.colors.container.background.base};\n border: ${({ theme }) => theme.borderWidths[500]} solid\n ${({ theme }) => theme.colors.container.border.base};\n border-radius: ${({ theme }) => theme.radii.outer};\n`;\n\nexport const ContainerHeader = styled(Box)`\n display: flex;\n justify-content: space-between;\n align-items: center;\n border-bottom: ${({ theme }) => theme.borderWidths[500]} solid\n ${({ theme }) => theme.colors.container.border.base};\n color: ${({ theme }) => theme.colors.text.headline};\n padding: ${({ theme }) => theme.space[400]};\n`;\n\nexport const ContainerContent = styled(Box)`\n padding: ${({ theme }) => theme.space[400]};\n`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAClB,IAAAA,0BAAoB;AACpB,8BAAqB;AACrB,gCAAuB;;;ACHvB,+BAAmB;AACnB,6BAAoB;AAEb,IAAM,kBAAkB,yBAAAC,QAAO;AAAA,gBACtB,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,WAAW,IAAI;AAAA,YACzD,CAAC,EAAE,MAAM,MAAM,MAAM,aAAa,GAAG,CAAC;AAAA,MAC5C,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA,mBACpC,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,KAAK;AAAA;AAG5C,IAAM,sBAAkB,yBAAAA,SAAO,0BAAG;AAAA;AAAA;AAAA;AAAA,mBAItB,CAAC,EAAE,MAAM,MAAM,MAAM,aAAa,GAAG,CAAC;AAAA,MACnD,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA,WAC5C,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,KAAK,QAAQ;AAAA,aACvC,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAGrC,IAAM,uBAAmB,yBAAAA,SAAO,0BAAG;AAAA,aAC7B,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;;;ADUpC;AAdR,IAAM,YAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SACE,6CAAC,mBAAgB,IAAG,WAAW,GAAG,UAChC;AAAA,iDAAC,mBACC;AAAA,mDAAC,+BACC;AAAA,oDAAC,6BAAK,UAAL,EAAc,IAAI,SAAU,iBAAM;AAAA,QACnC,4CAAC,6BAAK,QAAL,EAAY,IAAI,YAAY,YAAW,UACrC,oBACH;AAAA,SACF;AAAA,MACC,iBAAiB,4CAAC,+BAAK,yBAAc;AAAA,OACxC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,GAAG;AAAA,QACF,GAAG;AAAA,QACJ,wBAAuB;AAAA,QACvB,yBAAwB;AAAA,QAEvB,sBACC,4CAAC,+BAAI,IAAI,KACP,sDAAC,oCAAO,OAAO,OAAO,GACxB,IAEA;AAAA;AAAA,IAEJ;AAAA,KACF;AAEJ;AAEA,IAAO,oBAAQ;;;ADrDf,IAAO,gBAAQ;","names":["import_seeds_react_box","styled"]}
package/jest.config.js ADDED
@@ -0,0 +1,9 @@
1
+ const baseConfig = require("@sproutsocial/seeds-testing");
2
+
3
+ /** * @type {import('jest').Config} */
4
+ const config = {
5
+ ...baseConfig,
6
+ displayName: "seeds-react-container",
7
+ };
8
+
9
+ module.exports = config;
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@sproutsocial/seeds-react-container",
3
+ "version": "0.1.0",
4
+ "description": "Seeds React Container",
5
+ "author": "Sprout Social, Inc.",
6
+ "license": "MIT",
7
+ "main": "dist/index.js",
8
+ "module": "dist/esm/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "scripts": {
11
+ "build": "tsup --dts",
12
+ "build:debug": "tsup --dts --metafile",
13
+ "dev": "tsup --watch --dts",
14
+ "clean": "rm -rf .turbo dist",
15
+ "clean:modules": "rm -rf node_modules",
16
+ "typecheck": "tsc --noEmit",
17
+ "test": "jest",
18
+ "test:watch": "jest --watch --coverage=false"
19
+ },
20
+ "dependencies": {
21
+ "@sproutsocial/seeds-react-box": "^1.1.5",
22
+ "@sproutsocial/seeds-react-button": "^1.3.2",
23
+ "@sproutsocial/seeds-react-icon": "^1.1.6",
24
+ "@sproutsocial/seeds-react-loader": "^1.0.4",
25
+ "@sproutsocial/seeds-react-system-props": "^3.0.2",
26
+ "@sproutsocial/seeds-react-text": "^1.3.2",
27
+ "@sproutsocial/seeds-react-theme": "^3.1.1"
28
+ },
29
+ "devDependencies": {
30
+ "@types/react": "^18.0.0",
31
+ "@types/styled-components": "^5.1.26",
32
+ "@sproutsocial/eslint-config-seeds": "*",
33
+ "react": "^18.0.0",
34
+ "styled-components": "^5.2.3",
35
+ "tsup": "^8.3.4",
36
+ "typescript": "^5.6.2",
37
+ "@sproutsocial/seeds-tsconfig": "*",
38
+ "@sproutsocial/seeds-testing": "*",
39
+ "@sproutsocial/seeds-react-testing-library": "*"
40
+ },
41
+ "peerDependencies": {
42
+ "styled-components": "^5.2.3"
43
+ },
44
+ "engines": {
45
+ "node": ">=18"
46
+ }
47
+ }
@@ -0,0 +1,52 @@
1
+ import Container from "./Container";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { Text } from "@sproutsocial/seeds-react-text";
4
+ import { Button } from "@sproutsocial/seeds-react-button";
5
+ import { Icon } from "@sproutsocial/seeds-react-icon";
6
+
7
+ const meta: Meta<typeof Container> = {
8
+ title: "Components/Container",
9
+ component: Container,
10
+ args: {
11
+ title: "Volume Breakdown - Outbound",
12
+ subtitle: "View a breakdown of your outbound volume.",
13
+ content: (
14
+ <Text.SmallBodyCopy>
15
+ Here is some content inside the container.
16
+ </Text.SmallBodyCopy>
17
+ ),
18
+ isLoading: false,
19
+ headerActions: null,
20
+ },
21
+ };
22
+
23
+ export default meta;
24
+
25
+ type Story = StoryObj<typeof Container>;
26
+
27
+ export const Default: Story = {
28
+ render: (args) => <Container {...args} />,
29
+ };
30
+
31
+ export const WithHeaderActions: Story = {
32
+ render: (args) => (
33
+ <Container
34
+ {...args}
35
+ headerActions={
36
+ <Button size="small">
37
+ <Icon name="face-frown-open-solid" />
38
+ </Button>
39
+ }
40
+ />
41
+ ),
42
+ };
43
+
44
+ export const LoadingState: Story = {
45
+ render: (args) => <Container {...args} isLoading={true} />,
46
+ };
47
+
48
+ export const WithContentStyles: Story = {
49
+ render: (args) => (
50
+ <Container {...args} contentProps={{ p: 0, py: 400, bg: "blue.300" }} />
51
+ ),
52
+ };
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import { Box } from "@sproutsocial/seeds-react-box";
3
+ import { Text } from "@sproutsocial/seeds-react-text";
4
+ import { Loader } from "@sproutsocial/seeds-react-loader";
5
+ import { ContainerHeader, ContainerStyles } from "./styles";
6
+
7
+ export interface ContainerProps {
8
+ title: string;
9
+ subtitle: string;
10
+ titleAs: "h1" | "h2" | "h3" | "h4";
11
+ subtitleAs: "h2" | "h3" | "h4" | "h5" | "p";
12
+ isLoading?: boolean;
13
+ content?: React.ReactNode;
14
+ headerActions?: React.ReactNode;
15
+ contentProps?: React.ComponentProps<typeof Box>;
16
+ }
17
+
18
+ const Container: React.FC<ContainerProps> = ({
19
+ title,
20
+ subtitle,
21
+ titleAs = "h2",
22
+ subtitleAs = "h3",
23
+ content,
24
+ isLoading,
25
+ headerActions,
26
+ contentProps,
27
+ ...boxProps
28
+ }) => {
29
+ return (
30
+ <ContainerStyles as="section" {...boxProps}>
31
+ <ContainerHeader>
32
+ <Box>
33
+ <Text.Headline as={titleAs}>{title}</Text.Headline>
34
+ <Text.Byline as={subtitleAs} fontWeight="normal">
35
+ {subtitle}
36
+ </Text.Byline>
37
+ </Box>
38
+ {headerActions && <Box>{headerActions}</Box>}
39
+ </ContainerHeader>
40
+ <Box
41
+ p={400}
42
+ {...contentProps}
43
+ borderBottomLeftRadius="outer"
44
+ borderBottomRightRadius="outer"
45
+ >
46
+ {isLoading ? (
47
+ <Box my={400}>
48
+ <Loader delay={false} />
49
+ </Box>
50
+ ) : (
51
+ content
52
+ )}
53
+ </Box>
54
+ </ContainerStyles>
55
+ );
56
+ };
57
+
58
+ export default Container;
@@ -0,0 +1,53 @@
1
+ import { render, screen } from "@sproutsocial/seeds-react-testing-library";
2
+ import Container from "../Container";
3
+
4
+ describe("Container Features", () => {
5
+ test("renders title and subtitle with correct semantic elements", () => {
6
+ render(
7
+ <Container
8
+ title="Test Title"
9
+ subtitle="Test Subtitle"
10
+ titleAs="h1"
11
+ subtitleAs="h2"
12
+ />
13
+ );
14
+
15
+ const titleElement = screen.getByText("Test Title");
16
+ const subtitleElement = screen.getByText("Test Subtitle");
17
+
18
+ expect(titleElement.tagName).toBe("H1");
19
+ expect(subtitleElement.tagName).toBe("H2");
20
+ });
21
+
22
+ test("renders content when not loading", () => {
23
+ render(
24
+ <Container
25
+ title="Test Title"
26
+ subtitle="Test Subtitle"
27
+ titleAs="h2"
28
+ subtitleAs="h3"
29
+ isLoading={false}
30
+ content={<div>Loaded Content</div>}
31
+ />
32
+ );
33
+ expect(screen.getByText("Loaded Content")).toBeInTheDocument();
34
+ });
35
+
36
+ test("renders loader when loading", () => {
37
+ render(
38
+ <Container
39
+ title="Test Title"
40
+ subtitle="Test Subtitle"
41
+ titleAs="h2"
42
+ subtitleAs="h3"
43
+ isLoading={true}
44
+ />
45
+ );
46
+
47
+ expect(
48
+ screen.getByDataQaLabel({
49
+ loader: "",
50
+ })
51
+ ).toBeInTheDocument();
52
+ });
53
+ });
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ import Container from "./Container";
2
+
3
+ export type { ContainerProps } from "./Container";
4
+
5
+ export default Container;
6
+ export { Container };
@@ -0,0 +1,7 @@
1
+ import "styled-components";
2
+ import { TypeTheme } from "@sproutsocial/seeds-react-theme";
3
+
4
+ declare module "styled-components" {
5
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
6
+ export interface DefaultTheme extends TypeTheme {}
7
+ }
package/src/styles.ts ADDED
@@ -0,0 +1,23 @@
1
+ import styled from "styled-components";
2
+ import { Box } from "@sproutsocial/seeds-react-box";
3
+
4
+ export const ContainerStyles = styled.section`
5
+ background: ${({ theme }) => theme.colors.container.background.base};
6
+ border: ${({ theme }) => theme.borderWidths[500]} solid
7
+ ${({ theme }) => theme.colors.container.border.base};
8
+ border-radius: ${({ theme }) => theme.radii.outer};
9
+ `;
10
+
11
+ export const ContainerHeader = styled(Box)`
12
+ display: flex;
13
+ justify-content: space-between;
14
+ align-items: center;
15
+ border-bottom: ${({ theme }) => theme.borderWidths[500]} solid
16
+ ${({ theme }) => theme.colors.container.border.base};
17
+ color: ${({ theme }) => theme.colors.text.headline};
18
+ padding: ${({ theme }) => theme.space[400]};
19
+ `;
20
+
21
+ export const ContainerContent = styled(Box)`
22
+ padding: ${({ theme }) => theme.space[400]};
23
+ `;
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@sproutsocial/seeds-tsconfig/bundler/dom/library-monorepo",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "module": "esnext"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules", "dist", "coverage"]
9
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig((options) => ({
4
+ entry: ["src/index.ts"],
5
+ format: ["cjs", "esm"],
6
+ clean: true,
7
+ legacyOutput: true,
8
+ dts: options.dts,
9
+ external: ["react"],
10
+ sourcemap: true,
11
+ metafile: options.metafile,
12
+ }));